Mercurial > hg
annotate mcabber/src/screen.c @ 1515:9013d23f0a86
Forgot those poor non-utf8 locale-souls
author | franky@diable |
---|---|
date | Sat, 27 Sep 2008 20:58:45 +0200 |
parents | 939e2957f8a8 |
children | 63dc211a4c1a |
rev | line source |
---|---|
307 | 1 /* |
2 * screen.c -- UI stuff | |
393 | 3 * |
1414 | 4 * Copyright (C) 2005-2008 Mikael Berthe <mikael@lilotux.net> |
307 | 5 * Parts of this file come from the Cabber project <cabber@ajmacias.com> |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or (at | |
10 * your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
20 * USA | |
21 */ | |
22 | |
24 | 23 #include <stdio.h> |
24 #include <stdlib.h> | |
25 #include <string.h> | |
26 #include <time.h> | |
27 #include <ctype.h> | |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
28 |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
29 #include <config.h> |
24 | 30 #include <locale.h> |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
31 #include <assert.h> |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
32 #ifdef USE_SIGWINCH |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
33 # include <sys/ioctl.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
34 # include <termios.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
35 # include <unistd.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
36 #endif |
929 | 37 |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
38 #ifdef HAVE_LOCALCHARSET_H |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
39 # include <localcharset.h> |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
40 #else |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
41 # include <langinfo.h> |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
42 #endif |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
43 |
1179 | 44 #ifdef HAVE_ASPELL_H |
45 # include <aspell.h> | |
46 #endif | |
47 | |
24 | 48 #include "screen.h" |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
49 #include "utf8.h" |
81 | 50 #include "hbuf.h" |
47 | 51 #include "commands.h" |
95 | 52 #include "compl.h" |
81 | 53 #include "roster.h" |
180 | 54 #include "histolog.h" |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
55 #include "settings.h" |
81 | 56 #include "utils.h" |
24 | 57 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
58 #define get_color(col) (COLOR_PAIR(col)|COLOR_ATTRIB[col]) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
59 #define compose_color(col) (COLOR_PAIR(col->color_pair)|col->color_attrib) |
24 | 60 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
61 #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
|
62 #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
|
63 #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
|
64 |
1390 | 65 const char *LocaleCharSet = "C"; |
592
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
66 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
67 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
|
68 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
|
69 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
70 static inline void check_offset(int); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
71 static void scr_cancel_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
72 static void scr_end_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
73 static void scr_insert_text(const char*); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
74 static void scr_handle_tab(void); |
151 | 75 |
1179 | 76 #ifdef HAVE_ASPELL_H |
77 static void spellcheck(char *, char *); | |
78 #endif | |
79 | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
80 static GHashTable *winbufhash; |
24 | 81 |
822 | 82 typedef struct { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
83 GList *hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
84 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
|
85 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
|
86 char lock; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
87 } buffdata; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
88 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
89 typedef struct { |
24 | 90 WINDOW *win; |
108 | 91 PANEL *panel; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
92 buffdata *bd; |
822 | 93 } winbuf; |
24 | 94 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
95 struct dimensions { |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
96 int l; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
97 int c; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
98 }; |
24 | 99 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
100 static WINDOW *rosterWnd, *chatWnd, *activechatWnd, *inputWnd, *logWnd; |
711 | 101 static WINDOW *mainstatusWnd, *chatstatusWnd; |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
102 static PANEL *rosterPanel, *chatPanel, *activechatPanel, *inputPanel; |
711 | 103 static PANEL *mainstatusPanel, *chatstatusPanel; |
104 static PANEL *logPanel; | |
24 | 105 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
|
106 static int prev_chatwidth; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
107 static winbuf *statusWindow; |
822 | 108 static winbuf *currentWindow; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
109 static GList *statushbuf; |
24 | 110 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
111 static int roster_hidden; |
24 | 112 static int chatmode; |
238 | 113 static int multimode; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
114 static char *multiline, *multimode_subj; |
30 | 115 int update_roster; |
232 | 116 int utf8_mode = 0; |
332
a1901741890e
scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
117 static bool Curses; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
118 static bool log_win_on_top; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
119 static bool roster_win_on_right; |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
120 static time_t LastActivity; |
24 | 121 |
174 | 122 static char inputLine[INPUTLINE_LENGTH+1]; |
1179 | 123 #ifdef HAVE_ASPELL_H |
124 static char maskLine[INPUTLINE_LENGTH+1]; | |
125 #endif | |
174 | 126 static char *ptr_inputline; |
127 static short int inputline_offset; | |
128 static int completion_started; | |
173 | 129 static GList *cmdhisto; |
130 static GList *cmdhisto_cur; | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
131 static guint cmdhisto_nblines; |
174 | 132 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
24 | 133 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
134 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
|
135 static bool lock_chatstate; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
136 static time_t chatstate_timestamp; |
993
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
137 int chatstates_disabled; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
138 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
139 #define MAX_KEYSEQ_LENGTH 8 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
140 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
141 typedef struct { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
142 char *seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
143 guint mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
144 gint value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
145 } keyseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
146 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
147 GSList *keyseqlist; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
148 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
|
149 |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
150 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
151 unsigned int prefix_flags, int force_show, |
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
152 unsigned mucnicklen); |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
153 |
1413 | 154 inline void scr_UpdateBuddyWindow(void); |
155 inline void scr_set_chatmode(int enable); | |
156 | |
1179 | 157 #ifdef HAVE_ASPELL_H |
158 #define ASPELLBADCHAR 5 | |
159 AspellConfig *spell_config; | |
160 AspellSpeller *spell_checker; | |
161 #endif | |
24 | 162 |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
163 typedef struct { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
164 int color_pair; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
165 int color_attrib; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
166 } ccolor; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
167 |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
168 typedef struct { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
169 char *status, *wildcard; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
170 ccolor * color; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
171 GPatternSpec *compiled; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
172 } rostercolor; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
173 |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
174 static GSList *rostercolrules = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
175 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
176 static GHashTable *muccolors = NULL, *nickcolors = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
177 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
178 typedef struct { |
1413 | 179 bool manual; // Manually set? |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
180 ccolor * color; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
181 } nickcolor; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
182 |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
183 static int nickcolcount = 0; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
184 static ccolor ** nickcols = NULL; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
185 static muccoltype glob_muccol = MC_OFF; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
186 |
99 | 187 /* Functions */ |
24 | 188 |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
189 static int FindColor(const char *name) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
190 { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
191 int result; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
192 |
24 | 193 if (!strcmp(name, "default")) |
194 return -1; | |
195 if (!strcmp(name, "black")) | |
196 return COLOR_BLACK; | |
197 if (!strcmp(name, "red")) | |
198 return COLOR_RED; | |
199 if (!strcmp(name, "green")) | |
200 return COLOR_GREEN; | |
201 if (!strcmp(name, "yellow")) | |
202 return COLOR_YELLOW; | |
203 if (!strcmp(name, "blue")) | |
204 return COLOR_BLUE; | |
205 if (!strcmp(name, "magenta")) | |
206 return COLOR_MAGENTA; | |
207 if (!strcmp(name, "cyan")) | |
208 return COLOR_CYAN; | |
209 if (!strcmp(name, "white")) | |
210 return COLOR_WHITE; | |
211 | |
1417
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
212 // Directly support 256-color values |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
213 result = atoi(name); |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
214 if (result > 0 && result < COLORS) |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
215 return result; |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
216 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
217 scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name); |
24 | 218 return -1; |
219 } | |
220 | |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
221 static ccolor * get_user_color(const char *color) |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
222 { |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
223 bool isbright = FALSE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
224 int cl; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
225 ccolor * ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
226 if (!strncmp(color, "bright", 6)) { |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
227 isbright = TRUE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
228 color += 6; |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
229 } |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
230 cl = FindColor(color); |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
231 if (cl < 0) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
232 return NULL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
233 ccol = g_new0(ccolor, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
234 ccol->color_attrib = isbright ? A_BOLD : A_NORMAL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
235 ccol->color_pair = cl + COLOR_max; //user colors come after the internal ones |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
236 return ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
237 } |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
238 |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
239 static void ensure_string_htable(GHashTable **table, |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
240 GDestroyNotify value_destroy_func) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
241 { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
242 if (*table)//Have it already |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
243 return; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
244 *table = g_hash_table_new_full(g_str_hash, g_str_equal, |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
245 g_free, value_destroy_func); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
246 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
247 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
248 // Sets the coloring mode for given MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
249 // The MUC room does not need to be in the roster at that time |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
250 // muc - the JID of room |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
251 // type - the new type |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
252 void scr_MucColor(const char *muc, muccoltype type) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
253 { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
254 gchar *muclow = g_utf8_strdown(muc, -1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
255 if (type == MC_REMOVE) {//Remove it |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
256 if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
257 if (muccolors && g_hash_table_lookup(muccolors, muclow)) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
258 g_hash_table_remove(muccolors, muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
259 } else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
260 scr_LogPrint(LPRINT_NORMAL, "Can not remove global coloring mode"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
261 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
262 g_free(muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
263 } else {//Add or overwrite |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
264 if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
265 muccoltype *value = g_new(muccoltype, 1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
266 *value = type; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
267 ensure_string_htable(&muccolors, g_free); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
268 g_hash_table_replace(muccolors, muclow, value); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
269 } else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
270 glob_muccol = type; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
271 g_free(muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
272 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
273 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
274 //Need to redraw? |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
275 if (chatmode && |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
276 ((buddy_search_jid(muc) == current_buddy) || !strcmp(muc, "*"))) |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
277 scr_UpdateBuddyWindow(); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
278 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
279 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
280 // Sets the color for nick in MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
281 // If color is "-", the color is marked as automaticly assigned and is |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
282 // not used if the room is in the "preset" mode |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
283 void scr_MucNickColor(const char *nick, const char *color) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
284 { |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
285 char *snick, *mnick; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
286 bool need_update = FALSE; |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
287 snick = g_strdup_printf("<%s>", nick); |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
288 mnick = g_strdup_printf("*%s ", nick); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
289 if (!strcmp(color, "-")) {//Remove the color |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
290 if (nickcolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
291 nickcolor *nc = g_hash_table_lookup(nickcolors, snick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
292 if (nc) {//Have this nick already |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
293 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
294 nc = g_hash_table_lookup(nickcolors, mnick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
295 assert(nc);//Must have both at the same time |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
296 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
297 }// Else -> no color saved, nothing to delete |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
298 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
299 g_free(snick);//They are not saved in the hash |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
300 g_free(mnick); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
301 need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
302 } else { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
303 ccolor * cl = get_user_color(color); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
304 if (!cl) { |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
305 scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
306 g_free(snick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
307 g_free(mnick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
308 } else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
309 nickcolor *nc = g_new(nickcolor, 1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
310 ensure_string_htable(&nickcolors, NULL); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
311 nc->manual = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
312 nc->color = cl; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
313 //Free the struct, if any there already |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
314 g_free(g_hash_table_lookup(nickcolors, mnick)); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
315 //Save the new ones |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
316 g_hash_table_replace(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
317 g_hash_table_replace(nickcolors, snick, nc); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
318 need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
319 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
320 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
321 if (need_update && chatmode && |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
322 (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM)) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
323 scr_UpdateBuddyWindow(); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
324 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
325 |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
326 static void free_rostercolrule(rostercolor *col) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
327 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
328 g_free(col->status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
329 g_free(col->wildcard); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
330 g_free(col->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
331 g_pattern_spec_free(col->compiled); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
332 g_free(col); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
333 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
334 |
1284 | 335 // Removes all roster coloring rules |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
336 void scr_RosterClearColor(void) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
337 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
338 GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
339 for (head = rostercolrules; head; head = g_slist_next(head)) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
340 free_rostercolrule(head->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
341 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
342 g_slist_free(rostercolrules); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
343 rostercolrules = NULL; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
344 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
345 |
1284 | 346 // Adds, modifies or removes roster coloring rule |
347 // color set to "-" removes the rule, | |
348 // otherwise it is modified (if exists) or added | |
349 // | |
350 // Returns weather it was successfull (therefore the roster should be | |
351 // redrawed) or not. If it failed, for example because of invalid color | |
352 // name, it also prints the error. | |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
353 bool scr_RosterColor(const char *status, const char *wildcard, |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
354 const char *color) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
355 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
356 GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
357 GSList *found = NULL; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
358 for (head = rostercolrules; head; head = g_slist_next(head)) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
359 rostercolor *rc = head->data; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
360 if ((!strcmp(status, rc->status)) && (!strcmp(wildcard, rc->wildcard))) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
361 found = head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
362 break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
363 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
364 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
365 if (!strcmp(color,"-")) {//Delete the rule |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
366 if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
367 free_rostercolrule(found->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
368 rostercolrules = g_slist_delete_link(rostercolrules, found); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
369 return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
370 } else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
371 scr_LogPrint(LPRINT_NORMAL, "No such color rule, nothing removed"); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
372 return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
373 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
374 } else { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
375 ccolor * cl = get_user_color(color); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
376 if (!cl) { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
377 scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
378 return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
379 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
380 if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
381 rostercolor *rc = found->data; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
382 g_free(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
383 rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
384 } else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
385 rostercolor *rc = g_new(rostercolor, 1); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
386 rc->status = g_strdup(status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
387 rc->wildcard = g_strdup(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
388 rc->compiled = g_pattern_spec_new(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
389 rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
390 rostercolrules = g_slist_prepend(rostercolrules, rc); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
391 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
392 return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
393 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
394 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
395 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
396 static void ParseColors(void) |
24 | 397 { |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
398 const char *colors[] = { |
24 | 399 "", "", |
267 | 400 "general", |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
401 "msgout", |
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
402 "msghl", |
711 | 403 "status", |
712 | 404 "roster", |
405 "rostersel", | |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
406 "rosterselmsg", |
712 | 407 "rosternewmsg", |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
408 "info", |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
409 "msgin", |
24 | 410 NULL |
411 }; | |
412 | |
281
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
413 const char *color; |
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
414 const char *background = settings_opt_get("color_background"); |
712 | 415 const char *backselected = settings_opt_get("color_bgrostersel"); |
416 const char *backstatus = settings_opt_get("color_bgstatus"); | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
417 char *tmp; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
418 int i; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
419 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
420 // Initialize color attributes |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
421 memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB)); |
24 | 422 |
267 | 423 // Default values |
711 | 424 if (!background) background = "black"; |
267 | 425 if (!backselected) backselected = "cyan"; |
711 | 426 if (!backstatus) backstatus = "blue"; |
267 | 427 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
428 for (i=0; colors[i]; i++) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
429 tmp = g_strdup_printf("color_%s", colors[i]); |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
430 color = settings_opt_get(tmp); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
431 g_free(tmp); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
432 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
433 if (color) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
434 if (!strncmp(color, "bright", 6)) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
435 COLOR_ATTRIB[i+1] = A_BOLD; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
436 color += 6; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
437 } |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
438 } |
24 | 439 |
440 switch (i + 1) { | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
441 case 1: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
442 init_pair(1, COLOR_BLACK, COLOR_WHITE); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
443 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
444 case 2: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
445 init_pair(2, COLOR_WHITE, COLOR_BLACK); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
446 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
447 case COLOR_GENERAL: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
448 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
449 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
450 break; |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
451 case COLOR_MSGOUT: |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
452 init_pair(i+1, ((color) ? FindColor(color) : COLOR_CYAN), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
453 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
454 break; |
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
455 case COLOR_MSGHL: |
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
456 init_pair(i+1, ((color) ? FindColor(color) : COLOR_YELLOW), |
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
457 FindColor(background)); |
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
458 break; |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
459 case COLOR_STATUS: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
460 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
461 FindColor(backstatus)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
462 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
463 case COLOR_ROSTER: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
464 init_pair(i+1, ((color) ? FindColor(color) : COLOR_GREEN), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
465 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
466 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
467 case COLOR_ROSTERSEL: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
468 init_pair(i+1, ((color) ? FindColor(color) : COLOR_BLUE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
469 FindColor(backselected)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
470 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
471 case COLOR_ROSTERSELNMSG: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
472 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
473 FindColor(backselected)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
474 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
475 case COLOR_ROSTERNMSG: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
476 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
477 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
478 break; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
479 case COLOR_INFO: |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
480 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
481 FindColor(background)); |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
482 break; |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
483 case COLOR_MSGIN: |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
484 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
485 FindColor(background)); |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
486 break; |
24 | 487 } |
488 } | |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
489 for (i = COLOR_max; i < (COLOR_max + COLORS); i++) |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
490 init_pair(i, i-COLOR_max, FindColor(background)); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
491 |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
492 if (!nickcols) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
493 char *ncolors = g_strdup(settings_opt_get("nick_colors")); |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
494 if (ncolors) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
495 char *ncolor_start, *ncolor_end; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
496 ncolor_start = ncolor_end = ncolors; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
497 |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
498 while (*ncolor_end) |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
499 ncolor_end++; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
500 |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
501 while (ncolors < ncolor_end && *ncolors) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
502 if ((*ncolors == ' ') || (*ncolors == '\t')) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
503 ncolors++; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
504 } else { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
505 char *end = ncolors; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
506 ccolor * cl; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
507 while (*end && (*end != ' ') && (*end != '\t')) |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
508 end++; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
509 *end = '\0'; |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
510 cl = get_user_color(ncolors); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
511 if (!cl) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
512 scr_LogPrint(LPRINT_NORMAL, "Unknown color %s", ncolors); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
513 } else { |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
514 nickcols = g_realloc(nickcols, (++nickcolcount) * sizeof *nickcols); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
515 nickcols[nickcolcount-1] = cl; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
516 } |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
517 ncolors = end+1; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
518 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
519 } |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
520 g_free(ncolor_start); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
521 } |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
522 if (!nickcols) {//Fallback to have something |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
523 nickcolcount = 1; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
524 nickcols = g_new(ccolor*, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
525 *nickcols = g_new(ccolor, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
526 (*nickcols)->color_pair = COLOR_GENERAL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
527 (*nickcols)->color_attrib = A_NORMAL; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
528 } |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
529 } |
24 | 530 } |
531 | |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
532 static void init_keycodes(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
533 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
534 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
535 add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
536 add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
537 add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 538 add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up |
539 add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down | |
540 add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right | |
541 add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left | |
542 add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up | |
543 add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down | |
544 add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right | |
545 add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left | |
546 add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
547 add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown | |
548 add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp | |
549 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
|
550 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
|
551 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
|
552 add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
553 add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
554 add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
555 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
|
556 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
557 // Xterm |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
558 add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
559 add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
560 add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
561 add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
562 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
|
563 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
|
564 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
|
565 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
|
566 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
|
567 add_keyseq("[1;6F", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End |
763 | 568 add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up |
569 add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down | |
570 add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
571 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
|
572 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
|
573 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
|
574 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
|
575 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
|
576 |
768
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
577 // PuTTY |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
578 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
|
579 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
|
580 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
|
581 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
|
582 |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
583 // screen |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
584 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
|
585 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
|
586 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
|
587 add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 588 add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up |
589 add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down | |
590 add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right | |
591 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
|
592 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
|
593 add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown |
1170 | 594 |
595 // VT100 | |
596 add_keyseq("[H", MKEY_EQUIV, KEY_HOME); // Home | |
597 add_keyseq("[F", MKEY_EQUIV, KEY_END); // End | |
598 | |
599 // Konsole Linux | |
600 add_keyseq("[1~", MKEY_EQUIV, KEY_HOME); // Home | |
601 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
|
602 } |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
603 |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
604 // scr_init_bindings() |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
605 // Create default key bindings |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
606 // 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
|
607 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
|
608 { |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
609 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
|
610 |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
611 // 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
|
612 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
|
613 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
|
614 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
|
615 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
|
616 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
|
617 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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 g_string_printf(sbuf, "%d", KEY_UP); |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
624 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
625 "iline hist_beginning_search_bwd"); |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
626 g_string_printf(sbuf, "%d", KEY_DOWN); |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
627 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
628 "iline hist_beginning_search_fwd"); |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
629 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
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 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
|
638 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
|
639 // 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
|
640 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
|
641 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
|
642 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
|
643 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
|
644 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
|
645 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
|
646 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
|
647 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
|
648 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
|
649 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
|
650 settings_set(SETTINGS_TYPE_BINDING, "M102", "iline fword"); // Meta-f |
1186
0158bd8ca9d6
Add a default binding to Meta-d (iline word_fdel)
Mikael Berthe <mikael@lilotux.net>
parents:
1185
diff
changeset
|
651 settings_set(SETTINGS_TYPE_BINDING, "M100", "iline word_fdel"); // Meta-d |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
652 // Ctrl-Left (2 codes): |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
653 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
|
654 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
|
655 // Ctrl-Right (2 codes): |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
656 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
|
657 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
|
658 settings_set(SETTINGS_TYPE_BINDING, "12", "screen_refresh"); // Ctrl-l |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
659 settings_set(SETTINGS_TYPE_BINDING, "27", "chat_disable --show-roster");// Esc |
1185
5c34af370b67
Bind Meta-Esc (Esc-Esc) to chat_disable by default
Mikael Berthe <mikael@lilotux.net>
parents:
1179
diff
changeset
|
660 settings_set(SETTINGS_TYPE_BINDING, "M27", "chat_disable"); // Esc-Esc |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
661 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
|
662 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
|
663 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
|
664 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
|
665 |
1208
0dbe51d1e62e
Add default binding for F1 (265) to /help
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
666 settings_set(SETTINGS_TYPE_BINDING, "265", "help"); // Bind F1 to help... |
0dbe51d1e62e
Add default binding for F1 (265) to /help
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
667 |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
668 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
|
669 } |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
670 |
1229
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
671 // is_speckey(key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
672 // Return TRUE if key is a special code, i.e. no char should be displayed on |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
673 // the screen. It's not very nice, it's a workaround for the systems where |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
674 // isprint(KEY_PPAGE) returns TRUE... |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
675 static int is_speckey(int key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
676 { |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
677 switch (key) { |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
678 case 127: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
679 case 393: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
680 case 402: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
681 case KEY_BACKSPACE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
682 case KEY_DC: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
683 case KEY_LEFT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
684 case KEY_RIGHT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
685 case KEY_UP: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
686 case KEY_DOWN: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
687 case KEY_PPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
688 case KEY_NPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
689 case KEY_HOME: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
690 case KEY_END: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
691 case KEY_EOL: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
692 return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
693 } |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
694 |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
695 // Fn keys |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
696 if (key >= 265 && key < 265+12) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
697 return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
698 |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
699 // Special key combinations |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
700 if (key >= 513 && key <= 521) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
701 return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
702 |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
703 return FALSE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
704 } |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
705 |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
706 void scr_InitLocaleCharSet(void) |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
707 { |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
708 setlocale(LC_CTYPE, ""); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
709 #ifdef HAVE_LOCALCHARSET_H |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
710 LocaleCharSet = locale_charset(); |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
711 #else |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
712 LocaleCharSet = nl_langinfo(CODESET); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
713 #endif |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
714 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
715 } |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
716 |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
717 void scr_InitCurses(void) |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
718 { |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
719 /* Key sequences initialization */ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
720 init_keycodes(); |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
721 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
722 initscr(); |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
723 raw(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
724 noecho(); |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
725 nonl(); |
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
726 intrflush(stdscr, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
727 start_color(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
728 use_default_colors(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
729 |
1386 | 730 if (settings_opt_get("escdelay")) { |
731 #ifdef HAVE_ESCDELAY | |
732 ESCDELAY = (unsigned) settings_opt_get_int("escdelay"); | |
733 #else | |
734 scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support."); | |
735 #endif | |
736 } | |
737 | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
738 ParseColors(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
739 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
740 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
|
741 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
|
742 // 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
|
743 // 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
|
744 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
745 inputLine[0] = 0; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
746 ptr_inputline = inputLine; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
747 |
966
d9acb7f2a3d1
Do not set Curses variable too early
Mikael Berthe <mikael@lilotux.net>
parents:
961
diff
changeset
|
748 Curses = TRUE; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
749 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
750 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
751 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
752 void scr_TerminateCurses(void) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
753 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
754 if (!Curses) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
755 clear(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
756 refresh(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
757 endwin(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
758 Curses = FALSE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
759 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
760 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
761 |
1413 | 762 void scr_Beep(void) |
675
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
763 { |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
764 beep(); |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
765 } |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
766 |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
767 // This and following belongs to dynamic setting of time prefix |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
768 static const char *timeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
769 "%m-%d %H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
770 "%H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
771 " " |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
772 }; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
773 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
774 static const char *spectimeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
775 "%m-%d %H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
776 "%H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
777 " " |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
778 }; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
779 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
780 static int timepreflengths[] = { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
781 // (length of the corresponding timeprefix + 5) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
782 17, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
783 11, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
784 6 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
785 }; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
786 |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
787 static const char *gettprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
788 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
789 guint n = settings_opt_get_int("time_prefix"); |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
790 return timeprefixes[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
791 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
792 |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
793 static const char *getspectprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
794 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
795 guint n = settings_opt_get_int("time_prefix"); |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
796 return spectimeprefixes[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
797 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
798 |
1487 | 799 guint scr_getprefixwidth(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
800 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
801 guint n = settings_opt_get_int("time_prefix"); |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
802 return timepreflengths[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
803 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
804 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
805 // scr_LogPrint(...) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
806 // 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
|
807 // 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
|
808 void scr_LogPrint(unsigned int flag, const char *fmt, ...) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
809 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
810 time_t timestamp; |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
811 char strtimestamp[64]; |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
812 char *buffer, *btext; |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
813 char *convbuf1 = NULL, *convbuf2 = NULL; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
814 va_list ap; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
815 |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
816 if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
817 |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
818 timestamp = time(NULL); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
819 strftime(strtimestamp, 48, "[%H:%M:%S]", localtime(×tamp)); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
820 va_start(ap, fmt); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
821 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
|
822 va_end(ap); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
823 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
824 if (flag & LPRINT_NORMAL) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
825 char *buffer_locale; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
826 char *buf_specialwindow; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
827 |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
828 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
|
829 |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
830 // 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
|
831 if (!(flag & LPRINT_NOTUTF8)) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
832 buffer_locale = convbuf1 = from_utf8(buffer); |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
833 else |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
834 buffer_locale = buffer; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
835 |
884
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
836 if (!buffer_locale) { |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
837 wprintw(logWnd, |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
838 "\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
|
839 update_panels(); |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
840 g_free(buffer); |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
841 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
|
842 return; |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
843 } |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
844 |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
845 // 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
|
846 if (flag & LPRINT_NOTUTF8) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
847 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
|
848 else |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
849 buf_specialwindow = btext; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
850 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
851 if (Curses) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
852 wprintw(logWnd, "\n%s", buffer_locale); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
853 update_panels(); |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
854 scr_WriteInWindow(NULL, buf_specialwindow, timestamp, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
855 HBB_PREFIX_SPECIAL, FALSE, 0); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
856 } else { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
857 printf("%s\n", buffer_locale); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
858 // 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
|
859 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
860 HBB_PREFIX_SPECIAL, 0, 0, 0); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
861 } |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
862 |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
863 g_free(convbuf1); |
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
864 g_free(convbuf2); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
865 g_free(buffer); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
866 } |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
867 |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
868 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
869 strftime(strtimestamp, 23, "[%Y-%m-%d %H:%M:%S]", localtime(×tamp)); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
870 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
|
871 ut_WriteLog(flag, buffer); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
872 g_free(buffer); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
873 } |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
874 g_free(btext); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
875 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
876 |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
877 static winbuf *scr_SearchWindow(const char *winId, int special) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
878 { |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
879 char *id; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
880 winbuf *wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
881 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
882 if (special) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
883 return statusWindow; // Only one special window atm. |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
884 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
885 if (!winId) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
886 return NULL; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
887 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
888 id = g_strdup(winId); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
889 mc_strtolower(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
890 wbp = g_hash_table_lookup(winbufhash, id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
891 g_free(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
892 return wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
893 } |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
894 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
895 int scr_BuddyBufferExists(const char *bjid) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
896 { |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
897 return (scr_SearchWindow(bjid, FALSE) != NULL); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
898 } |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
899 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
900 // scr_new_buddy(title, dontshow) |
1139 | 901 // 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
|
902 static winbuf *scr_new_buddy(const char *title, int dont_show) |
24 | 903 { |
822 | 904 winbuf *tmp; |
393 | 905 |
822 | 906 tmp = g_new0(winbuf, 1); |
24 | 907 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
908 tmp->win = activechatWnd; |
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
909 tmp->panel = activechatPanel; |
24 | 910 |
143 | 911 if (!dont_show) { |
24 | 912 currentWindow = tmp; |
913 } else { | |
914 if (currentWindow) | |
915 top_panel(currentWindow->panel); | |
916 else | |
917 top_panel(chatPanel); | |
918 } | |
143 | 919 update_panels(); |
24 | 920 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
921 // If title is NULL, this is a special buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
922 if (title) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
923 char *id; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
924 id = hlog_get_log_jid(title); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
925 if (id) { |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
926 winbuf *wb = scr_SearchWindow(id, FALSE); |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
927 if (!wb) |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
928 wb = scr_new_buddy(id, TRUE); |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
929 tmp->bd=wb->bd; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
930 g_free(id); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
931 } 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
|
932 tmp->bd = g_new0(buffdata, 1); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
933 hlog_read_history(title, &tmp->bd->hbuf, |
1487 | 934 maxX - Roster_Width - scr_getprefixwidth()); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
935 } |
181 | 936 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
937 id = g_strdup(title); |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
938 mc_strtolower(id); |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
939 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
|
940 } else { |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
941 tmp->bd = g_new0(buffdata, 1); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
942 } |
24 | 943 return tmp; |
944 } | |
945 | |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
946 // scr_line_prefix(line, pref, preflen) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
947 // Use data from the hbb_line structure and write the prefix |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
948 // to pref (not exceeding preflen, trailing null byte included). |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
949 void scr_line_prefix(hbb_line *line, char *pref, guint preflen) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
950 { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
951 char date[64]; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
952 |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
953 if (line->timestamp && |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
954 !(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
955 strftime(date, 30, gettprefix(), localtime(&line->timestamp)); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
956 } else |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
957 strcpy(date, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
958 |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
959 if (!(line->flags & HBB_PREFIX_CONT)) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
960 if (line->flags & HBB_PREFIX_INFO) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
961 char dir = '*'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
962 if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
963 dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
964 else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
965 dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
966 g_snprintf(pref, preflen, "%s*%c* ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
967 } else if (line->flags & HBB_PREFIX_ERR) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
968 char dir = '#'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
969 if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
970 dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
971 else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
972 dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
973 g_snprintf(pref, preflen, "%s#%c# ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
974 } else if (line->flags & HBB_PREFIX_IN) { |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
975 char cryptflag; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
976 if (line->flags & HBB_PREFIX_PGPCRYPT) |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
977 cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
978 else if (line->flags & HBB_PREFIX_OTRCRYPT) |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
979 cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
980 else |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
981 cryptflag = '='; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
982 g_snprintf(pref, preflen, "%s<%c= ", date, cryptflag); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
983 } else if (line->flags & HBB_PREFIX_OUT) { |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
984 char cryptflag; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
985 if (line->flags & HBB_PREFIX_PGPCRYPT) |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
986 cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
987 else if (line->flags & HBB_PREFIX_OTRCRYPT) |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
988 cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
989 else |
1488
b393b8cee171
Fix small mistake in changeset 7b36b91a4388
Mikael Berthe <mikael@lilotux.net>
parents:
1487
diff
changeset
|
990 cryptflag = '-'; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
991 g_snprintf(pref, preflen, "%s-%c> ", date, cryptflag); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
992 } else if (line->flags & HBB_PREFIX_SPECIAL) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
993 strftime(date, 30, getspectprefix(), localtime(&line->timestamp)); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
994 g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
995 } else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
996 g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
997 } |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
998 } else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
999 g_snprintf(pref, preflen, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1000 } |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1001 } |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1002 |
143 | 1003 // scr_UpdateWindow() |
1004 // (Re-)Display the given chat window. | |
822 | 1005 static void scr_UpdateWindow(winbuf *win_entry) |
74 | 1006 { |
1007 int n; | |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1008 int width; |
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1009 guint prefixwidth; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1010 char pref[96]; |
184 | 1011 hbb_line **lines, *line; |
74 | 1012 GList *hbuf_head; |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1013 int color; |
74 | 1014 |
1077
c51ca5225516
Remove useless WindowWidth function
Mikael Berthe <mikael@lilotux.net>
parents:
1076
diff
changeset
|
1015 width = getmaxx(win_entry->win); |
1487 | 1016 prefixwidth = scr_getprefixwidth(); |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1017 prefixwidth = MIN(prefixwidth, sizeof pref); |
108 | 1018 |
1019 // Should the window be empty? | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1020 if (win_entry->bd->cleared) { |
168 | 1021 werase(win_entry->win); |
108 | 1022 return; |
1023 } | |
1024 | |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1025 // 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
|
1026 // we are displaying the last messages. |
105 | 1027 |
74 | 1028 // We will show the last CHAT_WIN_HEIGHT lines. |
1029 // Let's find out where it begins. | |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1030 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
|
1031 win_entry->bd->top) == -1)) { |
105 | 1032 // 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
|
1033 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
|
1034 hbuf_head = win_entry->bd->hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1035 win_entry->bd->top = NULL; // (Just to make sure) |
105 | 1036 n = 0; |
1037 while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { | |
1038 hbuf_head = g_list_previous(hbuf_head); | |
1039 n++; | |
1040 } | |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1041 // 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
|
1042 if (win_entry->bd->lock) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1043 win_entry->bd->top = hbuf_head; |
105 | 1044 } else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1045 hbuf_head = win_entry->bd->top; |
74 | 1046 |
1047 // Get the last CHAT_WIN_HEIGHT lines. | |
1048 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); | |
1049 | |
1050 // Display these lines | |
1051 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { | |
168 | 1052 wmove(win_entry->win, n, 0); |
184 | 1053 line = *(lines+n); |
1054 if (line) { | |
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
1055 if (line->flags & HBB_PREFIX_HLIGHT_OUT) |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1056 color = COLOR_MSGOUT; |
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
1057 else if (line->flags & HBB_PREFIX_HLIGHT) |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1058 color = COLOR_MSGHL; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1059 else if (line->flags & HBB_PREFIX_INFO) |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1060 color = COLOR_INFO; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1061 else if (line->flags & HBB_PREFIX_IN) |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1062 color = COLOR_MSGIN; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1063 else |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1064 color = COLOR_GENERAL; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1065 |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1066 if (color != COLOR_GENERAL) |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1067 wattrset(win_entry->win, get_color(color)); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1068 |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1069 // Generate the prefix area and display it |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1070 scr_line_prefix(line, pref, prefixwidth); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1071 wprintw(win_entry->win, pref); |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1072 |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
1073 // Make sure we are at the right position |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1074 wmove(win_entry->win, n, prefixwidth-1); |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1075 |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1076 // The MUC nick - overwrite with proper color |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1077 if (line->mucnicklen) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1078 char *mucjid; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1079 char tmp; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1080 nickcolor *actual = NULL; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1081 muccoltype type, *typetmp; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1082 |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1083 // Store the char after the nick |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1084 tmp = line->text[line->mucnicklen]; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1085 type = glob_muccol; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1086 // Terminate the string after the nick |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1087 line->text[line->mucnicklen] = '\0'; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1088 mucjid = g_utf8_strdown(CURRENT_JID, -1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1089 if (muccolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1090 typetmp = g_hash_table_lookup(muccolors, mucjid); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1091 if (typetmp) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1092 type = *typetmp; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1093 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1094 g_free(mucjid); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1095 // Need to generate a color for the specified nick? |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1096 if ((type == MC_ALL) && (!nickcolors || |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1097 !g_hash_table_lookup(nickcolors, line->text))) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1098 char *snick, *mnick; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1099 nickcolor *nc; |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1100 const char *p = line->text; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1101 unsigned int nicksum = 0; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1102 snick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1103 mnick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1104 nc = g_new(nickcolor, 1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1105 ensure_string_htable(&nickcolors, NULL); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1106 while (*p) |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1107 nicksum += *p++; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1108 nc->color = nickcols[nicksum % nickcolcount]; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
1109 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1110 *snick = '<'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1111 snick[strlen(snick)-1] = '>'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1112 *mnick = '*'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1113 mnick[strlen(mnick)-1] = ' '; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1114 // Insert them |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1115 g_hash_table_insert(nickcolors, snick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1116 g_hash_table_insert(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1117 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1118 if (nickcolors) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1119 actual = g_hash_table_lookup(nickcolors, line->text); |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1120 if (actual && ((type == MC_ALL) || (actual->manual)) |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1121 && (line->flags & HBB_PREFIX_IN) && |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1122 (!(line->flags & HBB_PREFIX_HLIGHT_OUT))) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
1123 wattrset(win_entry->win, compose_color(actual->color)); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1124 wprintw(win_entry->win, "%s", line->text); |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1125 // Return the char |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1126 line->text[line->mucnicklen] = tmp; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1127 // Return the color back |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1128 wattrset(win_entry->win, get_color(color)); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1129 } |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1130 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1131 // Display text line |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1132 wprintw(win_entry->win, "%s", line->text+line->mucnicklen); |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1133 wclrtoeol(win_entry->win); |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1134 |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1135 // Return the color back |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1136 if (color != COLOR_GENERAL) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1137 wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1138 |
184 | 1139 g_free(line->text); |
898
c65b71dcda94
Fix memory leak in scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
897
diff
changeset
|
1140 g_free(line); |
168 | 1141 } else { |
1142 wclrtobot(win_entry->win); | |
1143 break; | |
75 | 1144 } |
74 | 1145 } |
1146 g_free(lines); | |
1147 } | |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1148 |
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1149 static winbuf *scr_CreateWindow(const char *winId, int special, int dont_show) |
1154 | 1150 { |
1151 if (special) { | |
1152 if (!statusWindow) { | |
1153 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
|
1154 statusWindow->bd->hbuf = statushbuf; |
1154 | 1155 } |
1156 return statusWindow; | |
1157 } else { | |
1158 return scr_new_buddy(winId, dont_show); | |
1159 } | |
1160 } | |
1161 | |
143 | 1162 // scr_ShowWindow() |
1163 // Display the chat window with the given identifier. | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1164 // "special" must be true if this is a special buffer window. |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1165 static void scr_ShowWindow(const char *winId, int special) |
24 | 1166 { |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1167 winbuf *win_entry; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1168 |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1169 win_entry = scr_SearchWindow(winId, special); |
74 | 1170 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1171 if (!win_entry) { |
1154 | 1172 win_entry = scr_CreateWindow(winId, special, FALSE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1173 } |
74 | 1174 |
180 | 1175 top_panel(win_entry->panel); |
1176 currentWindow = win_entry; | |
1177 chatmode = TRUE; | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1178 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
|
1179 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
|
1180 if (!special) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1181 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
|
1182 update_roster = TRUE; |
74 | 1183 |
180 | 1184 // Refresh the window |
1185 scr_UpdateWindow(win_entry); | |
1186 | |
1187 // Finished :) | |
1188 update_panels(); | |
142 | 1189 |
1190 top_panel(inputPanel); | |
24 | 1191 } |
1192 | |
143 | 1193 // scr_ShowBuddyWindow() |
1194 // Display the chat window buffer for the current buddy. | |
24 | 1195 void scr_ShowBuddyWindow(void) |
1196 { | |
1058 | 1197 const gchar *bjid; |
140 | 1198 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1199 if (!current_buddy) { |
1058 | 1200 bjid = NULL; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1201 } else { |
1058 | 1202 bjid = CURRENT_JID; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1203 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1204 scr_ShowWindow(buddy_getname(BUDDATA(current_buddy)), TRUE); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1205 return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1206 } |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1207 } |
140 | 1208 |
1058 | 1209 if (!bjid) { |
140 | 1210 top_panel(chatPanel); |
143 | 1211 top_panel(inputPanel); |
140 | 1212 currentWindow = NULL; |
105 | 1213 return; |
140 | 1214 } |
1215 | |
1058 | 1216 scr_ShowWindow(bjid, FALSE); |
24 | 1217 } |
1218 | |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1219 // scr_UpdateBuddyWindow() |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1220 // (Re)Display the current window. |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1221 // 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
|
1222 // else display the chat window. |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1223 inline void scr_UpdateBuddyWindow(void) |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1224 { |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1225 if (chatmode) { |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1226 scr_ShowBuddyWindow(); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1227 return; |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1228 } |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1229 |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1230 top_panel(chatPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1231 top_panel(inputPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1232 } |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1233 |
143 | 1234 // scr_WriteInWindow() |
1235 // 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
|
1236 // Use winId == NULL for the special status buffer. |
143 | 1237 // Lines are splitted when they are too long to fit in the chat window. |
1238 // If this window doesn't exist, it is created. | |
184 | 1239 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1240 unsigned int prefix_flags, int force_show, |
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1241 unsigned mucnicklen) |
24 | 1242 { |
822 | 1243 winbuf *win_entry; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1244 char *text_locale; |
24 | 1245 int dont_show = FALSE; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1246 int special; |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1247 guint num_history_blocks; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1248 bool setmsgflg = FALSE; |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1249 char *nicktmp, *nicklocaltmp; |
24 | 1250 |
74 | 1251 // Look for the window entry. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1252 special = (winId == NULL); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1253 win_entry = scr_SearchWindow(winId, special); |
74 | 1254 |
1255 // Do we have to really show the window? | |
24 | 1256 if (!chatmode) |
1257 dont_show = TRUE; | |
74 | 1258 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24 | 1259 dont_show = TRUE; |
1260 | |
74 | 1261 // 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
|
1262 if (!win_entry) { |
1154 | 1263 win_entry = scr_CreateWindow(winId, special, dont_show); |
24 | 1264 } |
1265 | |
220 | 1266 // 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
|
1267 if (win_entry->bd->cleared) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1268 win_entry->bd->top = g_list_last(win_entry->bd->hbuf); |
220 | 1269 |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1270 // 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
|
1271 // top is set. |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1272 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
|
1273 num_history_blocks = 0U; |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1274 else |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1275 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
|
1276 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1277 text_locale = from_utf8(text); |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1278 //Convert the nick alone and compute its length |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1279 if (mucnicklen) { |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1280 nicktmp = g_strndup(text, mucnicklen); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1281 nicklocaltmp = from_utf8(nicktmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1282 mucnicklen = strlen(nicklocaltmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1283 g_free(nicklocaltmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1284 g_free(nicktmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1285 } |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1286 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, |
1487 | 1287 maxX - Roster_Width - scr_getprefixwidth(), num_history_blocks, |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1288 mucnicklen); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1289 g_free(text_locale); |
74 | 1290 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1291 if (win_entry->bd->cleared) { |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1292 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1293 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
|
1294 win_entry->bd->top = g_list_next(win_entry->bd->top); |
220 | 1295 } |
1296 | |
1297 // 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
|
1298 if (!win_entry->bd->lock && win_entry->bd->top) { |
220 | 1299 int dist; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1300 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
|
1301 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
|
1302 g_list_position(first, win_entry->bd->top); |
220 | 1303 if (dist >= CHAT_WIN_HEIGHT) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1304 win_entry->bd->top = NULL; |
108 | 1305 } |
1306 | |
24 | 1307 if (!dont_show) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1308 if (win_entry->bd->lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1309 setmsgflg = TRUE; |
74 | 1310 // Show and refresh the window |
1311 top_panel(win_entry->panel); | |
1312 scr_UpdateWindow(win_entry); | |
142 | 1313 top_panel(inputPanel); |
24 | 1314 update_panels(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1315 } 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
|
1316 setmsgflg = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1317 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1318 if (setmsgflg && !special) { |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1319 if (special && !winId) |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1320 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
|
1321 roster_msg_setflag(winId, special, TRUE); |
30 | 1322 update_roster = TRUE; |
24 | 1323 } |
1324 } | |
1325 | |
713 | 1326 // scr_UpdateMainStatus() |
1327 // Redraw the main (bottom) status line. | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1328 void scr_UpdateMainStatus(int forceupdate) |
713 | 1329 { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1330 char *sm = from_utf8(jb_getstatusmsg()); |
1514 | 1331 const char *info = settings_opt_get("info"); |
713 | 1332 |
1333 werase(mainstatusWnd); | |
1515 | 1334 if (info) { |
1335 char *info_utf8 = from_utf8(info); | |
1514 | 1336 mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s: %s", |
1337 (unread_msg(NULL) ? '#' : ' '), | |
1338 imstatus2char[jb_getstatus()], | |
1515 | 1339 info_utf8, (sm ? sm : "")); |
1340 g_free(info_utf8); | |
1341 } else | |
1514 | 1342 mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s", |
1343 (unread_msg(NULL) ? '#' : ' '), | |
1344 imstatus2char[jb_getstatus()], (sm ? sm : "")); | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1345 if (forceupdate) { |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1346 top_panel(inputPanel); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1347 update_panels(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1348 } |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1349 g_free(sm); |
713 | 1350 } |
1351 | |
151 | 1352 // scr_DrawMainWindow() |
157 | 1353 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151 | 1354 // |
1355 // I think it could be improved a _lot_ but I'm really not an ncurses | |
1356 // expert... :-\ Mikael. | |
1357 // | |
1358 void scr_DrawMainWindow(unsigned int fullinit) | |
24 | 1359 { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1360 int requested_size; |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1361 gchar *ver, *message; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1362 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
|
1363 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
|
1364 |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1365 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
|
1366 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
|
1367 if (requested_size > 0) { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1368 if (maxY > requested_size + 3) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1369 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
|
1370 else |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1371 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
|
1372 } else if (requested_size < 0) { |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1373 Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1374 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1375 |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1376 if (maxY < Log_Win_Height+2) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1377 if (maxY < 5) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1378 Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1379 maxY = Log_Win_Height+2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1380 } else { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1381 Log_Win_Height = maxY - 2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1382 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1383 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1384 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1385 if (roster_hidden) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1386 Roster_Width = 0; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1387 } else { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1388 requested_size = settings_opt_get_int("roster_width"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1389 if (requested_size > 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1390 Roster_Width = requested_size; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1391 else if (requested_size == 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1392 Roster_Width = 2; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1393 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1394 Roster_Width = DEFAULT_ROSTER_WIDTH; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1395 } |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1396 |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1397 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
|
1398 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
|
1399 |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1400 if (log_win_on_top) { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1401 chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1402 log_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1403 chatstatus_y_pos = Log_Win_Height-2; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1404 } else { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1405 chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1406 log_y_pos = CHAT_WIN_HEIGHT+1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1407 chatstatus_y_pos = CHAT_WIN_HEIGHT; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1408 } |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1409 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1410 if (roster_win_on_right) { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1411 roster_x_pos = maxX - Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1412 chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1413 } else { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1414 roster_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1415 chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1416 } |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1417 |
157 | 1418 if (fullinit) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1419 if (!winbufhash) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1420 winbufhash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
157 | 1421 /* Create windows */ |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1422 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
|
1423 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
|
1424 chat_x_pos); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1425 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
|
1426 chat_x_pos); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1427 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
|
1428 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); |
711 | 1429 mainstatusWnd = newwin(1, maxX, maxY-2, 0); |
157 | 1430 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
|
1431 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
|
1432 scr_TerminateCurses(); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1433 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
|
1434 exit(EXIT_FAILURE); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1435 } |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1436 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1437 wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1438 wbkgd(activechatWnd, get_color(COLOR_GENERAL)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1439 wbkgd(logWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1440 wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1441 wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
157 | 1442 } else { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1443 /* Resize/move windows */ |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1444 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1445 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
711 | 1446 wresize(logWnd, Log_Win_Height-2, maxX); |
157 | 1447 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1448 mvwin(chatWnd, chat_y_pos, chat_x_pos); |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1449 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
|
1450 mvwin(logWnd, log_y_pos, 0); |
157 | 1451 |
711 | 1452 // Resize & move chat status window |
1453 wresize(chatstatusWnd, 1, maxX); | |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1454 mvwin(chatstatusWnd, chatstatus_y_pos, 0); |
711 | 1455 // Resize & move main status window |
1456 wresize(mainstatusWnd, 1, maxX); | |
1457 mvwin(mainstatusWnd, maxY-2, 0); | |
1458 // Resize & move input line window | |
157 | 1459 wresize(inputWnd, 1, maxX); |
1460 mvwin(inputWnd, maxY-1, 0); | |
168 | 1461 |
1462 werase(chatWnd); | |
157 | 1463 } |
151 | 1464 |
1465 /* Draw/init windows */ | |
1466 | |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1467 ver = mcabber_version(); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1468 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
|
1469 mvwprintw(chatWnd, 0, 0, message); |
1455
bec235cd28a8
Misc. documentation updates
Mikael Berthe <mikael@lilotux.net>
parents:
1454
diff
changeset
|
1470 mvwprintw(chatWnd, 1, 0, "http://mcabber.com/"); |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1471 g_free(ver); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1472 g_free(message); |
24 | 1473 |
157 | 1474 // Auto-scrolling in log window |
74 | 1475 scrollok(logWnd, TRUE); |
24 | 1476 |
1477 | |
151 | 1478 if (fullinit) { |
157 | 1479 // Enable keypad (+ special keys) |
1480 keypad(inputWnd, TRUE); | |
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1481 #ifdef __MirBSD__ |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1482 wtimeout(inputWnd, 50 /* ms */); |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1483 #else |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
1484 nodelay(inputWnd, TRUE); |
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1485 #endif |
157 | 1486 |
151 | 1487 // Create panels |
1488 rosterPanel = new_panel(rosterWnd); | |
1489 chatPanel = new_panel(chatWnd); | |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1490 activechatPanel = new_panel(activechatWnd); |
151 | 1491 logPanel = new_panel(logWnd); |
711 | 1492 chatstatusPanel = new_panel(chatstatusWnd); |
1493 mainstatusPanel = new_panel(mainstatusWnd); | |
151 | 1494 inputPanel = new_panel(inputWnd); |
232 | 1495 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1496 // 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
|
1497 // is added |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1498 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
|
1499 |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1500 // 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
|
1501 // from rewrapping buffers when the width doesn't change. |
1487 | 1502 prev_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
1503 // 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
|
1504 hbuf_rebuild(&statushbuf, prev_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1505 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1506 #ifndef UNICODE |
232 | 1507 if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1508 scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1509 "WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1510 #endif |
157 | 1511 } else { |
1512 // Update panels | |
1513 replace_panel(rosterPanel, rosterWnd); | |
1514 replace_panel(chatPanel, chatWnd); | |
1515 replace_panel(logPanel, logWnd); | |
711 | 1516 replace_panel(chatstatusPanel, chatstatusWnd); |
1517 replace_panel(mainstatusPanel, mainstatusWnd); | |
157 | 1518 replace_panel(inputPanel, inputWnd); |
151 | 1519 } |
1520 | |
1521 // We'll need to redraw the roster | |
149 | 1522 update_roster = TRUE; |
24 | 1523 return; |
1524 } | |
1525 | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1526 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
|
1527 { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1528 winbuf *wbp = value; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1529 struct dimensions *dim = data; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1530 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
|
1531 int new_chatwidth; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1532 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1533 if (!(wbp && wbp->win)) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1534 return; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1535 |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1536 if (log_win_on_top) |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1537 chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1538 else |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1539 chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1540 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1541 if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1542 chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1543 else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1544 chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1545 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1546 // Resize/move buddy window |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1547 wresize(wbp->win, dim->l, dim->c); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1548 mvwin(wbp->win, chat_y_pos, chat_x_pos); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1549 werase(wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1550 // If a panel exists, replace the old window with the new |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1551 if (wbp->panel) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1552 replace_panel(wbp->panel, wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1553 // Redo line wrapping |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1554 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
|
1555 |
1487 | 1556 new_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1557 if (new_chatwidth != prev_chatwidth) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1558 hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1559 } |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1560 |
151 | 1561 // scr_Resize() |
1562 // Function called when the window is resized. | |
157 | 1563 // - Resize windows |
151 | 1564 // - Rewrap lines in each buddy buffer |
1059 | 1565 void scr_Resize(void) |
151 | 1566 { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1567 struct dimensions dim; |
151 | 1568 |
1569 // First, update the global variables | |
1570 getmaxyx(stdscr, maxY, maxX); | |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1571 // 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
|
1572 |
151 | 1573 // Make sure the cursor stays inside the window |
1574 check_offset(0); | |
1575 | |
157 | 1576 // Resize windows and update panels |
151 | 1577 scr_DrawMainWindow(FALSE); |
1578 | |
1579 // Resize all buddy windows | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1580 dim.l = CHAT_WIN_HEIGHT; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1581 dim.c = maxX - Roster_Width; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1582 if (dim.c < 1) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1583 dim.c = 1; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1584 |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1585 // Resize all buffers |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1586 g_hash_table_foreach(winbufhash, resize_win_buffer, &dim); |
151 | 1587 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1588 // Resize/move special status buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1589 if (statusWindow) |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1590 resize_win_buffer(NULL, statusWindow, &dim); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1591 |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1592 // Update prev_chatwidth, now that all buffers have been resized |
1487 | 1593 prev_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1594 |
151 | 1595 // Refresh current buddy window |
157 | 1596 if (chatmode) |
151 | 1597 scr_ShowBuddyWindow(); |
1598 } | |
1599 | |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1600 // scr_UpdateChatStatus(forceupdate) |
713 | 1601 // Redraw the buddy status bar. |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1602 // 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
|
1603 void scr_UpdateChatStatus(int forceupdate) |
713 | 1604 { |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1605 unsigned short btype, isgrp, ismuc, isspe; |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1606 const char *btypetext = "Unknown"; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1607 const char *fullname; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1608 const char *msg = NULL; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1609 char status; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1610 char *buf, *buf_locale; |
713 | 1611 |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1612 // 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
|
1613 // at least to refresh the pending message flag. |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1614 scr_UpdateMainStatus(FALSE); |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1615 |
806
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1616 // Clear the line |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1617 werase(chatstatusWnd); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1618 |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1619 if (!current_buddy) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1620 if (forceupdate) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1621 update_panels(); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1622 } |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1623 return; |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1624 } |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1625 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1626 fullname = buddy_getname(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1627 btype = buddy_gettype(BUDDATA(current_buddy)); |
713 | 1628 |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1629 isgrp = ismuc = isspe = 0; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1630 if (btype & ROSTER_TYPE_USER) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1631 btypetext = "Buddy"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1632 } else if (btype & ROSTER_TYPE_GROUP) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1633 btypetext = "Group"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1634 isgrp = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1635 } else if (btype & ROSTER_TYPE_AGENT) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1636 btypetext = "Agent"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1637 } else if (btype & ROSTER_TYPE_ROOM) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1638 btypetext = "Room"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1639 ismuc = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1640 } else if (btype & ROSTER_TYPE_SPECIAL) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1641 btypetext = "Special buffer"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1642 isspe = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1643 } |
713 | 1644 |
1513
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1645 if (chatmode) { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1646 wprintw(chatstatusWnd, "~"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1647 } else { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1648 unsigned short bflags = buddy_getflags(BUDDATA(current_buddy)); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1649 if (bflags & ROSTER_FLAG_MSG) { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1650 // There is an unread message from the current buddy |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1651 wprintw(chatstatusWnd, "#"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1652 } |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1653 } |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1654 |
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1655 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
|
1656 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
|
1657 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
|
1658 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
|
1659 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
|
1660 } |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1661 |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1662 if (isgrp || isspe) { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1663 buf_locale = from_utf8(fullname); |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1664 mvwprintw(chatstatusWnd, 0, 5, "%s: %s", btypetext, buf_locale); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1665 g_free(buf_locale); |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1666 if (forceupdate) { |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1667 update_panels(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1668 } |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1669 return; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1670 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1671 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1672 status = '?'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1673 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1674 if (ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1675 if (buddy_getinsideroom(BUDDATA(current_buddy))) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1676 status = 'C'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1677 else |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1678 status = 'x'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1679 } else if (jb_getstatus() != offline) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1680 enum imstatus budstate; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1681 budstate = buddy_getstatus(BUDDATA(current_buddy), NULL); |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1682 if (budstate < imstatus_size) |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1683 status = imstatus2char[budstate]; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1684 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1685 |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1686 // No status message for MUC rooms |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1687 if (!ismuc) { |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1688 GSList *resources, *p_res; |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1689 resources = buddy_getresources(BUDDATA(current_buddy)); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
833
diff
changeset
|
1690 msg = buddy_getstatusmsg(BUDDATA(current_buddy), |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
833
diff
changeset
|
1691 resources ? resources->data : ""); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1692 // Free the resources list data |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1693 for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1694 g_free(p_res->data); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1695 g_slist_free(resources); |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1696 } else { |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1697 msg = buddy_gettopic(BUDDATA(current_buddy)); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1698 } |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1699 |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1700 if (msg) |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1701 buf = g_strdup_printf("[%c] %s: %s -- %s", status, btypetext, fullname, msg); |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1702 else |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1703 buf = g_strdup_printf("[%c] %s: %s", status, btypetext, fullname); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1704 replace_nl_with_dots(buf); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1705 buf_locale = from_utf8(buf); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1706 mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1707 g_free(buf_locale); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1708 g_free(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1709 |
996
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1710 // Display chatstates of the contact, if available. |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1711 if (btype & ROSTER_TYPE_USER) { |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1712 char eventchar = 0; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1713 guint event; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1714 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1715 // We do not specify the resource here, so one of the resources with the |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1716 // highest priority will be used. |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1717 event = buddy_resource_getevents(BUDDATA(current_buddy), NULL); |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1718 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1719 if (event == ROSTER_EVENT_ACTIVE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1720 eventchar = 'A'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1721 else if (event == ROSTER_EVENT_COMPOSING) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1722 eventchar = 'C'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1723 else if (event == ROSTER_EVENT_PAUSED) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1724 eventchar = 'P'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1725 else if (event == ROSTER_EVENT_INACTIVE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1726 eventchar = 'I'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1727 else if (event == ROSTER_EVENT_GONE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1728 eventchar = 'G'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1729 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1730 if (eventchar) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1731 mvwprintw(chatstatusWnd, 0, maxX-3, "[%c]", eventchar); |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1732 } |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1733 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1734 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1735 if (forceupdate) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1736 update_panels(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1737 } |
713 | 1738 } |
1739 | |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1740 void increment_if_buddy_not_filtered(gpointer rosterdata, void *param) |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1741 { |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1742 int *p = param; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1743 if (buddylist_is_status_filtered(buddy_getstatus(rosterdata, NULL))) |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1744 *p=*p+1; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1745 } |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1746 |
143 | 1747 // scr_DrawRoster() |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1748 // Display the buddylist (not really the roster) on the screen |
81 | 1749 void scr_DrawRoster(void) |
24 | 1750 { |
735 | 1751 static int offset = 0; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1752 char *name, *rline; |
81 | 1753 int maxx, maxy; |
1754 GList *buddy; | |
1755 int i, n; | |
1756 int rOffset; | |
713 | 1757 int cursor_backup; |
1758 char status, pending; | |
164 | 1759 enum imstatus currentstatus = jb_getstatus(); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1760 int x_pos; |
81 | 1761 |
123 | 1762 // We can reset update_roster |
1763 update_roster = FALSE; | |
1764 | |
81 | 1765 getmaxyx(rosterWnd, maxy, maxx); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1766 maxx--; // Last char is for vertical border |
81 | 1767 |
713 | 1768 cursor_backup = curs_set(0); |
1769 | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1770 if (!buddylist) |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1771 offset = 0; |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1772 else |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1773 scr_UpdateChatStatus(FALSE); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1774 |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1775 // Cleanup of roster window |
168 | 1776 werase(rosterWnd); |
81 | 1777 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1778 if (Roster_Width) { |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1779 int line_x_pos = roster_win_on_right ? 0 : Roster_Width-1; |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1780 // Redraw the vertical line (not very good...) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1781 wattrset(rosterWnd, get_color(COLOR_GENERAL)); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1782 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1783 mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1784 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1785 |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1786 // Leave now if buddylist is empty or the roster is hidden |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1787 if (!buddylist || !Roster_Width) { |
123 | 1788 update_panels(); |
713 | 1789 curs_set(cursor_backup); |
81 | 1790 return; |
1791 } | |
1792 | |
84 | 1793 // Update offset if necessary |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1794 // a) Try to show as many buddylist items as possible |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1795 i = g_list_length(buddylist) - maxy; |
682
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1796 if (i < 0) |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1797 i = 0; |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1798 if (i < offset) |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1799 offset = i; |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1800 // b) Make sure the current_buddy is visible |
84 | 1801 i = g_list_position(buddylist, current_buddy); |
1802 if (i == -1) { // This is bad | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1803 scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
713 | 1804 curs_set(cursor_backup); |
84 | 1805 return; |
1806 } else if (i < offset) { | |
1807 offset = i; | |
1808 } else if (i+1 > offset + maxy) { | |
1809 offset = i + 1 - maxy; | |
1810 } | |
81 | 1811 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1812 if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1813 x_pos = 1; // 1 char offset (vertical line) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1814 else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1815 x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1816 |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1817 name = g_new0(char, 4*Roster_Width); |
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1818 rline = g_new0(char, 4*Roster_Width+1); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1819 |
81 | 1820 buddy = buddylist; |
1821 rOffset = offset; | |
1822 | |
84 | 1823 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1824 unsigned short bflags, btype, ismsg, isgrp, ismuc, ishid, isspe; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1825 gchar *rline_locale; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1826 GSList *resources, *p_res; |
713 | 1827 |
1828 bflags = buddy_getflags(BUDDATA(buddy)); | |
1829 btype = buddy_gettype(BUDDATA(buddy)); | |
1830 | |
1831 ismsg = bflags & ROSTER_FLAG_MSG; | |
1832 ishid = bflags & ROSTER_FLAG_HIDE; | |
1833 isgrp = btype & ROSTER_TYPE_GROUP; | |
1834 ismuc = btype & ROSTER_TYPE_ROOM; | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1835 isspe = btype & ROSTER_TYPE_SPECIAL; |
81 | 1836 |
1837 if (rOffset > 0) { | |
1838 rOffset--; | |
1839 continue; | |
1840 } | |
1841 | |
713 | 1842 status = '?'; |
1843 pending = ' '; | |
1844 | |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1845 resources = buddy_getresources(BUDDATA(buddy)); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1846 for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) { |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1847 guint events = buddy_resource_getevents(BUDDATA(buddy), |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1848 p_res ? p_res->data : ""); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1849 if ((events & ROSTER_EVENT_PAUSED) && pending != '+') |
992
b37348c2aa79
Chatstates: display "paused" states in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
991
diff
changeset
|
1850 pending = '.'; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1851 if (events & ROSTER_EVENT_COMPOSING) |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1852 pending = '+'; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1853 g_free(p_res->data); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1854 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1855 g_slist_free(resources); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1856 |
149 | 1857 // Display message notice if there is a message flag, but not |
1858 // for unfolded groups. | |
1859 if (ismsg && (!isgrp || ishid)) { | |
81 | 1860 pending = '#'; |
1861 } | |
1862 | |
713 | 1863 if (ismuc) { |
1864 if (buddy_getinsideroom(BUDDATA(buddy))) | |
1865 status = 'C'; | |
1866 else | |
1867 status = 'x'; | |
1868 } else if (currentstatus != offline) { | |
1869 enum imstatus budstate; | |
1870 budstate = buddy_getstatus(BUDDATA(buddy), NULL); | |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1871 if (budstate < imstatus_size) |
713 | 1872 status = imstatus2char[budstate]; |
1873 } | |
81 | 1874 if (buddy == current_buddy) { |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
1875 if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1876 wattrset(rosterWnd, get_color(COLOR_ROSTERSELNMSG)); |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
1877 else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1878 wattrset(rosterWnd, get_color(COLOR_ROSTERSEL)); |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
1879 // The 3 following lines aim at coloring the whole line |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1880 wmove(rosterWnd, i, x_pos); |
81 | 1881 for (n = 0; n < maxx; n++) |
1882 waddch(rosterWnd, ' '); | |
1883 } else { | |
149 | 1884 if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1885 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1886 else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1887 int color = get_color(COLOR_ROSTER); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1888 if ((!isspe) && (!isgrp)) {//Look for color rules |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1889 GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1890 const char *jid = buddy_getjid(BUDDATA(buddy)); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1891 for (head = rostercolrules; head; head = g_slist_next(head)) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1892 rostercolor *rc = head->data; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1893 if (g_pattern_match_string(rc->compiled, jid) && |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1894 (!strcmp("*", rc->status) || strchr(rc->status, status))) { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
1895 color = compose_color(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1896 break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1897 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1898 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1899 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1900 wattrset(rosterWnd, color); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1901 } |
81 | 1902 } |
1903 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1904 if (Roster_Width > 7) |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1905 g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1906 else |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1907 name[0] = 0; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1908 |
149 | 1909 if (isgrp) { |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1910 if (ishid){ |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1911 int group_count = 0; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1912 foreach_group_member(BUDDATA(buddy), increment_if_buddy_not_filtered, |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1913 &group_count); |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1914 snprintf(rline, 4*Roster_Width, " %c+++ %s (%i)", pending, name, |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1915 group_count); |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1916 } |
133 | 1917 else |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1918 snprintf(rline, 4*Roster_Width, " %c--- %s", pending, name); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1919 } else if (isspe) { |
1168
eb05f960613f
Fix UTF-8 group names in the roster (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1160
diff
changeset
|
1920 snprintf(rline, 4*Roster_Width, " %c%s", pending, name); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1921 } else { |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1922 char sepleft = '['; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1923 char sepright = ']'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1924 if (btype & ROSTER_TYPE_USER) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1925 guint subtype = buddy_getsubscription(BUDDATA(buddy)); |
832
7c210263c661
Small scr_DrawRoster() fix
Mikael Berthe <mikael@lilotux.net>
parents:
828
diff
changeset
|
1926 if (status == '_' && !(subtype & sub_to)) |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1927 status = '?'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1928 if (!(subtype & sub_from)) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1929 sepleft = '{'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1930 sepright = '}'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1931 } |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1932 } |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1933 |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1934 snprintf(rline, 4*Roster_Width, |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1935 " %c%c%c%c %s", pending, sepleft, status, sepright, name); |
133 | 1936 } |
84 | 1937 |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1938 rline_locale = from_utf8(rline); |
981
553b8ecf901f
Fixes truncating of utf-8 buddy names (again)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
980
diff
changeset
|
1939 mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1940 g_free(rline_locale); |
84 | 1941 i++; |
81 | 1942 } |
1943 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1944 g_free(rline); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1945 g_free(name); |
142 | 1946 top_panel(inputPanel); |
81 | 1947 update_panels(); |
713 | 1948 curs_set(cursor_backup); |
24 | 1949 } |
1950 | |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1951 // scr_RosterVisibility(status) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1952 // Set the roster visibility: |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1953 // status=1 Show roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1954 // status=0 Hide roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1955 // status=-1 Toggle roster status |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1956 void scr_RosterVisibility(int status) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1957 { |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1958 int old_roster_status = roster_hidden; |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1959 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1960 if (status > 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1961 roster_hidden = FALSE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1962 else if (status == 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1963 roster_hidden = TRUE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1964 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1965 roster_hidden = !roster_hidden; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1966 |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1967 if (roster_hidden != old_roster_status) { |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1968 // Recalculate windows size and redraw |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1969 scr_Resize(); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1970 redrawwin(stdscr); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1971 } |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1972 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1973 |
1058 | 1974 inline void scr_WriteMessage(const char *bjid, const char *text, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1975 time_t timestamp, guint prefix_flags, |
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1976 unsigned mucnicklen) |
24 | 1977 { |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
1978 char *xtext; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1979 |
726 | 1980 if (!timestamp) timestamp = time(NULL); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1981 |
1122
648fe6f715a6
Filter out ^M (0x0d) characters in incoming messages
Mikael Berthe <mikael@lilotux.net>
parents:
1115
diff
changeset
|
1982 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
726 | 1983 |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1984 scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE, mucnicklen); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1985 |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1986 if (xtext != (char*)text) |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1987 g_free(xtext); |
24 | 1988 } |
1989 | |
726 | 1990 // If prefix is NULL, HBB_PREFIX_IN is supposed. |
1991 void scr_WriteIncomingMessage(const char *jidfrom, const char *text, | |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1992 time_t timestamp, guint prefix, unsigned mucnicklen) |
726 | 1993 { |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1994 if (!(prefix & |
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
1995 ~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT & ~HBB_PREFIX_HLIGHT_OUT & |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1996 ~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT)) |
726 | 1997 prefix |= HBB_PREFIX_IN; |
1998 | |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1999 scr_WriteMessage(jidfrom, text, timestamp, prefix, mucnicklen); |
726 | 2000 } |
2001 | |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
2002 void scr_WriteOutgoingMessage(const char *jidto, const char *text, guint prefix) |
47 | 2003 { |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2004 GSList *roster_elt; |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2005 roster_elt = roster_find(jidto, jidsearch, |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2006 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2007 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
2008 scr_WriteMessage(jidto, text, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
2009 0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT, 0); |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2010 |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2011 // Show jidto's buffer unless the buddy is not in the buddylist |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2012 if (roster_elt && g_list_position(buddylist, roster_elt->data) != -1) |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2013 scr_ShowWindow(jidto, FALSE); |
47 | 2014 } |
2015 | |
935
97e6a6da2b2c
Fix ncurses #include (again)
Mikael Berthe <mikael@lilotux.net>
parents:
933
diff
changeset
|
2016 static inline void set_autoaway(bool setaway) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2017 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2018 static enum imstatus oldstatus; |
521 | 2019 static char *oldmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2020 Autoaway = setaway; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2021 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2022 if (setaway) { |
521 | 2023 const char *msg, *prevmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2024 oldstatus = jb_getstatus(); |
521 | 2025 if (oldmsg) { |
2026 g_free(oldmsg); | |
2027 oldmsg = NULL; | |
2028 } | |
2029 prevmsg = jb_getstatusmsg(); | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2030 msg = settings_opt_get("message_autoaway"); |
521 | 2031 if (!msg) |
2032 msg = prevmsg; | |
2033 if (prevmsg) | |
2034 oldmsg = g_strdup(prevmsg); | |
1056
5b3ecae91c95
PGP: sign auto-away presence too
Mikael Berthe <mikael@lilotux.net>
parents:
1055
diff
changeset
|
2035 jb_setstatus(away, NULL, msg, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2036 } else { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2037 // Back |
1050
ea71d31a2607
PGP: Do not sign presence messages to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
2038 jb_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : ""), FALSE); |
521 | 2039 if (oldmsg) { |
2040 g_free(oldmsg); | |
2041 oldmsg = NULL; | |
2042 } | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2043 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2044 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2045 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2046 long int scr_GetAutoAwayTimeout(time_t now) |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2047 { |
940 | 2048 enum imstatus cur_st; |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2049 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2050 |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2051 if (Autoaway || !autoaway_timeout) |
940 | 2052 return 86400; |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2053 |
940 | 2054 cur_st = jb_getstatus(); |
2055 // Auto-away is disabled for the following states | |
2056 if ((cur_st != available) && (cur_st != freeforchat)) | |
2057 return 86400; | |
2058 | |
2059 if (now >= LastActivity + (time_t)autoaway_timeout) | |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2060 return 0; |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2061 else |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2062 return LastActivity + (time_t)autoaway_timeout - now; |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2063 } |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
2064 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2065 // set_chatstate(state) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2066 // Set the current chat state (0=active, 1=composing, 2=paused) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2067 // If the chat state has changed, call jb_send_chatstate() |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2068 static inline void set_chatstate(int state) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2069 { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2070 #if defined JEP0022 || defined JEP0085 |
993
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2071 if (chatstates_disabled) |
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2072 return; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2073 if (!chatmode) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2074 state = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2075 if (state != chatstate) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2076 chatstate = state; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2077 if (current_buddy && |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2078 buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_USER) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2079 guint jep_state; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2080 if (chatstate == 1) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2081 jep_state = ROSTER_EVENT_COMPOSING; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2082 else if (chatstate == 2) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2083 jep_state = ROSTER_EVENT_PAUSED; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2084 else |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2085 jep_state = ROSTER_EVENT_ACTIVE; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2086 jb_send_chatstate(BUDDATA(current_buddy), jep_state); |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2087 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2088 if (!chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2089 chatstate_timestamp = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2090 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2091 #endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2092 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2093 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2094 #if defined JEP0022 || defined JEP0085 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2095 inline long int scr_GetChatStatesTimeout(time_t now) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2096 { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2097 // Check if we're currently composing... |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2098 if (chatstate != 1 || !chatstate_timestamp) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2099 return 86400; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2100 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2101 // If the timeout is reached, let's change the state right now. |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2102 if (now >= chatstate_timestamp + COMPOSING_TIMEOUT) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2103 chatstate_timestamp = now; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2104 set_chatstate(2); |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2105 return 86400; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2106 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2107 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2108 return chatstate_timestamp + COMPOSING_TIMEOUT - now; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2109 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2110 #endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2111 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2112 // Check if we should enter/leave automatic away status |
935
97e6a6da2b2c
Fix ncurses #include (again)
Mikael Berthe <mikael@lilotux.net>
parents:
933
diff
changeset
|
2113 void scr_CheckAutoAway(int activity) |
24 | 2114 { |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2115 enum imstatus cur_st; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2116 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2117 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2118 if (Autoaway && activity) set_autoaway(FALSE); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2119 if (!autoaway_timeout) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2120 if (!LastActivity || activity) time(&LastActivity); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2121 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2122 cur_st = jb_getstatus(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2123 // Auto-away is disabled for the following states |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2124 if ((cur_st != available) && (cur_st != freeforchat)) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2125 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2126 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2127 if (!activity) { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2128 time_t now; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2129 time(&now); |
735 | 2130 if (!Autoaway && (now > LastActivity + (time_t)autoaway_timeout)) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2131 set_autoaway(TRUE); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2132 } |
24 | 2133 } |
2134 | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2135 // set_current_buddy(newbuddy) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2136 // Set the current_buddy to newbuddy (if not NULL) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2137 // Lock the newbuddy, and unlock the previous current_buddy |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2138 static void set_current_buddy(GList *newbuddy) |
24 | 2139 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2140 enum imstatus prev_st = imstatus_size; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2141 /* prev_st initialized to imstatus_size, which is used as "undef" value. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2142 * We are sure prev_st will get a different status value after the |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2143 * buddy_getstatus() call. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2144 */ |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2145 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2146 if (!current_buddy || !newbuddy) return; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2147 if (newbuddy == current_buddy) return; |
24 | 2148 |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2149 // We're moving to another buddy. We're thus inactive wrt current_buddy. |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2150 set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2151 // We don't want the chatstate to be changed again right now. |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
2152 lock_chatstate = TRUE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2153 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
2154 prev_st = buddy_getstatus(BUDDATA(current_buddy), NULL); |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2155 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
330 | 2156 if (chatmode) |
2157 alternate_buddy = current_buddy; | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2158 current_buddy = newbuddy; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2159 // Lock the buddy in the buddylist if we're in chat mode |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2160 if (chatmode) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2161 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2162 // We should rebuild the buddylist but not everytime |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2163 // Here we check if we were locking a buddy who is actually offline, |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2164 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2165 if (!(buddylist_get_filter() & 1<<prev_st)) |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2166 buddylist_build(); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2167 update_roster = TRUE; |
24 | 2168 } |
2169 | |
143 | 2170 // scr_RosterTop() |
2171 // Go to the first buddy in the buddylist | |
105 | 2172 void scr_RosterTop(void) |
104 | 2173 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2174 set_current_buddy(buddylist); |
104 | 2175 if (chatmode) |
2176 scr_ShowBuddyWindow(); | |
2177 } | |
2178 | |
143 | 2179 // scr_RosterBottom() |
2180 // Go to the last buddy in the buddylist | |
105 | 2181 void scr_RosterBottom(void) |
104 | 2182 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2183 set_current_buddy(g_list_last(buddylist)); |
104 | 2184 if (chatmode) |
2185 scr_ShowBuddyWindow(); | |
2186 } | |
2187 | |
143 | 2188 // scr_RosterUp() |
2189 // Go to the previous buddy in the buddylist | |
105 | 2190 void scr_RosterUp(void) |
81 | 2191 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2192 set_current_buddy(g_list_previous(current_buddy)); |
104 | 2193 if (chatmode) |
2194 scr_ShowBuddyWindow(); | |
81 | 2195 } |
2196 | |
143 | 2197 // scr_RosterDown() |
2198 // Go to the next buddy in the buddylist | |
105 | 2199 void scr_RosterDown(void) |
81 | 2200 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2201 set_current_buddy(g_list_next(current_buddy)); |
104 | 2202 if (chatmode) |
2203 scr_ShowBuddyWindow(); | |
81 | 2204 } |
2205 | |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2206 // scr_RosterPrevGroup() |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2207 // Go to the previous group in the buddylist |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2208 void scr_RosterPrevGroup(void) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2209 { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2210 GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2211 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2212 for (bud = current_buddy ; bud ; ) { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2213 bud = g_list_previous(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2214 if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2215 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2216 if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2217 set_current_buddy(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2218 if (chatmode) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2219 scr_ShowBuddyWindow(); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2220 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2221 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2222 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2223 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2224 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2225 // scr_RosterNextGroup() |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2226 // Go to the next group in the buddylist |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2227 void scr_RosterNextGroup(void) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2228 { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2229 GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2230 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2231 for (bud = current_buddy ; bud ; ) { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2232 bud = g_list_next(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2233 if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2234 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2235 if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2236 set_current_buddy(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2237 if (chatmode) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2238 scr_ShowBuddyWindow(); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2239 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2240 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2241 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2242 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2243 |
265 | 2244 // scr_RosterSearch(str) |
2245 // Look forward for a buddy with jid/name containing str. | |
2246 void scr_RosterSearch(char *str) | |
2247 { | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2248 set_current_buddy(buddy_search(str)); |
265 | 2249 if (chatmode) |
2250 scr_ShowBuddyWindow(); | |
2251 } | |
2252 | |
1058 | 2253 // scr_RosterJumpJid(bjid) |
2254 // Jump to buddy bjid. | |
480 | 2255 // NOTE: With this function, the buddy is added to the roster if doesn't exist. |
2256 void scr_RosterJumpJid(char *barejid) | |
2257 { | |
2258 GSList *roster_elt; | |
2259 // Look for an existing buddy | |
2260 roster_elt = roster_find(barejid, jidsearch, | |
2261 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); | |
2262 // Create it if necessary | |
2263 if (!roster_elt) | |
603 | 2264 roster_elt = roster_add_user(barejid, NULL, NULL, ROSTER_TYPE_USER, |
1355 | 2265 sub_none, -1); |
480 | 2266 // Set a lock to see it in the buddylist |
2267 buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); | |
2268 buddylist_build(); | |
2269 // Jump to the buddy | |
2270 set_current_buddy(buddy_search_jid(barejid)); | |
2271 if (chatmode) | |
2272 scr_ShowBuddyWindow(); | |
2273 } | |
2274 | |
236 | 2275 // scr_RosterUnreadMessage(next) |
2276 // Go to a new message. If next is not null, try to go to the next new | |
2277 // message. If it is not possible or if next is NULL, go to the first new | |
2278 // message from unread_list. | |
2279 void scr_RosterUnreadMessage(int next) | |
2280 { | |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2281 gpointer unread_ptr; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2282 gpointer refbuddata; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2283 GList *nbuddy; |
236 | 2284 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2285 if (!current_buddy) return; |
236 | 2286 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2287 if (next) refbuddata = BUDDATA(current_buddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2288 else refbuddata = NULL; |
236 | 2289 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2290 unread_ptr = unread_msg(refbuddata); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2291 if (!unread_ptr) return; |
236 | 2292 |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2293 if (!(buddy_gettype(unread_ptr) & ROSTER_TYPE_SPECIAL)) { |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2294 gpointer ngroup; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2295 // If buddy is in a folded group, we need to expand it |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2296 ngroup = buddy_getgroup(unread_ptr); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2297 if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) { |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2298 buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2299 buddylist_build(); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2300 } |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2301 } |
236 | 2302 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2303 nbuddy = g_list_find(buddylist, unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2304 if (nbuddy) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2305 set_current_buddy(nbuddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2306 if (chatmode) scr_ShowBuddyWindow(); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2307 } else |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2308 scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
236 | 2309 } |
2310 | |
330 | 2311 // scr_RosterJumpAlternate() |
2312 // Try to jump to alternate (== previous) buddy | |
2313 void scr_RosterJumpAlternate(void) | |
105 | 2314 { |
330 | 2315 if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
2316 return; | |
2317 set_current_buddy(alternate_buddy); | |
2318 if (chatmode) | |
2319 scr_ShowBuddyWindow(); | |
2320 } | |
2321 | |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2322 // scr_RosterDisplay(filter) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2323 // Set the roster filter mask. If filter is null/empty, the current |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2324 // mask is displayed. |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2325 void scr_RosterDisplay(const char *filter) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2326 { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2327 guchar status; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2328 enum imstatus budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2329 char strfilter[imstatus_size+1]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2330 char *psfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2331 |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2332 if (filter && *filter) { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2333 int show_all = (*filter == '*'); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2334 status = 0; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2335 for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2336 if (strchr(filter, imstatus2char[budstate]) || show_all) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2337 status |= 1<<budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2338 buddylist_set_filter(status); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2339 buddylist_build(); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2340 update_roster = TRUE; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2341 return; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2342 } |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2343 |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2344 // Display current filter |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2345 psfilter = strfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2346 status = buddylist_get_filter(); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2347 for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2348 if (status & 1<<budstate) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2349 *psfilter++ = imstatus2char[budstate]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2350 *psfilter = '\0'; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2351 scr_LogPrint(LPRINT_NORMAL, "Roster status filter: %s", strfilter); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2352 } |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2353 |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
2354 // scr_BufferScrollUpDown() |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2355 // Scroll up/down the current buddy window, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2356 // - half a screen if nblines is 0, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2357 // - up if updown == -1, down if updown == 1 |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2358 void scr_BufferScrollUpDown(int updown, unsigned int nblines) |
105 | 2359 { |
822 | 2360 winbuf *win_entry; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2361 int n, nbl; |
105 | 2362 GList *hbuf_top; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2363 guint isspe; |
105 | 2364 |
2365 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2366 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2367 |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2368 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2369 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2370 if (!win_entry) return; |
105 | 2371 |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2372 if (!nblines) { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2373 // Scroll half a screen (or less) |
512 | 2374 nbl = CHAT_WIN_HEIGHT/2; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2375 } else { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2376 nbl = nblines; |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2377 } |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2378 hbuf_top = win_entry->bd->top; |
105 | 2379 |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2380 if (updown == -1) { // UP |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2381 if (!hbuf_top) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2382 hbuf_top = 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
|
2383 if (!win_entry->bd->cleared) { |
512 | 2384 if (!nblines) nbl = nbl*3 - 1; |
2385 else nbl += CHAT_WIN_HEIGHT - 1; | |
2386 } else { | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2387 win_entry->bd->cleared = FALSE; |
512 | 2388 } |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2389 } |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2390 for (n=0 ; hbuf_top && n < nbl && g_list_previous(hbuf_top) ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2391 hbuf_top = g_list_previous(hbuf_top); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2392 win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2393 } else { // DOWN |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2394 for (n=0 ; hbuf_top && n < nbl ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2395 hbuf_top = g_list_next(hbuf_top); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2396 win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2397 // Check if we are at the bottom |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2398 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2399 hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2400 if (!hbuf_top) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2401 win_entry->bd->top = NULL; // End reached |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2402 } |
105 | 2403 |
2404 // Refresh the window | |
2405 scr_UpdateWindow(win_entry); | |
2406 | |
2407 // Finished :) | |
2408 update_panels(); | |
2409 } | |
2410 | |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
2411 // scr_BufferClear() |
143 | 2412 // Clear the current buddy window (used for the /clear command) |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
2413 void scr_BufferClear(void) |
108 | 2414 { |
822 | 2415 winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2416 guint isspe; |
108 | 2417 |
2418 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2419 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2420 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2421 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2422 if (!win_entry) return; |
108 | 2423 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2424 win_entry->bd->cleared = TRUE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2425 win_entry->bd->top = NULL; |
108 | 2426 |
2427 // Refresh the window | |
2428 scr_UpdateWindow(win_entry); | |
2429 | |
2430 // Finished :) | |
2431 update_panels(); | |
2432 } | |
2433 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2434 // buffer_purge() |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2435 // key: winId/jid |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2436 // value: winbuf structure |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2437 // data: int, set to 1 if the buffer should be closed. |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2438 // NOTE: does not work for special buffers. |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2439 static void buffer_purge(gpointer key, gpointer value, gpointer data) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2440 { |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2441 int *p_closebuf = data; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2442 winbuf *win_entry = value; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2443 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2444 // Delete the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2445 hbuf_free(&win_entry->bd->hbuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2446 |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2447 if (*p_closebuf) { |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2448 g_hash_table_remove(winbufhash, key); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2449 } else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2450 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2451 win_entry->bd->top = NULL; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2452 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2453 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2454 |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2455 // scr_BufferPurge(closebuf, jid) |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2456 // Purge/Drop the current buddy buffer or jid's buffer if jid != NULL. |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2457 // If closebuf is 1, close the buffer. |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2458 void scr_BufferPurge(int closebuf, const char *jid) |
866 | 2459 { |
2460 winbuf *win_entry; | |
2461 guint isspe; | |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2462 guint *p_closebuf; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2463 const char *cjid; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2464 guint hold_chatmode = FALSE; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2465 |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2466 if (jid) { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2467 cjid = jid; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2468 isspe = FALSE; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2469 // If closebuf is TRUE, it's probably better not to leave chat mode |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2470 // if the change isn't related to the current buffer. |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2471 if (closebuf && current_buddy) { |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2472 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL || |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2473 strcasecmp(jid, CURRENT_JID)) |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2474 hold_chatmode = TRUE; |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2475 } |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2476 } else { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2477 // Get win_entry |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2478 if (!current_buddy) return; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2479 cjid = CURRENT_JID; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2480 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2481 } |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2482 win_entry = scr_SearchWindow(cjid, isspe); |
866 | 2483 if (!win_entry) return; |
2484 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2485 if (!isspe) { |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2486 p_closebuf = g_new(guint, 1); |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2487 *p_closebuf = closebuf; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2488 buffer_purge((gpointer)cjid, win_entry, p_closebuf); |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2489 g_free(p_closebuf); |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2490 if (closebuf && !hold_chatmode) { |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2491 scr_set_chatmode(FALSE); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2492 currentWindow = NULL; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2493 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2494 } else { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2495 // (Special buffer) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2496 // Reset the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2497 hbuf_free(&win_entry->bd->hbuf); |
866 | 2498 // Currently it can only be the status buffer |
2499 statushbuf = NULL; | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2500 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2501 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2502 win_entry->bd->top = NULL; |
866 | 2503 } |
2504 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2505 // Refresh the window |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2506 scr_UpdateBuddyWindow(); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2507 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2508 // Finished :) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2509 update_panels(); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2510 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2511 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2512 void scr_BufferPurgeAll(int closebuf) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2513 { |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2514 guint *p_closebuf; |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2515 p_closebuf = g_new(guint, 1); |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2516 |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2517 *p_closebuf = closebuf; |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2518 g_hash_table_foreach(winbufhash, buffer_purge, p_closebuf); |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2519 g_free(p_closebuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2520 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2521 if (closebuf) { |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2522 scr_set_chatmode(FALSE); |
1137
5752017f6e2b
Fix a bug in /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
2523 currentWindow = NULL; |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2524 } |
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2525 |
866 | 2526 // Refresh the window |
2527 scr_UpdateBuddyWindow(); | |
2528 | |
2529 // Finished :) | |
2530 update_panels(); | |
2531 } | |
2532 | |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2533 // scr_BufferScrollLock(lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2534 // Lock/unlock the current buddy buffer |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2535 // lock = 1 : lock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2536 // lock = 0 : unlock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2537 // lock = -1: toggle lock status |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2538 void scr_BufferScrollLock(int lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2539 { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2540 winbuf *win_entry; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2541 guint isspe; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2542 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2543 // Get win_entry |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2544 if (!current_buddy) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2545 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2546 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2547 if (!win_entry) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2548 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2549 if (lock == -1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2550 lock = !win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2551 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2552 if (lock) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2553 win_entry->bd->lock = TRUE; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2554 } else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2555 win_entry->bd->lock = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2556 //win_entry->bd->cleared = FALSE; |
880
ea983a945eba
/buffer scroll_unlock: Don't always jump to the end of the buffer
Mikael Berthe <mikael@lilotux.net>
parents:
878
diff
changeset
|
2557 if (isspe || (buddy_getflags(BUDDATA(current_buddy)) & ROSTER_FLAG_MSG)) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2558 win_entry->bd->top = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2559 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2560 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2561 // If chatmode is disabled and we're at the bottom of the buffer, |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2562 // we need to set the "top" line, so we need to call scr_ShowBuddyWindow() |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2563 // at least once. (Maybe it will cause a double refresh...) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2564 if (!chatmode && !win_entry->bd->top) { |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2565 chatmode = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2566 scr_ShowBuddyWindow(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2567 chatmode = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2568 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2569 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2570 // Refresh the window |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2571 scr_UpdateBuddyWindow(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2572 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2573 // Finished :) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2574 update_panels(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2575 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2576 |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2577 // scr_BufferTopBottom() |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2578 // Jump to the head/tail of the current buddy window |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2579 // (top if topbottom == -1, bottom topbottom == 1) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2580 void scr_BufferTopBottom(int topbottom) |
187 | 2581 { |
822 | 2582 winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2583 guint isspe; |
187 | 2584 |
2585 // Get win_entry | |
2586 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2587 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2588 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
187 | 2589 if (!win_entry) return; |
2590 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2591 win_entry->bd->cleared = FALSE; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2592 if (topbottom == 1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2593 win_entry->bd->top = NULL; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2594 else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2595 win_entry->bd->top = g_list_first(win_entry->bd->hbuf); |
187 | 2596 |
2597 // Refresh the window | |
2598 scr_UpdateWindow(win_entry); | |
2599 | |
2600 // Finished :) | |
2601 update_panels(); | |
2602 } | |
2603 | |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2604 // scr_BufferSearch(direction, text) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2605 // Jump to the next line containing text |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2606 // (backward search if direction == -1, forward if topbottom == 1) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2607 void scr_BufferSearch(int direction, const char *text) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2608 { |
822 | 2609 winbuf *win_entry; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2610 GList *current_line, *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2611 guint isspe; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2612 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2613 // Get win_entry |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2614 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2615 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2616 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2617 if (!win_entry) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2618 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2619 if (win_entry->bd->top) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2620 current_line = win_entry->bd->top; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2621 else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2622 current_line = g_list_last(win_entry->bd->hbuf); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2623 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2624 search_res = hbuf_search(current_line, direction, text); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2625 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2626 if (search_res) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2627 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2628 win_entry->bd->top = search_res; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2629 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2630 // Refresh the window |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2631 scr_UpdateWindow(win_entry); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2632 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2633 // Finished :) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2634 update_panels(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2635 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2636 scr_LogPrint(LPRINT_NORMAL, "Search string not found"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2637 } |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2638 |
462 | 2639 // scr_BufferPercent(n) |
2640 // Jump to the specified position in the buffer, in % | |
2641 void scr_BufferPercent(int pc) | |
2642 { | |
822 | 2643 winbuf *win_entry; |
462 | 2644 GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2645 guint isspe; |
462 | 2646 |
2647 // Get win_entry | |
2648 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2649 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2650 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
462 | 2651 if (!win_entry) return; |
2652 | |
2653 if (pc < 0 || pc > 100) { | |
2654 scr_LogPrint(LPRINT_NORMAL, "Bad % value"); | |
2655 return; | |
2656 } | |
2657 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2658 search_res = hbuf_jump_percent(win_entry->bd->hbuf, pc); |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2659 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2660 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2661 win_entry->bd->top = search_res; |
462 | 2662 |
2663 // Refresh the window | |
2664 scr_UpdateWindow(win_entry); | |
2665 | |
2666 // Finished :) | |
2667 update_panels(); | |
2668 } | |
2669 | |
464 | 2670 // scr_BufferDate(t) |
2671 // Jump to the first line after date t in the buffer | |
2672 // t is a date in seconds since `00:00:00 1970-01-01 UTC' | |
2673 void scr_BufferDate(time_t t) | |
2674 { | |
822 | 2675 winbuf *win_entry; |
464 | 2676 GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2677 guint isspe; |
464 | 2678 |
2679 // Get win_entry | |
2680 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2681 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2682 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
464 | 2683 if (!win_entry) return; |
2684 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2685 search_res = hbuf_jump_date(win_entry->bd->hbuf, t); |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2686 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2687 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2688 win_entry->bd->top = search_res; |
464 | 2689 |
2690 // Refresh the window | |
2691 scr_UpdateWindow(win_entry); | |
2692 | |
2693 // Finished :) | |
2694 update_panels(); | |
2695 } | |
2696 | |
1485
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2697 void scr_BufferDump(const char *file) |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2698 { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2699 char *extfname; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2700 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2701 if (!currentWindow) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2702 scr_LogPrint(LPRINT_NORMAL, "No current buffer!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2703 return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2704 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2705 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2706 if (!file || !*file) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2707 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (file name)!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2708 return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2709 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2710 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2711 extfname = expand_filename(file); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2712 hbuf_dump_to_file(currentWindow->bd->hbuf, extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2713 g_free(extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2714 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2715 |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2716 // buffer_list() |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2717 // key: winId/jid |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2718 // value: winbuf structure |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2719 // data: none. |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2720 static void buffer_list(gpointer key, gpointer value, gpointer data) |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2721 { |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2722 GList *head; |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2723 winbuf *win_entry = value; |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2724 |
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2725 head = g_list_first(win_entry->bd->hbuf); |
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2726 |
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2727 scr_LogPrint(LPRINT_NORMAL, " %s (%u/%u)", key, |
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2728 g_list_length(head), hbuf_get_blocks_number(head)); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2729 } |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2730 |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2731 void scr_BufferList(void) |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2732 { |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2733 scr_LogPrint(LPRINT_NORMAL, "Buffer list:"); |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2734 buffer_list("[status]", statusWindow, NULL); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2735 g_hash_table_foreach(winbufhash, buffer_list, NULL); |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2736 scr_LogPrint(LPRINT_NORMAL, "End of buffer list."); |
1252
9f7e6c22cd14
"buffer list" sets the new_msg flag
Mikael Berthe <mikael@lilotux.net>
parents:
1245
diff
changeset
|
2737 scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
9f7e6c22cd14
"buffer list" sets the new_msg flag
Mikael Berthe <mikael@lilotux.net>
parents:
1245
diff
changeset
|
2738 update_roster = TRUE; |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2739 } |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2740 |
143 | 2741 // scr_set_chatmode() |
261 | 2742 // Public function to (un)set chatmode... |
129 | 2743 inline void scr_set_chatmode(int enable) |
2744 { | |
2745 chatmode = enable; | |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
2746 scr_UpdateChatStatus(TRUE); |
129 | 2747 } |
2748 | |
1129
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2749 // scr_get_chatmode() |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2750 // Public function to get chatmode state. |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2751 inline int scr_get_chatmode(void) |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2752 { |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2753 return chatmode; |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2754 } |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2755 |
238 | 2756 // scr_get_multimode() |
261 | 2757 // Public function to get multimode status... |
1059 | 2758 inline int scr_get_multimode(void) |
238 | 2759 { |
2760 return multimode; | |
2761 } | |
2762 | |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2763 // scr_setmsgflag_if_needed(jid) |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2764 // Set the message flag unless we're already in the jid buffer window |
1058 | 2765 void scr_setmsgflag_if_needed(const char *bjid, int special) |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2766 { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2767 const char *current_id; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2768 bool iscurrentlocked = FALSE; |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
2769 |
1058 | 2770 if (!bjid) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2771 return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2772 |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2773 if (current_buddy) { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2774 if (special) |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2775 current_id = buddy_getname(BUDDATA(current_buddy)); |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2776 else |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2777 current_id = buddy_getjid(BUDDATA(current_buddy)); |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2778 if (current_id) { |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2779 winbuf *win_entry = scr_SearchWindow(current_id, special); |
888
578d2034e971
scr_setmsgflag_if_needed(): Add a check after scr_SearchWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
884
diff
changeset
|
2780 if (!win_entry) return; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2781 iscurrentlocked = win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2782 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2783 } else { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2784 current_id = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2785 } |
1058 | 2786 if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) |
2787 roster_msg_setflag(bjid, special, TRUE); | |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2788 } |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2789 |
238 | 2790 // scr_set_multimode() |
261 | 2791 // Public function to (un)set multimode... |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2792 // Convention: |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2793 // 0 = disabled / 1 = multimode / 2 = multimode verbatim (commands disabled) |
1413 | 2794 void scr_set_multimode(int enable, char *subject) |
238 | 2795 { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2796 g_free(multiline); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2797 multiline = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2798 |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2799 g_free(multimode_subj); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2800 if (enable && subject) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2801 multimode_subj = g_strdup(subject); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2802 else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2803 multimode_subj = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2804 |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2805 multimode = enable; |
238 | 2806 } |
2807 | |
2808 // scr_get_multiline() | |
261 | 2809 // Public function to get the current multi-line. |
1413 | 2810 const char *scr_get_multiline(void) |
238 | 2811 { |
2812 if (multimode && multiline) | |
2813 return multiline; | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2814 return NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2815 } |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2816 |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2817 // scr_get_multimode_subj() |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2818 // Public function to get the multi-line subject, if any. |
1413 | 2819 const char *scr_get_multimode_subj(void) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2820 { |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2821 if (multimode) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2822 return multimode_subj; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2823 return NULL; |
238 | 2824 } |
2825 | |
2826 // scr_append_multiline(line) | |
2827 // Public function to append a line to the current multi-line message. | |
2828 // Skip empty leading lines. | |
2829 void scr_append_multiline(const char *line) | |
2830 { | |
2831 static int num; | |
2832 | |
2833 if (!multimode) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2834 scr_LogPrint(LPRINT_NORMAL, "Error: Not in multi-line message mode!"); |
238 | 2835 return; |
2836 } | |
2837 if (multiline) { | |
2838 int len = strlen(multiline)+strlen(line)+2; | |
252 | 2839 if (len >= HBB_BLOCKSIZE - 1) { |
238 | 2840 // We don't handle single messages with size > HBB_BLOCKSIZE |
2841 // (see hbuf) | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2842 scr_LogPrint(LPRINT_NORMAL, "Your multi-line message is too big, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2843 "this line has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2844 scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
238 | 2845 return; |
2846 } | |
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
2847 if (num >= MULTILINE_MAX_LINE_NUMBER) { |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
2848 // We don't allow too many lines; however the maximum is arbitrary |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
2849 // (It should be < 1000 yet) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2850 scr_LogPrint(LPRINT_NORMAL, "Your message has too many lines, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2851 "this one has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2852 scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
2853 return; |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
2854 } |
238 | 2855 multiline = g_renew(char, multiline, len); |
2856 strcat(multiline, "\n"); | |
2857 strcat(multiline, line); | |
2858 num++; | |
2859 } else { | |
2860 // First message line (we skip leading empty lines) | |
2861 num = 0; | |
2862 if (line[0]) { | |
419 | 2863 multiline = g_strdup(line); |
238 | 2864 num++; |
2865 } else | |
2866 return; | |
2867 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
2868 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
2869 "Multi-line mode: line #%d added [%.25s...", num, line); |
238 | 2870 } |
2871 | |
173 | 2872 // scr_cmdhisto_addline() |
2873 // Add a line to the inputLine history | |
2874 inline void scr_cmdhisto_addline(char *line) | |
2875 { | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2876 int max_histo_lines; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2877 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2878 if (!line || !*line) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2879 return; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2880 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2881 max_histo_lines = settings_opt_get_int("cmdhistory_lines"); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2882 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2883 if (max_histo_lines < 0) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2884 max_histo_lines = 1; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2885 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2886 if (max_histo_lines) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2887 while (cmdhisto_nblines >= (guint)max_histo_lines) { |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2888 if (cmdhisto_cur && cmdhisto_cur == cmdhisto) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2889 break; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2890 g_free(cmdhisto->data); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2891 cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2892 cmdhisto_nblines--; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2893 } |
173 | 2894 |
2895 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2896 cmdhisto_nblines++; |
173 | 2897 } |
2898 | |
2899 // scr_cmdhisto_prev() | |
2900 // Look for previous line beginning w/ the given mask in the inputLine history | |
175 | 2901 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2902 static const char *scr_cmdhisto_prev(char *mask, guint len) |
173 | 2903 { |
2904 GList *hl; | |
2905 if (!cmdhisto_cur) { | |
2906 hl = g_list_last(cmdhisto); | |
174 | 2907 if (hl) { // backup current line |
2908 strncpy(cmdhisto_backup, mask, INPUTLINE_LENGTH); | |
2909 } | |
173 | 2910 } else { |
2911 hl = g_list_previous(cmdhisto_cur); | |
2912 } | |
2913 while (hl) { | |
2914 if (!strncmp((char*)hl->data, mask, len)) { | |
2915 // Found a match | |
2916 cmdhisto_cur = hl; | |
2917 return (const char*)hl->data; | |
2918 } | |
2919 hl = g_list_previous(hl); | |
2920 } | |
2921 return NULL; | |
2922 } | |
2923 | |
2924 // scr_cmdhisto_next() | |
2925 // Look for next line beginning w/ the given mask in the inputLine history | |
175 | 2926 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2927 static const char *scr_cmdhisto_next(char *mask, guint len) |
173 | 2928 { |
2929 GList *hl; | |
2930 if (!cmdhisto_cur) return NULL; | |
2931 hl = cmdhisto_cur; | |
2932 while ((hl = g_list_next(hl)) != NULL) | |
2933 if (!strncmp((char*)hl->data, mask, len)) { | |
2934 // Found a match | |
2935 cmdhisto_cur = hl; | |
2936 return (const char*)hl->data; | |
2937 } | |
175 | 2938 // If the "backuped" line matches, we'll use it |
2939 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match | |
174 | 2940 cmdhisto_cur = NULL; |
2941 return cmdhisto_backup; | |
173 | 2942 } |
2943 | |
195 | 2944 // readline_transpose_chars() |
2945 // Drag the character before point forward over the character at | |
2946 // point, moving point forward as well. If point is at the end of | |
2947 // the line, then this transposes the two characters before point. | |
1059 | 2948 void readline_transpose_chars(void) |
195 | 2949 { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2950 char *c1, *c2; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2951 unsigned a, b; |
195 | 2952 |
2953 if (ptr_inputline == inputLine) return; | |
2954 | |
2955 if (!*ptr_inputline) { // We're at EOL | |
2956 // If line is only 1 char long, nothing to do... | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2957 if (ptr_inputline == prev_char(ptr_inputline, inputLine)) return; |
195 | 2958 // Transpose the two previous characters |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2959 c2 = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2960 c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2961 a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2962 b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2963 put_char(put_char(c1, b), a); |
195 | 2964 } else { |
196 | 2965 // Swap the two characters before the cursor and move right. |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2966 c2 = ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2967 c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2968 a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2969 b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2970 put_char(put_char(c1, b), a); |
195 | 2971 check_offset(1); |
2972 } | |
2973 } | |
2974 | |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2975 void readline_forward_kill_word(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2976 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2977 char *c, *old = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2978 int spaceallowed = 1; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2979 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2980 if (! *ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2981 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2982 for (c = ptr_inputline ; *c ; c = next_char(c)) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2983 if (!iswalnum(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2984 if (iswblank(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2985 if (!spaceallowed) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2986 } else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2987 } else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2988 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2989 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2990 // Modify the line |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2991 for (;;) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2992 *old = *c++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2993 if (!*old++) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2994 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2995 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2996 |
195 | 2997 // readline_backward_kill_word() |
194 | 2998 // Kill the word before the cursor, in input line |
1059 | 2999 void readline_backward_kill_word(void) |
194 | 3000 { |
3001 char *c, *old = ptr_inputline; | |
3002 int spaceallowed = 1; | |
3003 | |
3004 if (ptr_inputline == inputLine) return; | |
3005 | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3006 c = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3007 for ( ; c > inputLine ; c = prev_char(c, inputLine)) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3008 if (!iswalnum(get_char(c))) { |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3009 if (iswblank(get_char(c))) { |
194 | 3010 if (!spaceallowed) break; |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3011 } else spaceallowed = 0; |
194 | 3012 } else spaceallowed = 0; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3013 } |
194 | 3014 |
1280
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3015 if (c == inputLine && *c == COMMAND_CHAR && old != c+1) { |
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3016 c = next_char(c); |
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3017 } else if (c != inputLine || iswblank(get_char(c))) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3018 if ((c < prev_char(ptr_inputline, inputLine)) && (!iswalnum(get_char(c)))) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3019 c = next_char(c); |
1280
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3020 } |
194 | 3021 |
3022 // Modify the line | |
3023 ptr_inputline = c; | |
3024 for (;;) { | |
3025 *c = *old++; | |
3026 if (!*c++) break; | |
3027 } | |
195 | 3028 check_offset(-1); |
194 | 3029 } |
3030 | |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3031 // readline_backward_word() |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3032 // Move back to the start of the current or previous word |
1059 | 3033 void readline_backward_word(void) |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3034 { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3035 int i = 0; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3036 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3037 if (ptr_inputline == inputLine) return; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3038 |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3039 if (iswalnum(get_char(ptr_inputline)) && |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3040 !iswalnum(get_char(prev_char(ptr_inputline, inputLine)))) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3041 i--; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3042 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3043 for ( ; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3044 ptr_inputline > inputLine; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3045 ptr_inputline = prev_char(ptr_inputline, inputLine)) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3046 if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3047 if (i) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3048 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3049 break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3050 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3051 } else i++; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3052 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3053 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3054 check_offset(-1); |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3055 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3056 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3057 // readline_forward_word() |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3058 // Move forward to the end of the next word |
1059 | 3059 void readline_forward_word(void) |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3060 { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3061 int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3062 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3063 while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3064 if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3065 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3066 } else stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3067 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3068 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3069 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3070 check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3071 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3072 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3073 void readline_updowncase_word(int upcase) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3074 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3075 int stopsymbol_allowed = 1; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3076 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3077 while (*ptr_inputline) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3078 if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3079 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3080 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3081 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3082 if (upcase) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3083 *ptr_inputline = towupper(get_char(ptr_inputline)); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3084 else |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3085 *ptr_inputline = towlower(get_char(ptr_inputline)); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3086 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3087 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3088 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3089 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3090 check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3091 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3092 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3093 void readline_capitalize_word(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3094 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3095 int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3096 int upcased = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3097 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3098 while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3099 if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3100 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3101 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3102 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3103 if (!upcased) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3104 *ptr_inputline = towupper(get_char(ptr_inputline)); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3105 upcased = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3106 } else *ptr_inputline = towlower(get_char(ptr_inputline)); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3107 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3108 ptr_inputline = next_char(ptr_inputline); |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3109 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3110 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3111 check_offset(1); |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3112 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3113 |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3114 void readline_backward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3115 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3116 if (ptr_inputline == (char*)&inputLine) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3117 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3118 ptr_inputline = prev_char(ptr_inputline, inputLine); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3119 check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3120 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3121 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3122 void readline_forward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3123 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3124 if (!*ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3125 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3126 ptr_inputline = next_char(ptr_inputline); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3127 check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3128 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3129 |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3130 // readline_accept_line(down_history) |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3131 // Validate current command line. |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3132 // If down_history is true, load the next history line. |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3133 int readline_accept_line(int down_history) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3134 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3135 scr_CheckAutoAway(TRUE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3136 if (process_line(inputLine)) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3137 return 255; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3138 // Add line to history |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3139 scr_cmdhisto_addline(inputLine); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3140 // Reset the line |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3141 ptr_inputline = inputLine; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3142 *ptr_inputline = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3143 inputline_offset = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3144 |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3145 if (down_history) { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3146 // Use next history line instead of a blank line |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3147 const char *l = scr_cmdhisto_next("", 0); |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3148 if (l) strcpy(inputLine, l); |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3149 // Reset backup history line |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3150 cmdhisto_backup[0] = 0; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3151 } else { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3152 // Reset history line pointer |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3153 cmdhisto_cur = NULL; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3154 } |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3155 return 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3156 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3157 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3158 void readline_cancel_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3159 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3160 scr_cancel_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3161 scr_end_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3162 check_offset(-1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3163 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3164 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3165 void readline_do_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3166 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3167 int i, n; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3168 |
1413 | 3169 if (multimode != 2) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3170 // Not in verbatim multi-line mode |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3171 scr_handle_tab(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3172 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3173 // Verbatim multi-line mode: expand tab |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3174 char tabstr[9]; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3175 n = 8 - (ptr_inputline - inputLine) % 8; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3176 for (i = 0; i < n; i++) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3177 tabstr[i] = ' '; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3178 tabstr[i] = '\0'; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3179 scr_insert_text(tabstr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3180 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3181 check_offset(0); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3182 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3183 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3184 void readline_refresh_screen(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3185 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3186 scr_CheckAutoAway(TRUE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3187 ParseColors(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3188 scr_Resize(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3189 redrawwin(stdscr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3190 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3191 |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
3192 void readline_disable_chat_mode(guint show_roster) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3193 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3194 scr_CheckAutoAway(TRUE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3195 currentWindow = NULL; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3196 chatmode = FALSE; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3197 if (current_buddy) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3198 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
3199 if (show_roster) |
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
3200 scr_RosterVisibility(1); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3201 scr_UpdateChatStatus(FALSE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3202 top_panel(chatPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3203 top_panel(inputPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3204 update_panels(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3205 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3206 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3207 void readline_hist_beginning_search_bwd(void) |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3208 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3209 const char *l = scr_cmdhisto_prev(inputLine, ptr_inputline-inputLine); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3210 if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3211 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3212 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3213 void readline_hist_beginning_search_fwd(void) |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3214 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3215 const char *l = scr_cmdhisto_next(inputLine, ptr_inputline-inputLine); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3216 if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3217 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3218 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3219 void readline_hist_prev(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3220 { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3221 const char *l = scr_cmdhisto_prev(inputLine, 0); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3222 if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3223 strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3224 // Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3225 // We have to move it to BOL first, because we could be too far already. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3226 readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3227 readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3228 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3229 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3230 |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3231 void readline_hist_next(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3232 { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3233 const char *l = scr_cmdhisto_next(inputLine, 0); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3234 if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3235 strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3236 // Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3237 // We have to move it to BOL first, because we could be too far already. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3238 readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3239 readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3240 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3241 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3242 |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3243 void readline_backward_kill_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3244 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3245 char *src, *c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3246 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3247 if (ptr_inputline == (char*)&inputLine) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3248 return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3249 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3250 src = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3251 c = prev_char(ptr_inputline, inputLine); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3252 ptr_inputline = c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3253 for ( ; *src ; ) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3254 *c++ = *src++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3255 *c = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3256 check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3257 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3258 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3259 void readline_forward_kill_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3260 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3261 if (!*ptr_inputline) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3262 return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3263 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3264 strcpy(ptr_inputline, next_char(ptr_inputline)); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3265 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3266 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3267 void readline_iline_start(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3268 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3269 ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3270 inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3271 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3272 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3273 void readline_iline_end(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3274 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3275 for (; *ptr_inputline; ptr_inputline++) ; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3276 check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3277 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3278 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3279 void readline_backward_kill_iline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3280 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3281 strcpy(inputLine, ptr_inputline); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3282 ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3283 inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3284 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3285 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3286 void readline_forward_kill_iline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3287 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3288 *ptr_inputline = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3289 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3290 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3291 void readline_send_multiline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3292 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3293 // Validate current multi-line |
1413 | 3294 if (multimode) |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1186
diff
changeset
|
3295 process_command(mkcmdstr("msay send"), TRUE); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3296 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3297 |
98 | 3298 // which_row() |
3299 // Tells which row our cursor is in, in the command line. | |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3300 // -2 -> normal text |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3301 // -1 -> room: nickname completion |
98 | 3302 // 0 -> command |
3303 // 1 -> parameter 1 (etc.) | |
102 | 3304 // If > 0, then *p_row is set to the beginning of the row |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3305 static int which_row(const char **p_row) |
98 | 3306 { |
3307 int row = -1; | |
3308 char *p; | |
3309 int quote = FALSE; | |
3310 | |
3311 // Not a command? | |
967 | 3312 if ((ptr_inputline == inputLine) || (inputLine[0] != COMMAND_CHAR)) { |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3313 if (!current_buddy) return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3314 if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_ROOM) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3315 *p_row = inputLine; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3316 return -1; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3317 } |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3318 return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3319 } |
98 | 3320 |
3321 // This is a command | |
3322 row = 0; | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3323 for (p = inputLine ; p < ptr_inputline ; p = next_char(p)) { |
98 | 3324 if (quote) { |
3325 if (*p == '"' && *(p-1) != '\\') | |
3326 quote = FALSE; | |
3327 continue; | |
3328 } | |
3329 if (*p == '"' && *(p-1) != '\\') { | |
3330 quote = TRUE; | |
121 | 3331 } else if (*p == ' ') { |
3332 if (*(p-1) != ' ') | |
3333 row++; | |
102 | 3334 *p_row = p+1; |
3335 } | |
98 | 3336 } |
3337 return row; | |
3338 } | |
3339 | |
143 | 3340 // scr_insert_text() |
3341 // Insert the given text at the current cursor position. | |
3342 // The cursor is moved. We don't check if the cursor still is in the screen | |
3343 // after, the caller should do that. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3344 static void scr_insert_text(const char *text) |
98 | 3345 { |
3346 char tmpLine[INPUTLINE_LENGTH+1]; | |
3347 int len = strlen(text); | |
3348 // Check the line isn't too long | |
3349 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3350 scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
98 | 3351 return; |
3352 } | |
3353 | |
3354 strcpy(tmpLine, ptr_inputline); | |
419 | 3355 strcpy(ptr_inputline, text); |
3356 ptr_inputline += len; | |
98 | 3357 strcpy(ptr_inputline, tmpLine); |
3358 } | |
3359 | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3360 static void scr_cancel_current_completion(void); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3361 |
143 | 3362 // scr_handle_tab() |
3363 // Function called when tab is pressed. | |
3364 // Initiate or continue a completion... | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3365 static void scr_handle_tab(void) |
98 | 3366 { |
102 | 3367 int nrow; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3368 const char *row; |
102 | 3369 const char *cchar; |
103 | 3370 guint compl_categ; |
98 | 3371 |
740 | 3372 row = inputLine; // (Kills a GCC warning) |
102 | 3373 nrow = which_row(&row); |
98 | 3374 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3375 // a) No completion if no leading slash ('cause not a command), |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3376 // unless this is a room (then, it is a nickname completion) |
103 | 3377 // b) We can't have more than 2 parameters (we use 2 flags) |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3378 if ((nrow == -2) || (nrow == 3 && !completion_started) || nrow > 3) |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3379 return; |
102 | 3380 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3381 if (nrow == 0) { // Command completion |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3382 row = next_char(inputLine); |
103 | 3383 compl_categ = COMPL_CMD; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3384 } else if (nrow == -1) { // Nickname completion |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3385 compl_categ = COMPL_RESOURCE; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3386 } else { // Other completion, depending on the command |
285 | 3387 int alias = FALSE; |
3388 cmd *com; | |
3389 char *xpline = expandalias(inputLine); | |
3390 com = cmd_get(xpline); | |
3391 if (xpline != inputLine) { | |
3392 // This is an alias, so we can't complete rows > 0 | |
3393 alias = TRUE; | |
3394 g_free(xpline); | |
3395 } | |
3396 if ((!com && (!alias || !completion_started)) || !row) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3397 scr_LogPrint(LPRINT_NORMAL, "I cannot complete that..."); |
103 | 3398 return; |
3399 } | |
285 | 3400 if (!alias) |
3401 compl_categ = com->completion_flags[nrow-1]; | |
3402 else | |
3403 compl_categ = 0; | |
103 | 3404 } |
3405 | |
3406 if (!completion_started) { | |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3407 guint dynlist; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3408 GSList *list = compl_get_category_list(compl_categ, &dynlist); |
103 | 3409 if (list) { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3410 guint n; |
103 | 3411 char *prefix = g_strndup(row, ptr_inputline-row); |
3412 // Init completion | |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3413 n = new_completion(prefix, list); |
103 | 3414 g_free(prefix); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3415 if (n == 0 && nrow == -1) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3416 // This is a MUC room and we can't complete from the beginning of the |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3417 // line. Let's try a bit harder and complete the current word. |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3418 row = prev_char(ptr_inputline, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3419 while (row >= inputLine) { |
1239
eb9fc5d6d085
MUC: Nickname completion starts from any non-space character
Mikael Berthe <mikael@lilotux.net>
parents:
1229
diff
changeset
|
3420 if (iswspace(get_char(row)) || get_char(row) == '(') { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3421 row = next_char((char*)row); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3422 break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3423 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3424 if (row == inputLine) |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3425 break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3426 row = prev_char((char*)row, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3427 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3428 // There's no need to try again if row == inputLine |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3429 if (row > inputLine) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3430 prefix = g_strndup(row, ptr_inputline-row); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3431 new_completion(prefix, list); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3432 g_free(prefix); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3433 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3434 } |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3435 // Free the list if it's a dynamic one |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3436 if (dynlist) { |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3437 GSList *slp; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3438 for (slp = list; slp; slp = g_slist_next(slp)) |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3439 g_free(slp->data); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3440 g_slist_free(list); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3441 } |
103 | 3442 // Now complete |
98 | 3443 cchar = complete(); |
3444 if (cchar) | |
3445 scr_insert_text(cchar); | |
103 | 3446 completion_started = TRUE; |
98 | 3447 } |
103 | 3448 } else { // Completion already initialized |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3449 scr_cancel_current_completion(); |
103 | 3450 // Now complete again |
3451 cchar = complete(); | |
3452 if (cchar) | |
3453 scr_insert_text(cchar); | |
102 | 3454 } |
98 | 3455 } |
3456 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3457 static void scr_cancel_current_completion(void) |
98 | 3458 { |
3459 char *c; | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3460 char *src = ptr_inputline; |
98 | 3461 guint back = cancel_completion(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3462 guint i; |
98 | 3463 // Remove $back chars |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3464 for (i = 0; i < back; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3465 ptr_inputline = prev_char(ptr_inputline, inputLine); |
98 | 3466 c = ptr_inputline; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3467 for ( ; *src ; ) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3468 *c++ = *src++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3469 *c = 0; |
98 | 3470 } |
3471 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3472 static void scr_end_current_completion(void) |
98 | 3473 { |
3474 done_completion(); | |
3475 completion_started = FALSE; | |
3476 } | |
3477 | |
24 | 3478 // check_offset(int direction) |
3479 // Check inputline_offset value, and make sure the cursor is inside the | |
3480 // screen. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3481 static inline void check_offset(int direction) |
24 | 3482 { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3483 int i; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3484 char *c = &inputLine[inputline_offset]; |
24 | 3485 // Left side |
3486 if (inputline_offset && direction <= 0) { | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3487 while (ptr_inputline <= c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3488 for (i = 0; i < 5; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3489 c = prev_char(c, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3490 if (c == inputLine) |
828
319fc55b9a2b
Fix a bug in check_offset()
Mikael Berthe <mikael@lilotux.net>
parents:
827
diff
changeset
|
3491 break; |
24 | 3492 } |
3493 } | |
3494 // Right side | |
3495 if (direction >= 0) { | |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
3496 int delta = get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3497 while (ptr_inputline > c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3498 c = next_char(c); |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
3499 delta += get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3500 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3501 c = &inputLine[inputline_offset]; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3502 while (delta >= maxX) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3503 for (i = 0; i < 5; i++) { |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
3504 delta -= get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3505 c = next_char(c); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3506 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3507 } |
24 | 3508 } |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3509 inputline_offset = c - inputLine; |
24 | 3510 } |
3511 | |
1179 | 3512 #ifdef HAVE_ASPELL_H |
3513 // prints inputLine with underlined words when misspelled | |
3514 static inline void print_checked_line(void) | |
3515 { | |
3516 char *wprint_char_fmt = "%c"; | |
3517 int point; | |
3518 char *ptrCur = inputLine + inputline_offset; | |
3519 | |
3520 #ifdef UNICODE | |
3521 // We need this to display a single UTF-8 char... Any better solution? | |
3522 if (utf8_mode) | |
3523 wprint_char_fmt = "%lc"; | |
3524 #endif | |
3525 | |
3526 wmove(inputWnd, 0, 0); // problem with backspace | |
3527 | |
3528 while (*ptrCur) { | |
3529 point = ptrCur - inputLine; | |
3530 if (maskLine[point]) | |
3531 wattrset(inputWnd, A_UNDERLINE); | |
3532 wprintw(inputWnd, wprint_char_fmt, get_char(ptrCur)); | |
3533 wattrset(inputWnd, A_NORMAL); | |
3534 ptrCur = next_char(ptrCur); | |
3535 } | |
3536 } | |
3537 #endif | |
3538 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3539 static inline void refresh_inputline(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3540 { |
1179 | 3541 #ifdef HAVE_ASPELL_H |
3542 if (settings_opt_get_int("aspell_enable")) { | |
3543 memset(maskLine, 0, INPUTLINE_LENGTH+1); | |
3544 spellcheck(inputLine, maskLine); | |
3545 } | |
3546 print_checked_line(); | |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3547 wclrtoeol(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3548 if (*ptr_inputline) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3549 // hack to set cursor pos. Characters can have different width, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3550 // so I know of no better way. |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3551 char c = *ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3552 *ptr_inputline = 0; |
1179 | 3553 print_checked_line(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3554 *ptr_inputline = c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3555 } |
1179 | 3556 #else |
3557 mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); | |
3558 wclrtoeol(inputWnd); | |
3559 if (*ptr_inputline) { | |
3560 // hack to set cursor pos. Characters can have different width, | |
3561 // so I know of no better way. | |
3562 char c = *ptr_inputline; | |
3563 *ptr_inputline = 0; | |
3564 mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); | |
3565 *ptr_inputline = c; | |
3566 } | |
3567 #endif | |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3568 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3569 |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
3570 void scr_handle_CtrlC(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3571 { |
365
ddb6593bedc9
Fix segfault when mcabber receives an INT signal (Ctrl-C) early
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
3572 if (!Curses) return; |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
3573 // Leave multi-line mode |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1186
diff
changeset
|
3574 process_command(mkcmdstr("msay abort"), TRUE); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3575 // Same as Ctrl-g, now |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3576 scr_cancel_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3577 scr_end_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3578 check_offset(-1); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3579 refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3580 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3581 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3582 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
|
3583 { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3584 keyseq *ks; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3585 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3586 // Let's make sure the length is correct |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3587 if (strlen(seqstr) > MAX_KEYSEQ_LENGTH) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3588 scr_LogPrint(LPRINT_LOGNORM, "add_keyseq(): key sequence is too long!"); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3589 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3590 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3591 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3592 ks = g_new0(keyseq, 1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3593 ks->seqstr = g_strdup(seqstr); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3594 ks->mkeycode = mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3595 ks->value = value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3596 keyseqlist = g_slist_append(keyseqlist, ks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3597 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3598 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3599 // match_keyseq(iseq, &ret) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3600 // Check if "iseq" is a known key escape sequence. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3601 // Return value: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3602 // -1 if "seq" matches no known sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3603 // 0 if "seq" could match 1 or more known sequences |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3604 // >0 if "seq" matches a key sequence; the mkey code is returned |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3605 // and *ret is set to the matching keyseq structure. |
952 | 3606 static inline gint match_keyseq(int *iseq, keyseq **ret) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
3607 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3608 GSList *ksl; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3609 keyseq *ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3610 char *p, c; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3611 int *i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3612 int needmore = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3613 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3614 for (ksl = keyseqlist; ksl; ksl = g_slist_next(ksl)) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3615 ksp = ksl->data; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3616 p = ksp->seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3617 i = iseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3618 while (1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3619 c = (unsigned char)*i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3620 if (!*p && !c) { // Match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3621 (*ret) = ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3622 return ksp->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3623 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3624 if (!c) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3625 // iseq is too short |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3626 needmore = TRUE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3627 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3628 } else if (!*p || c != *p) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3629 // This isn't a match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3630 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3631 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3632 p++; i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3633 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3634 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3635 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3636 if (needmore) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3637 return 0; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3638 return -1; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3639 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3640 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3641 static inline int match_utf8_keyseq(int *iseq) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3642 { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3643 int *strp = iseq; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3644 unsigned c = *strp++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3645 unsigned mask = 0x80; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3646 int len = -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3647 while (c & mask) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3648 mask >>= 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3649 len++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3650 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3651 if (len <= 0 || len > 4) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3652 return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3653 c &= mask - 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3654 while ((*strp & 0xc0) == 0x80) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3655 if (len-- <= 0) // can't happen |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3656 return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3657 c = (c << 6) | (*strp++ & 0x3f); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3658 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3659 if (len) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3660 return 0; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3661 return c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3662 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3663 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3664 void scr_Getch(keycode *kcode) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3665 { |
769 | 3666 keyseq *mks = NULL; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3667 int ks[MAX_KEYSEQ_LENGTH+1]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3668 int i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3669 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3670 memset(kcode, 0, sizeof(keycode)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3671 memset(ks, 0, sizeof(ks)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3672 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3673 kcode->value = wgetch(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3674 if (utf8_mode) { |
1058 | 3675 bool ismeta = (kcode->value == 27); |
3676 | |
3677 if (ismeta) | |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3678 ks[0] = wgetch(inputWnd); |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3679 else |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3680 ks[0] = kcode->value; |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3681 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3682 for (i = 0; i < MAX_KEYSEQ_LENGTH - 1; i++) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3683 int match = match_utf8_keyseq(ks); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3684 if (match == -1) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3685 break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3686 if (match > 0) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3687 kcode->value = match; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3688 kcode->utf8 = 1; |
1058 | 3689 if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3690 kcode->mcode = MKEY_META; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3691 return; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3692 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3693 ks[i + 1] = wgetch(inputWnd); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3694 if (ks[i + 1] == ERR) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3695 break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3696 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3697 while (i > 0) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3698 ungetch(ks[i--]); |
1058 | 3699 if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3700 ungetch(ks[0]); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3701 memset(ks, 0, sizeof(ks)); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3702 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3703 if (kcode->value != 27) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3704 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3705 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3706 // Check for escape key sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3707 for (i=0; i < MAX_KEYSEQ_LENGTH; i++) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3708 int match; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3709 ks[i] = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3710 if (ks[i] == ERR) break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3711 match = match_keyseq(ks, &mks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3712 if (match == -1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3713 // No such key sequence. Let's increment i as it is a valid key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3714 i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3715 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3716 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3717 if (match > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3718 // We have a matching sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3719 kcode->mcode = mks->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3720 kcode->value = mks->value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3721 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3722 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3723 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3724 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3725 // No match. Let's return a meta-key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3726 if (i > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3727 kcode->mcode = MKEY_META; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3728 kcode->value = ks[0]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3729 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3730 if (i > 1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3731 // We need to push some keys back to the keyboard buffer |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3732 while (i-- > 1) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3733 ungetch(ks[i]); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3734 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3735 return; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
3736 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
3737 |
1413 | 3738 void scr_DoUpdate(void) |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3739 { |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3740 doupdate(); |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3741 } |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3742 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3743 static int bindcommand(keycode kcode) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3744 { |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3745 gchar asciikey[16], asciicode[16]; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3746 const gchar *boundcmd; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3747 |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3748 if (kcode.utf8) |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3749 g_snprintf(asciicode, 15, "U%d", kcode.value); |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3750 else |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3751 g_snprintf(asciicode, 15, "%d", kcode.value); |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3752 |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3753 if (!kcode.mcode || kcode.mcode == MKEY_EQUIV) |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3754 g_snprintf(asciikey, 15, "%s", asciicode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3755 else if (kcode.mcode == MKEY_META) |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3756 g_snprintf(asciikey, 15, "M%s", asciicode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3757 else |
949
e3c49b2f8143
Fix bindings of special keys (MK*)
Mikael Berthe <mikael@lilotux.net>
parents:
945
diff
changeset
|
3758 g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3759 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3760 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3761 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3762 if (boundcmd) { |
1357
7bbfb0073f88
Fix an UTF-8 problem in new hook_execute_internal() function
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
3763 gchar *cmdline = from_utf8(boundcmd); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3764 scr_CheckAutoAway(TRUE); |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1186
diff
changeset
|
3765 if (process_command(cmdline, TRUE)) |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3766 return 255; // Quit |
1058 | 3767 g_free(cmdline); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3768 return 0; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3769 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3770 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3771 scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3772 #ifndef UNICODE |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3773 if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3774 scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3775 "WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3776 #endif |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3777 return -1; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3778 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3779 |
44 | 3780 // process_key(key) |
3781 // Handle the pressed key, in the command line (bottom). | |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3782 void process_key(keycode kcode) |
24 | 3783 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3784 int key = kcode.value; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3785 int display_char = FALSE; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3786 |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
3787 lock_chatstate = FALSE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3788 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3789 switch (kcode.mcode) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3790 case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3791 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3792 case MKEY_EQUIV: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3793 key = kcode.value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3794 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3795 case MKEY_META: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3796 default: |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3797 if (bindcommand(kcode) == 255) { |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3798 mcabber_set_terminate_ui(); |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3799 return; |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3800 } |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3801 key = ERR; // Do not process any further |
758 | 3802 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3803 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3804 if (kcode.utf8) { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3805 if (key != ERR && !kcode.mcode) |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3806 display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3807 goto display; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3808 } |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3809 |
758 | 3810 switch (key) { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3811 case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3812 case ERR: |
758 | 3813 break; |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3814 case 9: // Tab |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3815 readline_do_completion(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3816 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3817 case 13: // Enter |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3818 if (readline_accept_line(FALSE) == 255) { |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3819 mcabber_set_terminate_ui(); |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3820 return; |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3821 } |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3822 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3823 case 3: // Ctrl-C |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3824 scr_handle_CtrlC(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3825 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3826 case KEY_RESIZE: |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3827 #ifdef USE_SIGWINCH |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3828 { |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3829 struct winsize size; |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3830 if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3831 resizeterm(size.ws_row, size.ws_col); |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3832 } |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3833 scr_Resize(); |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3834 process_command(mkcmdstr("screen_refresh"), TRUE); |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3835 #else |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3836 scr_Resize(); |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
3837 #endif |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3838 break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
3839 default: |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3840 display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3841 } // switch |
263 | 3842 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3843 display: |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3844 if (display_char) { |
1394 | 3845 guint printable; |
3846 | |
3847 if (kcode.utf8) { | |
3848 printable = iswprint(key); | |
3849 } else { | |
3850 #ifdef __CYGWIN__ | |
3851 printable = (isprint(key) || (key >= 161 && key <= 255)) | |
3852 && !is_speckey(key); | |
3853 #else | |
3854 printable = isprint(key) && !is_speckey(key); | |
3855 #endif | |
3856 } | |
3857 if (printable) { | |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3858 char tmpLine[INPUTLINE_LENGTH+1]; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
3859 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3860 // Check the line isn't too long |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3861 if (strlen(inputLine) + 4 > INPUTLINE_LENGTH) |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3862 return; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3863 |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3864 // Insert char |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3865 strcpy(tmpLine, ptr_inputline); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3866 ptr_inputline = put_char(ptr_inputline, key); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3867 strcpy(ptr_inputline, tmpLine); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3868 check_offset(1); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3869 } else { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3870 // Look for a key binding. |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3871 if (!kcode.utf8 && (bindcommand(kcode) == 255)) { |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3872 mcabber_set_terminate_ui(); |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3873 return; |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3874 } |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3875 } |
24 | 3876 } |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
3877 |
157 | 3878 if (completion_started && key != 9 && key != KEY_RESIZE) |
98 | 3879 scr_end_current_completion(); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3880 refresh_inputline(); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3881 |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3882 if (!lock_chatstate) { |
997 | 3883 // Set chat state to composing (1) if the user is currently composing, |
3884 // i.e. not an empty line and not a command line. | |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3885 if (inputLine[0] == 0 || inputLine[0] == COMMAND_CHAR) |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3886 set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3887 else |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3888 set_chatstate(1); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
3889 if (chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
3890 time(&chatstate_timestamp); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3891 } |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
3892 return; |
24 | 3893 } |
576 | 3894 |
1179 | 3895 #ifdef HAVE_ASPELL_H |
3896 // Aspell initialization | |
3897 void spellcheck_init(void) | |
3898 { | |
3899 int aspell_enable = settings_opt_get_int("aspell_enable"); | |
3900 const char *aspell_lang = settings_opt_get("aspell_lang"); | |
3901 const char *aspell_encoding = settings_opt_get("aspell_encoding"); | |
3902 AspellCanHaveError *possible_err; | |
3903 | |
3904 if (!aspell_enable) | |
3905 return; | |
3906 | |
3907 if (spell_checker) { | |
3908 delete_aspell_speller(spell_checker); | |
3909 delete_aspell_config(spell_config); | |
3910 spell_checker = NULL; | |
3911 spell_config = NULL; | |
3912 } | |
3913 | |
3914 spell_config = new_aspell_config(); | |
3915 aspell_config_replace(spell_config, "encoding", aspell_encoding); | |
3916 aspell_config_replace(spell_config, "lang", aspell_lang); | |
3917 possible_err = new_aspell_speller(spell_config); | |
3918 | |
3919 if (aspell_error_number(possible_err) != 0) { | |
3920 spell_checker = NULL; | |
3921 delete_aspell_config(spell_config); | |
3922 spell_config = NULL; | |
3923 } else { | |
3924 spell_checker = to_aspell_speller(possible_err); | |
3925 } | |
3926 } | |
3927 | |
3928 // Deinitialization of Aspell spellchecker | |
3929 void spellcheck_deinit(void) | |
3930 { | |
3931 if (spell_checker) { | |
3932 delete_aspell_speller(spell_checker); | |
3933 spell_checker = NULL; | |
3934 } | |
3935 | |
3936 if (spell_config) { | |
3937 delete_aspell_config(spell_config); | |
3938 spell_config = NULL; | |
3939 } | |
3940 } | |
3941 | |
1245
e6ddd19956eb
Fix Aspell support on some systems
Mikael Berthe <mikael@lilotux.net>
parents:
1239
diff
changeset
|
3942 #define aspell_isalpha(c) (utf8_mode ? iswalpha(get_char(c)) : isalpha(*c)) |
e6ddd19956eb
Fix Aspell support on some systems
Mikael Berthe <mikael@lilotux.net>
parents:
1239
diff
changeset
|
3943 |
1179 | 3944 // Spell checking function |
3945 static void spellcheck(char *line, char *checked) | |
3946 { | |
3947 const char *start, *line_start; | |
3948 | |
3949 if (inputLine[0] == 0 || inputLine[0] == COMMAND_CHAR) | |
3950 return; | |
3951 | |
3952 line_start = line; | |
3953 | |
3954 while (*line) { | |
3955 | |
1245
e6ddd19956eb
Fix Aspell support on some systems
Mikael Berthe <mikael@lilotux.net>
parents:
1239
diff
changeset
|
3956 if (!aspell_isalpha(line)) { |
1179 | 3957 line = next_char(line); |
3958 continue; | |
3959 } | |
3960 | |
3961 if (!strncmp(line, "http://", 7)) { | |
3962 line += 7; // : and / characters are 1 byte long in utf8, right? | |
3963 | |
3964 while (!strchr(" \t\r\n", *line)) | |
3965 line = next_char(line); // i think line++ would be fine here? | |
3966 | |
3967 continue; | |
3968 } | |
3969 | |
3970 if (!strncmp(line, "ftp://", 6)) { | |
3971 line += 6; | |
3972 | |
3973 while (!strchr(" \t\r\n", *line)) | |
3974 line = next_char(line); | |
3975 | |
3976 continue; | |
3977 } | |
3978 | |
3979 start = line; | |
3980 | |
1245
e6ddd19956eb
Fix Aspell support on some systems
Mikael Berthe <mikael@lilotux.net>
parents:
1239
diff
changeset
|
3981 while (aspell_isalpha(line)) |
1179 | 3982 line = next_char(line); |
3983 | |
3984 if (spell_checker && | |
3985 aspell_speller_check(spell_checker, start, line - start) == 0) | |
3986 memset(&checked[start - line_start], ASPELLBADCHAR, line - start); | |
3987 } | |
3988 } | |
3989 #endif | |
3990 | |
580 | 3991 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |