Mercurial > hg
annotate mcabber/src/screen.c @ 1187:16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 20 Apr 2007 17:14:38 +0200 |
parents | 0158bd8ca9d6 |
children | be06bbe7e449 |
rev | line source |
---|---|
307 | 1 /* |
2 * screen.c -- UI stuff | |
393 | 3 * |
699 | 4 * Copyright (C) 2005, 2006 Mikael Berthe <bmikael@lists.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> | |
28 #include <locale.h> | |
232 | 29 #include <langinfo.h> |
929 | 30 #include <config.h> |
31 | |
1179 | 32 #ifdef HAVE_ASPELL_H |
33 # include <aspell.h> | |
34 #endif | |
35 | |
24 | 36 #include "screen.h" |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
37 #include "utf8.h" |
81 | 38 #include "hbuf.h" |
47 | 39 #include "commands.h" |
95 | 40 #include "compl.h" |
81 | 41 #include "roster.h" |
180 | 42 #include "histolog.h" |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
43 #include "settings.h" |
81 | 44 #include "utils.h" |
24 | 45 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
46 #define get_color(col) (COLOR_PAIR(col)|COLOR_ATTRIB[col]) |
24 | 47 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
48 #define DEFAULT_LOG_WIN_HEIGHT (5+2) |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
49 #define DEFAULT_ROSTER_WIDTH 24 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
50 #define CHAT_WIN_HEIGHT (maxY-1-Log_Win_Height) |
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
51 |
592
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
52 char *LocaleCharSet = "C"; |
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
53 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
54 static unsigned short int Log_Win_Height; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
55 static unsigned short int Roster_Width; |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
56 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
57 static inline void check_offset(int); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
58 static void scr_cancel_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
59 static void scr_end_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
60 static void scr_insert_text(const char*); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
61 static void scr_handle_tab(void); |
151 | 62 |
1179 | 63 #ifdef HAVE_ASPELL_H |
64 static void spellcheck(char *, char *); | |
65 static inline int is_alpha(const char *); | |
66 #endif | |
67 | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
68 static GHashTable *winbufhash; |
24 | 69 |
822 | 70 typedef struct { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
71 GList *hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
72 GList *top; // If top is NULL, we'll display the last lines |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
73 char cleared; // For ex, user has issued a /clear command... |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
74 char lock; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
75 } buffdata; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
76 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
77 typedef struct { |
24 | 78 WINDOW *win; |
108 | 79 PANEL *panel; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
80 buffdata *bd; |
822 | 81 } winbuf; |
24 | 82 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
83 struct dimensions { |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
84 int l; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
85 int c; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
86 }; |
24 | 87 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
88 static WINDOW *rosterWnd, *chatWnd, *activechatWnd, *inputWnd, *logWnd; |
711 | 89 static WINDOW *mainstatusWnd, *chatstatusWnd; |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
90 static PANEL *rosterPanel, *chatPanel, *activechatPanel, *inputPanel; |
711 | 91 static PANEL *mainstatusPanel, *chatstatusPanel; |
92 static PANEL *logPanel; | |
24 | 93 static int maxY, maxX; |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
94 static int prev_chatwidth; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
95 static winbuf *statusWindow; |
822 | 96 static winbuf *currentWindow; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
97 static GList *statushbuf; |
24 | 98 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
99 static int roster_hidden; |
24 | 100 static int chatmode; |
238 | 101 static int multimode; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
102 static char *multiline, *multimode_subj; |
30 | 103 int update_roster; |
232 | 104 int utf8_mode = 0; |
322
da138cdebf04
Implement auto-away mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
105 static bool Autoaway; |
332
a1901741890e
scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
106 static bool Curses; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
107 static bool log_win_on_top; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
108 static bool roster_win_on_right; |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
109 static time_t LastActivity; |
24 | 110 |
174 | 111 static char inputLine[INPUTLINE_LENGTH+1]; |
1179 | 112 #ifdef HAVE_ASPELL_H |
113 static char maskLine[INPUTLINE_LENGTH+1]; | |
114 #endif | |
174 | 115 static char *ptr_inputline; |
116 static short int inputline_offset; | |
117 static int completion_started; | |
173 | 118 static GList *cmdhisto; |
119 static GList *cmdhisto_cur; | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
120 static guint cmdhisto_nblines; |
174 | 121 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
24 | 122 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
123 static int chatstate; /* (0=active, 1=composing, 2=paused) */ |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
124 static bool lock_chatstate; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
125 static time_t chatstate_timestamp; |
993
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
126 int chatstates_disabled; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
127 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
128 #define MAX_KEYSEQ_LENGTH 8 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
129 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
130 typedef struct { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
131 char *seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
132 guint mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
133 gint value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
134 } keyseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
135 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
136 GSList *keyseqlist; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
137 static void add_keyseq(char *seqstr, guint mkeycode, gint value); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
138 |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
139 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
140 unsigned int prefix_flags, int force_show); |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
141 |
1179 | 142 #ifdef HAVE_ASPELL_H |
143 #define ASPELLBADCHAR 5 | |
144 AspellConfig *spell_config; | |
145 AspellSpeller *spell_checker; | |
146 #endif | |
24 | 147 |
99 | 148 /* Functions */ |
24 | 149 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
150 static int FindColor(const char *name) |
24 | 151 { |
152 if (!strcmp(name, "default")) | |
153 return -1; | |
154 if (!strcmp(name, "black")) | |
155 return COLOR_BLACK; | |
156 if (!strcmp(name, "red")) | |
157 return COLOR_RED; | |
158 if (!strcmp(name, "green")) | |
159 return COLOR_GREEN; | |
160 if (!strcmp(name, "yellow")) | |
161 return COLOR_YELLOW; | |
162 if (!strcmp(name, "blue")) | |
163 return COLOR_BLUE; | |
164 if (!strcmp(name, "magenta")) | |
165 return COLOR_MAGENTA; | |
166 if (!strcmp(name, "cyan")) | |
167 return COLOR_CYAN; | |
168 if (!strcmp(name, "white")) | |
169 return COLOR_WHITE; | |
170 | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
171 scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name); |
24 | 172 return -1; |
173 } | |
174 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
175 static void ParseColors(void) |
24 | 176 { |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
177 const char *colors[] = { |
24 | 178 "", "", |
267 | 179 "general", |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
180 "msgout", |
711 | 181 "status", |
712 | 182 "roster", |
183 "rostersel", | |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
184 "rosterselmsg", |
712 | 185 "rosternewmsg", |
24 | 186 NULL |
187 }; | |
188 | |
281
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
189 const char *color; |
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
190 const char *background = settings_opt_get("color_background"); |
712 | 191 const char *backselected = settings_opt_get("color_bgrostersel"); |
192 const char *backstatus = settings_opt_get("color_bgstatus"); | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
193 char *tmp; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
194 int i; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
195 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
196 // Initialize color attributes |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
197 memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB)); |
24 | 198 |
267 | 199 // Default values |
711 | 200 if (!background) background = "black"; |
267 | 201 if (!backselected) backselected = "cyan"; |
711 | 202 if (!backstatus) backstatus = "blue"; |
267 | 203 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
204 for (i=0; colors[i]; i++) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
205 tmp = g_strdup_printf("color_%s", colors[i]); |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
206 color = settings_opt_get(tmp); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
207 g_free(tmp); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
208 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
209 if (color) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
210 if (!strncmp(color, "bright", 6)) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
211 COLOR_ATTRIB[i+1] = A_BOLD; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
212 color += 6; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
213 } |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
214 } |
24 | 215 |
216 switch (i + 1) { | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
217 case 1: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
218 init_pair(1, COLOR_BLACK, COLOR_WHITE); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
219 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
220 case 2: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
221 init_pair(2, COLOR_WHITE, COLOR_BLACK); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
222 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
223 case COLOR_GENERAL: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
224 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
225 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
226 break; |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
227 case COLOR_MSGOUT: |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
228 init_pair(i+1, ((color) ? FindColor(color) : COLOR_CYAN), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
229 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
230 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
231 case COLOR_STATUS: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
232 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
233 FindColor(backstatus)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
234 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
235 case COLOR_ROSTER: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
236 init_pair(i+1, ((color) ? FindColor(color) : COLOR_GREEN), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
237 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
238 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
239 case COLOR_ROSTERSEL: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
240 init_pair(i+1, ((color) ? FindColor(color) : COLOR_BLUE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
241 FindColor(backselected)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
242 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
243 case COLOR_ROSTERSELNMSG: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
244 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
245 FindColor(backselected)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
246 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
247 case COLOR_ROSTERNMSG: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
248 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
249 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
250 break; |
24 | 251 } |
252 } | |
253 } | |
254 | |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
255 static void init_keycodes(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
256 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
257 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
258 add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
259 add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
260 add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 261 add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up |
262 add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down | |
263 add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right | |
264 add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left | |
265 add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up | |
266 add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down | |
267 add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right | |
268 add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left | |
269 add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
270 add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown | |
271 add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp | |
272 add_keyseq("[6@", MKEY_CTRL_SHIFT_PGDOWN, 0); // Ctrl-Shift-PageDown | |
826
3a3c7a017904
Add Ctrl-Shift-{Home,End} key code sequences
Mikael Berthe <mikael@lilotux.net>
parents:
825
diff
changeset
|
273 add_keyseq("[7@", MKEY_CTRL_SHIFT_HOME, 0); // Ctrl-Shift-Home |
3a3c7a017904
Add Ctrl-Shift-{Home,End} key code sequences
Mikael Berthe <mikael@lilotux.net>
parents:
825
diff
changeset
|
274 add_keyseq("[8@", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End |
794
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
275 add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
276 add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
277 add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
278 add_keyseq("[3^", MKEY_CTRL_DEL, 0); // Ctrl-Delete |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
279 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
280 // Xterm |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
281 add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
282 add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
283 add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
284 add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
285 add_keyseq("[1;6A", MKEY_EQUIV, 520); // Ctrl-Shift-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
286 add_keyseq("[1;6B", MKEY_EQUIV, 513); // Ctrl-Shift-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
287 add_keyseq("[1;6C", MKEY_EQUIV, 402); // Ctrl-Shift-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
288 add_keyseq("[1;6D", MKEY_EQUIV, 393); // Ctrl-Shift-Left |
826
3a3c7a017904
Add Ctrl-Shift-{Home,End} key code sequences
Mikael Berthe <mikael@lilotux.net>
parents:
825
diff
changeset
|
289 add_keyseq("[1;6H", MKEY_CTRL_SHIFT_HOME, 0); // Ctrl-Shift-Home |
3a3c7a017904
Add Ctrl-Shift-{Home,End} key code sequences
Mikael Berthe <mikael@lilotux.net>
parents:
825
diff
changeset
|
290 add_keyseq("[1;6F", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End |
763 | 291 add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up |
292 add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down | |
293 add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
294 add_keyseq("[6;5~", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown | |
794
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
295 add_keyseq("[1;5F", MKEY_CTRL_END, 0); // Ctrl-End |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
296 add_keyseq("[1;5H", MKEY_CTRL_HOME, 0); // Ctrl-Home |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
297 add_keyseq("[2;5~", MKEY_CTRL_INS, 0); // Ctrl-Insert |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
298 add_keyseq("[3;5~", MKEY_CTRL_DEL, 0); // Ctrl-Delete |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
299 |
768
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
300 // PuTTY |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
301 add_keyseq("[A", MKEY_EQUIV, 521); // Ctrl-Up |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
302 add_keyseq("[B", MKEY_EQUIV, 514); // Ctrl-Down |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
303 add_keyseq("[C", MKEY_EQUIV, 518); // Ctrl-Right |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
304 add_keyseq("[D", MKEY_EQUIV, 516); // Ctrl-Left |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
305 |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
306 // screen |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
307 add_keyseq("Oa", MKEY_EQUIV, 521); // Ctrl-Up |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
308 add_keyseq("Ob", MKEY_EQUIV, 514); // Ctrl-Down |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
309 add_keyseq("Oc", MKEY_EQUIV, 518); // Ctrl-Right |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
310 add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 311 add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up |
312 add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down | |
313 add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right | |
314 add_keyseq("[d", MKEY_EQUIV, 393); // Shift-Left | |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
315 add_keyseq("[5$", MKEY_SHIFT_PGUP, 0); // Shift-PageUp |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
316 add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown |
1170 | 317 |
318 // VT100 | |
319 add_keyseq("[H", MKEY_EQUIV, KEY_HOME); // Home | |
320 add_keyseq("[F", MKEY_EQUIV, KEY_END); // End | |
321 | |
322 // Konsole Linux | |
323 add_keyseq("[1~", MKEY_EQUIV, KEY_HOME); // Home | |
324 add_keyseq("[4~", MKEY_EQUIV, KEY_END); // End | |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
325 } |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
326 |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
327 // scr_init_bindings() |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
328 // Create default key bindings |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
329 // Return 0 if error and 1 if none |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
330 void scr_init_bindings(void) |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
331 { |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
332 GString *sbuf = g_string_new(""); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
333 |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
334 // Common backspace key codes: 8, 127 |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
335 settings_set(SETTINGS_TYPE_BINDING, "8", "iline char_bdel"); // Ctrl-h |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
336 settings_set(SETTINGS_TYPE_BINDING, "127", "iline char_bdel"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
337 g_string_printf(sbuf, "%d", KEY_BACKSPACE); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
338 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline char_bdel"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
339 g_string_printf(sbuf, "%d", KEY_DC); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
340 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline char_fdel"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
341 g_string_printf(sbuf, "%d", KEY_LEFT); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
342 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline bchar"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
343 g_string_printf(sbuf, "%d", KEY_RIGHT); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
344 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline fchar"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
345 settings_set(SETTINGS_TYPE_BINDING, "7", "iline compl_cancel"); // Ctrl-g |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
346 g_string_printf(sbuf, "%d", KEY_UP); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
347 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline hist_prev"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
348 g_string_printf(sbuf, "%d", KEY_DOWN); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
349 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline hist_next"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
350 g_string_printf(sbuf, "%d", KEY_PPAGE); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
351 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "roster up"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
352 g_string_printf(sbuf, "%d", KEY_NPAGE); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
353 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "roster down"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
354 g_string_printf(sbuf, "%d", KEY_HOME); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
355 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_start"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
356 settings_set(SETTINGS_TYPE_BINDING, "1", "iline iline_start"); // Ctrl-a |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
357 g_string_printf(sbuf, "%d", KEY_END); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
358 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_end"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
359 settings_set(SETTINGS_TYPE_BINDING, "5", "iline iline_end"); // Ctrl-e |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
360 // Ctrl-o (accept-line-and-down-history): |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
361 settings_set(SETTINGS_TYPE_BINDING, "15", "iline iline_accept_down_hist"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
362 settings_set(SETTINGS_TYPE_BINDING, "21", "iline iline_bdel"); // Ctrl-u |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
363 g_string_printf(sbuf, "%d", KEY_EOL); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
364 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_fdel"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
365 settings_set(SETTINGS_TYPE_BINDING, "11", "iline iline_fdel"); // Ctrl-k |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
366 settings_set(SETTINGS_TYPE_BINDING, "16", "buffer up"); // Ctrl-p |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
367 settings_set(SETTINGS_TYPE_BINDING, "14", "buffer down"); // Ctrl-n |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
368 settings_set(SETTINGS_TYPE_BINDING, "20", "iline char_swap"); // Ctrl-t |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
369 settings_set(SETTINGS_TYPE_BINDING, "23", "iline word_bdel"); // Ctrl-w |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
370 settings_set(SETTINGS_TYPE_BINDING, "M98", "iline bword"); // Meta-b |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
371 settings_set(SETTINGS_TYPE_BINDING, "M102", "iline fword"); // Meta-f |
1186
0158bd8ca9d6
Add a default binding to Meta-d (iline word_fdel)
Mikael Berthe <mikael@lilotux.net>
parents:
1185
diff
changeset
|
372 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
|
373 // Ctrl-Left (2 codes): |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
374 settings_set(SETTINGS_TYPE_BINDING, "515", "iline bword"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
375 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
|
376 // Ctrl-Right (2 codes): |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
377 settings_set(SETTINGS_TYPE_BINDING, "517", "iline fword"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
378 settings_set(SETTINGS_TYPE_BINDING, "518", "iline fword"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
379 settings_set(SETTINGS_TYPE_BINDING, "12", "screen_refresh"); // Ctrl-l |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
380 settings_set(SETTINGS_TYPE_BINDING, "27", "chat_disable"); // Esc |
1185
5c34af370b67
Bind Meta-Esc (Esc-Esc) to chat_disable by default
Mikael Berthe <mikael@lilotux.net>
parents:
1179
diff
changeset
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
387 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
|
388 } |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
389 |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
390 void scr_InitLocaleCharSet(void) |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
391 { |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
392 setlocale(LC_CTYPE, ""); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
393 LocaleCharSet = nl_langinfo(CODESET); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
394 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
395 } |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
396 |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
397 void scr_InitCurses(void) |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
398 { |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
399 /* Key sequences initialization */ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
400 init_keycodes(); |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
401 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
402 initscr(); |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
403 raw(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
404 noecho(); |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
405 nonl(); |
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
406 intrflush(stdscr, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
407 start_color(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
408 use_default_colors(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
409 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
410 ParseColors(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
411 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
412 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
|
413 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
|
414 // 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
|
415 // 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
|
416 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
417 inputLine[0] = 0; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
418 ptr_inputline = inputLine; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
419 |
966
d9acb7f2a3d1
Do not set Curses variable too early
Mikael Berthe <mikael@lilotux.net>
parents:
961
diff
changeset
|
420 Curses = TRUE; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
421 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
422 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
423 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
424 void scr_TerminateCurses(void) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
425 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
426 if (!Curses) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
427 clear(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
428 refresh(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
429 endwin(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
430 Curses = FALSE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
431 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
432 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
433 |
675
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
434 inline void scr_Beep(void) |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
435 { |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
436 beep(); |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
437 } |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
438 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
439 // scr_LogPrint(...) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
440 // 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
|
441 // 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
|
442 void scr_LogPrint(unsigned int flag, const char *fmt, ...) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
443 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
444 time_t timestamp; |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
445 char strtimestamp[64]; |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
446 char *buffer, *btext; |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
447 char *convbuf1 = NULL, *convbuf2 = NULL; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
448 va_list ap; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
449 |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
450 if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
451 |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
452 timestamp = time(NULL); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
453 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
|
454 va_start(ap, fmt); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
455 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
|
456 va_end(ap); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
457 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
458 if (flag & LPRINT_NORMAL) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
459 char *buffer_locale; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
460 char *buf_specialwindow; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
461 |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
462 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
|
463 |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
464 // 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
|
465 if (!(flag & LPRINT_NOTUTF8)) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
466 buffer_locale = convbuf1 = from_utf8(buffer); |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
467 else |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
468 buffer_locale = buffer; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
469 |
884
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
470 if (!buffer_locale) { |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
471 wprintw(logWnd, |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
472 "\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
|
473 update_panels(); |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
474 g_free(buffer); |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
475 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
|
476 return; |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
477 } |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
478 |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
479 // 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
|
480 if (flag & LPRINT_NOTUTF8) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
481 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
|
482 else |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
483 buf_specialwindow = btext; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
484 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
485 if (Curses) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
486 wprintw(logWnd, "\n%s", buffer_locale); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
487 update_panels(); |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
488 scr_WriteInWindow(NULL, buf_specialwindow, timestamp, |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
489 HBB_PREFIX_SPECIAL, FALSE); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
490 } else { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
491 printf("%s\n", buffer_locale); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
492 // 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
|
493 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
1141
5be2408a6534
Add option "max_history_blocks"
Mikael Berthe <mikael@lilotux.net>
parents:
1139
diff
changeset
|
494 HBB_PREFIX_SPECIAL, 0, 0); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
495 } |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
496 |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
497 g_free(convbuf1); |
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
498 g_free(convbuf2); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
499 g_free(buffer); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
500 } |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
501 |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
502 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
503 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
|
504 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
|
505 ut_WriteLog(flag, buffer); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
506 g_free(buffer); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
507 } |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
508 g_free(btext); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
509 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
510 |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
511 static winbuf *scr_SearchWindow(const char *winId, int special) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
512 { |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
513 char *id; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
514 winbuf *wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
515 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
516 if (special) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
517 return statusWindow; // Only one special window atm. |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
518 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
519 if (!winId) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
520 return NULL; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
521 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
522 id = g_strdup(winId); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
523 mc_strtolower(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
524 wbp = g_hash_table_lookup(winbufhash, id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
525 g_free(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
526 return wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
527 } |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
528 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
529 int scr_BuddyBufferExists(const char *bjid) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
530 { |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
531 return (scr_SearchWindow(bjid, FALSE) != NULL); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
532 } |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
533 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
534 // scr_new_buddy(title, dontshow) |
1139 | 535 // 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
|
536 static winbuf *scr_new_buddy(const char *title, int dont_show) |
24 | 537 { |
822 | 538 winbuf *tmp; |
393 | 539 |
822 | 540 tmp = g_new0(winbuf, 1); |
24 | 541 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
542 tmp->win = activechatWnd; |
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
543 tmp->panel = activechatPanel; |
24 | 544 |
143 | 545 if (!dont_show) { |
24 | 546 currentWindow = tmp; |
547 } else { | |
548 if (currentWindow) | |
549 top_panel(currentWindow->panel); | |
550 else | |
551 top_panel(chatPanel); | |
552 } | |
143 | 553 update_panels(); |
24 | 554 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
555 // If title is NULL, this is a special buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
556 if (title) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
557 char *id; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
558 id = hlog_get_log_jid(title); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
559 if (id) { |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
560 winbuf *wb = scr_SearchWindow(id, FALSE); |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
561 if (!wb) |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
562 wb = scr_new_buddy(id, TRUE); |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
563 tmp->bd=wb->bd; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
564 g_free(id); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
565 } 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
|
566 tmp->bd = g_new0(buffdata, 1); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
567 hlog_read_history(title, &tmp->bd->hbuf, |
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
568 maxX - Roster_Width - PREFIX_WIDTH); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
569 } |
181 | 570 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
571 id = g_strdup(title); |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
572 mc_strtolower(id); |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
573 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
|
574 } else { |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
575 tmp->bd = g_new0(buffdata, 1); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
576 } |
24 | 577 return tmp; |
578 } | |
579 | |
143 | 580 // scr_UpdateWindow() |
581 // (Re-)Display the given chat window. | |
822 | 582 static void scr_UpdateWindow(winbuf *win_entry) |
74 | 583 { |
584 int n; | |
585 int width; | |
184 | 586 hbb_line **lines, *line; |
74 | 587 GList *hbuf_head; |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
588 char date[64]; |
74 | 589 |
1077
c51ca5225516
Remove useless WindowWidth function
Mikael Berthe <mikael@lilotux.net>
parents:
1076
diff
changeset
|
590 width = getmaxx(win_entry->win); |
108 | 591 |
592 // Should the window be empty? | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
593 if (win_entry->bd->cleared) { |
168 | 594 werase(win_entry->win); |
108 | 595 return; |
596 } | |
597 | |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
598 // 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
|
599 // we are displaying the last messages. |
105 | 600 |
74 | 601 // We will show the last CHAT_WIN_HEIGHT lines. |
602 // Let's find out where it begins. | |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
603 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
|
604 win_entry->bd->top) == -1)) { |
105 | 605 // 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
|
606 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
|
607 hbuf_head = win_entry->bd->hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
608 win_entry->bd->top = NULL; // (Just to make sure) |
105 | 609 n = 0; |
610 while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { | |
611 hbuf_head = g_list_previous(hbuf_head); | |
612 n++; | |
613 } | |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
614 // 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
|
615 if (win_entry->bd->lock) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
616 win_entry->bd->top = hbuf_head; |
105 | 617 } else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
618 hbuf_head = win_entry->bd->top; |
74 | 619 |
620 // Get the last CHAT_WIN_HEIGHT lines. | |
621 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); | |
622 | |
623 // Display these lines | |
624 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { | |
168 | 625 wmove(win_entry->win, n, 0); |
184 | 626 line = *(lines+n); |
185 | 627 // NOTE: update PREFIX_WIDTH if you change the date format!! |
628 // You need to set it to the whole prefix length + 1 | |
184 | 629 if (line) { |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
630 if (line->flags & HBB_PREFIX_HLIGHT) |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
631 wattrset(win_entry->win, get_color(COLOR_MSGOUT)); |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
632 |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
633 if (line->timestamp && !(line->flags & HBB_PREFIX_SPECIAL)) { |
419 | 634 strftime(date, 30, "%m-%d %H:%M", localtime(&line->timestamp)); |
184 | 635 } else |
185 | 636 strcpy(date, " "); |
197 | 637 if (line->flags & HBB_PREFIX_INFO) { |
638 char dir = '*'; | |
639 if (line->flags & HBB_PREFIX_IN) | |
640 dir = '<'; | |
641 else if (line->flags & HBB_PREFIX_OUT) | |
642 dir = '>'; | |
643 wprintw(win_entry->win, "%.11s *%c* ", date, dir); | |
325
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
644 } else if (line->flags & HBB_PREFIX_ERR) { |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
645 char dir = '#'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
646 if (line->flags & HBB_PREFIX_IN) |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
647 dir = '<'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
648 else if (line->flags & HBB_PREFIX_OUT) |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
649 dir = '>'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
650 wprintw(win_entry->win, "%.11s #%c# ", date, dir); |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
651 } else if (line->flags & HBB_PREFIX_IN) { |
1058 | 652 char cryptflag = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '='; |
653 wprintw(win_entry->win, "%.11s <%c= ", date, cryptflag); | |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
654 } else if (line->flags & HBB_PREFIX_OUT) { |
1058 | 655 char cryptflag = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '-'; |
656 wprintw(win_entry->win, "%.11s -%c> ", date, cryptflag); | |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
657 } else if (line->flags & HBB_PREFIX_SPECIAL) { |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
658 strftime(date, 30, "%m-%d %H:%M:%S", localtime(&line->timestamp)); |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
659 wprintw(win_entry->win, "%.14s ", date); |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
660 } else { |
185 | 661 wprintw(win_entry->win, "%.11s ", date); |
75 | 662 } |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
663 |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
664 wprintw(win_entry->win, "%s", line->text); // Display text line |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
665 |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
666 if (line->flags & HBB_PREFIX_HLIGHT) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
667 wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
168 | 668 wclrtoeol(win_entry->win); |
184 | 669 g_free(line->text); |
898
c65b71dcda94
Fix memory leak in scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
897
diff
changeset
|
670 g_free(line); |
168 | 671 } else { |
672 wclrtobot(win_entry->win); | |
673 break; | |
75 | 674 } |
74 | 675 } |
676 g_free(lines); | |
677 } | |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
678 |
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
679 static winbuf *scr_CreateWindow(const char *winId, int special, int dont_show) |
1154 | 680 { |
681 if (special) { | |
682 if (!statusWindow) { | |
683 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
|
684 statusWindow->bd->hbuf = statushbuf; |
1154 | 685 } |
686 return statusWindow; | |
687 } else { | |
688 return scr_new_buddy(winId, dont_show); | |
689 } | |
690 } | |
691 | |
143 | 692 // scr_ShowWindow() |
693 // Display the chat window with the given identifier. | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
694 // "special" must be true if this is a special buffer window. |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
695 static void scr_ShowWindow(const char *winId, int special) |
24 | 696 { |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
697 winbuf *win_entry; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
698 |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
699 win_entry = scr_SearchWindow(winId, special); |
74 | 700 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
701 if (!win_entry) { |
1154 | 702 win_entry = scr_CreateWindow(winId, special, FALSE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
703 } |
74 | 704 |
180 | 705 top_panel(win_entry->panel); |
706 currentWindow = win_entry; | |
707 chatmode = TRUE; | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
708 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
|
709 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
|
710 if (!special) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
711 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
|
712 update_roster = TRUE; |
74 | 713 |
180 | 714 // Refresh the window |
715 scr_UpdateWindow(win_entry); | |
716 | |
717 // Finished :) | |
718 update_panels(); | |
142 | 719 |
720 top_panel(inputPanel); | |
24 | 721 } |
722 | |
143 | 723 // scr_ShowBuddyWindow() |
724 // Display the chat window buffer for the current buddy. | |
24 | 725 void scr_ShowBuddyWindow(void) |
726 { | |
1058 | 727 const gchar *bjid; |
140 | 728 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
729 if (!current_buddy) { |
1058 | 730 bjid = NULL; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
731 } else { |
1058 | 732 bjid = CURRENT_JID; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
733 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
734 scr_ShowWindow(buddy_getname(BUDDATA(current_buddy)), TRUE); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
735 return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
736 } |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
737 } |
140 | 738 |
1058 | 739 if (!bjid) { |
140 | 740 top_panel(chatPanel); |
143 | 741 top_panel(inputPanel); |
140 | 742 currentWindow = NULL; |
105 | 743 return; |
140 | 744 } |
745 | |
1058 | 746 scr_ShowWindow(bjid, FALSE); |
24 | 747 } |
748 | |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
749 // scr_UpdateBuddyWindow() |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
750 // (Re)Display the current window. |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
751 // 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
|
752 // else display the chat window. |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
753 inline void scr_UpdateBuddyWindow(void) |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
754 { |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
755 if (chatmode) { |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
756 scr_ShowBuddyWindow(); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
757 return; |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
758 } |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
759 |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
760 top_panel(chatPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
761 top_panel(inputPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
762 } |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
763 |
143 | 764 // scr_WriteInWindow() |
765 // 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
|
766 // Use winId == NULL for the special status buffer. |
143 | 767 // Lines are splitted when they are too long to fit in the chat window. |
768 // If this window doesn't exist, it is created. | |
184 | 769 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
770 unsigned int prefix_flags, int force_show) |
24 | 771 { |
822 | 772 winbuf *win_entry; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
773 char *text_locale; |
24 | 774 int dont_show = FALSE; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
775 int special; |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
776 guint num_history_blocks; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
777 bool setmsgflg = FALSE; |
24 | 778 |
74 | 779 // Look for the window entry. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
780 special = (winId == NULL); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
781 win_entry = scr_SearchWindow(winId, special); |
74 | 782 |
783 // Do we have to really show the window? | |
24 | 784 if (!chatmode) |
785 dont_show = TRUE; | |
74 | 786 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24 | 787 dont_show = TRUE; |
788 | |
74 | 789 // 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
|
790 if (!win_entry) { |
1154 | 791 win_entry = scr_CreateWindow(winId, special, dont_show); |
24 | 792 } |
793 | |
220 | 794 // 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
|
795 if (win_entry->bd->cleared) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
796 win_entry->bd->top = g_list_last(win_entry->bd->hbuf); |
220 | 797 |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
798 // 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
|
799 // top is set. |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
800 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
|
801 num_history_blocks = 0U; |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
802 else |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
803 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
|
804 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
805 text_locale = from_utf8(text); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
806 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
807 maxX - Roster_Width - PREFIX_WIDTH, num_history_blocks); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
808 g_free(text_locale); |
74 | 809 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
810 if (win_entry->bd->cleared) { |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
811 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
812 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
|
813 win_entry->bd->top = g_list_next(win_entry->bd->top); |
220 | 814 } |
815 | |
816 // 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
|
817 if (!win_entry->bd->lock && win_entry->bd->top) { |
220 | 818 int dist; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
819 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
|
820 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
|
821 g_list_position(first, win_entry->bd->top); |
220 | 822 if (dist >= CHAT_WIN_HEIGHT) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
823 win_entry->bd->top = NULL; |
108 | 824 } |
825 | |
24 | 826 if (!dont_show) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
827 if (win_entry->bd->lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
828 setmsgflg = TRUE; |
74 | 829 // Show and refresh the window |
830 top_panel(win_entry->panel); | |
831 scr_UpdateWindow(win_entry); | |
142 | 832 top_panel(inputPanel); |
24 | 833 update_panels(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
834 } 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
|
835 setmsgflg = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
836 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
837 if (setmsgflg && !special) { |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
838 if (special && !winId) |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
839 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
|
840 roster_msg_setflag(winId, special, TRUE); |
30 | 841 update_roster = TRUE; |
24 | 842 } |
843 } | |
844 | |
713 | 845 // scr_UpdateMainStatus() |
846 // Redraw the main (bottom) status line. | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
847 void scr_UpdateMainStatus(int forceupdate) |
713 | 848 { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
849 char *sm = from_utf8(jb_getstatusmsg()); |
713 | 850 |
851 werase(mainstatusWnd); | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
852 mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s", |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
853 (unread_msg(NULL) ? '#' : ' '), |
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
854 imstatus2char[jb_getstatus()], (sm ? sm : "")); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
855 if (forceupdate) { |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
856 top_panel(inputPanel); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
857 update_panels(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
858 } |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
859 g_free(sm); |
713 | 860 } |
861 | |
151 | 862 // scr_DrawMainWindow() |
157 | 863 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151 | 864 // |
865 // I think it could be improved a _lot_ but I'm really not an ncurses | |
866 // expert... :-\ Mikael. | |
867 // | |
868 void scr_DrawMainWindow(unsigned int fullinit) | |
24 | 869 { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
870 int requested_size; |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
871 gchar *ver, *message; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
872 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
|
873 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
|
874 |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
875 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
|
876 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
|
877 if (requested_size > 0) { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
878 if (maxY > requested_size + 3) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
879 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
|
880 else |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
881 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
|
882 } else if (requested_size < 0) { |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
883 Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
884 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
885 |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
886 if (maxY < Log_Win_Height+2) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
887 if (maxY < 5) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
888 Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
889 maxY = Log_Win_Height+2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
890 } else { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
891 Log_Win_Height = maxY - 2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
892 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
893 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
894 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
895 if (roster_hidden) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
896 Roster_Width = 0; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
897 } else { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
898 requested_size = settings_opt_get_int("roster_width"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
899 if (requested_size > 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
900 Roster_Width = requested_size; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
901 else if (requested_size == 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
902 Roster_Width = 2; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
903 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
904 Roster_Width = DEFAULT_ROSTER_WIDTH; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
905 } |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
906 |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
907 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
|
908 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
|
909 |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
910 if (log_win_on_top) { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
911 chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
912 log_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
913 chatstatus_y_pos = Log_Win_Height-2; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
914 } else { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
915 chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
916 log_y_pos = CHAT_WIN_HEIGHT+1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
917 chatstatus_y_pos = CHAT_WIN_HEIGHT; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
918 } |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
919 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
920 if (roster_win_on_right) { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
921 roster_x_pos = maxX - Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
922 chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
923 } else { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
924 roster_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
925 chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
926 } |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
927 |
157 | 928 if (fullinit) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
929 if (!winbufhash) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
930 winbufhash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
157 | 931 /* Create windows */ |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
932 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
|
933 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
|
934 chat_x_pos); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
935 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
|
936 chat_x_pos); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
937 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
|
938 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); |
711 | 939 mainstatusWnd = newwin(1, maxX, maxY-2, 0); |
157 | 940 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
|
941 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
|
942 scr_TerminateCurses(); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
943 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
|
944 exit(EXIT_FAILURE); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
945 } |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
946 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
947 wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
948 wbkgd(activechatWnd, get_color(COLOR_GENERAL)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
949 wbkgd(logWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
950 wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
951 wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
157 | 952 } else { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
953 /* Resize/move windows */ |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
954 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
955 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
711 | 956 wresize(logWnd, Log_Win_Height-2, maxX); |
157 | 957 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
958 mvwin(chatWnd, chat_y_pos, chat_x_pos); |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
959 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
|
960 mvwin(logWnd, log_y_pos, 0); |
157 | 961 |
711 | 962 // Resize & move chat status window |
963 wresize(chatstatusWnd, 1, maxX); | |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
964 mvwin(chatstatusWnd, chatstatus_y_pos, 0); |
711 | 965 // Resize & move main status window |
966 wresize(mainstatusWnd, 1, maxX); | |
967 mvwin(mainstatusWnd, maxY-2, 0); | |
968 // Resize & move input line window | |
157 | 969 wresize(inputWnd, 1, maxX); |
970 mvwin(inputWnd, maxY-1, 0); | |
168 | 971 |
972 werase(chatWnd); | |
157 | 973 } |
151 | 974 |
975 /* Draw/init windows */ | |
976 | |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
977 ver = mcabber_version(); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
978 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
|
979 mvwprintw(chatWnd, 0, 0, message); |
679
5933a8036672
Remove "This is the status window" message
Mikael Berthe <mikael@lilotux.net>
parents:
675
diff
changeset
|
980 mvwprintw(chatWnd, 1, 0, "http://www.lilotux.net/~mikael/mcabber/"); |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
981 g_free(ver); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
982 g_free(message); |
24 | 983 |
157 | 984 // Auto-scrolling in log window |
74 | 985 scrollok(logWnd, TRUE); |
24 | 986 |
987 | |
151 | 988 if (fullinit) { |
157 | 989 // Enable keypad (+ special keys) |
990 keypad(inputWnd, TRUE); | |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
991 nodelay(inputWnd, TRUE); |
157 | 992 |
151 | 993 // Create panels |
994 rosterPanel = new_panel(rosterWnd); | |
995 chatPanel = new_panel(chatWnd); | |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
996 activechatPanel = new_panel(activechatWnd); |
151 | 997 logPanel = new_panel(logWnd); |
711 | 998 chatstatusPanel = new_panel(chatstatusWnd); |
999 mainstatusPanel = new_panel(mainstatusWnd); | |
151 | 1000 inputPanel = new_panel(inputWnd); |
232 | 1001 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1002 // 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
|
1003 // is added |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1004 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
|
1005 |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1006 // 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
|
1007 // from rewrapping buffers when the width doesn't change. |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1008 prev_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
1009 // 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
|
1010 hbuf_rebuild(&statushbuf, prev_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1011 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1012 #ifndef UNICODE |
232 | 1013 if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1014 scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1015 "WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1016 #endif |
157 | 1017 } else { |
1018 // Update panels | |
1019 replace_panel(rosterPanel, rosterWnd); | |
1020 replace_panel(chatPanel, chatWnd); | |
1021 replace_panel(logPanel, logWnd); | |
711 | 1022 replace_panel(chatstatusPanel, chatstatusWnd); |
1023 replace_panel(mainstatusPanel, mainstatusWnd); | |
157 | 1024 replace_panel(inputPanel, inputWnd); |
151 | 1025 } |
1026 | |
1027 // We'll need to redraw the roster | |
149 | 1028 update_roster = TRUE; |
24 | 1029 return; |
1030 } | |
1031 | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1032 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
|
1033 { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1034 winbuf *wbp = value; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1035 struct dimensions *dim = data; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1036 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
|
1037 int new_chatwidth; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1038 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1039 if (!(wbp && wbp->win)) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1040 return; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1041 |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1042 if (log_win_on_top) |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1043 chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1044 else |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1045 chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1046 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1047 if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1048 chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1049 else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1050 chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1051 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1052 // Resize/move buddy window |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1053 wresize(wbp->win, dim->l, dim->c); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1054 mvwin(wbp->win, chat_y_pos, chat_x_pos); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1055 werase(wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1056 // If a panel exists, replace the old window with the new |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1057 if (wbp->panel) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1058 replace_panel(wbp->panel, wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1059 // Redo line wrapping |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1060 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
|
1061 |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1062 new_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1063 if (new_chatwidth != prev_chatwidth) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1064 hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1065 } |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1066 |
151 | 1067 // scr_Resize() |
1068 // Function called when the window is resized. | |
157 | 1069 // - Resize windows |
151 | 1070 // - Rewrap lines in each buddy buffer |
1059 | 1071 void scr_Resize(void) |
151 | 1072 { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1073 struct dimensions dim; |
151 | 1074 |
1075 // First, update the global variables | |
1076 getmaxyx(stdscr, maxY, maxX); | |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1077 // 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
|
1078 |
151 | 1079 // Make sure the cursor stays inside the window |
1080 check_offset(0); | |
1081 | |
157 | 1082 // Resize windows and update panels |
151 | 1083 scr_DrawMainWindow(FALSE); |
1084 | |
1085 // Resize all buddy windows | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1086 dim.l = CHAT_WIN_HEIGHT; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1087 dim.c = maxX - Roster_Width; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1088 if (dim.c < 1) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1089 dim.c = 1; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1090 |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1091 // Resize all buffers |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1092 g_hash_table_foreach(winbufhash, resize_win_buffer, &dim); |
151 | 1093 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1094 // Resize/move special status buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1095 if (statusWindow) |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1096 resize_win_buffer(NULL, statusWindow, &dim); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1097 |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1098 // Update prev_chatwidth, now that all buffers have been resized |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1099 prev_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1100 |
151 | 1101 // Refresh current buddy window |
157 | 1102 if (chatmode) |
151 | 1103 scr_ShowBuddyWindow(); |
1104 } | |
1105 | |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1106 // scr_UpdateChatStatus(forceupdate) |
713 | 1107 // Redraw the buddy status bar. |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1108 // 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
|
1109 void scr_UpdateChatStatus(int forceupdate) |
713 | 1110 { |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1111 unsigned short btype, isgrp, ismuc, isspe; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1112 const char *fullname; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1113 const char *msg = NULL; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1114 char status; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1115 char *buf, *buf_locale; |
713 | 1116 |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1117 // 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
|
1118 // at least to refresh the pending message flag. |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1119 scr_UpdateMainStatus(FALSE); |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1120 |
806
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1121 // Clear the line |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1122 werase(chatstatusWnd); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1123 |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1124 if (chatmode) |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1125 wprintw(chatstatusWnd, "~"); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1126 |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1127 if (!current_buddy) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1128 if (forceupdate) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1129 update_panels(); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1130 } |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1131 return; |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1132 } |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1133 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1134 fullname = buddy_getname(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1135 btype = buddy_gettype(BUDDATA(current_buddy)); |
713 | 1136 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1137 isgrp = btype & ROSTER_TYPE_GROUP; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1138 ismuc = btype & ROSTER_TYPE_ROOM; |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1139 isspe = btype & ROSTER_TYPE_SPECIAL; |
713 | 1140 |
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1141 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
|
1142 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
|
1143 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
|
1144 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
|
1145 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
|
1146 } |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1147 |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1148 if (isgrp || isspe) { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1149 buf_locale = from_utf8(fullname); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1150 if (isgrp) |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1151 mvwprintw(chatstatusWnd, 0, 5, "Group: %s", buf_locale); |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1152 else |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1153 mvwprintw(chatstatusWnd, 0, 5, "Special buffer: %s", buf_locale); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1154 g_free(buf_locale); |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1155 if (forceupdate) { |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1156 update_panels(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1157 } |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1158 return; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1159 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1160 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1161 status = '?'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1162 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1163 if (ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1164 if (buddy_getinsideroom(BUDDATA(current_buddy))) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1165 status = 'C'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1166 else |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1167 status = 'x'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1168 } else if (jb_getstatus() != offline) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1169 enum imstatus budstate; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1170 budstate = buddy_getstatus(BUDDATA(current_buddy), NULL); |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1171 if (budstate < imstatus_size) |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1172 status = imstatus2char[budstate]; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1173 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1174 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1175 // No status message for groups & MUC rooms |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1176 if (!isgrp && !ismuc) { |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1177 GSList *resources, *p_res; |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1178 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
|
1179 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
|
1180 resources ? resources->data : ""); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1181 // Free the resources list data |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1182 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
|
1183 g_free(p_res->data); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1184 g_slist_free(resources); |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1185 } else if (ismuc) { |
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1186 msg = buddy_gettopic(BUDDATA(current_buddy)); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1187 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1188 if (!msg) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1189 msg = ""; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1190 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1191 buf = g_strdup_printf("[%c] Buddy: %s -- %s", status, fullname, msg); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1192 replace_nl_with_dots(buf); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1193 buf_locale = from_utf8(buf); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1194 mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1195 g_free(buf_locale); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1196 g_free(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1197 |
996
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1198 // 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
|
1199 if (btype & ROSTER_TYPE_USER) { |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1200 char eventchar = 0; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1201 guint event; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1202 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1203 // 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
|
1204 // highest priority will be used. |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1205 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
|
1206 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1207 if (event == ROSTER_EVENT_ACTIVE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1208 eventchar = 'A'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1209 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
|
1210 eventchar = 'C'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1211 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
|
1212 eventchar = 'P'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1213 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
|
1214 eventchar = 'I'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1215 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
|
1216 eventchar = 'G'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1217 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1218 if (eventchar) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1219 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
|
1220 } |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1221 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1222 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1223 if (forceupdate) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1224 update_panels(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1225 } |
713 | 1226 } |
1227 | |
143 | 1228 // scr_DrawRoster() |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1229 // Display the buddylist (not really the roster) on the screen |
81 | 1230 void scr_DrawRoster(void) |
24 | 1231 { |
735 | 1232 static int offset = 0; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1233 char *name, *rline; |
81 | 1234 int maxx, maxy; |
1235 GList *buddy; | |
1236 int i, n; | |
1237 int rOffset; | |
713 | 1238 int cursor_backup; |
1239 char status, pending; | |
164 | 1240 enum imstatus currentstatus = jb_getstatus(); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1241 int x_pos; |
81 | 1242 |
123 | 1243 // We can reset update_roster |
1244 update_roster = FALSE; | |
1245 | |
81 | 1246 getmaxyx(rosterWnd, maxy, maxx); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1247 maxx--; // Last char is for vertical border |
81 | 1248 |
713 | 1249 cursor_backup = curs_set(0); |
1250 | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1251 if (!buddylist) |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1252 offset = 0; |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1253 else |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1254 scr_UpdateChatStatus(FALSE); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1255 |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1256 // Cleanup of roster window |
168 | 1257 werase(rosterWnd); |
81 | 1258 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1259 if (Roster_Width) { |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1260 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
|
1261 // Redraw the vertical line (not very good...) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1262 wattrset(rosterWnd, get_color(COLOR_GENERAL)); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1263 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
|
1264 mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1265 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1266 |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1267 // 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
|
1268 if (!buddylist || !Roster_Width) { |
123 | 1269 update_panels(); |
713 | 1270 curs_set(cursor_backup); |
81 | 1271 return; |
1272 } | |
1273 | |
84 | 1274 // Update offset if necessary |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1275 // 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
|
1276 i = g_list_length(buddylist) - maxy; |
682
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1277 if (i < 0) |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1278 i = 0; |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1279 if (i < offset) |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1280 offset = i; |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1281 // b) Make sure the current_buddy is visible |
84 | 1282 i = g_list_position(buddylist, current_buddy); |
1283 if (i == -1) { // This is bad | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1284 scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
713 | 1285 curs_set(cursor_backup); |
84 | 1286 return; |
1287 } else if (i < offset) { | |
1288 offset = i; | |
1289 } else if (i+1 > offset + maxy) { | |
1290 offset = i + 1 - maxy; | |
1291 } | |
81 | 1292 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1293 if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1294 x_pos = 1; // 1 char offset (vertical line) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1295 else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1296 x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1297 |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1298 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
|
1299 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
|
1300 |
81 | 1301 buddy = buddylist; |
1302 rOffset = offset; | |
1303 | |
84 | 1304 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
|
1305 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
|
1306 gchar *rline_locale; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1307 GSList *resources, *p_res; |
713 | 1308 |
1309 bflags = buddy_getflags(BUDDATA(buddy)); | |
1310 btype = buddy_gettype(BUDDATA(buddy)); | |
1311 | |
1312 ismsg = bflags & ROSTER_FLAG_MSG; | |
1313 ishid = bflags & ROSTER_FLAG_HIDE; | |
1314 isgrp = btype & ROSTER_TYPE_GROUP; | |
1315 ismuc = btype & ROSTER_TYPE_ROOM; | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1316 isspe = btype & ROSTER_TYPE_SPECIAL; |
81 | 1317 |
1318 if (rOffset > 0) { | |
1319 rOffset--; | |
1320 continue; | |
1321 } | |
1322 | |
713 | 1323 status = '?'; |
1324 pending = ' '; | |
1325 | |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1326 resources = buddy_getresources(BUDDATA(buddy)); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1327 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
|
1328 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
|
1329 p_res ? p_res->data : ""); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1330 if ((events & ROSTER_EVENT_PAUSED) && pending != '+') |
992
b37348c2aa79
Chatstates: display "paused" states in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
991
diff
changeset
|
1331 pending = '.'; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1332 if (events & ROSTER_EVENT_COMPOSING) |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1333 pending = '+'; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1334 g_free(p_res->data); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1335 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1336 g_slist_free(resources); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1337 |
149 | 1338 // Display message notice if there is a message flag, but not |
1339 // for unfolded groups. | |
1340 if (ismsg && (!isgrp || ishid)) { | |
81 | 1341 pending = '#'; |
1342 } | |
1343 | |
713 | 1344 if (ismuc) { |
1345 if (buddy_getinsideroom(BUDDATA(buddy))) | |
1346 status = 'C'; | |
1347 else | |
1348 status = 'x'; | |
1349 } else if (currentstatus != offline) { | |
1350 enum imstatus budstate; | |
1351 budstate = buddy_getstatus(BUDDATA(buddy), NULL); | |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1352 if (budstate < imstatus_size) |
713 | 1353 status = imstatus2char[budstate]; |
1354 } | |
81 | 1355 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
|
1356 if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1357 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
|
1358 else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1359 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
|
1360 // 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
|
1361 wmove(rosterWnd, i, x_pos); |
81 | 1362 for (n = 0; n < maxx; n++) |
1363 waddch(rosterWnd, ' '); | |
1364 } else { | |
149 | 1365 if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1366 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
139 | 1367 else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1368 wattrset(rosterWnd, get_color(COLOR_ROSTER)); |
81 | 1369 } |
1370 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1371 if (Roster_Width > 7) |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1372 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
|
1373 else |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1374 name[0] = 0; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1375 |
149 | 1376 if (isgrp) { |
133 | 1377 char *sep; |
149 | 1378 if (ishid) |
133 | 1379 sep = "+++"; |
1380 else | |
1381 sep = "---"; | |
1168
eb05f960613f
Fix UTF-8 group names in the roster (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1160
diff
changeset
|
1382 snprintf(rline, 4*Roster_Width, " %c%s %s", pending, sep, name); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1383 } else if (isspe) { |
1168
eb05f960613f
Fix UTF-8 group names in the roster (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1160
diff
changeset
|
1384 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
|
1385 } else { |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1386 char sepleft = '['; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1387 char sepright = ']'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1388 if (btype & ROSTER_TYPE_USER) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1389 guint subtype = buddy_getsubscription(BUDDATA(buddy)); |
832
7c210263c661
Small scr_DrawRoster() fix
Mikael Berthe <mikael@lilotux.net>
parents:
828
diff
changeset
|
1390 if (status == '_' && !(subtype & sub_to)) |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1391 status = '?'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1392 if (!(subtype & sub_from)) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1393 sepleft = '{'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1394 sepright = '}'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1395 } |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1396 } |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1397 |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1398 snprintf(rline, 4*Roster_Width, |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1399 " %c%c%c%c %s", pending, sepleft, status, sepright, name); |
133 | 1400 } |
84 | 1401 |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1402 rline_locale = from_utf8(rline); |
981
553b8ecf901f
Fixes truncating of utf-8 buddy names (again)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
980
diff
changeset
|
1403 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
|
1404 g_free(rline_locale); |
84 | 1405 i++; |
81 | 1406 } |
1407 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1408 g_free(rline); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1409 g_free(name); |
142 | 1410 top_panel(inputPanel); |
81 | 1411 update_panels(); |
713 | 1412 curs_set(cursor_backup); |
24 | 1413 } |
1414 | |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1415 // scr_RosterVisibility(status) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1416 // Set the roster visibility: |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1417 // status=1 Show roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1418 // status=0 Hide roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1419 // status=-1 Toggle roster status |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1420 void scr_RosterVisibility(int status) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1421 { |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1422 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
|
1423 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1424 if (status > 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1425 roster_hidden = FALSE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1426 else if (status == 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1427 roster_hidden = TRUE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1428 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1429 roster_hidden = !roster_hidden; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1430 |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1431 if (roster_hidden != old_roster_status) { |
709
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1432 if (roster_hidden) { |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1433 // Enter chat mode |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1434 scr_set_chatmode(TRUE); |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1435 scr_ShowBuddyWindow(); |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1436 } |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1437 // 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
|
1438 scr_Resize(); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1439 redrawwin(stdscr); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1440 } |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1441 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1442 |
1058 | 1443 inline void scr_WriteMessage(const char *bjid, const char *text, |
480 | 1444 time_t timestamp, guint prefix_flags) |
24 | 1445 { |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
1446 char *xtext; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1447 |
726 | 1448 if (!timestamp) timestamp = time(NULL); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1449 |
1122
648fe6f715a6
Filter out ^M (0x0d) characters in incoming messages
Mikael Berthe <mikael@lilotux.net>
parents:
1115
diff
changeset
|
1450 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
726 | 1451 |
1058 | 1452 scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1453 |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1454 if (xtext != (char*)text) |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1455 g_free(xtext); |
24 | 1456 } |
1457 | |
726 | 1458 // If prefix is NULL, HBB_PREFIX_IN is supposed. |
1459 void scr_WriteIncomingMessage(const char *jidfrom, const char *text, | |
1460 time_t timestamp, guint prefix) | |
1461 { | |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1462 if (!(prefix & |
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1463 ~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT & ~HBB_PREFIX_PGPCRYPT)) |
726 | 1464 prefix |= HBB_PREFIX_IN; |
1465 | |
1466 scr_WriteMessage(jidfrom, text, timestamp, prefix); | |
1467 } | |
1468 | |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1469 void scr_WriteOutgoingMessage(const char *jidto, const char *text, guint prefix) |
47 | 1470 { |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
1471 GSList *roster_elt; |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
1472 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
|
1473 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
|
1474 |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1475 scr_WriteMessage(jidto, text, 0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT); |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
1476 |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
1477 // 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
|
1478 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
|
1479 scr_ShowWindow(jidto, FALSE); |
47 | 1480 } |
1481 | |
935
97e6a6da2b2c
Fix ncurses #include (again)
Mikael Berthe <mikael@lilotux.net>
parents:
933
diff
changeset
|
1482 static inline void set_autoaway(bool setaway) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1483 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1484 static enum imstatus oldstatus; |
521 | 1485 static char *oldmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1486 Autoaway = setaway; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1487 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1488 if (setaway) { |
521 | 1489 const char *msg, *prevmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1490 oldstatus = jb_getstatus(); |
521 | 1491 if (oldmsg) { |
1492 g_free(oldmsg); | |
1493 oldmsg = NULL; | |
1494 } | |
1495 prevmsg = jb_getstatusmsg(); | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1496 msg = settings_opt_get("message_autoaway"); |
521 | 1497 if (!msg) |
1498 msg = prevmsg; | |
1499 if (prevmsg) | |
1500 oldmsg = g_strdup(prevmsg); | |
1056
5b3ecae91c95
PGP: sign auto-away presence too
Mikael Berthe <mikael@lilotux.net>
parents:
1055
diff
changeset
|
1501 jb_setstatus(away, NULL, msg, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1502 } else { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1503 // Back |
1050
ea71d31a2607
PGP: Do not sign presence messages to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
1504 jb_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : ""), FALSE); |
521 | 1505 if (oldmsg) { |
1506 g_free(oldmsg); | |
1507 oldmsg = NULL; | |
1508 } | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1509 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1510 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1511 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1512 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
|
1513 { |
940 | 1514 enum imstatus cur_st; |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1515 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
|
1516 |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1517 if (Autoaway || !autoaway_timeout) |
940 | 1518 return 86400; |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1519 |
940 | 1520 cur_st = jb_getstatus(); |
1521 // Auto-away is disabled for the following states | |
1522 if ((cur_st != available) && (cur_st != freeforchat)) | |
1523 return 86400; | |
1524 | |
1525 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
|
1526 return 0; |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1527 else |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1528 return LastActivity + (time_t)autoaway_timeout - now; |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1529 } |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1530 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1531 // set_chatstate(state) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1532 // 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
|
1533 // If the chat state has changed, call jb_send_chatstate() |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1534 static inline void set_chatstate(int state) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1535 { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1536 #if defined JEP0022 || defined JEP0085 |
993
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
1537 if (chatstates_disabled) |
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
1538 return; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1539 if (!chatmode) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1540 state = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1541 if (state != chatstate) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1542 chatstate = state; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1543 if (current_buddy && |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1544 buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_USER) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1545 guint jep_state; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1546 if (chatstate == 1) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1547 jep_state = ROSTER_EVENT_COMPOSING; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1548 else if (chatstate == 2) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1549 jep_state = ROSTER_EVENT_PAUSED; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1550 else |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1551 jep_state = ROSTER_EVENT_ACTIVE; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1552 jb_send_chatstate(BUDDATA(current_buddy), jep_state); |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1553 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1554 if (!chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1555 chatstate_timestamp = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1556 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1557 #endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1558 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1559 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1560 #if defined JEP0022 || defined JEP0085 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1561 inline long int scr_GetChatStatesTimeout(time_t now) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1562 { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1563 // Check if we're currently composing... |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1564 if (chatstate != 1 || !chatstate_timestamp) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1565 return 86400; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1566 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1567 // 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
|
1568 if (now >= chatstate_timestamp + COMPOSING_TIMEOUT) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1569 chatstate_timestamp = now; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1570 set_chatstate(2); |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1571 return 86400; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1572 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1573 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1574 return chatstate_timestamp + COMPOSING_TIMEOUT - now; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1575 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1576 #endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
1577 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1578 // Check if we should enter/leave automatic away status |
935
97e6a6da2b2c
Fix ncurses #include (again)
Mikael Berthe <mikael@lilotux.net>
parents:
933
diff
changeset
|
1579 void scr_CheckAutoAway(int activity) |
24 | 1580 { |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1581 enum imstatus cur_st; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1582 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1583 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1584 if (Autoaway && activity) set_autoaway(FALSE); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1585 if (!autoaway_timeout) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1586 if (!LastActivity || activity) time(&LastActivity); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1587 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1588 cur_st = jb_getstatus(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1589 // Auto-away is disabled for the following states |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1590 if ((cur_st != available) && (cur_st != freeforchat)) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1591 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1592 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1593 if (!activity) { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1594 time_t now; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1595 time(&now); |
735 | 1596 if (!Autoaway && (now > LastActivity + (time_t)autoaway_timeout)) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1597 set_autoaway(TRUE); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1598 } |
24 | 1599 } |
1600 | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1601 // set_current_buddy(newbuddy) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1602 // 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
|
1603 // 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
|
1604 static void set_current_buddy(GList *newbuddy) |
24 | 1605 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1606 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
|
1607 /* 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
|
1608 * 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
|
1609 * buddy_getstatus() call. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1610 */ |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1611 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1612 if (!current_buddy || !newbuddy) return; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1613 if (newbuddy == current_buddy) return; |
24 | 1614 |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
1615 // 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
|
1616 set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
1617 // We don't want the chatstate to be changed again right now. |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
1618 lock_chatstate = true; |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
1619 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
1620 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
|
1621 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
330 | 1622 if (chatmode) |
1623 alternate_buddy = current_buddy; | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1624 current_buddy = newbuddy; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1625 // 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
|
1626 if (chatmode) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1627 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
|
1628 // 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
|
1629 // 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
|
1630 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1631 if (prev_st == offline && buddylist_get_hide_offline_buddies()) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1632 buddylist_build(); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1633 update_roster = TRUE; |
24 | 1634 } |
1635 | |
143 | 1636 // scr_RosterTop() |
1637 // Go to the first buddy in the buddylist | |
105 | 1638 void scr_RosterTop(void) |
104 | 1639 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1640 set_current_buddy(buddylist); |
104 | 1641 if (chatmode) |
1642 scr_ShowBuddyWindow(); | |
1643 } | |
1644 | |
143 | 1645 // scr_RosterBottom() |
1646 // Go to the last buddy in the buddylist | |
105 | 1647 void scr_RosterBottom(void) |
104 | 1648 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1649 set_current_buddy(g_list_last(buddylist)); |
104 | 1650 if (chatmode) |
1651 scr_ShowBuddyWindow(); | |
1652 } | |
1653 | |
143 | 1654 // scr_RosterUp() |
1655 // Go to the previous buddy in the buddylist | |
105 | 1656 void scr_RosterUp(void) |
81 | 1657 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1658 set_current_buddy(g_list_previous(current_buddy)); |
104 | 1659 if (chatmode) |
1660 scr_ShowBuddyWindow(); | |
81 | 1661 } |
1662 | |
143 | 1663 // scr_RosterDown() |
1664 // Go to the next buddy in the buddylist | |
105 | 1665 void scr_RosterDown(void) |
81 | 1666 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1667 set_current_buddy(g_list_next(current_buddy)); |
104 | 1668 if (chatmode) |
1669 scr_ShowBuddyWindow(); | |
81 | 1670 } |
1671 | |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1672 // scr_RosterPrevGroup() |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1673 // 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
|
1674 void scr_RosterPrevGroup(void) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1675 { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1676 GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1677 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1678 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
|
1679 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
|
1680 if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1681 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1682 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
|
1683 set_current_buddy(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1684 if (chatmode) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1685 scr_ShowBuddyWindow(); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1686 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1687 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1688 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1689 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1690 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1691 // scr_RosterNextGroup() |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1692 // 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
|
1693 void scr_RosterNextGroup(void) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1694 { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1695 GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1696 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1697 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
|
1698 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
|
1699 if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1700 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1701 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
|
1702 set_current_buddy(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1703 if (chatmode) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1704 scr_ShowBuddyWindow(); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1705 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1706 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1707 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1708 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
1709 |
265 | 1710 // scr_RosterSearch(str) |
1711 // Look forward for a buddy with jid/name containing str. | |
1712 void scr_RosterSearch(char *str) | |
1713 { | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1714 set_current_buddy(buddy_search(str)); |
265 | 1715 if (chatmode) |
1716 scr_ShowBuddyWindow(); | |
1717 } | |
1718 | |
1058 | 1719 // scr_RosterJumpJid(bjid) |
1720 // Jump to buddy bjid. | |
480 | 1721 // NOTE: With this function, the buddy is added to the roster if doesn't exist. |
1722 void scr_RosterJumpJid(char *barejid) | |
1723 { | |
1724 GSList *roster_elt; | |
1725 // Look for an existing buddy | |
1726 roster_elt = roster_find(barejid, jidsearch, | |
1727 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); | |
1728 // Create it if necessary | |
1729 if (!roster_elt) | |
603 | 1730 roster_elt = roster_add_user(barejid, NULL, NULL, ROSTER_TYPE_USER, |
1731 sub_none); | |
480 | 1732 // Set a lock to see it in the buddylist |
1733 buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); | |
1734 buddylist_build(); | |
1735 // Jump to the buddy | |
1736 set_current_buddy(buddy_search_jid(barejid)); | |
1737 if (chatmode) | |
1738 scr_ShowBuddyWindow(); | |
1739 } | |
1740 | |
236 | 1741 // scr_RosterUnreadMessage(next) |
1742 // Go to a new message. If next is not null, try to go to the next new | |
1743 // message. If it is not possible or if next is NULL, go to the first new | |
1744 // message from unread_list. | |
1745 void scr_RosterUnreadMessage(int next) | |
1746 { | |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1747 gpointer unread_ptr; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1748 gpointer refbuddata; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1749 GList *nbuddy; |
236 | 1750 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1751 if (!current_buddy) return; |
236 | 1752 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1753 if (next) refbuddata = BUDDATA(current_buddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1754 else refbuddata = NULL; |
236 | 1755 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1756 unread_ptr = unread_msg(refbuddata); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1757 if (!unread_ptr) return; |
236 | 1758 |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1759 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
|
1760 gpointer ngroup; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1761 // 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
|
1762 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
|
1763 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
|
1764 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
|
1765 buddylist_build(); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1766 } |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1767 } |
236 | 1768 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1769 nbuddy = g_list_find(buddylist, unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1770 if (nbuddy) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1771 set_current_buddy(nbuddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1772 if (chatmode) scr_ShowBuddyWindow(); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1773 } else |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1774 scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
236 | 1775 } |
1776 | |
330 | 1777 // scr_RosterJumpAlternate() |
1778 // Try to jump to alternate (== previous) buddy | |
1779 void scr_RosterJumpAlternate(void) | |
105 | 1780 { |
330 | 1781 if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
1782 return; | |
1783 set_current_buddy(alternate_buddy); | |
1784 if (chatmode) | |
1785 scr_ShowBuddyWindow(); | |
1786 } | |
1787 | |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
1788 // scr_BufferScrollUpDown() |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1789 // Scroll up/down the current buddy window, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1790 // - half a screen if nblines is 0, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1791 // - up if updown == -1, down if updown == 1 |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1792 void scr_BufferScrollUpDown(int updown, unsigned int nblines) |
105 | 1793 { |
822 | 1794 winbuf *win_entry; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1795 int n, nbl; |
105 | 1796 GList *hbuf_top; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1797 guint isspe; |
105 | 1798 |
1799 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1800 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1801 |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1802 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1803 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1804 if (!win_entry) return; |
105 | 1805 |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1806 if (!nblines) { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1807 // Scroll half a screen (or less) |
512 | 1808 nbl = CHAT_WIN_HEIGHT/2; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1809 } else { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1810 nbl = nblines; |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1811 } |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1812 hbuf_top = win_entry->bd->top; |
105 | 1813 |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1814 if (updown == -1) { // UP |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1815 if (!hbuf_top) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1816 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
|
1817 if (!win_entry->bd->cleared) { |
512 | 1818 if (!nblines) nbl = nbl*3 - 1; |
1819 else nbl += CHAT_WIN_HEIGHT - 1; | |
1820 } else { | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1821 win_entry->bd->cleared = FALSE; |
512 | 1822 } |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1823 } |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1824 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
|
1825 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
|
1826 win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1827 } else { // DOWN |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1828 for (n=0 ; hbuf_top && n < nbl ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1829 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
|
1830 win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1831 // Check if we are at the bottom |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1832 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1833 hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1834 if (!hbuf_top) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1835 win_entry->bd->top = NULL; // End reached |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1836 } |
105 | 1837 |
1838 // Refresh the window | |
1839 scr_UpdateWindow(win_entry); | |
1840 | |
1841 // Finished :) | |
1842 update_panels(); | |
1843 } | |
1844 | |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
1845 // scr_BufferClear() |
143 | 1846 // 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
|
1847 void scr_BufferClear(void) |
108 | 1848 { |
822 | 1849 winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1850 guint isspe; |
108 | 1851 |
1852 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1853 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1854 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1855 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1856 if (!win_entry) return; |
108 | 1857 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1858 win_entry->bd->cleared = TRUE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1859 win_entry->bd->top = NULL; |
108 | 1860 |
1861 // Refresh the window | |
1862 scr_UpdateWindow(win_entry); | |
1863 | |
1864 // Finished :) | |
1865 update_panels(); | |
1866 } | |
1867 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1868 // buffer_purge() |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1869 // key: winId/jid |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1870 // value: winbuf structure |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1871 // 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
|
1872 // NOTE: does not work for special buffers. |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1873 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
|
1874 { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1875 int closebuf = (gint)data; // XXX GPOINTER_TO_INT? |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1876 winbuf *win_entry = value; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1877 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1878 // Delete the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1879 hbuf_free(&win_entry->bd->hbuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1880 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1881 if (closebuf) { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1882 g_hash_table_remove(winbufhash, key); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1883 } else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1884 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1885 win_entry->bd->top = NULL; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1886 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1887 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1888 |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
1889 // scr_BufferPurge(closebuf) |
866 | 1890 // Purge/Drop the current buddy buffer |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
1891 // If closebuf is 1, close the buffer. |
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
1892 void scr_BufferPurge(int closebuf) |
866 | 1893 { |
1894 winbuf *win_entry; | |
1895 guint isspe; | |
1896 | |
1897 // Get win_entry | |
1898 if (!current_buddy) return; | |
1899 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | |
1900 win_entry = scr_SearchWindow(CURRENT_JID, isspe); | |
1901 if (!win_entry) return; | |
1902 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1903 if (!isspe) { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1904 buffer_purge((gpointer)CURRENT_JID, win_entry, (gpointer)closebuf); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1905 // XXX GINT_TO_POINTER? |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1906 if (closebuf) { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1907 scr_set_chatmode(FALSE); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1908 currentWindow = NULL; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1909 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1910 } else { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1911 // (Special buffer) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1912 // Reset the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1913 hbuf_free(&win_entry->bd->hbuf); |
866 | 1914 // Currently it can only be the status buffer |
1915 statushbuf = NULL; | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1916 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1917 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1918 win_entry->bd->top = NULL; |
866 | 1919 } |
1920 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1921 // Refresh the window |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1922 scr_UpdateBuddyWindow(); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1923 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1924 // Finished :) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1925 update_panels(); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1926 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1927 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1928 void scr_BufferPurgeAll(int closebuf) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1929 { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1930 g_hash_table_foreach(winbufhash, buffer_purge, (gpointer)closebuf); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1931 // XXX GINT_TO_POINTER? |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1932 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
1933 if (closebuf) { |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
1934 scr_set_chatmode(FALSE); |
1137
5752017f6e2b
Fix a bug in /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1935 currentWindow = NULL; |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
1936 } |
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
1937 |
866 | 1938 // Refresh the window |
1939 scr_UpdateBuddyWindow(); | |
1940 | |
1941 // Finished :) | |
1942 update_panels(); | |
1943 } | |
1944 | |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1945 // scr_BufferScrollLock(lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1946 // Lock/unlock the current buddy buffer |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1947 // lock = 1 : lock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1948 // lock = 0 : unlock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1949 // lock = -1: toggle lock status |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1950 void scr_BufferScrollLock(int lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1951 { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1952 winbuf *win_entry; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1953 guint isspe; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1954 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1955 // Get win_entry |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1956 if (!current_buddy) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1957 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
|
1958 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
|
1959 if (!win_entry) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1960 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1961 if (lock == -1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1962 lock = !win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1963 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1964 if (lock) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1965 win_entry->bd->lock = TRUE; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1966 } else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1967 win_entry->bd->lock = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1968 //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
|
1969 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
|
1970 win_entry->bd->top = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1971 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1972 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1973 // 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
|
1974 // 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
|
1975 // 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
|
1976 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
|
1977 chatmode = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1978 scr_ShowBuddyWindow(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1979 chatmode = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1980 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1981 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1982 // Refresh the window |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1983 scr_UpdateBuddyWindow(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1984 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1985 // Finished :) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1986 update_panels(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1987 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1988 |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1989 // scr_BufferTopBottom() |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1990 // Jump to the head/tail of the current buddy window |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1991 // (top if topbottom == -1, bottom topbottom == 1) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1992 void scr_BufferTopBottom(int topbottom) |
187 | 1993 { |
822 | 1994 winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1995 guint isspe; |
187 | 1996 |
1997 // Get win_entry | |
1998 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1999 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2000 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
187 | 2001 if (!win_entry) return; |
2002 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2003 win_entry->bd->cleared = FALSE; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2004 if (topbottom == 1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2005 win_entry->bd->top = NULL; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2006 else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2007 win_entry->bd->top = g_list_first(win_entry->bd->hbuf); |
187 | 2008 |
2009 // Refresh the window | |
2010 scr_UpdateWindow(win_entry); | |
2011 | |
2012 // Finished :) | |
2013 update_panels(); | |
2014 } | |
2015 | |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2016 // scr_BufferSearch(direction, text) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2017 // Jump to the next line containing text |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2018 // (backward search if direction == -1, forward if topbottom == 1) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2019 void scr_BufferSearch(int direction, const char *text) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2020 { |
822 | 2021 winbuf *win_entry; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2022 GList *current_line, *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2023 guint isspe; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2024 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2025 // Get win_entry |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2026 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2027 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2028 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2029 if (!win_entry) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2030 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2031 if (win_entry->bd->top) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2032 current_line = win_entry->bd->top; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2033 else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2034 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
|
2035 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2036 search_res = hbuf_search(current_line, direction, text); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2037 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2038 if (search_res) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2039 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2040 win_entry->bd->top = search_res; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2041 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2042 // Refresh the window |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2043 scr_UpdateWindow(win_entry); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2044 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2045 // Finished :) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2046 update_panels(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2047 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2048 scr_LogPrint(LPRINT_NORMAL, "Search string not found"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2049 } |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2050 |
462 | 2051 // scr_BufferPercent(n) |
2052 // Jump to the specified position in the buffer, in % | |
2053 void scr_BufferPercent(int pc) | |
2054 { | |
822 | 2055 winbuf *win_entry; |
462 | 2056 GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2057 guint isspe; |
462 | 2058 |
2059 // Get win_entry | |
2060 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2061 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2062 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
462 | 2063 if (!win_entry) return; |
2064 | |
2065 if (pc < 0 || pc > 100) { | |
2066 scr_LogPrint(LPRINT_NORMAL, "Bad % value"); | |
2067 return; | |
2068 } | |
2069 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2070 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
|
2071 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2072 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2073 win_entry->bd->top = search_res; |
462 | 2074 |
2075 // Refresh the window | |
2076 scr_UpdateWindow(win_entry); | |
2077 | |
2078 // Finished :) | |
2079 update_panels(); | |
2080 } | |
2081 | |
464 | 2082 // scr_BufferDate(t) |
2083 // Jump to the first line after date t in the buffer | |
2084 // t is a date in seconds since `00:00:00 1970-01-01 UTC' | |
2085 void scr_BufferDate(time_t t) | |
2086 { | |
822 | 2087 winbuf *win_entry; |
464 | 2088 GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2089 guint isspe; |
464 | 2090 |
2091 // Get win_entry | |
2092 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2093 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2094 win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
464 | 2095 if (!win_entry) return; |
2096 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2097 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
|
2098 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2099 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2100 win_entry->bd->top = search_res; |
464 | 2101 |
2102 // Refresh the window | |
2103 scr_UpdateWindow(win_entry); | |
2104 | |
2105 // Finished :) | |
2106 update_panels(); | |
2107 } | |
2108 | |
143 | 2109 // scr_set_chatmode() |
261 | 2110 // Public function to (un)set chatmode... |
129 | 2111 inline void scr_set_chatmode(int enable) |
2112 { | |
2113 chatmode = enable; | |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
2114 scr_UpdateChatStatus(TRUE); |
129 | 2115 } |
2116 | |
1129
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2117 // scr_get_chatmode() |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2118 // Public function to get chatmode state. |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2119 inline int scr_get_chatmode(void) |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2120 { |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2121 return chatmode; |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2122 } |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2123 |
238 | 2124 // scr_get_multimode() |
261 | 2125 // Public function to get multimode status... |
1059 | 2126 inline int scr_get_multimode(void) |
238 | 2127 { |
2128 return multimode; | |
2129 } | |
2130 | |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2131 // 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
|
2132 // Set the message flag unless we're already in the jid buffer window |
1058 | 2133 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
|
2134 { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2135 const char *current_id; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2136 bool iscurrentlocked = FALSE; |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
2137 |
1058 | 2138 if (!bjid) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2139 return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2140 |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2141 if (current_buddy) { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2142 if (special) |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2143 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
|
2144 else |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2145 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
|
2146 if (current_id) { |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2147 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
|
2148 if (!win_entry) return; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2149 iscurrentlocked = win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2150 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2151 } else { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2152 current_id = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2153 } |
1058 | 2154 if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) |
2155 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
|
2156 } |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2157 |
238 | 2158 // scr_set_multimode() |
261 | 2159 // Public function to (un)set multimode... |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2160 // Convention: |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2161 // 0 = disabled / 1 = multimode / 2 = multimode verbatim (commands disabled) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2162 inline void scr_set_multimode(int enable, char *subject) |
238 | 2163 { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2164 g_free(multiline); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2165 multiline = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2166 |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2167 g_free(multimode_subj); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2168 if (enable && subject) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2169 multimode_subj = g_strdup(subject); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2170 else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2171 multimode_subj = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2172 |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2173 multimode = enable; |
238 | 2174 } |
2175 | |
2176 // scr_get_multiline() | |
261 | 2177 // Public function to get the current multi-line. |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2178 inline const char *scr_get_multiline(void) |
238 | 2179 { |
2180 if (multimode && multiline) | |
2181 return multiline; | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2182 return NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2183 } |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2184 |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2185 // scr_get_multimode_subj() |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2186 // Public function to get the multi-line subject, if any. |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2187 inline const char *scr_get_multimode_subj(void) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2188 { |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2189 if (multimode) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2190 return multimode_subj; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2191 return NULL; |
238 | 2192 } |
2193 | |
2194 // scr_append_multiline(line) | |
2195 // Public function to append a line to the current multi-line message. | |
2196 // Skip empty leading lines. | |
2197 void scr_append_multiline(const char *line) | |
2198 { | |
2199 static int num; | |
2200 | |
2201 if (!multimode) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2202 scr_LogPrint(LPRINT_NORMAL, "Error: Not in multi-line message mode!"); |
238 | 2203 return; |
2204 } | |
2205 if (multiline) { | |
2206 int len = strlen(multiline)+strlen(line)+2; | |
252 | 2207 if (len >= HBB_BLOCKSIZE - 1) { |
238 | 2208 // We don't handle single messages with size > HBB_BLOCKSIZE |
2209 // (see hbuf) | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2210 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
|
2211 "this line has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2212 scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
238 | 2213 return; |
2214 } | |
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
2215 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
|
2216 // 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
|
2217 // (It should be < 1000 yet) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2218 scr_LogPrint(LPRINT_NORMAL, "Your message has too many lines, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2219 "this one has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2220 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
|
2221 return; |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
2222 } |
238 | 2223 multiline = g_renew(char, multiline, len); |
2224 strcat(multiline, "\n"); | |
2225 strcat(multiline, line); | |
2226 num++; | |
2227 } else { | |
2228 // First message line (we skip leading empty lines) | |
2229 num = 0; | |
2230 if (line[0]) { | |
419 | 2231 multiline = g_strdup(line); |
238 | 2232 num++; |
2233 } else | |
2234 return; | |
2235 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
2236 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
2237 "Multi-line mode: line #%d added [%.25s...", num, line); |
238 | 2238 } |
2239 | |
173 | 2240 // scr_cmdhisto_addline() |
2241 // Add a line to the inputLine history | |
2242 inline void scr_cmdhisto_addline(char *line) | |
2243 { | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2244 int max_histo_lines; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2245 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2246 if (!line || !*line) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2247 return; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2248 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2249 max_histo_lines = settings_opt_get_int("cmdhistory_lines"); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2250 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2251 if (max_histo_lines < 0) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2252 max_histo_lines = 1; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2253 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2254 if (max_histo_lines) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2255 while (cmdhisto_nblines >= (guint)max_histo_lines) { |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2256 if (cmdhisto_cur && cmdhisto_cur == cmdhisto) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2257 break; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2258 g_free(cmdhisto->data); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2259 cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2260 cmdhisto_nblines--; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2261 } |
173 | 2262 |
2263 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
2264 cmdhisto_nblines++; |
173 | 2265 } |
2266 | |
2267 // scr_cmdhisto_prev() | |
2268 // Look for previous line beginning w/ the given mask in the inputLine history | |
175 | 2269 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2270 static const char *scr_cmdhisto_prev(char *mask, guint len) |
173 | 2271 { |
2272 GList *hl; | |
2273 if (!cmdhisto_cur) { | |
2274 hl = g_list_last(cmdhisto); | |
174 | 2275 if (hl) { // backup current line |
2276 strncpy(cmdhisto_backup, mask, INPUTLINE_LENGTH); | |
2277 } | |
173 | 2278 } else { |
2279 hl = g_list_previous(cmdhisto_cur); | |
2280 } | |
2281 while (hl) { | |
2282 if (!strncmp((char*)hl->data, mask, len)) { | |
2283 // Found a match | |
2284 cmdhisto_cur = hl; | |
2285 return (const char*)hl->data; | |
2286 } | |
2287 hl = g_list_previous(hl); | |
2288 } | |
2289 return NULL; | |
2290 } | |
2291 | |
2292 // scr_cmdhisto_next() | |
2293 // Look for next line beginning w/ the given mask in the inputLine history | |
175 | 2294 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2295 static const char *scr_cmdhisto_next(char *mask, guint len) |
173 | 2296 { |
2297 GList *hl; | |
2298 if (!cmdhisto_cur) return NULL; | |
2299 hl = cmdhisto_cur; | |
2300 while ((hl = g_list_next(hl)) != NULL) | |
2301 if (!strncmp((char*)hl->data, mask, len)) { | |
2302 // Found a match | |
2303 cmdhisto_cur = hl; | |
2304 return (const char*)hl->data; | |
2305 } | |
175 | 2306 // If the "backuped" line matches, we'll use it |
2307 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match | |
174 | 2308 cmdhisto_cur = NULL; |
2309 return cmdhisto_backup; | |
173 | 2310 } |
2311 | |
195 | 2312 // readline_transpose_chars() |
2313 // Drag the character before point forward over the character at | |
2314 // point, moving point forward as well. If point is at the end of | |
2315 // the line, then this transposes the two characters before point. | |
1059 | 2316 void readline_transpose_chars(void) |
195 | 2317 { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2318 char *c1, *c2; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2319 unsigned a, b; |
195 | 2320 |
2321 if (ptr_inputline == inputLine) return; | |
2322 | |
2323 if (!*ptr_inputline) { // We're at EOL | |
2324 // 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
|
2325 if (ptr_inputline == prev_char(ptr_inputline, inputLine)) return; |
195 | 2326 // Transpose the two previous characters |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2327 c2 = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2328 c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2329 a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2330 b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2331 put_char(put_char(c1, b), a); |
195 | 2332 } else { |
196 | 2333 // 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
|
2334 c2 = ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2335 c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2336 a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2337 b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2338 put_char(put_char(c1, b), a); |
195 | 2339 check_offset(1); |
2340 } | |
2341 } | |
2342 | |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2343 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
|
2344 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2345 char *c, *old = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2346 int spaceallowed = 1; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2347 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2348 if (! *ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2349 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2350 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
|
2351 if (!iswalnum(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2352 if (iswblank(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2353 if (!spaceallowed) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2354 } else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2355 } else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2356 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2357 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2358 // Modify the line |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2359 for (;;) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2360 *old = *c++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2361 if (!*old++) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2362 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2363 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2364 |
195 | 2365 // readline_backward_kill_word() |
194 | 2366 // Kill the word before the cursor, in input line |
1059 | 2367 void readline_backward_kill_word(void) |
194 | 2368 { |
2369 char *c, *old = ptr_inputline; | |
2370 int spaceallowed = 1; | |
2371 | |
2372 if (ptr_inputline == inputLine) return; | |
2373 | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2374 c = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2375 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
|
2376 if (!iswalnum(get_char(c))) { |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
2377 if (iswblank(get_char(c))) { |
194 | 2378 if (!spaceallowed) break; |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
2379 } else spaceallowed = 0; |
194 | 2380 } 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
|
2381 } |
194 | 2382 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2383 if (c != inputLine || iswblank(get_char(c))) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2384 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
|
2385 c = next_char(c); |
194 | 2386 |
2387 // Modify the line | |
2388 ptr_inputline = c; | |
2389 for (;;) { | |
2390 *c = *old++; | |
2391 if (!*c++) break; | |
2392 } | |
195 | 2393 check_offset(-1); |
194 | 2394 } |
2395 | |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2396 // 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
|
2397 // Move back to the start of the current or previous word |
1059 | 2398 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
|
2399 { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2400 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
|
2401 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2402 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
|
2403 |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2404 if (iswalnum(get_char(ptr_inputline)) && |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2405 !iswalnum(get_char(prev_char(ptr_inputline, inputLine)))) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2406 i--; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2407 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2408 for( ; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2409 ptr_inputline > inputLine; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2410 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
|
2411 if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2412 if (i) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2413 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2414 break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2415 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2416 } 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
|
2417 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2418 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2419 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
|
2420 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2421 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2422 // 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
|
2423 // Move forward to the end of the next word |
1059 | 2424 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
|
2425 { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2426 int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2427 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2428 while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2429 if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2430 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2431 } else stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2432 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2433 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2434 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2435 check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2436 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2437 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2438 void readline_updowncase_word(int upcase) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2439 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2440 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
|
2441 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2442 while (*ptr_inputline) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2443 if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2444 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2445 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2446 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2447 if (upcase) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2448 *ptr_inputline = towupper(get_char(ptr_inputline)); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2449 else |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2450 *ptr_inputline = towlower(get_char(ptr_inputline)); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2451 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2452 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2453 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2454 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2455 check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2456 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2457 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2458 void readline_capitalize_word(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2459 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2460 int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2461 int upcased = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2462 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2463 while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2464 if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2465 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2466 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2467 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2468 if (!upcased) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2469 *ptr_inputline = towupper(get_char(ptr_inputline)); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2470 upcased = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2471 } else *ptr_inputline = towlower(get_char(ptr_inputline)); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2472 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2473 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
|
2474 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2475 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2476 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
|
2477 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2478 |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2479 void readline_backward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2480 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2481 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
|
2482 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2483 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
|
2484 check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2485 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2486 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2487 void readline_forward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2488 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2489 if (!*ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2490 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2491 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
|
2492 check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2493 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2494 |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2495 // 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
|
2496 // Validate current command line. |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2497 // 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
|
2498 int readline_accept_line(int down_history) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2499 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2500 scr_CheckAutoAway(TRUE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2501 if (process_line(inputLine)) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2502 return 255; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2503 // Add line to history |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2504 scr_cmdhisto_addline(inputLine); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2505 // Reset the line |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2506 ptr_inputline = inputLine; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2507 *ptr_inputline = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2508 inputline_offset = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2509 |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2510 if (down_history) { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2511 // 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
|
2512 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
|
2513 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
|
2514 // Reset backup history line |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2515 cmdhisto_backup[0] = 0; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2516 } else { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2517 // Reset history line pointer |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2518 cmdhisto_cur = NULL; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
2519 } |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2520 return 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2521 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2522 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2523 void readline_cancel_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2524 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2525 scr_cancel_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2526 scr_end_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2527 check_offset(-1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2528 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2529 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2530 void readline_do_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2531 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2532 int i, n; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2533 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2534 if (scr_get_multimode() != 2) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2535 // Not in verbatim multi-line mode |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2536 scr_handle_tab(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2537 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2538 // Verbatim multi-line mode: expand tab |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2539 char tabstr[9]; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2540 n = 8 - (ptr_inputline - inputLine) % 8; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2541 for (i = 0; i < n; i++) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2542 tabstr[i] = ' '; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2543 tabstr[i] = '\0'; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2544 scr_insert_text(tabstr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2545 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2546 check_offset(0); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2547 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2548 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2549 void readline_refresh_screen(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2550 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2551 scr_CheckAutoAway(TRUE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2552 ParseColors(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2553 scr_Resize(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2554 redrawwin(stdscr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2555 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2556 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2557 void readline_disable_chat_mode(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2558 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2559 scr_CheckAutoAway(TRUE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2560 currentWindow = NULL; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2561 chatmode = FALSE; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2562 if (current_buddy) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2563 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2564 scr_RosterVisibility(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2565 scr_UpdateChatStatus(FALSE); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2566 top_panel(chatPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2567 top_panel(inputPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2568 update_panels(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2569 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
2570 |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2571 void readline_hist_prev(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2572 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2573 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
|
2574 if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2575 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2576 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2577 void readline_hist_next(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2578 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2579 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
|
2580 if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2581 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2582 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2583 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
|
2584 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2585 char *src, *c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2586 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2587 if (ptr_inputline == (char*)&inputLine) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2588 return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2589 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2590 src = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2591 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
|
2592 ptr_inputline = c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2593 for ( ; *src ; ) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2594 *c++ = *src++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2595 *c = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2596 check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2597 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2598 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2599 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
|
2600 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2601 if (!*ptr_inputline) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2602 return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2603 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2604 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
|
2605 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2606 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2607 void readline_iline_start(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2608 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2609 ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2610 inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2611 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2612 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2613 void readline_iline_end(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2614 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2615 for (; *ptr_inputline; ptr_inputline++) ; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2616 check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2617 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2618 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2619 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
|
2620 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2621 strcpy(inputLine, ptr_inputline); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2622 ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2623 inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2624 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2625 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2626 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
|
2627 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2628 *ptr_inputline = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2629 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2630 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2631 void readline_send_multiline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2632 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2633 // Validate current multi-line |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2634 if (scr_get_multimode()) |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1186
diff
changeset
|
2635 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
|
2636 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
2637 |
98 | 2638 // which_row() |
2639 // 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
|
2640 // -2 -> normal text |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2641 // -1 -> room: nickname completion |
98 | 2642 // 0 -> command |
2643 // 1 -> parameter 1 (etc.) | |
102 | 2644 // 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
|
2645 static int which_row(const char **p_row) |
98 | 2646 { |
2647 int row = -1; | |
2648 char *p; | |
2649 int quote = FALSE; | |
2650 | |
2651 // Not a command? | |
967 | 2652 if ((ptr_inputline == inputLine) || (inputLine[0] != COMMAND_CHAR)) { |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2653 if (!current_buddy) return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2654 if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_ROOM) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2655 *p_row = inputLine; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2656 return -1; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2657 } |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2658 return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2659 } |
98 | 2660 |
2661 // This is a command | |
2662 row = 0; | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2663 for (p = inputLine ; p < ptr_inputline ; p = next_char(p)) { |
98 | 2664 if (quote) { |
2665 if (*p == '"' && *(p-1) != '\\') | |
2666 quote = FALSE; | |
2667 continue; | |
2668 } | |
2669 if (*p == '"' && *(p-1) != '\\') { | |
2670 quote = TRUE; | |
121 | 2671 } else if (*p == ' ') { |
2672 if (*(p-1) != ' ') | |
2673 row++; | |
102 | 2674 *p_row = p+1; |
2675 } | |
98 | 2676 } |
2677 return row; | |
2678 } | |
2679 | |
143 | 2680 // scr_insert_text() |
2681 // Insert the given text at the current cursor position. | |
2682 // The cursor is moved. We don't check if the cursor still is in the screen | |
2683 // after, the caller should do that. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2684 static void scr_insert_text(const char *text) |
98 | 2685 { |
2686 char tmpLine[INPUTLINE_LENGTH+1]; | |
2687 int len = strlen(text); | |
2688 // Check the line isn't too long | |
2689 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2690 scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
98 | 2691 return; |
2692 } | |
2693 | |
2694 strcpy(tmpLine, ptr_inputline); | |
419 | 2695 strcpy(ptr_inputline, text); |
2696 ptr_inputline += len; | |
98 | 2697 strcpy(ptr_inputline, tmpLine); |
2698 } | |
2699 | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2700 static void scr_cancel_current_completion(void); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2701 |
143 | 2702 // scr_handle_tab() |
2703 // Function called when tab is pressed. | |
2704 // Initiate or continue a completion... | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2705 static void scr_handle_tab(void) |
98 | 2706 { |
102 | 2707 int nrow; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2708 const char *row; |
102 | 2709 const char *cchar; |
103 | 2710 guint compl_categ; |
98 | 2711 |
740 | 2712 row = inputLine; // (Kills a GCC warning) |
102 | 2713 nrow = which_row(&row); |
98 | 2714 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2715 // a) No completion if no leading slash ('cause not a command), |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2716 // unless this is a room (then, it is a nickname completion) |
103 | 2717 // 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
|
2718 if ((nrow == -2) || (nrow == 3 && !completion_started) || nrow > 3) |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2719 return; |
102 | 2720 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2721 if (nrow == 0) { // Command completion |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2722 row = next_char(inputLine); |
103 | 2723 compl_categ = COMPL_CMD; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2724 } else if (nrow == -1) { // Nickname completion |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2725 compl_categ = COMPL_RESOURCE; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2726 } else { // Other completion, depending on the command |
285 | 2727 int alias = FALSE; |
2728 cmd *com; | |
2729 char *xpline = expandalias(inputLine); | |
2730 com = cmd_get(xpline); | |
2731 if (xpline != inputLine) { | |
2732 // This is an alias, so we can't complete rows > 0 | |
2733 alias = TRUE; | |
2734 g_free(xpline); | |
2735 } | |
2736 if ((!com && (!alias || !completion_started)) || !row) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2737 scr_LogPrint(LPRINT_NORMAL, "I cannot complete that..."); |
103 | 2738 return; |
2739 } | |
285 | 2740 if (!alias) |
2741 compl_categ = com->completion_flags[nrow-1]; | |
2742 else | |
2743 compl_categ = 0; | |
103 | 2744 } |
2745 | |
2746 if (!completion_started) { | |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
2747 guint dynlist; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
2748 GSList *list = compl_get_category_list(compl_categ, &dynlist); |
103 | 2749 if (list) { |
2750 char *prefix = g_strndup(row, ptr_inputline-row); | |
2751 // Init completion | |
2752 new_completion(prefix, list); | |
2753 g_free(prefix); | |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
2754 // 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
|
2755 if (dynlist) { |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
2756 GSList *slp; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
2757 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
|
2758 g_free(slp->data); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
2759 g_slist_free(list); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
2760 |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
2761 } |
103 | 2762 // Now complete |
98 | 2763 cchar = complete(); |
2764 if (cchar) | |
2765 scr_insert_text(cchar); | |
103 | 2766 completion_started = TRUE; |
98 | 2767 } |
103 | 2768 } else { // Completion already initialized |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2769 scr_cancel_current_completion(); |
103 | 2770 // Now complete again |
2771 cchar = complete(); | |
2772 if (cchar) | |
2773 scr_insert_text(cchar); | |
102 | 2774 } |
98 | 2775 } |
2776 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2777 static void scr_cancel_current_completion(void) |
98 | 2778 { |
2779 char *c; | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2780 char *src = ptr_inputline; |
98 | 2781 guint back = cancel_completion(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2782 guint i; |
98 | 2783 // Remove $back chars |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2784 for (i = 0; i < back; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2785 ptr_inputline = prev_char(ptr_inputline, inputLine); |
98 | 2786 c = ptr_inputline; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2787 for ( ; *src ; ) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2788 *c++ = *src++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2789 *c = 0; |
98 | 2790 } |
2791 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2792 static void scr_end_current_completion(void) |
98 | 2793 { |
2794 done_completion(); | |
2795 completion_started = FALSE; | |
2796 } | |
2797 | |
24 | 2798 // check_offset(int direction) |
2799 // Check inputline_offset value, and make sure the cursor is inside the | |
2800 // screen. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2801 static inline void check_offset(int direction) |
24 | 2802 { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2803 int i; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2804 char *c = &inputLine[inputline_offset]; |
24 | 2805 // Left side |
2806 if (inputline_offset && direction <= 0) { | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2807 while (ptr_inputline <= c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2808 for (i = 0; i < 5; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2809 c = prev_char(c, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2810 if (c == inputLine) |
828
319fc55b9a2b
Fix a bug in check_offset()
Mikael Berthe <mikael@lilotux.net>
parents:
827
diff
changeset
|
2811 break; |
24 | 2812 } |
2813 } | |
2814 // Right side | |
2815 if (direction >= 0) { | |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
2816 int delta = get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2817 while (ptr_inputline > c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2818 c = next_char(c); |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
2819 delta += get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2820 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2821 c = &inputLine[inputline_offset]; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2822 while (delta >= maxX) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2823 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
|
2824 delta -= get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2825 c = next_char(c); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2826 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2827 } |
24 | 2828 } |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2829 inputline_offset = c - inputLine; |
24 | 2830 } |
2831 | |
1179 | 2832 #ifdef HAVE_ASPELL_H |
2833 // prints inputLine with underlined words when misspelled | |
2834 static inline void print_checked_line(void) | |
2835 { | |
2836 char *wprint_char_fmt = "%c"; | |
2837 int point; | |
2838 char *ptrCur = inputLine + inputline_offset; | |
2839 | |
2840 #ifdef UNICODE | |
2841 // We need this to display a single UTF-8 char... Any better solution? | |
2842 if (utf8_mode) | |
2843 wprint_char_fmt = "%lc"; | |
2844 #endif | |
2845 | |
2846 wmove(inputWnd, 0, 0); // problem with backspace | |
2847 | |
2848 while (*ptrCur) { | |
2849 point = ptrCur - inputLine; | |
2850 if (maskLine[point]) | |
2851 wattrset(inputWnd, A_UNDERLINE); | |
2852 wprintw(inputWnd, wprint_char_fmt, get_char(ptrCur)); | |
2853 wattrset(inputWnd, A_NORMAL); | |
2854 ptrCur = next_char(ptrCur); | |
2855 } | |
2856 } | |
2857 #endif | |
2858 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2859 static inline void refresh_inputline(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2860 { |
1179 | 2861 #ifdef HAVE_ASPELL_H |
2862 if (settings_opt_get_int("aspell_enable")) { | |
2863 memset(maskLine, 0, INPUTLINE_LENGTH+1); | |
2864 spellcheck(inputLine, maskLine); | |
2865 } | |
2866 print_checked_line(); | |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2867 wclrtoeol(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2868 if (*ptr_inputline) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2869 // 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
|
2870 // so I know of no better way. |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2871 char c = *ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2872 *ptr_inputline = 0; |
1179 | 2873 print_checked_line(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2874 *ptr_inputline = c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2875 } |
1179 | 2876 #else |
2877 mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); | |
2878 wclrtoeol(inputWnd); | |
2879 if (*ptr_inputline) { | |
2880 // hack to set cursor pos. Characters can have different width, | |
2881 // so I know of no better way. | |
2882 char c = *ptr_inputline; | |
2883 *ptr_inputline = 0; | |
2884 mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); | |
2885 *ptr_inputline = c; | |
2886 } | |
2887 #endif | |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2888 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2889 |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
2890 void scr_handle_CtrlC(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2891 { |
365
ddb6593bedc9
Fix segfault when mcabber receives an INT signal (Ctrl-C) early
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
2892 if (!Curses) return; |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
2893 // 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
|
2894 process_command(mkcmdstr("msay abort"), TRUE); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2895 // Same as Ctrl-g, now |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2896 scr_cancel_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2897 scr_end_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2898 check_offset(-1); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2899 refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2900 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2901 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2902 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
|
2903 { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2904 keyseq *ks; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2905 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2906 // Let's make sure the length is correct |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2907 if (strlen(seqstr) > MAX_KEYSEQ_LENGTH) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2908 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
|
2909 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2910 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2911 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2912 ks = g_new0(keyseq, 1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2913 ks->seqstr = g_strdup(seqstr); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2914 ks->mkeycode = mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2915 ks->value = value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2916 keyseqlist = g_slist_append(keyseqlist, ks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2917 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2918 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2919 // match_keyseq(iseq, &ret) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2920 // Check if "iseq" is a known key escape sequence. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2921 // Return value: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2922 // -1 if "seq" matches no known sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2923 // 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
|
2924 // >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
|
2925 // and *ret is set to the matching keyseq structure. |
952 | 2926 static inline gint match_keyseq(int *iseq, keyseq **ret) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2927 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2928 GSList *ksl; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2929 keyseq *ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2930 char *p, c; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2931 int *i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2932 int needmore = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2933 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2934 for (ksl = keyseqlist; ksl; ksl = g_slist_next(ksl)) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2935 ksp = ksl->data; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2936 p = ksp->seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2937 i = iseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2938 while (1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2939 c = (unsigned char)*i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2940 if (!*p && !c) { // Match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2941 (*ret) = ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2942 return ksp->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2943 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2944 if (!c) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2945 // iseq is too short |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2946 needmore = TRUE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2947 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2948 } else if (!*p || c != *p) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2949 // This isn't a match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2950 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2951 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2952 p++; i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2953 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2954 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2955 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2956 if (needmore) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2957 return 0; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2958 return -1; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2959 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2960 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2961 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
|
2962 { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2963 int *strp = iseq; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2964 unsigned c = *strp++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2965 unsigned mask = 0x80; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2966 int len = -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2967 while (c & mask) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2968 mask >>= 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2969 len++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2970 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2971 if (len <= 0 || len > 4) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2972 return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2973 c &= mask - 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2974 while ((*strp & 0xc0) == 0x80) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2975 if (len-- <= 0) // can't happen |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2976 return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2977 c = (c << 6) | (*strp++ & 0x3f); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2978 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2979 if (len) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2980 return 0; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2981 return c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2982 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2983 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2984 void scr_Getch(keycode *kcode) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2985 { |
769 | 2986 keyseq *mks = NULL; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2987 int ks[MAX_KEYSEQ_LENGTH+1]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2988 int i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2989 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2990 memset(kcode, 0, sizeof(keycode)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2991 memset(ks, 0, sizeof(ks)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2992 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2993 kcode->value = wgetch(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
2994 if (utf8_mode) { |
1058 | 2995 bool ismeta = (kcode->value == 27); |
2996 | |
2997 if (ismeta) | |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
2998 ks[0] = wgetch(inputWnd); |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
2999 else |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3000 ks[0] = kcode->value; |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3001 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3002 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
|
3003 int match = match_utf8_keyseq(ks); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3004 if (match == -1) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3005 break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3006 if (match > 0) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3007 kcode->value = match; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3008 kcode->utf8 = 1; |
1058 | 3009 if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3010 kcode->mcode = MKEY_META; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3011 return; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3012 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3013 ks[i + 1] = wgetch(inputWnd); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3014 if (ks[i + 1] == ERR) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3015 break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3016 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3017 while (i > 0) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3018 ungetch(ks[i--]); |
1058 | 3019 if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3020 ungetch(ks[0]); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3021 memset(ks, 0, sizeof(ks)); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3022 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3023 if (kcode->value != 27) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3024 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3025 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3026 // Check for escape key sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3027 for (i=0; i < MAX_KEYSEQ_LENGTH; i++) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3028 int match; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3029 ks[i] = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3030 if (ks[i] == ERR) break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3031 match = match_keyseq(ks, &mks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3032 if (match == -1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3033 // 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
|
3034 i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3035 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3036 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3037 if (match > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3038 // We have a matching sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3039 kcode->mcode = mks->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3040 kcode->value = mks->value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3041 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3042 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3043 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3044 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3045 // No match. Let's return a meta-key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3046 if (i > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3047 kcode->mcode = MKEY_META; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3048 kcode->value = ks[0]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3049 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3050 if (i > 1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3051 // 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
|
3052 while (i-- > 1) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3053 ungetch(ks[i]); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3054 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3055 return; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
3056 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
3057 |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3058 inline void scr_DoUpdate(void) |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3059 { |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3060 doupdate(); |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3061 } |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3062 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3063 static int bindcommand(keycode kcode) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3064 { |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3065 gchar asciikey[16], asciicode[16]; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3066 const gchar *boundcmd; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3067 |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3068 if (kcode.utf8) |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3069 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
|
3070 else |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3071 g_snprintf(asciicode, 15, "%d", kcode.value); |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3072 |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3073 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
|
3074 g_snprintf(asciikey, 15, "%s", asciicode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3075 else if (kcode.mcode == MKEY_META) |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3076 g_snprintf(asciikey, 15, "M%s", asciicode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3077 else |
949
e3c49b2f8143
Fix bindings of special keys (MK*)
Mikael Berthe <mikael@lilotux.net>
parents:
945
diff
changeset
|
3078 g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3079 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3080 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3081 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3082 if (boundcmd) { |
1058 | 3083 gchar *cmdline, *boundcmd_locale; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3084 boundcmd_locale = from_utf8(boundcmd); |
1058 | 3085 cmdline = g_strdup_printf(mkcmdstr("%s"), boundcmd_locale); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3086 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
|
3087 if (process_command(cmdline, TRUE)) |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3088 return 255; // Quit |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3089 g_free(boundcmd_locale); |
1058 | 3090 g_free(cmdline); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3091 return 0; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3092 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3093 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3094 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
|
3095 #ifndef UNICODE |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3096 if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3097 scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3098 "WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3099 #endif |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3100 return -1; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3101 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3102 |
44 | 3103 // process_key(key) |
3104 // Handle the pressed key, in the command line (bottom). | |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3105 int process_key(keycode kcode) |
24 | 3106 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3107 int key = kcode.value; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3108 int display_char = FALSE; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3109 |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3110 lock_chatstate = false; |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3111 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3112 switch (kcode.mcode) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3113 case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3114 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3115 case MKEY_EQUIV: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3116 key = kcode.value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3117 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3118 case MKEY_META: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3119 default: |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3120 if (bindcommand(kcode) == 255) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3121 return 255; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3122 key = ERR; // Do not process any further |
758 | 3123 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3124 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3125 if (kcode.utf8) { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3126 if (key != ERR && !kcode.mcode) |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3127 display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3128 goto display; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3129 } |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3130 |
758 | 3131 switch (key) { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3132 case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3133 case ERR: |
758 | 3134 break; |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3135 case 9: // Tab |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3136 readline_do_completion(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3137 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3138 case 13: // Enter |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3139 if (readline_accept_line(FALSE) == 255) |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3140 return 255; |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3141 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3142 case 3: // Ctrl-C |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3143 scr_handle_CtrlC(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3144 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3145 case KEY_RESIZE: |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3146 scr_Resize(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3147 break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
3148 default: |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3149 display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3150 } // switch |
263 | 3151 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3152 display: |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3153 if (display_char) { |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
3154 if (kcode.utf8 ? iswprint(key) : isprint(key)) { |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3155 char tmpLine[INPUTLINE_LENGTH+1]; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
3156 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3157 // Check the line isn't too long |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3158 if (strlen(inputLine) + 4 > INPUTLINE_LENGTH) |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3159 return 0; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3160 |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3161 // Insert char |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3162 strcpy(tmpLine, ptr_inputline); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3163 ptr_inputline = put_char(ptr_inputline, key); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3164 strcpy(ptr_inputline, tmpLine); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3165 check_offset(1); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3166 } else { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3167 // Look for a key binding. |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3168 if (!kcode.utf8 && (bindcommand(kcode) == 255)) |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3169 return 255; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3170 } |
24 | 3171 } |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
3172 |
157 | 3173 if (completion_started && key != 9 && key != KEY_RESIZE) |
98 | 3174 scr_end_current_completion(); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3175 refresh_inputline(); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3176 |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3177 if (!lock_chatstate) { |
997 | 3178 // Set chat state to composing (1) if the user is currently composing, |
3179 // 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
|
3180 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
|
3181 set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3182 else |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3183 set_chatstate(1); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
3184 if (chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
3185 time(&chatstate_timestamp); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3186 } |
24 | 3187 return 0; |
3188 } | |
576 | 3189 |
1179 | 3190 #ifdef HAVE_ASPELL_H |
3191 // Aspell initialization | |
3192 void spellcheck_init(void) | |
3193 { | |
3194 int aspell_enable = settings_opt_get_int("aspell_enable"); | |
3195 const char *aspell_lang = settings_opt_get("aspell_lang"); | |
3196 const char *aspell_encoding = settings_opt_get("aspell_encoding"); | |
3197 AspellCanHaveError *possible_err; | |
3198 | |
3199 if (!aspell_enable) | |
3200 return; | |
3201 | |
3202 if (spell_checker) { | |
3203 delete_aspell_speller(spell_checker); | |
3204 delete_aspell_config(spell_config); | |
3205 spell_checker = NULL; | |
3206 spell_config = NULL; | |
3207 } | |
3208 | |
3209 spell_config = new_aspell_config(); | |
3210 aspell_config_replace(spell_config, "encoding", aspell_encoding); | |
3211 aspell_config_replace(spell_config, "lang", aspell_lang); | |
3212 possible_err = new_aspell_speller(spell_config); | |
3213 | |
3214 if (aspell_error_number(possible_err) != 0) { | |
3215 spell_checker = NULL; | |
3216 delete_aspell_config(spell_config); | |
3217 spell_config = NULL; | |
3218 } else { | |
3219 spell_checker = to_aspell_speller(possible_err); | |
3220 } | |
3221 } | |
3222 | |
3223 // Deinitialization of Aspell spellchecker | |
3224 void spellcheck_deinit(void) | |
3225 { | |
3226 if (spell_checker) { | |
3227 delete_aspell_speller(spell_checker); | |
3228 spell_checker = NULL; | |
3229 } | |
3230 | |
3231 if (spell_config) { | |
3232 delete_aspell_config(spell_config); | |
3233 spell_config = NULL; | |
3234 } | |
3235 } | |
3236 | |
3237 // Spell checking function | |
3238 static void spellcheck(char *line, char *checked) | |
3239 { | |
3240 const char *start, *line_start; | |
3241 | |
3242 if (inputLine[0] == 0 || inputLine[0] == COMMAND_CHAR) | |
3243 return; | |
3244 | |
3245 line_start = line; | |
3246 | |
3247 while (*line) { | |
3248 | |
3249 if (!is_alpha(line)) { | |
3250 line = next_char(line); | |
3251 continue; | |
3252 } | |
3253 | |
3254 if (!strncmp(line, "http://", 7)) { | |
3255 line += 7; // : and / characters are 1 byte long in utf8, right? | |
3256 | |
3257 while (!strchr(" \t\r\n", *line)) | |
3258 line = next_char(line); // i think line++ would be fine here? | |
3259 | |
3260 continue; | |
3261 } | |
3262 | |
3263 if (!strncmp(line, "ftp://", 6)) { | |
3264 line += 6; | |
3265 | |
3266 while (!strchr(" \t\r\n", *line)) | |
3267 line = next_char(line); | |
3268 | |
3269 continue; | |
3270 } | |
3271 | |
3272 start = line; | |
3273 | |
3274 while (is_alpha(line)) | |
3275 line = next_char(line); | |
3276 | |
3277 if (spell_checker && | |
3278 aspell_speller_check(spell_checker, start, line - start) == 0) | |
3279 memset(&checked[start - line_start], ASPELLBADCHAR, line - start); | |
3280 } | |
3281 } | |
3282 | |
3283 // Universal isalpha function | |
3284 static inline int is_alpha(const char *c) | |
3285 { | |
3286 if (utf8_mode) { | |
3287 if (iswalpha(get_char(c))) | |
3288 return 1; | |
3289 } else { | |
3290 if (isalpha(*c)) | |
3291 return 1; | |
3292 } | |
3293 return 0; | |
3294 } | |
3295 #endif | |
3296 | |
580 | 3297 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |