annotate mcabber/src/screen.c @ 1179:0f7e0346d9cb

Add aspell support [Note: Patch slightly modified by Mikael]
author entragian <entragian@o2.pl>
date Wed, 04 Apr 2007 23:23:37 +0200
parents 220e04816524
children 5c34af370b67
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
307
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
1 /*
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
2 * screen.c -- UI stuff
393
f8f3c7493457 Whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 389
diff changeset
3 *
699
ee03b56b93ee Update Copyright (2006)
Mikael Berthe <mikael@lilotux.net>
parents: 682
diff changeset
4 * Copyright (C) 2005, 2006 Mikael Berthe <bmikael@lists.lilotux.net>
307
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
5 * Parts of this file come from the Cabber project <cabber@ajmacias.com>
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
6 *
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
7 * This program is free software; you can redistribute it and/or modify
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
8 * it under the terms of the GNU General Public License as published by
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or (at
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
10 * your option) any later version.
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
11 *
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
12 * This program is distributed in the hope that it will be useful, but
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
15 * General Public License for more details.
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
16 *
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
17 * You should have received a copy of the GNU General Public License
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
18 * along with this program; if not, write to the Free Software
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
20 * USA
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
21 */
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
22
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
23 #include <stdio.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
24 #include <stdlib.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
25 #include <string.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
26 #include <time.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
27 #include <ctype.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
28 #include <locale.h>
232
9a6ba4b38e63 [/trunk] Changeset 245 by mikael
mikael
parents: 220
diff changeset
29 #include <langinfo.h>
929
f4bf564893b5 Fix ncurses #include
Mikael Berthe <mikael@lilotux.net>
parents: 898
diff changeset
30 #include <config.h>
f4bf564893b5 Fix ncurses #include
Mikael Berthe <mikael@lilotux.net>
parents: 898
diff changeset
31
1179
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
32 #ifdef HAVE_ASPELL_H
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
33 # include <aspell.h>
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
34 #endif
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
35
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
36 #include "screen.h"
930
a75f7a13df7b UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents: 929
diff changeset
37 #include "utf8.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
38 #include "hbuf.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents: 44
diff changeset
39 #include "commands.h"
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 84
diff changeset
40 #include "compl.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
41 #include "roster.h"
180
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
42 #include "histolog.h"
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents: 276
diff changeset
43 #include "settings.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
44 #include "utils.h"
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
45
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
46 #define get_color(col) (COLOR_PAIR(col)|COLOR_ATTRIB[col])
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
47
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
48 #define DEFAULT_LOG_WIN_HEIGHT (5+2)
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
49 #define DEFAULT_ROSTER_WIDTH 24
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
50 #define CHAT_WIN_HEIGHT (maxY-1-Log_Win_Height)
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
51
592
67a332121aea Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents: 580
diff changeset
52 char *LocaleCharSet = "C";
67a332121aea Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents: 580
diff changeset
53
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
54 static unsigned short int Log_Win_Height;
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
55 static unsigned short int Roster_Width;
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
56
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
57 static inline void check_offset(int);
1172
334ae9f498f1 Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents: 1171
diff changeset
58 static void scr_cancel_current_completion(void);
334ae9f498f1 Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents: 1171
diff changeset
59 static void scr_end_current_completion(void);
334ae9f498f1 Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents: 1171
diff changeset
60 static void scr_insert_text(const char*);
334ae9f498f1 Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents: 1171
diff changeset
61 static void scr_handle_tab(void);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
62
1179
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
63 #ifdef HAVE_ASPELL_H
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
64 static void spellcheck(char *, char *);
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
65 static inline int is_alpha(const char *);
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
66 #endif
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
67
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
68 static GHashTable *winbufhash;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
69
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
70 typedef struct {
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
71 GList *hbuf;
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
72 GList *top; // If top is NULL, we'll display the last lines
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
73 char cleared; // For ex, user has issued a /clear command...
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
74 char lock;
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
75 } buffdata;
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
76
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
77 typedef struct {
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
78 WINDOW *win;
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
79 PANEL *panel;
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
80 buffdata *bd;
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
81 } winbuf;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
82
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
83 struct dimensions {
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
84 int l;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
85 int c;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
86 };
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
87
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
88 static WINDOW *rosterWnd, *chatWnd, *activechatWnd, *inputWnd, *logWnd;
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
89 static WINDOW *mainstatusWnd, *chatstatusWnd;
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
90 static PANEL *rosterPanel, *chatPanel, *activechatPanel, *inputPanel;
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
91 static PANEL *mainstatusPanel, *chatstatusPanel;
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
92 static PANEL *logPanel;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
93 static int maxY, maxX;
1093
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
94 static int prev_chatwidth;
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
95 static winbuf *statusWindow;
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
96 static winbuf *currentWindow;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
97 static GList *statushbuf;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
98
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
99 static int roster_hidden;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
100 static int chatmode;
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
101 static int multimode;
807
f6cda389db48 Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents: 806
diff changeset
102 static char *multiline, *multimode_subj;
30
4ea2df449381 [/trunk] Changeset 46 by mikael
mikael
parents: 29
diff changeset
103 int update_roster;
232
9a6ba4b38e63 [/trunk] Changeset 245 by mikael
mikael
parents: 220
diff changeset
104 int utf8_mode = 0;
322
da138cdebf04 Implement auto-away mode
Mikael Berthe <mikael@lilotux.net>
parents: 314
diff changeset
105 static bool Autoaway;
332
a1901741890e scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents: 330
diff changeset
106 static bool Curses;
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
107 static bool log_win_on_top;
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
108 static bool roster_win_on_right;
939
12fa2ae6445d Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents: 936
diff changeset
109 static time_t LastActivity;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
110
174
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
111 static char inputLine[INPUTLINE_LENGTH+1];
1179
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
112 #ifdef HAVE_ASPELL_H
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
113 static char maskLine[INPUTLINE_LENGTH+1];
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
114 #endif
174
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
115 static char *ptr_inputline;
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
116 static short int inputline_offset;
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
117 static int completion_started;
173
09e24917059d [/trunk] Changeset 185 by mikael
mikael
parents: 168
diff changeset
118 static GList *cmdhisto;
09e24917059d [/trunk] Changeset 185 by mikael
mikael
parents: 168
diff changeset
119 static GList *cmdhisto_cur;
1127
fddf2fef7b83 Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents: 1122
diff changeset
120 static guint cmdhisto_nblines;
174
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
121 static char cmdhisto_backup[INPUTLINE_LENGTH+1];
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
122
991
ef10906691bb Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents: 990
diff changeset
123 static int chatstate; /* (0=active, 1=composing, 2=paused) */
990
35e7913affb7 Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents: 987
diff changeset
124 static bool lock_chatstate;
991
ef10906691bb Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents: 990
diff changeset
125 static time_t chatstate_timestamp;
993
0759f4c7da68 Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents: 992
diff changeset
126 int chatstates_disabled;
990
35e7913affb7 Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents: 987
diff changeset
127
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
128 #define MAX_KEYSEQ_LENGTH 8
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
129
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
130 typedef struct {
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
131 char *seqstr;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
132 guint mkeycode;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
133 gint value;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
134 } keyseq;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
135
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
136 GSList *keyseqlist;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
137 static void add_keyseq(char *seqstr, guint mkeycode, gint value);
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
138
850
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
139 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp,
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
140 unsigned int prefix_flags, int force_show);
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
141
1179
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
142 #ifdef HAVE_ASPELL_H
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
143 #define ASPELLBADCHAR 5
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
144 AspellConfig *spell_config;
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
145 AspellSpeller *spell_checker;
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
146 #endif
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
147
99
7fffb8a6b229 [/trunk] Changeset 113 by mikael
mikael
parents: 98
diff changeset
148 /* Functions */
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
149
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
150 static int FindColor(const char *name)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
151 {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
152 if (!strcmp(name, "default"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
153 return -1;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
154 if (!strcmp(name, "black"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
155 return COLOR_BLACK;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
156 if (!strcmp(name, "red"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
157 return COLOR_RED;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
158 if (!strcmp(name, "green"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
159 return COLOR_GREEN;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
160 if (!strcmp(name, "yellow"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
161 return COLOR_YELLOW;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
162 if (!strcmp(name, "blue"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
163 return COLOR_BLUE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
164 if (!strcmp(name, "magenta"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
165 return COLOR_MAGENTA;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
166 if (!strcmp(name, "cyan"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
167 return COLOR_CYAN;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
168 if (!strcmp(name, "white"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
169 return COLOR_WHITE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
170
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
171 scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
172 return -1;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
173 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
174
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
175 static void ParseColors(void)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
176 {
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
177 const char *colors[] = {
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
178 "", "",
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
179 "general",
785
7e0562e3bc83 Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents: 779
diff changeset
180 "msgout",
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
181 "status",
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
182 "roster",
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
183 "rostersel",
723
23068490d063 Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents: 721
diff changeset
184 "rosterselmsg",
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
185 "rosternewmsg",
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
186 NULL
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
187 };
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
188
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
189 const char *color;
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
190 const char *background = settings_opt_get("color_background");
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
191 const char *backselected = settings_opt_get("color_bgrostersel");
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
192 const char *backstatus = settings_opt_get("color_bgstatus");
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
193 char *tmp;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
194 int i;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
195
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
196 // Initialize color attributes
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
197 memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB));
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
198
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
199 // Default values
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
200 if (!background) background = "black";
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
201 if (!backselected) backselected = "cyan";
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
202 if (!backstatus) backstatus = "blue";
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
203
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
204 for (i=0; colors[i]; i++) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
205 tmp = g_strdup_printf("color_%s", colors[i]);
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents: 276
diff changeset
206 color = settings_opt_get(tmp);
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
207 g_free(tmp);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
208
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
209 if (color) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
210 if (!strncmp(color, "bright", 6)) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
211 COLOR_ATTRIB[i+1] = A_BOLD;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
212 color += 6;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
213 }
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
214 }
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
215
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
216 switch (i + 1) {
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
217 case 1:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
218 init_pair(1, COLOR_BLACK, COLOR_WHITE);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
219 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
220 case 2:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
221 init_pair(2, COLOR_WHITE, COLOR_BLACK);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
222 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
223 case COLOR_GENERAL:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
224 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
225 FindColor(background));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
226 break;
785
7e0562e3bc83 Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents: 779
diff changeset
227 case COLOR_MSGOUT:
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
228 init_pair(i+1, ((color) ? FindColor(color) : COLOR_CYAN),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
229 FindColor(background));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
230 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
231 case COLOR_STATUS:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
232 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
233 FindColor(backstatus));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
234 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
235 case COLOR_ROSTER:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
236 init_pair(i+1, ((color) ? FindColor(color) : COLOR_GREEN),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
237 FindColor(background));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
238 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
239 case COLOR_ROSTERSEL:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
240 init_pair(i+1, ((color) ? FindColor(color) : COLOR_BLUE),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
241 FindColor(backselected));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
242 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
243 case COLOR_ROSTERSELNMSG:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
244 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
245 FindColor(backselected));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
246 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
247 case COLOR_ROSTERNMSG:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
248 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
249 FindColor(background));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
250 break;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
251 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
252 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
253 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
254
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
255 static void init_keycodes(void)
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
256 {
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
257 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
258 add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
259 add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
260 add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left
763
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
261 add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
262 add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
263 add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
264 add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
265 add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
266 add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
267 add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
268 add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
269 add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
270 add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
271 add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
272 add_keyseq("[6@", MKEY_CTRL_SHIFT_PGDOWN, 0); // Ctrl-Shift-PageDown
826
3a3c7a017904 Add Ctrl-Shift-{Home,End} key code sequences
Mikael Berthe <mikael@lilotux.net>
parents: 825
diff changeset
273 add_keyseq("[7@", MKEY_CTRL_SHIFT_HOME, 0); // Ctrl-Shift-Home
3a3c7a017904 Add Ctrl-Shift-{Home,End} key code sequences
Mikael Berthe <mikael@lilotux.net>
parents: 825
diff changeset
274 add_keyseq("[8@", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End
794
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
275 add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
276 add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
277 add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
278 add_keyseq("[3^", MKEY_CTRL_DEL, 0); // Ctrl-Delete
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
279
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
280 // Xterm
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
281 add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
282 add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
283 add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
284 add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
285 add_keyseq("[1;6A", MKEY_EQUIV, 520); // Ctrl-Shift-Up
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
286 add_keyseq("[1;6B", MKEY_EQUIV, 513); // Ctrl-Shift-Down
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
287 add_keyseq("[1;6C", MKEY_EQUIV, 402); // Ctrl-Shift-Right
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
288 add_keyseq("[1;6D", MKEY_EQUIV, 393); // Ctrl-Shift-Left
826
3a3c7a017904 Add Ctrl-Shift-{Home,End} key code sequences
Mikael Berthe <mikael@lilotux.net>
parents: 825
diff changeset
289 add_keyseq("[1;6H", MKEY_CTRL_SHIFT_HOME, 0); // Ctrl-Shift-Home
3a3c7a017904 Add Ctrl-Shift-{Home,End} key code sequences
Mikael Berthe <mikael@lilotux.net>
parents: 825
diff changeset
290 add_keyseq("[1;6F", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End
763
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
291 add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
292 add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
293 add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
294 add_keyseq("[6;5~", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown
794
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
295 add_keyseq("[1;5F", MKEY_CTRL_END, 0); // Ctrl-End
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
296 add_keyseq("[1;5H", MKEY_CTRL_HOME, 0); // Ctrl-Home
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
297 add_keyseq("[2;5~", MKEY_CTRL_INS, 0); // Ctrl-Insert
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
298 add_keyseq("[3;5~", MKEY_CTRL_DEL, 0); // Ctrl-Delete
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
299
768
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
300 // PuTTY
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
301 add_keyseq("[A", MKEY_EQUIV, 521); // Ctrl-Up
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
302 add_keyseq("[B", MKEY_EQUIV, 514); // Ctrl-Down
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
303 add_keyseq("[C", MKEY_EQUIV, 518); // Ctrl-Right
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
304 add_keyseq("[D", MKEY_EQUIV, 516); // Ctrl-Left
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
305
762
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
306 // screen
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
307 add_keyseq("Oa", MKEY_EQUIV, 521); // Ctrl-Up
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
308 add_keyseq("Ob", MKEY_EQUIV, 514); // Ctrl-Down
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
309 add_keyseq("Oc", MKEY_EQUIV, 518); // Ctrl-Right
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
310 add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left
763
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
311 add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
312 add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
313 add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
314 add_keyseq("[d", MKEY_EQUIV, 393); // Shift-Left
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
315 add_keyseq("[5$", MKEY_SHIFT_PGUP, 0); // Shift-PageUp
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
316 add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown
1170
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
317
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
318 // VT100
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
319 add_keyseq("[H", MKEY_EQUIV, KEY_HOME); // Home
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
320 add_keyseq("[F", MKEY_EQUIV, KEY_END); // End
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
321
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
322 // Konsole Linux
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
323 add_keyseq("[1~", MKEY_EQUIV, KEY_HOME); // Home
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
324 add_keyseq("[4~", MKEY_EQUIV, KEY_END); // End
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
325 }
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
326
1176
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
327 // scr_init_bindings()
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
328 // Create default key bindings
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
329 // Return 0 if error and 1 if none
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
330 void scr_init_bindings(void)
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
331 {
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
332 GString *sbuf = g_string_new("");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
333
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
334 // Common backspace key codes: 8, 127
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
335 settings_set(SETTINGS_TYPE_BINDING, "8", "iline char_bdel"); // Ctrl-h
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
336 settings_set(SETTINGS_TYPE_BINDING, "127", "iline char_bdel");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
337 g_string_printf(sbuf, "%d", KEY_BACKSPACE);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
338 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline char_bdel");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
339 g_string_printf(sbuf, "%d", KEY_DC);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
340 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline char_fdel");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
341 g_string_printf(sbuf, "%d", KEY_LEFT);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
342 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline bchar");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
343 g_string_printf(sbuf, "%d", KEY_RIGHT);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
344 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline fchar");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
345 settings_set(SETTINGS_TYPE_BINDING, "7", "iline compl_cancel"); // Ctrl-g
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
346 g_string_printf(sbuf, "%d", KEY_UP);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
347 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline hist_prev");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
348 g_string_printf(sbuf, "%d", KEY_DOWN);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
349 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline hist_next");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
350 g_string_printf(sbuf, "%d", KEY_PPAGE);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
351 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "roster up");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
352 g_string_printf(sbuf, "%d", KEY_NPAGE);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
353 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "roster down");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
354 g_string_printf(sbuf, "%d", KEY_HOME);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
355 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_start");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
356 settings_set(SETTINGS_TYPE_BINDING, "1", "iline iline_start"); // Ctrl-a
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
357 g_string_printf(sbuf, "%d", KEY_END);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
358 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_end");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
359 settings_set(SETTINGS_TYPE_BINDING, "5", "iline iline_end"); // Ctrl-e
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
360 // Ctrl-o (accept-line-and-down-history):
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
361 settings_set(SETTINGS_TYPE_BINDING, "15", "iline iline_accept_down_hist");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
362 settings_set(SETTINGS_TYPE_BINDING, "21", "iline iline_bdel"); // Ctrl-u
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
363 g_string_printf(sbuf, "%d", KEY_EOL);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
364 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_fdel");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
365 settings_set(SETTINGS_TYPE_BINDING, "11", "iline iline_fdel"); // Ctrl-k
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
366 settings_set(SETTINGS_TYPE_BINDING, "16", "buffer up"); // Ctrl-p
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
367 settings_set(SETTINGS_TYPE_BINDING, "14", "buffer down"); // Ctrl-n
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
368 settings_set(SETTINGS_TYPE_BINDING, "20", "iline char_swap"); // Ctrl-t
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
369 settings_set(SETTINGS_TYPE_BINDING, "23", "iline word_bdel"); // Ctrl-w
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
370 settings_set(SETTINGS_TYPE_BINDING, "M98", "iline bword"); // Meta-b
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
371 settings_set(SETTINGS_TYPE_BINDING, "M102", "iline fword"); // Meta-f
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
372 // Ctrl-Left (2 codes):
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
373 settings_set(SETTINGS_TYPE_BINDING, "515", "iline bword");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
374 settings_set(SETTINGS_TYPE_BINDING, "516", "iline bword");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
375 // Ctrl-Right (2 codes):
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
376 settings_set(SETTINGS_TYPE_BINDING, "517", "iline fword");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
377 settings_set(SETTINGS_TYPE_BINDING, "518", "iline fword");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
378 settings_set(SETTINGS_TYPE_BINDING, "12", "screen_refresh"); // Ctrl-l
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
379 settings_set(SETTINGS_TYPE_BINDING, "27", "chat_disable"); // Esc
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
380 settings_set(SETTINGS_TYPE_BINDING, "4", "iline send_multiline"); // Ctrl-d
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
381 settings_set(SETTINGS_TYPE_BINDING, "M117", "iline word_upcase"); // Meta-u
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
382 settings_set(SETTINGS_TYPE_BINDING, "M108", "iline word_downcase"); // Meta-l
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
383 settings_set(SETTINGS_TYPE_BINDING, "M99", "iline word_capit"); // Meta-c
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
384
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
385 g_string_free(sbuf, TRUE);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
386 }
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
387
779
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
388 void scr_InitLocaleCharSet(void)
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
389 {
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
390 setlocale(LC_CTYPE, "");
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
391 LocaleCharSet = nl_langinfo(CODESET);
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
392 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0);
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
393 }
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
394
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
395 void scr_InitCurses(void)
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
396 {
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
397 /* Key sequences initialization */
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
398 init_keycodes();
762
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
399
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
400 initscr();
382
4c6e8392e465 Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents: 374
diff changeset
401 raw();
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
402 noecho();
389
6e895f397474 Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents: 388
diff changeset
403 nonl();
6e895f397474 Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents: 388
diff changeset
404 intrflush(stdscr, FALSE);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
405 start_color();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
406 use_default_colors();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
407
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
408 ParseColors();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
409
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
410 getmaxyx(stdscr, maxY, maxX);
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
411 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
412 // Note scr_DrawMainWindow() should be called early after scr_InitCurses()
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
413 // to update Log_Win_Height and set max{X,Y}
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
414
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
415 inputLine[0] = 0;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
416 ptr_inputline = inputLine;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
417
966
d9acb7f2a3d1 Do not set Curses variable too early
Mikael Berthe <mikael@lilotux.net>
parents: 961
diff changeset
418 Curses = TRUE;
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
419 return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
420 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
421
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
422 void scr_TerminateCurses(void)
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
423 {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
424 if (!Curses) return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
425 clear();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
426 refresh();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
427 endwin();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
428 Curses = FALSE;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
429 return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
430 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
431
675
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
432 inline void scr_Beep(void)
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
433 {
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
434 beep();
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
435 }
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
436
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
437 // scr_LogPrint(...)
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
438 // Display a message in the log window.
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
439 // This function will convert from UTF-8 unless the LPRINT_NOTUTF8 flag is set.
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
440 void scr_LogPrint(unsigned int flag, const char *fmt, ...)
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
441 {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
442 time_t timestamp;
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
443 char strtimestamp[64];
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
444 char *buffer, *btext;
1075
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
445 char *convbuf1 = NULL, *convbuf2 = NULL;
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
446 va_list ap;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
447
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
448 if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
449
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
450 timestamp = time(NULL);
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
451 strftime(strtimestamp, 48, "[%H:%M:%S]", localtime(&timestamp));
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
452 va_start(ap, fmt);
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
453 btext = g_strdup_vprintf(fmt, ap);
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
454 va_end(ap);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
455
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
456 if (flag & LPRINT_NORMAL) {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
457 char *buffer_locale;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
458 char *buf_specialwindow;
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
459
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
460 buffer = g_strdup_printf("%s %s", strtimestamp, btext);
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
461
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
462 // Convert buffer to current locale for wprintw()
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
463 if (!(flag & LPRINT_NOTUTF8))
1075
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
464 buffer_locale = convbuf1 = from_utf8(buffer);
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
465 else
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
466 buffer_locale = buffer;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
467
884
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
468 if (!buffer_locale) {
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
469 wprintw(logWnd,
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
470 "\n%s*Error: cannot convert string to locale.", strtimestamp);
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
471 update_panels();
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
472 g_free(buffer);
897
a05b5a16a06a Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents: 891
diff changeset
473 g_free(btext);
884
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
474 return;
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
475 }
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
476
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
477 // For the special status buffer, we need utf-8, but without the timestamp
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
478 if (flag & LPRINT_NOTUTF8)
1075
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
479 buf_specialwindow = convbuf2 = to_utf8(btext);
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
480 else
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
481 buf_specialwindow = btext;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
482
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
483 if (Curses) {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
484 wprintw(logWnd, "\n%s", buffer_locale);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
485 update_panels();
850
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
486 scr_WriteInWindow(NULL, buf_specialwindow, timestamp,
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
487 HBB_PREFIX_SPECIAL, FALSE);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
488 } else {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
489 printf("%s\n", buffer_locale);
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
490 // ncurses are not initialized yet, so we call directly hbuf routine
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
491 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp,
1141
5be2408a6534 Add option "max_history_blocks"
Mikael Berthe <mikael@lilotux.net>
parents: 1139
diff changeset
492 HBB_PREFIX_SPECIAL, 0, 0);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
493 }
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
494
1075
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
495 g_free(convbuf1);
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
496 g_free(convbuf2);
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
497 g_free(buffer);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
498 }
412
9c640ee3bae3 Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
499
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
500 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) {
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
501 strftime(strtimestamp, 23, "[%Y-%m-%d %H:%M:%S]", localtime(&timestamp));
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
502 buffer = g_strdup_printf("%s %s\n", strtimestamp, btext);
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
503 ut_WriteLog(flag, buffer);
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
504 g_free(buffer);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
505 }
897
a05b5a16a06a Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents: 891
diff changeset
506 g_free(btext);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
507 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
508
1156
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
509 static winbuf *scr_SearchWindow(const char *winId, int special)
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
510 {
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
511 char *id;
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
512 winbuf *wbp;
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
513
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
514 if (special)
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
515 return statusWindow; // Only one special window atm.
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
516
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
517 if (!winId)
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
518 return NULL;
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
519
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
520 id = g_strdup(winId);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
521 mc_strtolower(id);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
522 wbp = g_hash_table_lookup(winbufhash, id);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
523 g_free(id);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
524 return wbp;
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
525 }
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
526
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
527 int scr_BuddyBufferExists(const char *bjid)
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
528 {
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
529 return (scr_SearchWindow(bjid, FALSE) != NULL);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
530 }
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
531
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
532 // scr_new_buddy(title, dontshow)
1139
104676e3389b Update documentation
Mikael Berthe <mikael@lilotux.net>
parents: 1138
diff changeset
533 // Note: title (aka winId/jid) can be NULL for special buffers
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
534 static winbuf *scr_new_buddy(const char *title, int dont_show)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
535 {
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
536 winbuf *tmp;
393
f8f3c7493457 Whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 389
diff changeset
537
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
538 tmp = g_new0(winbuf, 1);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
539
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
540 tmp->win = activechatWnd;
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
541 tmp->panel = activechatPanel;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
542
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
543 if (!dont_show) {
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
544 currentWindow = tmp;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
545 } else {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
546 if (currentWindow)
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
547 top_panel(currentWindow->panel);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
548 else
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
549 top_panel(chatPanel);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
550 }
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
551 update_panels();
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
552
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
553 // If title is NULL, this is a special buffer
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
554 if (title) {
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
555 char *id;
1156
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
556 id = hlog_get_log_jid(title);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
557 if (id) {
1160
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
558 winbuf *wb = scr_SearchWindow(id, FALSE);
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
559 if (!wb)
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
560 wb = scr_new_buddy(id, TRUE);
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
561 tmp->bd=wb->bd;
1156
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
562 g_free(id);
1159
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
563 } else { // Load buddy history from file (if enabled)
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
564 tmp->bd = g_new0(buffdata, 1);
1159
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
565 hlog_read_history(title, &tmp->bd->hbuf,
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
566 maxX - Roster_Width - PREFIX_WIDTH);
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
567 }
181
4a0bde661562 [/trunk] Changeset 193 by mikael
mikael
parents: 180
diff changeset
568
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
569 id = g_strdup(title);
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
570 mc_strtolower(id);
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
571 g_hash_table_insert(winbufhash, id, tmp);
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
572 } else {
1159
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
573 tmp->bd = g_new0(buffdata, 1);
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
574 }
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
575 return tmp;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
576 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
577
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
578 // scr_UpdateWindow()
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
579 // (Re-)Display the given chat window.
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
580 static void scr_UpdateWindow(winbuf *win_entry)
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
581 {
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
582 int n;
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
583 int width;
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
584 hbb_line **lines, *line;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
585 GList *hbuf_head;
850
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
586 char date[64];
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
587
1077
c51ca5225516 Remove useless WindowWidth function
Mikael Berthe <mikael@lilotux.net>
parents: 1076
diff changeset
588 width = getmaxx(win_entry->win);
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
589
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
590 // Should the window be empty?
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
591 if (win_entry->bd->cleared) {
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
592 werase(win_entry->win);
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
593 return;
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
594 }
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
595
1160
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
596 // win_entry->bd->top is the top message of the screen. If it set to NULL,
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
597 // we are displaying the last messages.
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
598
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
599 // We will show the last CHAT_WIN_HEIGHT lines.
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
600 // Let's find out where it begins.
1160
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
601 if (!win_entry->bd->top || (g_list_position(g_list_first(win_entry->bd->hbuf),
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
602 win_entry->bd->top) == -1)) {
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
603 // Move up CHAT_WIN_HEIGHT lines
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
604 win_entry->bd->hbuf = g_list_last(win_entry->bd->hbuf);
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
605 hbuf_head = win_entry->bd->hbuf;
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
606 win_entry->bd->top = NULL; // (Just to make sure)
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
607 n = 0;
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
608 while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) {
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
609 hbuf_head = g_list_previous(hbuf_head);
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
610 n++;
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
611 }
873
ee39f6d94d43 Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents: 866
diff changeset
612 // If the buffer is locked, remember current "top" line for the next time.
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
613 if (win_entry->bd->lock)
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
614 win_entry->bd->top = hbuf_head;
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
615 } else
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
616 hbuf_head = win_entry->bd->top;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
617
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
618 // Get the last CHAT_WIN_HEIGHT lines.
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
619 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT);
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
620
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
621 // Display these lines
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
622 for (n = 0; n < CHAT_WIN_HEIGHT; n++) {
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
623 wmove(win_entry->win, n, 0);
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
624 line = *(lines+n);
185
e8e447a07641 [/trunk] Changeset 197 by mikael
mikael
parents: 184
diff changeset
625 // NOTE: update PREFIX_WIDTH if you change the date format!!
e8e447a07641 [/trunk] Changeset 197 by mikael
mikael
parents: 184
diff changeset
626 // You need to set it to the whole prefix length + 1
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
627 if (line) {
730
e46c680bdd3d New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents: 729
diff changeset
628 if (line->flags & HBB_PREFIX_HLIGHT)
785
7e0562e3bc83 Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents: 779
diff changeset
629 wattrset(win_entry->win, get_color(COLOR_MSGOUT));
730
e46c680bdd3d New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents: 729
diff changeset
630
850
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
631 if (line->timestamp && !(line->flags & HBB_PREFIX_SPECIAL)) {
419
2f9852610cf4 Small code review
Mikael Berthe <mikael@lilotux.net>
parents: 412
diff changeset
632 strftime(date, 30, "%m-%d %H:%M", localtime(&line->timestamp));
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
633 } else
185
e8e447a07641 [/trunk] Changeset 197 by mikael
mikael
parents: 184
diff changeset
634 strcpy(date, " ");
197
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
635 if (line->flags & HBB_PREFIX_INFO) {
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
636 char dir = '*';
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
637 if (line->flags & HBB_PREFIX_IN)
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
638 dir = '<';
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
639 else if (line->flags & HBB_PREFIX_OUT)
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
640 dir = '>';
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
641 wprintw(win_entry->win, "%.11s *%c* ", date, dir);
325
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
642 } else if (line->flags & HBB_PREFIX_ERR) {
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
643 char dir = '#';
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
644 if (line->flags & HBB_PREFIX_IN)
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
645 dir = '<';
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
646 else if (line->flags & HBB_PREFIX_OUT)
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
647 dir = '>';
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
648 wprintw(win_entry->win, "%.11s #%c# ", date, dir);
728
421b337dc6d2 Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents: 727
diff changeset
649 } else if (line->flags & HBB_PREFIX_IN) {
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
650 char cryptflag = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '=';
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
651 wprintw(win_entry->win, "%.11s <%c= ", date, cryptflag);
728
421b337dc6d2 Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents: 727
diff changeset
652 } else if (line->flags & HBB_PREFIX_OUT) {
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
653 char cryptflag = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '-';
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
654 wprintw(win_entry->win, "%.11s -%c> ", date, cryptflag);
850
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
655 } else if (line->flags & HBB_PREFIX_SPECIAL) {
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
656 strftime(date, 30, "%m-%d %H:%M:%S", localtime(&line->timestamp));
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
657 wprintw(win_entry->win, "%.14s ", date);
728
421b337dc6d2 Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents: 727
diff changeset
658 } else {
185
e8e447a07641 [/trunk] Changeset 197 by mikael
mikael
parents: 184
diff changeset
659 wprintw(win_entry->win, "%.11s ", date);
75
ff119bb11563 [/trunk] Changeset 89 by mikael
mikael
parents: 74
diff changeset
660 }
729
39f67cade02c Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents: 728
diff changeset
661
730
e46c680bdd3d New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents: 729
diff changeset
662 wprintw(win_entry->win, "%s", line->text); // Display text line
729
39f67cade02c Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents: 728
diff changeset
663
730
e46c680bdd3d New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents: 729
diff changeset
664 if (line->flags & HBB_PREFIX_HLIGHT)
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
665 wattrset(win_entry->win, get_color(COLOR_GENERAL));
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
666 wclrtoeol(win_entry->win);
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
667 g_free(line->text);
898
c65b71dcda94 Fix memory leak in scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 897
diff changeset
668 g_free(line);
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
669 } else {
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
670 wclrtobot(win_entry->win);
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
671 break;
75
ff119bb11563 [/trunk] Changeset 89 by mikael
mikael
parents: 74
diff changeset
672 }
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
673 }
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
674 g_free(lines);
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
675 }
1159
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
676
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
677 static winbuf *scr_CreateWindow(const char *winId, int special, int dont_show)
1154
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
678 {
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
679 if (special) {
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
680 if (!statusWindow) {
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
681 statusWindow = scr_new_buddy(NULL, dont_show);
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
682 statusWindow->bd->hbuf = statushbuf;
1154
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
683 }
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
684 return statusWindow;
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
685 } else {
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
686 return scr_new_buddy(winId, dont_show);
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
687 }
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
688 }
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
689
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
690 // scr_ShowWindow()
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
691 // Display the chat window with the given identifier.
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
692 // "special" must be true if this is a special buffer window.
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
693 static void scr_ShowWindow(const char *winId, int special)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
694 {
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
695 winbuf *win_entry;
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
696
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
697 win_entry = scr_SearchWindow(winId, special);
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
698
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
699 if (!win_entry) {
1154
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
700 win_entry = scr_CreateWindow(winId, special, FALSE);
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
701 }
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
702
180
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
703 top_panel(win_entry->panel);
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
704 currentWindow = win_entry;
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
705 chatmode = TRUE;
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
706 if (!win_entry->bd->lock)
889
ae93e69aaaaf Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents: 888
diff changeset
707 roster_msg_setflag(winId, special, FALSE);
ae93e69aaaaf Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents: 888
diff changeset
708 if (!special)
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
709 roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE);
874
293e8955075c Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents: 873
diff changeset
710 update_roster = TRUE;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
711
180
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
712 // Refresh the window
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
713 scr_UpdateWindow(win_entry);
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
714
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
715 // Finished :)
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
716 update_panels();
142
bb6fe91589b9 [/trunk] Changeset 154 by mikael
mikael
parents: 140
diff changeset
717
bb6fe91589b9 [/trunk] Changeset 154 by mikael
mikael
parents: 140
diff changeset
718 top_panel(inputPanel);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
719 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
720
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
721 // scr_ShowBuddyWindow()
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
722 // Display the chat window buffer for the current buddy.
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
723 void scr_ShowBuddyWindow(void)
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
724 {
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
725 const gchar *bjid;
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
726
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
727 if (!current_buddy) {
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
728 bjid = NULL;
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
729 } else {
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
730 bjid = CURRENT_JID;
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
731 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) {
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
732 scr_ShowWindow(buddy_getname(BUDDATA(current_buddy)), TRUE);
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
733 return;
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
734 }
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
735 }
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
736
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
737 if (!bjid) {
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
738 top_panel(chatPanel);
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
739 top_panel(inputPanel);
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
740 currentWindow = NULL;
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
741 return;
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
742 }
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
743
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1056
diff changeset
744 scr_ShowWindow(bjid, FALSE);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
745 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
746
865
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
747 // scr_UpdateBuddyWindow()
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
748 // (Re)Display the current window.
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
749 // If chatmode is enabled, call scr_ShowBuddyWindow(),
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
750 // else display the chat window.
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
751 inline void scr_UpdateBuddyWindow(void)
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
752 {
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
753 if (chatmode) {
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
754 scr_ShowBuddyWindow();
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
755 return;
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
756 }
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
757
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
758 top_panel(chatPanel);
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
759 top_panel(inputPanel);
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
760 }
cee8d6be04e1 Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents: 858
diff changeset
761
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
762 // scr_WriteInWindow()
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
763 // Write some text in the winId window (this usually is a jid).
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
764 // Use winId == NULL for the special status buffer.
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
765 // Lines are splitted when they are too long to fit in the chat window.
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
766 // If this window doesn't exist, it is created.
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
767 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp,
850
d0781ca2dd08 Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents: 849
diff changeset
768 unsigned int prefix_flags, int force_show)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
769 {
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
770 winbuf *win_entry;
772
464be13343a9 Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents: 771
diff changeset
771 char *text_locale;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
772 int dont_show = FALSE;
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
773 int special;
1142
0e27177882c7 Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents: 1141
diff changeset
774 guint num_history_blocks;
873
ee39f6d94d43 Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents: 866
diff changeset
775 bool setmsgflg = FALSE;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
776
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
777 // Look for the window entry.
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
778 special = (winId == NULL);
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
779 win_entry = scr_SearchWindow(winId, special);
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
780
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
781 // Do we have to really show the window?
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
782 if (!chatmode)
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
783 dont_show = TRUE;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
784 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry))))
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
785 dont_show = TRUE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
786
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
787 // If the window entry doesn't exist yet, let's create it.
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
788 if (!win_entry) {
1154
f746d91c5d3b Rearranged duplicated code in screen.c
franky@teufel.fs
parents: 1142
diff changeset
789 win_entry = scr_CreateWindow(winId, special, dont_show);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
790 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
791
220
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
792 // The message must be displayed -> update top pointer
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
793 if (win_entry->bd->cleared)
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
794 win_entry->bd->top = g_list_last(win_entry->bd->hbuf);
220
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
795
1142
0e27177882c7 Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents: 1141
diff changeset
796 // Make sure we do not free the buffer while it's locked or when
0e27177882c7 Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents: 1141
diff changeset
797 // top is set.
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
798 if (win_entry->bd->lock || win_entry->bd->top)
1142
0e27177882c7 Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents: 1141
diff changeset
799 num_history_blocks = 0U;
0e27177882c7 Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents: 1141
diff changeset
800 else
0e27177882c7 Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents: 1141
diff changeset
801 num_history_blocks = get_max_history_blocks();
0e27177882c7 Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents: 1141
diff changeset
802
772
464be13343a9 Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents: 771
diff changeset
803 text_locale = from_utf8(text);
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
804 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags,
1142
0e27177882c7 Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents: 1141
diff changeset
805 maxX - Roster_Width - PREFIX_WIDTH, num_history_blocks);
772
464be13343a9 Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents: 771
diff changeset
806 g_free(text_locale);
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
807
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
808 if (win_entry->bd->cleared) {
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
809 win_entry->bd->cleared = FALSE;
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
810 if (g_list_next(win_entry->bd->top))
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
811 win_entry->bd->top = g_list_next(win_entry->bd->top);
220
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
812 }
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
813
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
814 // Make sure the last line appears in the window; update top if necessary
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
815 if (!win_entry->bd->lock && win_entry->bd->top) {
220
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
816 int dist;
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
817 GList *first = g_list_first(win_entry->bd->hbuf);
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
818 dist = g_list_position(first, g_list_last(win_entry->bd->hbuf)) -
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
819 g_list_position(first, win_entry->bd->top);
220
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
820 if (dist >= CHAT_WIN_HEIGHT)
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
821 win_entry->bd->top = NULL;
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
822 }
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
823
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
824 if (!dont_show) {
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
825 if (win_entry->bd->lock)
873
ee39f6d94d43 Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents: 866
diff changeset
826 setmsgflg = TRUE;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
827 // Show and refresh the window
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
828 top_panel(win_entry->panel);
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
829 scr_UpdateWindow(win_entry);
142
bb6fe91589b9 [/trunk] Changeset 154 by mikael
mikael
parents: 140
diff changeset
830 top_panel(inputPanel);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
831 update_panels();
873
ee39f6d94d43 Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents: 866
diff changeset
832 } else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) {
ee39f6d94d43 Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents: 866
diff changeset
833 setmsgflg = TRUE;
ee39f6d94d43 Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents: 866
diff changeset
834 }
ee39f6d94d43 Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents: 866
diff changeset
835 if (setmsgflg && !special) {
889
ae93e69aaaaf Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents: 888
diff changeset
836 if (special && !winId)
ae93e69aaaaf Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents: 888
diff changeset
837 winId = SPECIAL_BUFFER_STATUS_ID;
ae93e69aaaaf Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents: 888
diff changeset
838 roster_msg_setflag(winId, special, TRUE);
30
4ea2df449381 [/trunk] Changeset 46 by mikael
mikael
parents: 29
diff changeset
839 update_roster = TRUE;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
840 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
841 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
842
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
843 // scr_UpdateMainStatus()
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
844 // Redraw the main (bottom) status line.
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
845 void scr_UpdateMainStatus(int forceupdate)
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
846 {
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
847 char *sm = from_utf8(jb_getstatusmsg());
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
848
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
849 werase(mainstatusWnd);
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
850 mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s",
718
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
851 (unread_msg(NULL) ? '#' : ' '),
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
852 imstatus2char[jb_getstatus()], (sm ? sm : ""));
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
853 if (forceupdate) {
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
854 top_panel(inputPanel);
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
855 update_panels();
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
856 }
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
857 g_free(sm);
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
858 }
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
859
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
860 // scr_DrawMainWindow()
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
861 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize.
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
862 //
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
863 // I think it could be improved a _lot_ but I'm really not an ncurses
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
864 // expert... :-\ Mikael.
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
865 //
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
866 void scr_DrawMainWindow(unsigned int fullinit)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
867 {
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
868 int requested_size;
961
95659cf9ea1a Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents: 952
diff changeset
869 gchar *ver, *message;
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
870 int chat_y_pos, chatstatus_y_pos, log_y_pos;
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
871 int roster_x_pos, chat_x_pos;
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
872
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
873 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
874 requested_size = settings_opt_get_int("log_win_height");
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
875 if (requested_size > 0) {
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
876 if (maxY > requested_size + 3)
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
877 Log_Win_Height = requested_size + 2;
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
878 else
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
879 Log_Win_Height = ((maxY > 5) ? (maxY - 2) : 3);
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
880 } else if (requested_size < 0) {
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
881 Log_Win_Height = 3;
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
882 }
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
883
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
884 if (maxY < Log_Win_Height+2) {
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
885 if (maxY < 5) {
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
886 Log_Win_Height = 3;
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
887 maxY = Log_Win_Height+2;
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
888 } else {
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
889 Log_Win_Height = maxY - 2;
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
890 }
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
891 }
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
892
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
893 if (roster_hidden) {
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
894 Roster_Width = 0;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
895 } else {
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
896 requested_size = settings_opt_get_int("roster_width");
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
897 if (requested_size > 1)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
898 Roster_Width = requested_size;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
899 else if (requested_size == 1)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
900 Roster_Width = 2;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
901 else
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
902 Roster_Width = DEFAULT_ROSTER_WIDTH;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
903 }
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
904
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
905 log_win_on_top = (settings_opt_get_int("log_win_on_top") == 1);
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
906 roster_win_on_right = (settings_opt_get_int("roster_win_on_right") == 1);
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
907
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
908 if (log_win_on_top) {
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
909 chat_y_pos = Log_Win_Height-1;
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
910 log_y_pos = 0;
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
911 chatstatus_y_pos = Log_Win_Height-2;
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
912 } else {
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
913 chat_y_pos = 0;
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
914 log_y_pos = CHAT_WIN_HEIGHT+1;
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
915 chatstatus_y_pos = CHAT_WIN_HEIGHT;
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
916 }
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
917
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
918 if (roster_win_on_right) {
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
919 roster_x_pos = maxX - Roster_Width;
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
920 chat_x_pos = 0;
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
921 } else {
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
922 roster_x_pos = 0;
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
923 chat_x_pos = Roster_Width;
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
924 }
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
925
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
926 if (fullinit) {
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
927 if (!winbufhash)
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
928 winbufhash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
929 /* Create windows */
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
930 rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, chat_y_pos, roster_x_pos);
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
931 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, chat_y_pos,
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
932 chat_x_pos);
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
933 activechatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, chat_y_pos,
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
934 chat_x_pos);
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
935 logWnd = newwin(Log_Win_Height-2, maxX, log_y_pos, 0);
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
936 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0);
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
937 mainstatusWnd = newwin(1, maxX, maxY-2, 0);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
938 inputWnd = newwin(1, maxX, maxY-1, 0);
358
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
939 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) {
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
940 scr_TerminateCurses();
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
941 fprintf(stderr, "Cannot create windows!\n");
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
942 exit(EXIT_FAILURE);
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
943 }
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
944 wbkgd(rosterWnd, get_color(COLOR_GENERAL));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
945 wbkgd(chatWnd, get_color(COLOR_GENERAL));
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
946 wbkgd(activechatWnd, get_color(COLOR_GENERAL));
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
947 wbkgd(logWnd, get_color(COLOR_GENERAL));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
948 wbkgd(chatstatusWnd, get_color(COLOR_STATUS));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
949 wbkgd(mainstatusWnd, get_color(COLOR_STATUS));
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
950 } else {
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
951 /* Resize/move windows */
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
952 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
953 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width);
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
954 wresize(logWnd, Log_Win_Height-2, maxX);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
955
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
956 mvwin(chatWnd, chat_y_pos, chat_x_pos);
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
957 mvwin(rosterWnd, chat_y_pos, roster_x_pos);
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
958 mvwin(logWnd, log_y_pos, 0);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
959
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
960 // Resize & move chat status window
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
961 wresize(chatstatusWnd, 1, maxX);
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
962 mvwin(chatstatusWnd, chatstatus_y_pos, 0);
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
963 // Resize & move main status window
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
964 wresize(mainstatusWnd, 1, maxX);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
965 mvwin(mainstatusWnd, maxY-2, 0);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
966 // Resize & move input line window
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
967 wresize(inputWnd, 1, maxX);
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
968 mvwin(inputWnd, maxY-1, 0);
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
969
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
970 werase(chatWnd);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
971 }
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
972
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
973 /* Draw/init windows */
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
974
961
95659cf9ea1a Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents: 952
diff changeset
975 ver = mcabber_version();
95659cf9ea1a Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents: 952
diff changeset
976 message = g_strdup_printf("MCabber version %s.\n", ver);
95659cf9ea1a Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents: 952
diff changeset
977 mvwprintw(chatWnd, 0, 0, message);
679
5933a8036672 Remove "This is the status window" message
Mikael Berthe <mikael@lilotux.net>
parents: 675
diff changeset
978 mvwprintw(chatWnd, 1, 0, "http://www.lilotux.net/~mikael/mcabber/");
961
95659cf9ea1a Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents: 952
diff changeset
979 g_free(ver);
95659cf9ea1a Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents: 952
diff changeset
980 g_free(message);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
981
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
982 // Auto-scrolling in log window
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
983 scrollok(logWnd, TRUE);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
984
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
985
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
986 if (fullinit) {
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
987 // Enable keypad (+ special keys)
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
988 keypad(inputWnd, TRUE);
382
4c6e8392e465 Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents: 374
diff changeset
989 nodelay(inputWnd, TRUE);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
990
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
991 // Create panels
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
992 rosterPanel = new_panel(rosterWnd);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
993 chatPanel = new_panel(chatWnd);
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
994 activechatPanel = new_panel(activechatWnd);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
995 logPanel = new_panel(logWnd);
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
996 chatstatusPanel = new_panel(chatstatusWnd);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
997 mainstatusPanel = new_panel(mainstatusWnd);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
998 inputPanel = new_panel(inputWnd);
232
9a6ba4b38e63 [/trunk] Changeset 245 by mikael
mikael
parents: 220
diff changeset
999
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1000 // Build the buddylist at least once, to make sure the special buffer
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1001 // is added
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1002 buddylist_build();
1093
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1003
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1004 // Init prev_chatwidth; this variable will be used to prevent us
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1005 // from rewrapping buffers when the width doesn't change.
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1006 prev_chatwidth = maxX - Roster_Width - PREFIX_WIDTH;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
1007 // Wrap existing status buffer lines
1093
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1008 hbuf_rebuild(&statushbuf, prev_chatwidth);
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1009
930
a75f7a13df7b UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents: 929
diff changeset
1010 #ifndef UNICODE
232
9a6ba4b38e63 [/trunk] Changeset 245 by mikael
mikael
parents: 220
diff changeset
1011 if (utf8_mode)
930
a75f7a13df7b UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents: 929
diff changeset
1012 scr_LogPrint(LPRINT_NORMAL,
a75f7a13df7b UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents: 929
diff changeset
1013 "WARNING: Compiled without full UTF-8 support!");
a75f7a13df7b UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents: 929
diff changeset
1014 #endif
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1015 } else {
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1016 // Update panels
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1017 replace_panel(rosterPanel, rosterWnd);
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1018 replace_panel(chatPanel, chatWnd);
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1019 replace_panel(logPanel, logWnd);
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
1020 replace_panel(chatstatusPanel, chatstatusWnd);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
1021 replace_panel(mainstatusPanel, mainstatusWnd);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1022 replace_panel(inputPanel, inputWnd);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1023 }
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1024
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1025 // We'll need to redraw the roster
149
9f74832eb4f8 [/trunk] Changeset 161 by mikael
mikael
parents: 148
diff changeset
1026 update_roster = TRUE;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1027 return;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1028 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1029
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1030 static void resize_win_buffer(gpointer key, gpointer value, gpointer data)
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1031 {
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1032 winbuf *wbp = value;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1033 struct dimensions *dim = data;
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
1034 int chat_x_pos, chat_y_pos;
1093
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1035 int new_chatwidth;
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
1036
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1037 if (!(wbp && wbp->win))
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1038 return;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1039
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
1040 if (log_win_on_top)
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
1041 chat_y_pos = Log_Win_Height-1;
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
1042 else
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
1043 chat_y_pos = 0;
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
1044
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
1045 if (roster_win_on_right)
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
1046 chat_x_pos = 0;
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
1047 else
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
1048 chat_x_pos = Roster_Width;
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
1049
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1050 // Resize/move buddy window
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1051 wresize(wbp->win, dim->l, dim->c);
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
1052 mvwin(wbp->win, chat_y_pos, chat_x_pos);
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1053 werase(wbp->win);
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1054 // If a panel exists, replace the old window with the new
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1055 if (wbp->panel)
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1056 replace_panel(wbp->panel, wbp->win);
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1057 // Redo line wrapping
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
1058 wbp->bd->top = hbuf_previous_persistent(wbp->bd->top);
1093
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1059
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1060 new_chatwidth = maxX - Roster_Width - PREFIX_WIDTH;
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1061 if (new_chatwidth != prev_chatwidth)
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
1062 hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth);
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1063 }
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1064
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1065 // scr_Resize()
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1066 // Function called when the window is resized.
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1067 // - Resize windows
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1068 // - Rewrap lines in each buddy buffer
1059
875d2c9d399c Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1058
diff changeset
1069 void scr_Resize(void)
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1070 {
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1071 struct dimensions dim;
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1072
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1073 // First, update the global variables
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1074 getmaxyx(stdscr, maxY, maxX);
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
1075 // scr_DrawMainWindow() will take care of maxY and Log_Win_Height
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
1076
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1077 // Make sure the cursor stays inside the window
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1078 check_offset(0);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1079
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1080 // Resize windows and update panels
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1081 scr_DrawMainWindow(FALSE);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1082
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1083 // Resize all buddy windows
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1084 dim.l = CHAT_WIN_HEIGHT;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1085 dim.c = maxX - Roster_Width;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1086 if (dim.c < 1)
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1087 dim.c = 1;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1088
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1089 // Resize all buffers
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1090 g_hash_table_foreach(winbufhash, resize_win_buffer, &dim);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1091
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1092 // Resize/move special status buffer
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1093 if (statusWindow)
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1094 resize_win_buffer(NULL, statusWindow, &dim);
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1095
1093
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1096 // Update prev_chatwidth, now that all buffers have been resized
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1097 prev_chatwidth = maxX - Roster_Width - PREFIX_WIDTH;
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
1098
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1099 // Refresh current buddy window
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
1100 if (chatmode)
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1101 scr_ShowBuddyWindow();
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1102 }
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
1103
721
9cf31c9b1dc4 Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 720
diff changeset
1104 // scr_UpdateChatStatus(forceupdate)
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1105 // Redraw the buddy status bar.
939
12fa2ae6445d Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents: 936
diff changeset
1106 // Set forceupdate to TRUE if update_panels() must be called.
721
9cf31c9b1dc4 Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 720
diff changeset
1107 void scr_UpdateChatStatus(int forceupdate)
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1108 {
848
a9161d2dc414 Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents: 843
diff changeset
1109 unsigned short btype, isgrp, ismuc, isspe;
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1110 const char *fullname;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1111 const char *msg = NULL;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1112 char status;
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
1113 char *buf, *buf_locale;
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1114
718
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
1115 // Usually we need to update the bottom status line too,
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
1116 // at least to refresh the pending message flag.
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
1117 scr_UpdateMainStatus(FALSE);
718
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
1118
806
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1119 // Clear the line
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1120 werase(chatstatusWnd);
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1121
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1122 if (chatmode)
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1123 wprintw(chatstatusWnd, "~");
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1124
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1125 if (!current_buddy) {
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1126 if (forceupdate) {
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1127 update_panels();
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1128 }
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1129 return;
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1130 }
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
1131
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1132 fullname = buddy_getname(BUDDATA(current_buddy));
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1133 btype = buddy_gettype(BUDDATA(current_buddy));
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1134
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1135 isgrp = btype & ROSTER_TYPE_GROUP;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1136 ismuc = btype & ROSTER_TYPE_ROOM;
848
a9161d2dc414 Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents: 843
diff changeset
1137 isspe = btype & ROSTER_TYPE_SPECIAL;
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1138
874
293e8955075c Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents: 873
diff changeset
1139 if (chatmode && !isgrp) {
293e8955075c Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents: 873
diff changeset
1140 winbuf *win_entry;
293e8955075c Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents: 873
diff changeset
1141 win_entry = scr_SearchWindow(buddy_getjid(BUDDATA(current_buddy)), isspe);
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
1142 if (win_entry && win_entry->bd->lock)
874
293e8955075c Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents: 873
diff changeset
1143 mvwprintw(chatstatusWnd, 0, 0, "*");
293e8955075c Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents: 873
diff changeset
1144 }
293e8955075c Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents: 873
diff changeset
1145
848
a9161d2dc414 Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents: 843
diff changeset
1146 if (isgrp || isspe) {
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
1147 buf_locale = from_utf8(fullname);
848
a9161d2dc414 Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents: 843
diff changeset
1148 if (isgrp)
a9161d2dc414 Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents: 843
diff changeset
1149 mvwprintw(chatstatusWnd, 0, 5, "Group: %s", buf_locale);
a9161d2dc414 Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents: 843
diff changeset
1150 else
a9161d2dc414 Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents: 843
diff changeset
1151 mvwprintw(chatstatusWnd, 0, 5, "Special buffer: %s", buf_locale);
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
1152 g_free(buf_locale);
716
ba1137a01078 Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 715
diff changeset
1153 if (forceupdate) {
ba1137a01078 Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 715
diff changeset
1154 update_panels();
ba1137a01078 Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 715
diff changeset
1155 }
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1156 return;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1157 }
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
1158