Mercurial > hg
annotate mcabber/src/screen.c @ 770:c3bb5ae65a86
Merge with myself (PuTTY escape keys)
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Thu, 23 Mar 2006 19:14:15 +0100 |
parents | 15eefed5f1de 0f6d25a02450 |
children | ce4f8a2129a4 |
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 <ncurses.h> | |
27 #include <panel.h> | |
28 #include <time.h> | |
29 #include <ctype.h> | |
30 #include <locale.h> | |
232 | 31 #include <langinfo.h> |
24 | 32 |
33 #include "screen.h" | |
81 | 34 #include "hbuf.h" |
47 | 35 #include "commands.h" |
95 | 36 #include "compl.h" |
81 | 37 #include "roster.h" |
180 | 38 #include "histolog.h" |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
39 #include "settings.h" |
81 | 40 #include "utils.h" |
24 | 41 #include "list.h" |
42 | |
43 #define window_entry(n) list_entry(n, window_entry_t, list) | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
44 #define get_color(col) (COLOR_PAIR(col)|COLOR_ATTRIB[col]) |
24 | 45 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
46 #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
|
47 #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
|
48 #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
|
49 |
592
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
50 char *LocaleCharSet = "C"; |
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
51 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
52 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
|
53 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
|
54 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
55 static inline void check_offset(int); |
151 | 56 |
24 | 57 LIST_HEAD(window_list); |
58 | |
59 typedef struct _window_entry_t { | |
60 WINDOW *win; | |
108 | 61 PANEL *panel; |
62 char *name; | |
63 GList *hbuf; | |
181 | 64 GList *top; // If top is NULL, we'll display the last lines |
65 char cleared; // For ex, user has issued a /clear command... | |
24 | 66 struct list_head list; |
67 } window_entry_t; | |
68 | |
69 | |
711 | 70 static WINDOW *rosterWnd, *chatWnd, *inputWnd, *logWnd; |
71 static WINDOW *mainstatusWnd, *chatstatusWnd; | |
24 | 72 static PANEL *rosterPanel, *chatPanel, *inputPanel; |
711 | 73 static PANEL *mainstatusPanel, *chatstatusPanel; |
74 static PANEL *logPanel; | |
24 | 75 static int maxY, maxX; |
76 static window_entry_t *currentWindow; | |
77 | |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
78 static int roster_hidden; |
24 | 79 static int chatmode; |
238 | 80 static int multimode; |
81 static char *multiline; | |
30 | 82 int update_roster; |
232 | 83 int utf8_mode = 0; |
322
da138cdebf04
Implement auto-away mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
84 static bool Autoaway; |
332
a1901741890e
scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
85 static bool Curses; |
24 | 86 |
174 | 87 static char inputLine[INPUTLINE_LENGTH+1]; |
88 static char *ptr_inputline; | |
89 static short int inputline_offset; | |
90 static int completion_started; | |
173 | 91 static GList *cmdhisto; |
92 static GList *cmdhisto_cur; | |
174 | 93 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
24 | 94 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
95 #define MAX_KEYSEQ_LENGTH 8 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
96 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
97 typedef struct { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
98 char *seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
99 guint mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
100 gint value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
101 } keyseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
102 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
103 GSList *keyseqlist; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
104 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
|
105 |
24 | 106 |
99 | 107 /* Functions */ |
24 | 108 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
109 static int scr_WindowWidth(WINDOW * win) |
24 | 110 { |
111 int x, y; | |
112 getmaxyx(win, y, x); | |
113 return x; | |
114 } | |
115 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
116 static int FindColor(const char *name) |
24 | 117 { |
118 if (!strcmp(name, "default")) | |
119 return -1; | |
120 if (!strcmp(name, "black")) | |
121 return COLOR_BLACK; | |
122 if (!strcmp(name, "red")) | |
123 return COLOR_RED; | |
124 if (!strcmp(name, "green")) | |
125 return COLOR_GREEN; | |
126 if (!strcmp(name, "yellow")) | |
127 return COLOR_YELLOW; | |
128 if (!strcmp(name, "blue")) | |
129 return COLOR_BLUE; | |
130 if (!strcmp(name, "magenta")) | |
131 return COLOR_MAGENTA; | |
132 if (!strcmp(name, "cyan")) | |
133 return COLOR_CYAN; | |
134 if (!strcmp(name, "white")) | |
135 return COLOR_WHITE; | |
136 | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
137 scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name); |
24 | 138 return -1; |
139 } | |
140 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
141 static void ParseColors(void) |
24 | 142 { |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
143 const char *colors[] = { |
24 | 144 "", "", |
267 | 145 "general", |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
146 "highlight", |
711 | 147 "status", |
712 | 148 "roster", |
149 "rostersel", | |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
150 "rosterselmsg", |
712 | 151 "rosternewmsg", |
24 | 152 NULL |
153 }; | |
154 | |
281
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
155 const char *color; |
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
156 const char *background = settings_opt_get("color_background"); |
712 | 157 const char *backselected = settings_opt_get("color_bgrostersel"); |
158 const char *backstatus = settings_opt_get("color_bgstatus"); | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
159 char *tmp; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
160 int i; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
161 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
162 // Initialize color attributes |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
163 memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB)); |
24 | 164 |
267 | 165 // Default values |
711 | 166 if (!background) background = "black"; |
267 | 167 if (!backselected) backselected = "cyan"; |
711 | 168 if (!backstatus) backstatus = "blue"; |
267 | 169 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
170 for (i=0; colors[i]; i++) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
171 tmp = g_strdup_printf("color_%s", colors[i]); |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
172 color = settings_opt_get(tmp); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
173 g_free(tmp); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
174 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
175 if (color) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
176 if (!strncmp(color, "bright", 6)) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
177 COLOR_ATTRIB[i+1] = A_BOLD; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
178 color += 6; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
179 } |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
180 } |
24 | 181 |
182 switch (i + 1) { | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
183 case 1: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
184 init_pair(1, COLOR_BLACK, COLOR_WHITE); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
185 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
186 case 2: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
187 init_pair(2, COLOR_WHITE, COLOR_BLACK); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
188 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
189 case COLOR_GENERAL: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
190 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
191 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
192 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
193 case COLOR_HIGHLIGHT: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
194 init_pair(i+1, ((color) ? FindColor(color) : COLOR_CYAN), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
195 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
196 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
197 case COLOR_STATUS: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
198 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
199 FindColor(backstatus)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
200 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
201 case COLOR_ROSTER: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
202 init_pair(i+1, ((color) ? FindColor(color) : COLOR_GREEN), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
203 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
204 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
205 case COLOR_ROSTERSEL: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
206 init_pair(i+1, ((color) ? FindColor(color) : COLOR_BLUE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
207 FindColor(backselected)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
208 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
209 case COLOR_ROSTERSELNMSG: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
210 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
211 FindColor(backselected)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
212 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
213 case COLOR_ROSTERNMSG: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
214 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
215 FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
216 break; |
24 | 217 } |
218 } | |
219 } | |
220 | |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
221 static void init_keycodes(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
222 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
223 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
224 add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
225 add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
226 add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 227 add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up |
228 add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down | |
229 add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right | |
230 add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left | |
231 add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up | |
232 add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down | |
233 add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right | |
234 add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left | |
235 add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
236 add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown | |
237 add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp | |
238 add_keyseq("[6@", MKEY_CTRL_SHIFT_PGDOWN, 0); // Ctrl-Shift-PageDown | |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
239 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
240 // Xterm |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
241 add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
242 add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
243 add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
244 add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
245 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
|
246 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
|
247 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
|
248 add_keyseq("[1;6D", MKEY_EQUIV, 393); // Ctrl-Shift-Left |
763 | 249 add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up |
250 add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down | |
251 add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
252 add_keyseq("[6;5~", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown | |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
253 |
768
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
254 // PuTTY |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
255 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
|
256 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
|
257 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
|
258 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
|
259 |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
260 // screen |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 265 add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up |
266 add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down | |
267 add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right | |
268 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
|
269 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
|
270 add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
271 } |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
272 |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
273 void scr_InitCurses(void) |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
274 { |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
275 /* Key sequences initialization */ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
276 init_keycodes(); |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
277 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
278 initscr(); |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
279 raw(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
280 noecho(); |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
281 nonl(); |
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
282 intrflush(stdscr, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
283 start_color(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
284 use_default_colors(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
285 Curses = TRUE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
286 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
287 ParseColors(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
288 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
289 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
|
290 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
|
291 // 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
|
292 // 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
|
293 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
294 inputLine[0] = 0; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
295 ptr_inputline = inputLine; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
296 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
297 setlocale(LC_CTYPE, ""); |
592
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
298 LocaleCharSet = nl_langinfo(CODESET); |
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
299 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
300 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
301 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
302 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
303 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
304 void scr_TerminateCurses(void) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
305 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
306 if (!Curses) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
307 clear(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
308 refresh(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
309 endwin(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
310 Curses = FALSE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
311 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
312 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
313 |
675
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
314 inline void scr_Beep(void) |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
315 { |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
316 beep(); |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
317 } |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
318 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
319 // scr_LogPrint(...) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
320 // Display a message in the log window. |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
321 void scr_LogPrint(unsigned int flag, const char *fmt, ...) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
322 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
323 time_t timestamp; |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
324 char *buffer, *b2; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
325 va_list ap; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
326 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
327 if (!flag) return; |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
328 |
602
7b20c27cae48
Increase scr_LogPrint() buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
592
diff
changeset
|
329 buffer = g_new(char, 5184); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
330 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
331 timestamp = time(NULL); |
602
7b20c27cae48
Increase scr_LogPrint() buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
592
diff
changeset
|
332 strftime(buffer, 48, "[%H:%M:%S] ", localtime(×tamp)); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
333 for (b2 = buffer ; *b2 ; b2++) |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
334 ; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
335 va_start(ap, fmt); |
602
7b20c27cae48
Increase scr_LogPrint() buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
592
diff
changeset
|
336 vsnprintf(b2, 5120, fmt, ap); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
337 va_end(ap); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
338 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
339 if (flag & LPRINT_NORMAL) { |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
340 if (Curses) { |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
341 wprintw(logWnd, "\n%s", buffer); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
342 update_panels(); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
343 doupdate(); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
344 } else { |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
345 printf("%s\n", buffer); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
346 } |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
347 } |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
348 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
658 | 349 char *buffer2 = g_new(char, 5184); |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
350 |
658 | 351 strftime(buffer2, 23, "[%Y-%m-%d %H:%M:%S] ", localtime(×tamp)); |
352 strcat(buffer2, b2); | |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
353 strcat(buffer2, "\n"); |
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
354 ut_WriteLog(flag, buffer2); |
658 | 355 g_free(buffer2); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
356 } |
602
7b20c27cae48
Increase scr_LogPrint() buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
592
diff
changeset
|
357 g_free(buffer); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
358 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
359 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
360 static window_entry_t *scr_CreateBuddyPanel(const char *title, int dont_show) |
24 | 361 { |
151 | 362 int x; |
363 int y; | |
364 int lines; | |
365 int cols; | |
153 | 366 window_entry_t *tmp; |
393 | 367 |
657
056dc9e65c25
Some memory allocation code cleaning
Mikael Berthe <mikael@lilotux.net>
parents:
654
diff
changeset
|
368 tmp = g_new0(window_entry_t, 1); |
24 | 369 |
151 | 370 // Dimensions |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
371 x = Roster_Width; |
151 | 372 y = 0; |
373 lines = CHAT_WIN_HEIGHT; | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
374 cols = maxX - Roster_Width; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
375 if (cols < 1) cols = 1; |
151 | 376 |
24 | 377 tmp->win = newwin(lines, cols, y, x); |
154 | 378 while (!tmp->win) { |
419 | 379 safe_usleep(250); |
154 | 380 tmp->win = newwin(lines, cols, y, x); |
381 } | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
382 wbkgd(tmp->win, get_color(COLOR_GENERAL)); |
24 | 383 tmp->panel = new_panel(tmp->win); |
657
056dc9e65c25
Some memory allocation code cleaning
Mikael Berthe <mikael@lilotux.net>
parents:
654
diff
changeset
|
384 tmp->name = g_strdup(title); |
24 | 385 |
143 | 386 if (!dont_show) { |
24 | 387 currentWindow = tmp; |
388 } else { | |
389 if (currentWindow) | |
390 top_panel(currentWindow->panel); | |
391 else | |
392 top_panel(chatPanel); | |
393 } | |
143 | 394 update_panels(); |
24 | 395 |
181 | 396 // Load buddy history from file (if enabled) |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
397 hlog_read_history(title, &tmp->hbuf, maxX - Roster_Width - PREFIX_WIDTH); |
181 | 398 |
24 | 399 list_add_tail(&tmp->list, &window_list); |
400 | |
401 return tmp; | |
402 } | |
403 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
404 static window_entry_t *scr_SearchWindow(const char *winId) |
24 | 405 { |
406 struct list_head *pos, *n; | |
407 window_entry_t *search_entry = NULL; | |
408 | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
409 if (!winId) return NULL; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
410 |
24 | 411 list_for_each_safe(pos, n, &window_list) { |
412 search_entry = window_entry(pos); | |
413 if (search_entry->name) { | |
414 if (!strcasecmp(search_entry->name, winId)) { | |
415 return search_entry; | |
416 } | |
417 } | |
418 } | |
419 return NULL; | |
420 } | |
421 | |
514
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
422 bool scr_BuddyBufferExists(const char *jid) |
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
423 { |
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
424 return (scr_SearchWindow(jid) != NULL); |
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
425 } |
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
426 |
143 | 427 // scr_UpdateWindow() |
428 // (Re-)Display the given chat window. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
429 static void scr_UpdateWindow(window_entry_t *win_entry) |
74 | 430 { |
431 int n; | |
432 int width; | |
184 | 433 hbb_line **lines, *line; |
74 | 434 GList *hbuf_head; |
184 | 435 char date[32]; |
74 | 436 |
108 | 437 width = scr_WindowWidth(win_entry->win); |
438 | |
439 // Should the window be empty? | |
440 if (win_entry->cleared) { | |
168 | 441 werase(win_entry->win); |
108 | 442 return; |
443 } | |
444 | |
105 | 445 // win_entry->top is the top message of the screen. If it set to NULL, we |
446 // are displaying the last messages. | |
447 | |
74 | 448 // We will show the last CHAT_WIN_HEIGHT lines. |
449 // Let's find out where it begins. | |
105 | 450 if (!win_entry->top || |
451 (g_list_position(g_list_first(win_entry->hbuf), win_entry->top) == -1)) { | |
452 // Move up CHAT_WIN_HEIGHT lines | |
453 win_entry->hbuf = g_list_last(win_entry->hbuf); | |
454 hbuf_head = win_entry->hbuf; | |
455 win_entry->top = NULL; // (Just to make sure) | |
456 n = 0; | |
457 while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { | |
458 hbuf_head = g_list_previous(hbuf_head); | |
459 n++; | |
460 } | |
461 } else | |
462 hbuf_head = win_entry->top; | |
74 | 463 |
464 // Get the last CHAT_WIN_HEIGHT lines. | |
465 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); | |
466 | |
467 // Display these lines | |
468 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { | |
168 | 469 wmove(win_entry->win, n, 0); |
184 | 470 line = *(lines+n); |
185 | 471 // NOTE: update PREFIX_WIDTH if you change the date format!! |
472 // You need to set it to the whole prefix length + 1 | |
184 | 473 if (line) { |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
474 if (line->flags & HBB_PREFIX_HLIGHT) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
475 wattrset(win_entry->win, get_color(COLOR_HIGHLIGHT)); |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
476 |
184 | 477 if (line->timestamp) { |
419 | 478 strftime(date, 30, "%m-%d %H:%M", localtime(&line->timestamp)); |
184 | 479 } else |
185 | 480 strcpy(date, " "); |
197 | 481 if (line->flags & HBB_PREFIX_INFO) { |
482 char dir = '*'; | |
483 if (line->flags & HBB_PREFIX_IN) | |
484 dir = '<'; | |
485 else if (line->flags & HBB_PREFIX_OUT) | |
486 dir = '>'; | |
487 wprintw(win_entry->win, "%.11s *%c* ", date, dir); | |
325
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
488 } else if (line->flags & HBB_PREFIX_ERR) { |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
489 char dir = '#'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
490 if (line->flags & HBB_PREFIX_IN) |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
491 dir = '<'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
492 else if (line->flags & HBB_PREFIX_OUT) |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
493 dir = '>'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
494 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
|
495 } else if (line->flags & HBB_PREFIX_IN) { |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
496 wprintw(win_entry->win, "%.11s <== ", date); |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
497 } else if (line->flags & HBB_PREFIX_OUT) { |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
498 wprintw(win_entry->win, "%.11s --> ", date); |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
499 } else { |
185 | 500 wprintw(win_entry->win, "%.11s ", date); |
75 | 501 } |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
502 |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
503 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
|
504 |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
505 if (line->flags & HBB_PREFIX_HLIGHT) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
506 wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
168 | 507 wclrtoeol(win_entry->win); |
184 | 508 g_free(line->text); |
168 | 509 } else { |
510 wclrtobot(win_entry->win); | |
511 break; | |
75 | 512 } |
74 | 513 } |
514 g_free(lines); | |
515 } | |
516 | |
143 | 517 // scr_ShowWindow() |
518 // Display the chat window with the given identifier. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
519 static void scr_ShowWindow(const char *winId) |
24 | 520 { |
74 | 521 window_entry_t *win_entry = scr_SearchWindow(winId); |
522 | |
181 | 523 if (!win_entry) |
180 | 524 win_entry = scr_CreateBuddyPanel(winId, FALSE); |
74 | 525 |
180 | 526 top_panel(win_entry->panel); |
527 currentWindow = win_entry; | |
528 chatmode = TRUE; | |
529 roster_msg_setflag(winId, FALSE); | |
530 roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); | |
531 update_roster = TRUE; | |
74 | 532 |
180 | 533 // Refresh the window |
534 scr_UpdateWindow(win_entry); | |
535 | |
536 // Finished :) | |
537 update_panels(); | |
142 | 538 |
539 top_panel(inputPanel); | |
24 | 540 } |
541 | |
143 | 542 // scr_ShowBuddyWindow() |
543 // Display the chat window buffer for the current buddy. | |
24 | 544 void scr_ShowBuddyWindow(void) |
545 { | |
105 | 546 const gchar *jid; |
140 | 547 |
105 | 548 if (!current_buddy) |
140 | 549 jid = NULL; |
550 else | |
551 jid = CURRENT_JID; | |
552 | |
553 if (!jid) { | |
554 top_panel(chatPanel); | |
143 | 555 top_panel(inputPanel); |
140 | 556 currentWindow = NULL; |
105 | 557 return; |
140 | 558 } |
559 | |
105 | 560 scr_ShowWindow(jid); |
24 | 561 } |
562 | |
143 | 563 // scr_WriteInWindow() |
564 // Write some text in the winId window (this usually is a jid). | |
565 // Lines are splitted when they are too long to fit in the chat window. | |
566 // If this window doesn't exist, it is created. | |
184 | 567 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
568 unsigned int prefix_flags, int force_show) | |
24 | 569 { |
74 | 570 window_entry_t *win_entry; |
24 | 571 int dont_show = FALSE; |
572 | |
74 | 573 // Look for the window entry. |
574 win_entry = scr_SearchWindow(winId); | |
575 | |
576 // Do we have to really show the window? | |
24 | 577 if (!chatmode) |
578 dont_show = TRUE; | |
74 | 579 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24 | 580 dont_show = TRUE; |
581 | |
74 | 582 // If the window entry doesn't exist yet, let's create it. |
583 if (win_entry == NULL) { | |
151 | 584 win_entry = scr_CreateBuddyPanel(winId, dont_show); |
24 | 585 } |
586 | |
220 | 587 // The message must be displayed -> update top pointer |
588 if (win_entry->cleared) | |
589 win_entry->top = g_list_last(win_entry->hbuf); | |
590 | |
184 | 591 hbuf_add_line(&win_entry->hbuf, text, timestamp, prefix_flags, |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
592 maxX - Roster_Width - PREFIX_WIDTH); |
74 | 593 |
108 | 594 if (win_entry->cleared) { |
220 | 595 win_entry->cleared = FALSE; |
596 if (g_list_next(win_entry->top)) | |
597 win_entry->top = g_list_next(win_entry->top); | |
598 } | |
599 | |
600 // Make sure the last line appears in the window; update top if necessary | |
601 if (win_entry->top) { | |
602 int dist; | |
603 GList *first = g_list_first(win_entry->hbuf); | |
604 dist = g_list_position(first, g_list_last(win_entry->hbuf)) - | |
605 g_list_position(first, win_entry->top); | |
606 if (dist >= CHAT_WIN_HEIGHT) | |
607 win_entry->top = NULL; | |
108 | 608 } |
609 | |
24 | 610 if (!dont_show) { |
74 | 611 // Show and refresh the window |
612 top_panel(win_entry->panel); | |
613 scr_UpdateWindow(win_entry); | |
142 | 614 top_panel(inputPanel); |
24 | 615 update_panels(); |
616 doupdate(); | |
513 | 617 } else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) { |
148 | 618 roster_msg_setflag(winId, TRUE); |
30 | 619 update_roster = TRUE; |
24 | 620 } |
621 } | |
622 | |
713 | 623 // scr_UpdateMainStatus() |
624 // Redraw the main (bottom) status line. | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
625 void scr_UpdateMainStatus(int forceupdate) |
713 | 626 { |
627 const char *sm = jb_getstatusmsg(); | |
628 | |
629 werase(mainstatusWnd); | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
630 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
|
631 (unread_msg(NULL) ? '#' : ' '), |
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
632 imstatus2char[jb_getstatus()], (sm ? sm : "")); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
633 if (forceupdate) { |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
634 top_panel(inputPanel); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
635 update_panels(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
636 doupdate(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
637 } |
713 | 638 } |
639 | |
151 | 640 // scr_DrawMainWindow() |
157 | 641 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151 | 642 // |
643 // I think it could be improved a _lot_ but I'm really not an ncurses | |
644 // expert... :-\ Mikael. | |
645 // | |
646 void scr_DrawMainWindow(unsigned int fullinit) | |
24 | 647 { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
648 int requested_size; |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
649 |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
650 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
|
651 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
|
652 if (requested_size > 0) { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
653 if (maxY > requested_size + 3) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
654 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
|
655 else |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
656 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
|
657 } else if (requested_size < 0) { |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
658 Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
659 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
660 |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
661 if (maxY < Log_Win_Height+2) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
662 if (maxY < 5) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
663 Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
664 maxY = Log_Win_Height+2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
665 } else { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
666 Log_Win_Height = maxY - 2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
667 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
668 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
669 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
670 if (roster_hidden) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
671 Roster_Width = 0; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
672 } else { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
673 requested_size = settings_opt_get_int("roster_width"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
674 if (requested_size > 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
675 Roster_Width = requested_size; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
676 else if (requested_size == 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
677 Roster_Width = 2; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
678 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
679 Roster_Width = DEFAULT_ROSTER_WIDTH; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
680 } |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
681 |
157 | 682 if (fullinit) { |
683 /* Create windows */ | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
684 rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, 0, 0); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
685 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, 0, Roster_Width); |
711 | 686 logWnd = newwin(Log_Win_Height-2, maxX, CHAT_WIN_HEIGHT+1, 0); |
687 chatstatusWnd = newwin(1, maxX, CHAT_WIN_HEIGHT, 0); | |
688 mainstatusWnd = newwin(1, maxX, maxY-2, 0); | |
157 | 689 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
|
690 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
|
691 scr_TerminateCurses(); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
692 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
|
693 exit(EXIT_FAILURE); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
694 } |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
695 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
696 wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
697 wbkgd(logWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
698 wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
699 wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
157 | 700 } else { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
701 /* Resize/move windows */ |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
702 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
703 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
704 mvwin(chatWnd, 0, Roster_Width); |
157 | 705 |
711 | 706 wresize(logWnd, Log_Win_Height-2, maxX); |
707 mvwin(logWnd, CHAT_WIN_HEIGHT+1, 0); | |
157 | 708 |
711 | 709 // Resize & move chat status window |
710 wresize(chatstatusWnd, 1, maxX); | |
711 mvwin(chatstatusWnd, CHAT_WIN_HEIGHT, 0); | |
712 // Resize & move main status window | |
713 wresize(mainstatusWnd, 1, maxX); | |
714 mvwin(mainstatusWnd, maxY-2, 0); | |
715 // Resize & move input line window | |
157 | 716 wresize(inputWnd, 1, maxX); |
717 mvwin(inputWnd, maxY-1, 0); | |
168 | 718 |
719 werase(chatWnd); | |
157 | 720 } |
151 | 721 |
722 /* Draw/init windows */ | |
723 | |
679
5933a8036672
Remove "This is the status window" message
Mikael Berthe <mikael@lilotux.net>
parents:
675
diff
changeset
|
724 mvwprintw(chatWnd, 0, 0, "Thanks for using mcabber.\n"); |
5933a8036672
Remove "This is the status window" message
Mikael Berthe <mikael@lilotux.net>
parents:
675
diff
changeset
|
725 mvwprintw(chatWnd, 1, 0, "http://www.lilotux.net/~mikael/mcabber/"); |
24 | 726 |
157 | 727 // Auto-scrolling in log window |
74 | 728 scrollok(logWnd, TRUE); |
24 | 729 |
730 | |
151 | 731 if (fullinit) { |
157 | 732 // Enable keypad (+ special keys) |
733 keypad(inputWnd, TRUE); | |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
734 nodelay(inputWnd, TRUE); |
157 | 735 |
151 | 736 // Create panels |
737 rosterPanel = new_panel(rosterWnd); | |
738 chatPanel = new_panel(chatWnd); | |
739 logPanel = new_panel(logWnd); | |
711 | 740 chatstatusPanel = new_panel(chatstatusWnd); |
741 mainstatusPanel = new_panel(mainstatusWnd); | |
151 | 742 inputPanel = new_panel(inputWnd); |
232 | 743 |
744 if (utf8_mode) | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
745 scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!"); |
157 | 746 } else { |
747 // Update panels | |
748 replace_panel(rosterPanel, rosterWnd); | |
749 replace_panel(chatPanel, chatWnd); | |
750 replace_panel(logPanel, logWnd); | |
711 | 751 replace_panel(chatstatusPanel, chatstatusWnd); |
752 replace_panel(mainstatusPanel, mainstatusWnd); | |
157 | 753 replace_panel(inputPanel, inputWnd); |
151 | 754 } |
755 | |
756 // We'll need to redraw the roster | |
149 | 757 update_roster = TRUE; |
24 | 758 return; |
759 } | |
760 | |
151 | 761 // scr_Resize() |
762 // Function called when the window is resized. | |
157 | 763 // - Resize windows |
151 | 764 // - Rewrap lines in each buddy buffer |
765 void scr_Resize() | |
766 { | |
767 struct list_head *pos, *n; | |
768 window_entry_t *search_entry; | |
769 int x, y, lines, cols; | |
770 | |
771 // First, update the global variables | |
772 getmaxyx(stdscr, maxY, maxX); | |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
773 // 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
|
774 |
151 | 775 // Make sure the cursor stays inside the window |
776 check_offset(0); | |
777 | |
157 | 778 // Resize windows and update panels |
151 | 779 scr_DrawMainWindow(FALSE); |
780 | |
781 // Resize all buddy windows | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
782 x = Roster_Width; |
151 | 783 y = 0; |
784 lines = CHAT_WIN_HEIGHT; | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
785 cols = maxX - Roster_Width; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
786 if (cols < 1) cols = 1; |
151 | 787 |
788 list_for_each_safe(pos, n, &window_list) { | |
789 search_entry = window_entry(pos); | |
790 if (search_entry->win) { | |
189 | 791 GList *rescue_top; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
792 // Resize/move buddy window |
157 | 793 wresize(search_entry->win, lines, cols); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
794 mvwin(search_entry->win, 0, Roster_Width); |
168 | 795 werase(search_entry->win); |
151 | 796 // If a panel exists, replace the old window with the new |
797 if (search_entry->panel) { | |
798 replace_panel(search_entry->panel, search_entry->win); | |
799 } | |
800 // Redo line wrapping | |
189 | 801 rescue_top = hbuf_previous_persistent(search_entry->top); |
151 | 802 hbuf_rebuild(&search_entry->hbuf, |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
803 maxX - Roster_Width - PREFIX_WIDTH); |
388
f211238d5812
Ctrl-l does a full refresh
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
804 if (g_list_position(g_list_first(search_entry->hbuf), |
f211238d5812
Ctrl-l does a full refresh
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
805 search_entry->top) == -1) { |
189 | 806 search_entry->top = rescue_top; |
388
f211238d5812
Ctrl-l does a full refresh
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
807 } |
151 | 808 } |
809 } | |
810 | |
811 // Refresh current buddy window | |
157 | 812 if (chatmode) |
151 | 813 scr_ShowBuddyWindow(); |
814 } | |
815 | |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
816 // scr_UpdateChatStatus(forceupdate) |
713 | 817 // Redraw the buddy status bar. |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
818 // Set forceupdate to TRUE if doupdate() 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
|
819 void scr_UpdateChatStatus(int forceupdate) |
713 | 820 { |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
821 unsigned short btype, isgrp, ismuc; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
822 const char *fullname; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
823 const char *msg = NULL; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
824 char status; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
825 char *buf; |
713 | 826 |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
827 // 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
|
828 // at least to refresh the pending message flag. |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
829 scr_UpdateMainStatus(FALSE); |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
830 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
831 fullname = buddy_getname(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
832 btype = buddy_gettype(BUDDATA(current_buddy)); |
713 | 833 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
834 isgrp = btype & ROSTER_TYPE_GROUP; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
835 ismuc = btype & ROSTER_TYPE_ROOM; |
713 | 836 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
837 // Clear the line |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
838 werase(chatstatusWnd); |
713 | 839 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
840 if (chatmode) |
720
e5269eb416bb
Change chatmode status flag to '~'
Mikael Berthe <mikael@lilotux.net>
parents:
718
diff
changeset
|
841 wprintw(chatstatusWnd, "~"); |
713 | 842 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
843 if (isgrp) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
844 mvwprintw(chatstatusWnd, 0, 5, "Group: %s", fullname); |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
845 if (forceupdate) { |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
846 update_panels(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
847 doupdate(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
848 } |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
849 return; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
850 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
851 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
852 status = '?'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
853 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
854 if (ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
855 if (buddy_getinsideroom(BUDDATA(current_buddy))) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
856 status = 'C'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
857 else |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
858 status = 'x'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
859 } else if (jb_getstatus() != offline) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
860 enum imstatus budstate; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
861 budstate = buddy_getstatus(BUDDATA(current_buddy), NULL); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
862 if (budstate >= 0 && budstate < imstatus_size) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
863 status = imstatus2char[budstate]; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
864 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
865 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
866 // No status message for groups & MUC rooms |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
867 if (!isgrp && !ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
868 GSList *resources = buddy_getresources(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
869 if (resources) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
870 msg = buddy_getstatusmsg(BUDDATA(current_buddy), resources->data); |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
871 } else if (ismuc) { |
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
872 msg = buddy_gettopic(BUDDATA(current_buddy)); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
873 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
874 if (!msg) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
875 msg = ""; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
876 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
877 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
|
878 replace_nl_with_dots(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
879 mvwprintw(chatstatusWnd, 0, 1, "%s", buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
880 g_free(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
881 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
882 if (forceupdate) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
883 update_panels(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
884 doupdate(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
885 } |
713 | 886 } |
887 | |
143 | 888 // scr_DrawRoster() |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
889 // Display the buddylist (not really the roster) on the screen |
81 | 890 void scr_DrawRoster(void) |
24 | 891 { |
735 | 892 static int offset = 0; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
893 char *name, *rline; |
81 | 894 int maxx, maxy; |
895 GList *buddy; | |
896 int i, n; | |
897 int rOffset; | |
713 | 898 int cursor_backup; |
899 char status, pending; | |
164 | 900 enum imstatus currentstatus = jb_getstatus(); |
81 | 901 |
123 | 902 // We can reset update_roster |
903 update_roster = FALSE; | |
904 | |
81 | 905 getmaxyx(rosterWnd, maxy, maxx); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
906 maxx--; // Last char is for vertical border |
81 | 907 |
713 | 908 cursor_backup = curs_set(0); |
909 | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
910 if (!buddylist) |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
911 offset = 0; |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
912 else |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
913 scr_UpdateChatStatus(FALSE); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
914 |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
915 // Cleanup of roster window |
168 | 916 werase(rosterWnd); |
81 | 917 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
918 if (Roster_Width) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
919 // Redraw the vertical line (not very good...) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
920 wattrset(rosterWnd, get_color(COLOR_GENERAL)); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
921 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
922 mvwaddch(rosterWnd, i, Roster_Width-1, ACS_VLINE); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
923 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
924 |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
925 // 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
|
926 if (!buddylist || !Roster_Width) { |
123 | 927 update_panels(); |
928 doupdate(); | |
713 | 929 curs_set(cursor_backup); |
81 | 930 return; |
931 } | |
932 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
933 name = g_new0(char, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
934 |
84 | 935 // Update offset if necessary |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
936 // 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
|
937 i = g_list_length(buddylist) - maxy; |
682
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
938 if (i < 0) |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
939 i = 0; |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
940 if (i < offset) |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
941 offset = i; |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
942 // b) Make sure the current_buddy is visible |
84 | 943 i = g_list_position(buddylist, current_buddy); |
944 if (i == -1) { // This is bad | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
945 scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
946 g_free(name); |
713 | 947 curs_set(cursor_backup); |
84 | 948 return; |
949 } else if (i < offset) { | |
950 offset = i; | |
951 } else if (i+1 > offset + maxy) { | |
952 offset = i + 1 - maxy; | |
953 } | |
81 | 954 |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
955 rline = g_new0(char, Roster_Width+1); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
956 |
81 | 957 buddy = buddylist; |
958 rOffset = offset; | |
959 | |
84 | 960 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { |
713 | 961 unsigned short bflags, btype, ismsg, isgrp, ismuc, ishid; |
962 | |
963 bflags = buddy_getflags(BUDDATA(buddy)); | |
964 btype = buddy_gettype(BUDDATA(buddy)); | |
965 | |
966 ismsg = bflags & ROSTER_FLAG_MSG; | |
967 ishid = bflags & ROSTER_FLAG_HIDE; | |
968 isgrp = btype & ROSTER_TYPE_GROUP; | |
969 ismuc = btype & ROSTER_TYPE_ROOM; | |
81 | 970 |
971 if (rOffset > 0) { | |
972 rOffset--; | |
973 continue; | |
974 } | |
975 | |
713 | 976 status = '?'; |
977 pending = ' '; | |
978 | |
149 | 979 // Display message notice if there is a message flag, but not |
980 // for unfolded groups. | |
981 if (ismsg && (!isgrp || ishid)) { | |
81 | 982 pending = '#'; |
983 } | |
984 | |
713 | 985 if (ismuc) { |
986 if (buddy_getinsideroom(BUDDATA(buddy))) | |
987 status = 'C'; | |
988 else | |
989 status = 'x'; | |
990 } else if (currentstatus != offline) { | |
991 enum imstatus budstate; | |
992 budstate = buddy_getstatus(BUDDATA(buddy), NULL); | |
993 if (budstate >= 0 && budstate < imstatus_size) | |
994 status = imstatus2char[budstate]; | |
995 } | |
81 | 996 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
|
997 if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
998 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
|
999 else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1000 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
|
1001 // The 3 following lines aim at coloring the whole line |
81 | 1002 wmove(rosterWnd, i, 0); |
1003 for (n = 0; n < maxx; n++) | |
1004 waddch(rosterWnd, ' '); | |
1005 } else { | |
149 | 1006 if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1007 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
139 | 1008 else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1009 wattrset(rosterWnd, get_color(COLOR_ROSTER)); |
81 | 1010 } |
1011 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1012 if (Roster_Width > 7) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1013 strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1014 else |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1015 name[0] = 0; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1016 |
149 | 1017 if (isgrp) { |
133 | 1018 char *sep; |
149 | 1019 if (ishid) |
133 | 1020 sep = "+++"; |
1021 else | |
1022 sep = "---"; | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1023 snprintf(rline, Roster_Width, " %c%s %s", pending, sep, name); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1024 } else { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1025 snprintf(rline, Roster_Width, " %c[%c] %s", pending, status, name); |
133 | 1026 } |
84 | 1027 |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1028 mvwprintw(rosterWnd, i, 0, "%s", rline); |
84 | 1029 i++; |
81 | 1030 } |
1031 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1032 g_free(rline); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1033 g_free(name); |
142 | 1034 top_panel(inputPanel); |
81 | 1035 update_panels(); |
1036 doupdate(); | |
713 | 1037 curs_set(cursor_backup); |
24 | 1038 } |
1039 | |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1040 // scr_RosterVisibility(status) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1041 // Set the roster visibility: |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1042 // status=1 Show roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1043 // status=0 Hide roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1044 // status=-1 Toggle roster status |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1045 void scr_RosterVisibility(int status) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1046 { |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1047 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
|
1048 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1049 if (status > 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1050 roster_hidden = FALSE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1051 else if (status == 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1052 roster_hidden = TRUE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1053 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1054 roster_hidden = !roster_hidden; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1055 |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1056 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
|
1057 if (roster_hidden) { |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1058 // Enter chat mode |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1059 scr_set_chatmode(TRUE); |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1060 scr_ShowBuddyWindow(); |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1061 } |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1062 // 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
|
1063 scr_Resize(); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1064 redrawwin(stdscr); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1065 } |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1066 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1067 |
480 | 1068 inline void scr_WriteMessage(const char *jid, const char *text, |
1069 time_t timestamp, guint prefix_flags) | |
24 | 1070 { |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
1071 char *xtext; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1072 |
726 | 1073 if (!timestamp) timestamp = time(NULL); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1074 |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
1075 xtext = ut_expand_tabs(text); // Expand tabs |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1076 |
726 | 1077 // XXX Are there other special chars we should filter out? |
1078 | |
1079 scr_WriteInWindow(jid, xtext, timestamp, prefix_flags, FALSE); | |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1080 |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1081 if (xtext != (char*)text) |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1082 g_free(xtext); |
24 | 1083 } |
1084 | |
726 | 1085 // If prefix is NULL, HBB_PREFIX_IN is supposed. |
1086 void scr_WriteIncomingMessage(const char *jidfrom, const char *text, | |
1087 time_t timestamp, guint prefix) | |
1088 { | |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
1089 if (!(prefix & ~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT)) |
726 | 1090 prefix |= HBB_PREFIX_IN; |
1091 | |
1092 scr_WriteMessage(jidfrom, text, timestamp, prefix); | |
1093 update_panels(); | |
1094 doupdate(); | |
1095 } | |
1096 | |
50 | 1097 void scr_WriteOutgoingMessage(const char *jidto, const char *text) |
47 | 1098 { |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1099 scr_WriteMessage(jidto, text, 0, HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT); |
47 | 1100 scr_ShowWindow(jidto); |
1101 } | |
1102 | |
735 | 1103 inline void set_autoaway(bool setaway) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1104 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1105 static enum imstatus oldstatus; |
521 | 1106 static char *oldmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1107 Autoaway = setaway; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1108 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1109 if (setaway) { |
521 | 1110 const char *msg, *prevmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1111 oldstatus = jb_getstatus(); |
521 | 1112 if (oldmsg) { |
1113 g_free(oldmsg); | |
1114 oldmsg = NULL; | |
1115 } | |
1116 prevmsg = jb_getstatusmsg(); | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1117 msg = settings_opt_get("message_autoaway"); |
521 | 1118 if (!msg) |
1119 msg = prevmsg; | |
1120 if (prevmsg) | |
1121 oldmsg = g_strdup(prevmsg); | |
444 | 1122 jb_setstatus(away, NULL, msg); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1123 } else { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1124 // Back |
521 | 1125 jb_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : "")); |
1126 if (oldmsg) { | |
1127 g_free(oldmsg); | |
1128 oldmsg = NULL; | |
1129 } | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1130 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1131 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1132 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1133 // Check if we should enter/leave automatic away status |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1134 void scr_CheckAutoAway(bool activity) |
24 | 1135 { |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1136 static time_t LastActivity; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1137 enum imstatus cur_st; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1138 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1139 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1140 if (Autoaway && activity) set_autoaway(FALSE); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1141 if (!autoaway_timeout) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1142 if (!LastActivity || activity) time(&LastActivity); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1143 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1144 cur_st = jb_getstatus(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1145 // Auto-away is disabled for the following states |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1146 if ((cur_st != available) && (cur_st != freeforchat)) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1147 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1148 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1149 if (!activity) { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1150 time_t now; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1151 time(&now); |
735 | 1152 if (!Autoaway && (now > LastActivity + (time_t)autoaway_timeout)) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1153 set_autoaway(TRUE); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1154 } |
24 | 1155 } |
1156 | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1157 // set_current_buddy(newbuddy) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1158 // 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
|
1159 // 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
|
1160 static void set_current_buddy(GList *newbuddy) |
24 | 1161 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1162 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
|
1163 /* 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
|
1164 * 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
|
1165 * buddy_getstatus() call. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1166 */ |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1167 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1168 if (!current_buddy || !newbuddy) return; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1169 if (newbuddy == current_buddy) return; |
24 | 1170 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
1171 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
|
1172 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
330 | 1173 if (chatmode) |
1174 alternate_buddy = current_buddy; | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1175 current_buddy = newbuddy; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1176 // 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
|
1177 if (chatmode) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1178 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
|
1179 // 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
|
1180 // 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
|
1181 // 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
|
1182 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
|
1183 buddylist_build(); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1184 update_roster = TRUE; |
24 | 1185 } |
1186 | |
143 | 1187 // scr_RosterTop() |
1188 // Go to the first buddy in the buddylist | |
105 | 1189 void scr_RosterTop(void) |
104 | 1190 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1191 set_current_buddy(buddylist); |
104 | 1192 if (chatmode) |
1193 scr_ShowBuddyWindow(); | |
1194 } | |
1195 | |
143 | 1196 // scr_RosterBottom() |
1197 // Go to the last buddy in the buddylist | |
105 | 1198 void scr_RosterBottom(void) |
104 | 1199 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1200 set_current_buddy(g_list_last(buddylist)); |
104 | 1201 if (chatmode) |
1202 scr_ShowBuddyWindow(); | |
1203 } | |
1204 | |
143 | 1205 // scr_RosterUp() |
1206 // Go to the previous buddy in the buddylist | |
105 | 1207 void scr_RosterUp(void) |
81 | 1208 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1209 set_current_buddy(g_list_previous(current_buddy)); |
104 | 1210 if (chatmode) |
1211 scr_ShowBuddyWindow(); | |
81 | 1212 } |
1213 | |
143 | 1214 // scr_RosterDown() |
1215 // Go to the next buddy in the buddylist | |
105 | 1216 void scr_RosterDown(void) |
81 | 1217 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1218 set_current_buddy(g_list_next(current_buddy)); |
104 | 1219 if (chatmode) |
1220 scr_ShowBuddyWindow(); | |
81 | 1221 } |
1222 | |
265 | 1223 // scr_RosterSearch(str) |
1224 // Look forward for a buddy with jid/name containing str. | |
1225 void scr_RosterSearch(char *str) | |
1226 { | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1227 set_current_buddy(buddy_search(str)); |
265 | 1228 if (chatmode) |
1229 scr_ShowBuddyWindow(); | |
1230 } | |
1231 | |
480 | 1232 // scr_RosterJumpJid(jid) |
1233 // Jump to buddy jid. | |
1234 // NOTE: With this function, the buddy is added to the roster if doesn't exist. | |
1235 void scr_RosterJumpJid(char *barejid) | |
1236 { | |
1237 GSList *roster_elt; | |
1238 // Look for an existing buddy | |
1239 roster_elt = roster_find(barejid, jidsearch, | |
1240 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); | |
1241 // Create it if necessary | |
1242 if (!roster_elt) | |
603 | 1243 roster_elt = roster_add_user(barejid, NULL, NULL, ROSTER_TYPE_USER, |
1244 sub_none); | |
480 | 1245 // Set a lock to see it in the buddylist |
1246 buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); | |
1247 buddylist_build(); | |
1248 // Jump to the buddy | |
1249 set_current_buddy(buddy_search_jid(barejid)); | |
1250 if (chatmode) | |
1251 scr_ShowBuddyWindow(); | |
1252 } | |
1253 | |
236 | 1254 // scr_RosterUnreadMessage(next) |
1255 // Go to a new message. If next is not null, try to go to the next new | |
1256 // message. If it is not possible or if next is NULL, go to the first new | |
1257 // message from unread_list. | |
1258 void scr_RosterUnreadMessage(int next) | |
1259 { | |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1260 gpointer unread_ptr; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1261 gpointer refbuddata; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1262 gpointer ngroup; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1263 GList *nbuddy; |
236 | 1264 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1265 if (!current_buddy) return; |
236 | 1266 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1267 if (next) refbuddata = BUDDATA(current_buddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1268 else refbuddata = NULL; |
236 | 1269 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1270 unread_ptr = unread_msg(refbuddata); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1271 if (!unread_ptr) return; |
236 | 1272 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1273 // If buddy is in a folded group, we need to expand it |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1274 ngroup = buddy_getgroup(unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1275 if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1276 buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1277 buddylist_build(); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1278 } |
236 | 1279 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1280 nbuddy = g_list_find(buddylist, unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1281 if (nbuddy) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1282 set_current_buddy(nbuddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1283 if (chatmode) scr_ShowBuddyWindow(); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1284 } else |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1285 scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
236 | 1286 } |
1287 | |
330 | 1288 // scr_RosterJumpAlternate() |
1289 // Try to jump to alternate (== previous) buddy | |
1290 void scr_RosterJumpAlternate(void) | |
105 | 1291 { |
330 | 1292 if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
1293 return; | |
1294 set_current_buddy(alternate_buddy); | |
1295 if (chatmode) | |
1296 scr_ShowBuddyWindow(); | |
1297 } | |
1298 | |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
1299 // scr_BufferScrollUpDown() |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1300 // Scroll up/down the current buddy window, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1301 // - half a screen if nblines is 0, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1302 // - up if updown == -1, down if updown == 1 |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1303 void scr_BufferScrollUpDown(int updown, unsigned int nblines) |
105 | 1304 { |
1305 window_entry_t *win_entry; | |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1306 int n, nbl; |
105 | 1307 GList *hbuf_top; |
1308 | |
1309 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1310 if (!current_buddy) return; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1311 win_entry = scr_SearchWindow(CURRENT_JID); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1312 if (!win_entry) return; |
105 | 1313 |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1314 if (!nblines) { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1315 // Scroll half a screen (or less) |
512 | 1316 nbl = CHAT_WIN_HEIGHT/2; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1317 } else { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1318 nbl = nblines; |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1319 } |
105 | 1320 hbuf_top = win_entry->top; |
1321 | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1322 if (updown == -1) { // UP |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1323 if (!hbuf_top) { |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1324 hbuf_top = g_list_last(win_entry->hbuf); |
512 | 1325 if (!win_entry->cleared) { |
1326 if (!nblines) nbl = nbl*3 - 1; | |
1327 else nbl += CHAT_WIN_HEIGHT - 1; | |
1328 } else { | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1329 win_entry->cleared = FALSE; |
512 | 1330 } |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1331 } |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1332 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
|
1333 hbuf_top = g_list_previous(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1334 win_entry->top = hbuf_top; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1335 } else { // DOWN |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1336 for (n=0 ; hbuf_top && n < nbl ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1337 hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1338 win_entry->top = hbuf_top; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1339 // Check if we are at the bottom |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1340 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1341 hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1342 if (!hbuf_top) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1343 win_entry->top = NULL; // End reached |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1344 } |
105 | 1345 |
1346 // Refresh the window | |
1347 scr_UpdateWindow(win_entry); | |
1348 | |
1349 // Finished :) | |
1350 update_panels(); | |
1351 doupdate(); | |
1352 } | |
1353 | |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
1354 // scr_BufferClear() |
143 | 1355 // 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
|
1356 void scr_BufferClear(void) |
108 | 1357 { |
1358 window_entry_t *win_entry; | |
1359 | |
1360 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1361 if (!current_buddy) return; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1362 win_entry = scr_SearchWindow(CURRENT_JID); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1363 if (!win_entry) return; |
108 | 1364 |
1365 win_entry->cleared = TRUE; | |
109 | 1366 win_entry->top = NULL; |
108 | 1367 |
1368 // Refresh the window | |
1369 scr_UpdateWindow(win_entry); | |
1370 | |
1371 // Finished :) | |
1372 update_panels(); | |
1373 doupdate(); | |
1374 } | |
1375 | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1376 // scr_BufferTopBottom() |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1377 // Jump to the head/tail of the current buddy window |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1378 // (top if topbottom == -1, bottom topbottom == 1) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1379 void scr_BufferTopBottom(int topbottom) |
187 | 1380 { |
1381 window_entry_t *win_entry; | |
1382 | |
1383 // Get win_entry | |
1384 if (!current_buddy) return; | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1385 win_entry = scr_SearchWindow(CURRENT_JID); |
187 | 1386 if (!win_entry) return; |
1387 | |
1388 win_entry->cleared = FALSE; | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1389 if (topbottom == 1) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1390 win_entry->top = NULL; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1391 else |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1392 win_entry->top = g_list_first(win_entry->hbuf); |
187 | 1393 |
1394 // Refresh the window | |
1395 scr_UpdateWindow(win_entry); | |
1396 | |
1397 // Finished :) | |
1398 update_panels(); | |
1399 doupdate(); | |
1400 } | |
1401 | |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1402 // scr_BufferSearch(direction, text) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1403 // Jump to the next line containing text |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1404 // (backward search if direction == -1, forward if topbottom == 1) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1405 void scr_BufferSearch(int direction, const char *text) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1406 { |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1407 window_entry_t *win_entry; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1408 GList *current_line, *search_res; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1409 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1410 // Get win_entry |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1411 if (!current_buddy) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1412 win_entry = scr_SearchWindow(CURRENT_JID); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1413 if (!win_entry) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1414 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1415 if (win_entry->top) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1416 current_line = win_entry->top; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1417 else |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1418 current_line = g_list_last(win_entry->hbuf); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1419 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1420 search_res = hbuf_search(current_line, direction, text); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1421 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1422 if (search_res) { |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1423 win_entry->cleared = FALSE; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1424 win_entry->top = search_res; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1425 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1426 // Refresh the window |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1427 scr_UpdateWindow(win_entry); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1428 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1429 // Finished :) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1430 update_panels(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1431 doupdate(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1432 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1433 scr_LogPrint(LPRINT_NORMAL, "Search string not found"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1434 } |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1435 |
462 | 1436 // scr_BufferPercent(n) |
1437 // Jump to the specified position in the buffer, in % | |
1438 void scr_BufferPercent(int pc) | |
1439 { | |
1440 window_entry_t *win_entry; | |
1441 GList *search_res; | |
1442 | |
1443 // Get win_entry | |
1444 if (!current_buddy) return; | |
1445 win_entry = scr_SearchWindow(CURRENT_JID); | |
1446 if (!win_entry) return; | |
1447 | |
1448 if (pc < 0 || pc > 100) { | |
1449 scr_LogPrint(LPRINT_NORMAL, "Bad % value"); | |
1450 return; | |
1451 } | |
1452 | |
1453 search_res = hbuf_jump_percent(win_entry->hbuf, pc); | |
1454 | |
1455 win_entry->cleared = FALSE; | |
1456 win_entry->top = search_res; | |
1457 | |
1458 // Refresh the window | |
1459 scr_UpdateWindow(win_entry); | |
1460 | |
1461 // Finished :) | |
1462 update_panels(); | |
1463 doupdate(); | |
1464 } | |
1465 | |
464 | 1466 // scr_BufferDate(t) |
1467 // Jump to the first line after date t in the buffer | |
1468 // t is a date in seconds since `00:00:00 1970-01-01 UTC' | |
1469 void scr_BufferDate(time_t t) | |
1470 { | |
1471 window_entry_t *win_entry; | |
1472 GList *search_res; | |
1473 | |
1474 // Get win_entry | |
1475 if (!current_buddy) return; | |
1476 win_entry = scr_SearchWindow(CURRENT_JID); | |
1477 if (!win_entry) return; | |
1478 | |
1479 search_res = hbuf_jump_date(win_entry->hbuf, t); | |
1480 | |
1481 win_entry->cleared = FALSE; | |
1482 win_entry->top = search_res; | |
1483 | |
1484 // Refresh the window | |
1485 scr_UpdateWindow(win_entry); | |
1486 | |
1487 // Finished :) | |
1488 update_panels(); | |
1489 doupdate(); | |
1490 } | |
1491 | |
143 | 1492 // scr_set_chatmode() |
261 | 1493 // Public function to (un)set chatmode... |
129 | 1494 inline void scr_set_chatmode(int enable) |
1495 { | |
1496 chatmode = enable; | |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1497 scr_UpdateChatStatus(TRUE); |
129 | 1498 } |
1499 | |
238 | 1500 // scr_get_multimode() |
261 | 1501 // Public function to get multimode status... |
238 | 1502 inline int scr_get_multimode() |
1503 { | |
1504 return multimode; | |
1505 } | |
1506 | |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1507 // 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
|
1508 // Set the message flag unless we're already in the jid buffer window |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1509 void scr_setmsgflag_if_needed(const char *jid) |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1510 { |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1511 const char *current_jid; |
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1512 |
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1513 if (current_buddy) |
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1514 current_jid = buddy_getjid(BUDDATA(current_buddy)); |
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1515 else |
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1516 current_jid = NULL; |
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1517 if (!chatmode || !current_jid || strcmp(jid, current_jid)) |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1518 roster_msg_setflag(jid, TRUE); |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1519 } |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1520 |
238 | 1521 // scr_set_multimode() |
261 | 1522 // Public function to (un)set multimode... |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
1523 // Convention: |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
1524 // 0 = disabled / 1 = multimode / 2 = multimode verbatim (commands disabled) |
238 | 1525 inline void scr_set_multimode(int enable) |
1526 { | |
1527 if (multiline) { | |
1528 g_free(multiline); | |
1529 multiline = NULL; | |
1530 } | |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
1531 multimode = enable; |
238 | 1532 } |
1533 | |
1534 // scr_get_multiline() | |
261 | 1535 // Public function to get the current multi-line. |
238 | 1536 inline const char *scr_get_multiline() |
1537 { | |
1538 if (multimode && multiline) | |
1539 return multiline; | |
1540 else | |
1541 return ""; | |
1542 } | |
1543 | |
1544 // scr_append_multiline(line) | |
1545 // Public function to append a line to the current multi-line message. | |
1546 // Skip empty leading lines. | |
1547 void scr_append_multiline(const char *line) | |
1548 { | |
1549 static int num; | |
1550 | |
1551 if (!multimode) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1552 scr_LogPrint(LPRINT_NORMAL, "Error: Not in multi-line message mode!"); |
238 | 1553 return; |
1554 } | |
1555 if (multiline) { | |
1556 int len = strlen(multiline)+strlen(line)+2; | |
252 | 1557 if (len >= HBB_BLOCKSIZE - 1) { |
238 | 1558 // We don't handle single messages with size > HBB_BLOCKSIZE |
1559 // (see hbuf) | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1560 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
|
1561 "this line has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1562 scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
238 | 1563 return; |
1564 } | |
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
1565 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
|
1566 // 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
|
1567 // (It should be < 1000 yet) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1568 scr_LogPrint(LPRINT_NORMAL, "Your message has too many lines, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1569 "this one has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1570 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
|
1571 return; |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
1572 } |
238 | 1573 multiline = g_renew(char, multiline, len); |
1574 strcat(multiline, "\n"); | |
1575 strcat(multiline, line); | |
1576 num++; | |
1577 } else { | |
1578 // First message line (we skip leading empty lines) | |
1579 num = 0; | |
1580 if (line[0]) { | |
419 | 1581 multiline = g_strdup(line); |
238 | 1582 num++; |
1583 } else | |
1584 return; | |
1585 } | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1586 scr_LogPrint(LPRINT_NORMAL, "Multi-line mode: line #%d added [%.25s...", |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1587 num, line); |
238 | 1588 } |
1589 | |
173 | 1590 // scr_cmdhisto_addline() |
1591 // Add a line to the inputLine history | |
1592 inline void scr_cmdhisto_addline(char *line) | |
1593 { | |
1594 if (!line || !*line) return; | |
1595 | |
1596 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); | |
1597 } | |
1598 | |
1599 // scr_cmdhisto_prev() | |
1600 // Look for previous line beginning w/ the given mask in the inputLine history | |
175 | 1601 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1602 static const char *scr_cmdhisto_prev(char *mask, guint len) |
173 | 1603 { |
1604 GList *hl; | |
1605 if (!cmdhisto_cur) { | |
1606 hl = g_list_last(cmdhisto); | |
174 | 1607 if (hl) { // backup current line |
1608 strncpy(cmdhisto_backup, mask, INPUTLINE_LENGTH); | |
1609 } | |
173 | 1610 } else { |
1611 hl = g_list_previous(cmdhisto_cur); | |
1612 } | |
1613 while (hl) { | |
1614 if (!strncmp((char*)hl->data, mask, len)) { | |
1615 // Found a match | |
1616 cmdhisto_cur = hl; | |
1617 return (const char*)hl->data; | |
1618 } | |
1619 hl = g_list_previous(hl); | |
1620 } | |
1621 return NULL; | |
1622 } | |
1623 | |
1624 // scr_cmdhisto_next() | |
1625 // Look for next line beginning w/ the given mask in the inputLine history | |
175 | 1626 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1627 static const char *scr_cmdhisto_next(char *mask, guint len) |
173 | 1628 { |
1629 GList *hl; | |
1630 if (!cmdhisto_cur) return NULL; | |
1631 hl = cmdhisto_cur; | |
1632 while ((hl = g_list_next(hl)) != NULL) | |
1633 if (!strncmp((char*)hl->data, mask, len)) { | |
1634 // Found a match | |
1635 cmdhisto_cur = hl; | |
1636 return (const char*)hl->data; | |
1637 } | |
175 | 1638 // If the "backuped" line matches, we'll use it |
1639 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match | |
174 | 1640 cmdhisto_cur = NULL; |
1641 return cmdhisto_backup; | |
173 | 1642 } |
1643 | |
195 | 1644 // readline_transpose_chars() |
1645 // Drag the character before point forward over the character at | |
1646 // point, moving point forward as well. If point is at the end of | |
1647 // the line, then this transposes the two characters before point. | |
1648 void readline_transpose_chars() | |
1649 { | |
1650 char swp; | |
1651 | |
1652 if (ptr_inputline == inputLine) return; | |
1653 | |
1654 if (!*ptr_inputline) { // We're at EOL | |
1655 // If line is only 1 char long, nothing to do... | |
1656 if (ptr_inputline == inputLine+1) return; | |
1657 // Transpose the two previous characters | |
1658 swp = *(ptr_inputline-2); | |
1659 *(ptr_inputline-2) = *(ptr_inputline-1); | |
1660 *(ptr_inputline-1) = swp; | |
1661 } else { | |
196 | 1662 // Swap the two characters before the cursor and move right. |
195 | 1663 swp = *(ptr_inputline-1); |
1664 *(ptr_inputline-1) = *ptr_inputline; | |
1665 *ptr_inputline++ = swp; | |
1666 check_offset(1); | |
1667 } | |
1668 } | |
1669 | |
1670 // readline_backward_kill_word() | |
194 | 1671 // Kill the word before the cursor, in input line |
195 | 1672 void readline_backward_kill_word() |
194 | 1673 { |
1674 char *c, *old = ptr_inputline; | |
1675 int spaceallowed = 1; | |
1676 | |
1677 if (ptr_inputline == inputLine) return; | |
1678 | |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1679 for (c = ptr_inputline-1 ; c > inputLine ; c--) { |
194 | 1680 if (!isalnum(*c)) { |
1681 if (*c == ' ') | |
1682 if (!spaceallowed) break; | |
1683 } 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
|
1684 } |
194 | 1685 |
1686 if (c != inputLine || *c != ' ') | |
1687 if ((c < ptr_inputline-1) && (!isalnum(*c))) | |
1688 c++; | |
1689 | |
1690 // Modify the line | |
1691 ptr_inputline = c; | |
1692 for (;;) { | |
1693 *c = *old++; | |
1694 if (!*c++) break; | |
1695 } | |
195 | 1696 check_offset(-1); |
194 | 1697 } |
1698 | |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1699 // 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
|
1700 // Move back to the start of the current or previous word |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1701 void 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
|
1702 { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1703 char *old_ptr_inputLine = ptr_inputline; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1704 int spaceallowed = 1; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1705 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1706 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
|
1707 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1708 for (ptr_inputline-- ; ptr_inputline > inputLine ; ptr_inputline--) { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1709 if (!isalnum(*ptr_inputline)) { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1710 if (*ptr_inputline == ' ') |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1711 if (!spaceallowed) break; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1712 } else spaceallowed = 0; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1713 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1714 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1715 if (ptr_inputline < old_ptr_inputLine-1 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1716 && *ptr_inputline == ' ' && *(ptr_inputline+1) != ' ') |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1717 ptr_inputline++; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1718 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1719 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
|
1720 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1721 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1722 // 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
|
1723 // Move forward to the end of the next word |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1724 void 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
|
1725 { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1726 int spaceallowed = 1; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1727 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1728 while (*ptr_inputline) { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1729 ptr_inputline++; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1730 if (!isalnum(*ptr_inputline)) { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1731 if (*ptr_inputline == ' ') |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1732 if (!spaceallowed) break; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1733 } else spaceallowed = 0; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1734 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1735 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1736 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
|
1737 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1738 |
98 | 1739 // which_row() |
1740 // 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
|
1741 // -2 -> normal text |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1742 // -1 -> room: nickname completion |
98 | 1743 // 0 -> command |
1744 // 1 -> parameter 1 (etc.) | |
102 | 1745 // 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
|
1746 static int which_row(const char **p_row) |
98 | 1747 { |
1748 int row = -1; | |
1749 char *p; | |
1750 int quote = FALSE; | |
1751 | |
1752 // Not a command? | |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1753 if ((ptr_inputline == inputLine) || (inputLine[0] != '/')) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1754 if (!current_buddy) return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1755 if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_ROOM) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1756 *p_row = inputLine; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1757 return -1; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1758 } |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1759 return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1760 } |
98 | 1761 |
1762 // This is a command | |
1763 row = 0; | |
1764 for (p = inputLine ; p < ptr_inputline ; p++) { | |
1765 if (quote) { | |
1766 if (*p == '"' && *(p-1) != '\\') | |
1767 quote = FALSE; | |
1768 continue; | |
1769 } | |
1770 if (*p == '"' && *(p-1) != '\\') { | |
1771 quote = TRUE; | |
121 | 1772 } else if (*p == ' ') { |
1773 if (*(p-1) != ' ') | |
1774 row++; | |
102 | 1775 *p_row = p+1; |
1776 } | |
98 | 1777 } |
1778 return row; | |
1779 } | |
1780 | |
143 | 1781 // scr_insert_text() |
1782 // Insert the given text at the current cursor position. | |
1783 // The cursor is moved. We don't check if the cursor still is in the screen | |
1784 // after, the caller should do that. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1785 static void scr_insert_text(const char *text) |
98 | 1786 { |
1787 char tmpLine[INPUTLINE_LENGTH+1]; | |
1788 int len = strlen(text); | |
1789 // Check the line isn't too long | |
1790 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1791 scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
98 | 1792 return; |
1793 } | |
1794 | |
1795 strcpy(tmpLine, ptr_inputline); | |
419 | 1796 strcpy(ptr_inputline, text); |
1797 ptr_inputline += len; | |
98 | 1798 strcpy(ptr_inputline, tmpLine); |
1799 } | |
1800 | |
143 | 1801 // scr_handle_tab() |
1802 // Function called when tab is pressed. | |
1803 // Initiate or continue a completion... | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1804 static void scr_handle_tab(void) |
98 | 1805 { |
102 | 1806 int nrow; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1807 const char *row; |
102 | 1808 const char *cchar; |
103 | 1809 guint compl_categ; |
98 | 1810 |
740 | 1811 row = inputLine; // (Kills a GCC warning) |
102 | 1812 nrow = which_row(&row); |
98 | 1813 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1814 // a) No completion if no leading slash ('cause not a command), |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1815 // unless this is a room (then, it is a nickname completion) |
103 | 1816 // 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
|
1817 if ((nrow == -2) || (nrow == 3 && !completion_started) || nrow > 3) |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1818 return; |
102 | 1819 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1820 if (nrow == 0) { // Command completion |
103 | 1821 row = &inputLine[1]; |
1822 compl_categ = COMPL_CMD; | |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1823 } else if (nrow == -1) { // Nickname completion |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1824 compl_categ = COMPL_RESOURCE; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
1825 } else { // Other completion, depending on the command |
285 | 1826 int alias = FALSE; |
1827 cmd *com; | |
1828 char *xpline = expandalias(inputLine); | |
1829 com = cmd_get(xpline); | |
1830 if (xpline != inputLine) { | |
1831 // This is an alias, so we can't complete rows > 0 | |
1832 alias = TRUE; | |
1833 g_free(xpline); | |
1834 } | |
1835 if ((!com && (!alias || !completion_started)) || !row) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1836 scr_LogPrint(LPRINT_NORMAL, "I cannot complete that..."); |
103 | 1837 return; |
1838 } | |
285 | 1839 if (!alias) |
1840 compl_categ = com->completion_flags[nrow-1]; | |
1841 else | |
1842 compl_categ = 0; | |
103 | 1843 } |
1844 | |
1845 if (!completion_started) { | |
1846 GSList *list = compl_get_category_list(compl_categ); | |
1847 if (list) { | |
1848 char *prefix = g_strndup(row, ptr_inputline-row); | |
1849 // Init completion | |
1850 new_completion(prefix, list); | |
1851 g_free(prefix); | |
1852 // Now complete | |
98 | 1853 cchar = complete(); |
1854 if (cchar) | |
1855 scr_insert_text(cchar); | |
103 | 1856 completion_started = TRUE; |
98 | 1857 } |
103 | 1858 } else { // Completion already initialized |
1859 char *c; | |
1860 guint back = cancel_completion(); | |
1861 // Remove $back chars | |
1862 ptr_inputline -= back; | |
1863 c = ptr_inputline; | |
1864 for ( ; *c ; c++) | |
1865 *c = *(c+back); | |
1866 // Now complete again | |
1867 cchar = complete(); | |
1868 if (cchar) | |
1869 scr_insert_text(cchar); | |
102 | 1870 } |
98 | 1871 } |
1872 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1873 static void scr_cancel_current_completion(void) |
98 | 1874 { |
1875 char *c; | |
1876 guint back = cancel_completion(); | |
1877 // Remove $back chars | |
1878 ptr_inputline -= back; | |
1879 c = ptr_inputline; | |
1880 for ( ; *c ; c++) | |
1881 *c = *(c+back); | |
1882 } | |
1883 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1884 static void scr_end_current_completion(void) |
98 | 1885 { |
1886 done_completion(); | |
1887 completion_started = FALSE; | |
1888 } | |
1889 | |
24 | 1890 // check_offset(int direction) |
1891 // Check inputline_offset value, and make sure the cursor is inside the | |
1892 // screen. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1893 static inline void check_offset(int direction) |
24 | 1894 { |
1895 // Left side | |
1896 if (inputline_offset && direction <= 0) { | |
1897 while (ptr_inputline <= (char*)&inputLine + inputline_offset) { | |
1898 if (inputline_offset) { | |
1899 inputline_offset -= 5; | |
1900 if (inputline_offset < 0) | |
1901 inputline_offset = 0; | |
1902 } | |
1903 } | |
1904 } | |
1905 // Right side | |
1906 if (direction >= 0) { | |
1907 while (ptr_inputline >= inputline_offset + (char*)&inputLine + maxX) | |
1908 inputline_offset += 5; | |
1909 } | |
1910 } | |
1911 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1912 static inline void refresh_inputline(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1913 { |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1914 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1915 wclrtoeol(inputWnd); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1916 if (*ptr_inputline) |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1917 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1918 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1919 |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
1920 void scr_handle_CtrlC(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1921 { |
365
ddb6593bedc9
Fix segfault when mcabber receives an INT signal (Ctrl-C) early
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
1922 if (!Curses) return; |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
1923 // Leave multi-line mode |
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
1924 process_command("/msay abort"); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1925 // Same as Ctrl-g, now |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1926 scr_cancel_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1927 scr_end_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1928 check_offset(-1); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1929 refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1930 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
1931 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1932 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
|
1933 { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1934 keyseq *ks; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1935 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1936 // Let's make sure the length is correct |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1937 if (strlen(seqstr) > MAX_KEYSEQ_LENGTH) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1938 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
|
1939 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1940 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1941 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1942 ks = g_new0(keyseq, 1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1943 ks->seqstr = g_strdup(seqstr); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1944 ks->mkeycode = mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1945 ks->value = value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1946 keyseqlist = g_slist_append(keyseqlist, ks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1947 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1948 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1949 // match_keyseq(iseq, &ret) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1950 // Check if "iseq" is a known key escape sequence. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1951 // Return value: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1952 // -1 if "seq" matches no known sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1953 // 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
|
1954 // >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
|
1955 // and *ret is set to the matching keyseq structure. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1956 static inline guint match_keyseq(int *iseq, keyseq **ret) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1957 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1958 GSList *ksl; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1959 keyseq *ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1960 char *p, c; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1961 int *i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1962 int needmore = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1963 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1964 for (ksl = keyseqlist; ksl; ksl = g_slist_next(ksl)) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1965 ksp = ksl->data; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1966 p = ksp->seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1967 i = iseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1968 while (1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1969 c = (unsigned char)*i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1970 if (!*p && !c) { // Match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1971 (*ret) = ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1972 return ksp->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1973 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1974 if (!c) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1975 // iseq is too short |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1976 needmore = TRUE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1977 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1978 } else if (!*p || c != *p) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1979 // This isn't a match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1980 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1981 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1982 p++; i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1983 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1984 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1985 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1986 if (needmore) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1987 return 0; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1988 return -1; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1989 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1990 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1991 void scr_Getch(keycode *kcode) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1992 { |
769 | 1993 keyseq *mks = NULL; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1994 int ks[MAX_KEYSEQ_LENGTH+1]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1995 int i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1996 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1997 memset(kcode, 0, sizeof(keycode)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1998 memset(ks, 0, sizeof(ks)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
1999 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2000 kcode->value = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2001 if (kcode->value != 27) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2002 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2003 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2004 // Check for escape key sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2005 for (i=0; i < MAX_KEYSEQ_LENGTH; i++) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2006 int match; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2007 ks[i] = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2008 if (ks[i] == ERR) break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2009 match = match_keyseq(ks, &mks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2010 if (match == -1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2011 // 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
|
2012 i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2013 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2014 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2015 if (match > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2016 // We have a matching sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2017 kcode->mcode = mks->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2018 kcode->value = mks->value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2019 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2020 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2021 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2022 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2023 // No match. Let's return a meta-key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2024 if (i > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2025 kcode->mcode = MKEY_META; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2026 kcode->value = ks[0]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2027 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2028 if (i > 1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2029 // 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
|
2030 while (i-- > 1) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2031 ungetch(ks[i]); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2032 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2033 return; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2034 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2035 |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2036 static int bindcommand(keycode kcode) { |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2037 gchar asciikey[16]; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2038 const gchar *boundcmd; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2039 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2040 if (!kcode.mcode || kcode.mcode == MKEY_EQUIV) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2041 g_snprintf(asciikey, 15, "%d", kcode.value); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2042 else if (kcode.mcode == MKEY_META) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2043 g_snprintf(asciikey, 15, "M%d", kcode.value); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2044 else |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2045 g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2046 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2047 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2048 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2049 if (boundcmd) { |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2050 gchar *cmd = g_strdup_printf("/%s", boundcmd); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2051 scr_CheckAutoAway(TRUE); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2052 if (process_command(cmd)) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2053 return 255; // Quit |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2054 g_free(cmd); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2055 return 0; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2056 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2057 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2058 scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2059 if (utf8_mode) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2060 scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!"); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2061 return -1; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2062 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2063 |
44 | 2064 // process_key(key) |
2065 // 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
|
2066 int process_key(keycode kcode) |
24 | 2067 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2068 int key = kcode.value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2069 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2070 switch (kcode.mcode) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2071 case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2072 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2073 case MKEY_EQUIV: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2074 key = kcode.value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2075 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2076 case MKEY_META: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2077 key = ERR; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2078 switch (kcode.value) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2079 case 27: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2080 key = 27; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2081 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2082 default: |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2083 if (bindcommand(kcode) == 255) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2084 return 255; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2085 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2086 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2087 default: |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2088 if (bindcommand(kcode) == 255) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2089 return 255; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2090 key = ERR; // Do not process any further |
758 | 2091 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2092 |
758 | 2093 switch (key) { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2094 case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2095 case ERR: |
758 | 2096 break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2097 case 8: // Ctrl-h |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2098 case 127: // Backspace too |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2099 case KEY_BACKSPACE: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2100 if (ptr_inputline != (char*)&inputLine) { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2101 char *c = --ptr_inputline; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2102 for ( ; *c ; c++) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2103 *c = *(c+1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2104 check_offset(-1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2105 } |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2106 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2107 case KEY_DC:// Del |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2108 if (*ptr_inputline) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2109 strcpy(ptr_inputline, ptr_inputline+1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2110 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2111 case KEY_LEFT: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2112 if (ptr_inputline != (char*)&inputLine) { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2113 ptr_inputline--; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2114 check_offset(-1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2115 } |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2116 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2117 case KEY_RIGHT: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2118 if (*ptr_inputline) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2119 ptr_inputline++; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2120 check_offset(1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2121 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2122 case 7: // Ctrl-g |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2123 scr_cancel_current_completion(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2124 scr_end_current_completion(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2125 check_offset(-1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2126 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2127 case 9: // Tab |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2128 scr_handle_tab(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2129 check_offset(0); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2130 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2131 case 13: // Enter |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2132 case 15: // Ctrl-o ("accept-line-and-down-history") |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2133 scr_CheckAutoAway(TRUE); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2134 if (process_line(inputLine)) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2135 return 255; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2136 // Add line to history |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2137 scr_cmdhisto_addline(inputLine); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2138 // Reset the line |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2139 ptr_inputline = inputLine; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2140 *ptr_inputline = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2141 inputline_offset = 0; |
24 | 2142 |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2143 if (key == 13) // Enter |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2144 { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2145 // Reset history line pointer |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2146 cmdhisto_cur = NULL; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2147 } else { // down-history |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2148 // Use next history line instead of a blank line |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2149 const char *l = scr_cmdhisto_next("", 0); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2150 if (l) strcpy(inputLine, l); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2151 // Reset backup history line |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2152 cmdhisto_backup[0] = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2153 } |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2154 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2155 case KEY_UP: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2156 { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2157 const char *l = scr_cmdhisto_prev(inputLine, |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2158 ptr_inputline-inputLine); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2159 if (l) strcpy(inputLine, l); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2160 } |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2161 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2162 case KEY_DOWN: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2163 { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2164 const char *l = scr_cmdhisto_next(inputLine, |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2165 ptr_inputline-inputLine); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2166 if (l) strcpy(inputLine, l); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2167 } |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2168 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2169 case KEY_PPAGE: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2170 scr_CheckAutoAway(TRUE); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2171 scr_RosterUp(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2172 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2173 case KEY_NPAGE: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2174 scr_CheckAutoAway(TRUE); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2175 scr_RosterDown(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2176 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2177 case KEY_HOME: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2178 case 1: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2179 ptr_inputline = inputLine; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2180 inputline_offset = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2181 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2182 case 3: // Ctrl-C |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2183 scr_handle_CtrlC(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2184 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2185 case KEY_END: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2186 case 5: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2187 for (; *ptr_inputline; ptr_inputline++) ; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2188 check_offset(1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2189 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2190 case 21: // Ctrl-u |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2191 strcpy(inputLine, ptr_inputline); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2192 ptr_inputline = inputLine; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2193 inputline_offset = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2194 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2195 case KEY_EOL: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2196 case 11: // Ctrl-k |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2197 *ptr_inputline = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2198 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2199 case 16: // Ctrl-p |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2200 scr_BufferScrollUpDown(-1, 0); |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2201 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2202 case 14: // Ctrl-n |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2203 scr_BufferScrollUpDown(1, 0); |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2204 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2205 case 17: // Ctrl-q |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2206 scr_CheckAutoAway(TRUE); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2207 scr_RosterUnreadMessage(1); // next unread message |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2208 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2209 case 20: // Ctrl-t |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2210 readline_transpose_chars(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2211 break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2212 case 23: // Ctrl-w |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2213 readline_backward_kill_word(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2214 break; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2215 case 516: // Ctrl-Left |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2216 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
|
2217 break; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2218 case 518: // Ctrl-Right |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2219 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
|
2220 break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2221 case 12: // Ctrl-l |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2222 scr_CheckAutoAway(TRUE); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2223 scr_Resize(); |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2224 redrawwin(stdscr); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2225 break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2226 case KEY_RESIZE: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2227 scr_Resize(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2228 break; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2229 case 27: // ESC |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2230 scr_CheckAutoAway(TRUE); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2231 currentWindow = NULL; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2232 chatmode = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2233 if (current_buddy) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2234 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2235 scr_RosterVisibility(1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2236 scr_UpdateChatStatus(FALSE); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2237 top_panel(chatPanel); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2238 top_panel(inputPanel); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2239 update_panels(); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2240 break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2241 default: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2242 if (isprint(key)) { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2243 char tmpLine[INPUTLINE_LENGTH+1]; |
263 | 2244 |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2245 // Check the line isn't too long |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2246 if (strlen(inputLine) >= INPUTLINE_LENGTH) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2247 return 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2248 |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2249 // Insert char |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2250 strcpy(tmpLine, ptr_inputline); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2251 *ptr_inputline++ = key; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2252 strcpy(ptr_inputline, tmpLine); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2253 check_offset(1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2254 } else { |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2255 // Look for a key binding. |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2256 if (bindcommand(kcode) == 255) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2257 return 255; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2258 } |
24 | 2259 } |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2260 |
157 | 2261 if (completion_started && key != 9 && key != KEY_RESIZE) |
98 | 2262 scr_end_current_completion(); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2263 refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2264 if (!update_roster) |
157 | 2265 doupdate(); |
24 | 2266 return 0; |
2267 } | |
576 | 2268 |
580 | 2269 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |