24
|
1 #include <stdio.h> |
|
2 #include <stdlib.h> |
|
3 #include <string.h> |
|
4 #include <ncurses.h> |
|
5 #include <panel.h> |
|
6 #include <time.h> |
|
7 #include <ctype.h> |
|
8 #include <locale.h> |
|
9 |
|
10 #include "screen.h" |
81
|
11 #include "hbuf.h" |
47
|
12 #include "commands.h" |
95
|
13 #include "compl.h" |
81
|
14 #include "roster.h" |
24
|
15 #include "parsecfg.h" |
81
|
16 #include "utils.h" |
24
|
17 #include "list.h" |
|
18 |
|
19 #define window_entry(n) list_entry(n, window_entry_t, list) |
|
20 |
151
|
21 inline void check_offset(int); |
|
22 |
24
|
23 LIST_HEAD(window_list); |
|
24 |
|
25 typedef struct _window_entry_t { |
|
26 WINDOW *win; |
108
|
27 PANEL *panel; |
|
28 char *name; |
|
29 GList *hbuf; |
|
30 GList *top; // If top is not specified (NULL), we'll display the last lines |
|
31 char cleared; // For ex, user has issued a /clear command... |
24
|
32 struct list_head list; |
|
33 } window_entry_t; |
|
34 |
|
35 |
|
36 static WINDOW *rosterWnd, *chatWnd, *inputWnd; |
|
37 static WINDOW *logWnd, *logWnd_border; |
|
38 static PANEL *rosterPanel, *chatPanel, *inputPanel; |
|
39 static PANEL *logPanel, *logPanel_border; |
|
40 static int maxY, maxX; |
|
41 static window_entry_t *currentWindow; |
|
42 |
|
43 static int chatmode; |
30
|
44 int update_roster; |
24
|
45 |
|
46 static char inputLine[INPUTLINE_LENGTH+1]; |
|
47 static char *ptr_inputline; |
|
48 static short int inputline_offset; |
98
|
49 static int completion_started; |
24
|
50 |
|
51 |
99
|
52 /* Functions */ |
24
|
53 |
74
|
54 int scr_WindowWidth(WINDOW * win) |
24
|
55 { |
|
56 int x, y; |
|
57 getmaxyx(win, y, x); |
|
58 return x; |
|
59 } |
|
60 |
74
|
61 void scr_clear_box(WINDOW *win, int y, int x, int height, int width, int Color) |
|
62 { |
|
63 int i, j; |
|
64 |
|
65 wattrset(win, COLOR_PAIR(Color)); |
|
66 for (i = 0; i < height; i++) { |
|
67 wmove(win, y + i, x); |
|
68 for (j = 0; j < width; j++) |
|
69 wprintw(win, " "); |
|
70 } |
|
71 } |
|
72 |
24
|
73 void scr_draw_box(WINDOW * win, int y, int x, int height, int width, |
|
74 int Color, chtype box, chtype border) |
|
75 { |
|
76 int i, j; |
|
77 |
|
78 wattrset(win, COLOR_PAIR(Color)); |
|
79 for (i = 0; i < height; i++) { |
|
80 wmove(win, y + i, x); |
|
81 for (j = 0; j < width; j++) |
|
82 if (!i && !j) |
|
83 waddch(win, border | ACS_ULCORNER); |
|
84 else if (i == height - 1 && !j) |
|
85 waddch(win, border | ACS_LLCORNER); |
|
86 else if (!i && j == width - 1) |
|
87 waddch(win, box | ACS_URCORNER); |
|
88 else if (i == height - 1 && j == width - 1) |
|
89 waddch(win, box | ACS_LRCORNER); |
|
90 else if (!i) |
|
91 waddch(win, border | ACS_HLINE); |
|
92 else if (i == height - 1) |
|
93 waddch(win, box | ACS_HLINE); |
|
94 else if (!j) |
|
95 waddch(win, border | ACS_VLINE); |
|
96 else if (j == width - 1) |
|
97 waddch(win, box | ACS_VLINE); |
|
98 else |
|
99 waddch(win, box | ' '); |
|
100 } |
|
101 } |
|
102 |
|
103 int FindColor(char *name) |
|
104 { |
|
105 if (!strcmp(name, "default")) |
|
106 return -1; |
|
107 if (!strcmp(name, "black")) |
|
108 return COLOR_BLACK; |
|
109 if (!strcmp(name, "red")) |
|
110 return COLOR_RED; |
|
111 if (!strcmp(name, "green")) |
|
112 return COLOR_GREEN; |
|
113 if (!strcmp(name, "yellow")) |
|
114 return COLOR_YELLOW; |
|
115 if (!strcmp(name, "blue")) |
|
116 return COLOR_BLUE; |
|
117 if (!strcmp(name, "magenta")) |
|
118 return COLOR_MAGENTA; |
|
119 if (!strcmp(name, "cyan")) |
|
120 return COLOR_CYAN; |
|
121 if (!strcmp(name, "white")) |
|
122 return COLOR_WHITE; |
|
123 |
|
124 return -1; |
|
125 } |
|
126 |
|
127 void ParseColors(void) |
|
128 { |
|
129 char *colors[11] = { |
|
130 "", "", |
|
131 "borderlines", |
|
132 "jidonline", |
139
|
133 "newmsg", |
24
|
134 "jidofflineselected", |
|
135 "jidoffline", |
|
136 "text", |
|
137 NULL |
|
138 }; |
|
139 |
|
140 char *tmp = malloc(1024); |
|
141 char *color1; |
|
142 char *background = cfg_read("color_background"); |
|
143 char *backselected = cfg_read("color_backselected"); |
|
144 int i = 0; |
|
145 |
|
146 while (colors[i]) { |
|
147 sprintf(tmp, "color_%s", colors[i]); |
|
148 color1 = cfg_read(tmp); |
|
149 |
|
150 switch (i + 1) { |
|
151 case 1: |
|
152 init_pair(1, COLOR_BLACK, COLOR_WHITE); |
|
153 break; |
|
154 case 2: |
|
155 init_pair(2, COLOR_WHITE, COLOR_BLACK); |
|
156 break; |
|
157 case 3: |
|
158 init_pair(3, FindColor(color1), FindColor(background)); |
|
159 break; |
|
160 case 4: |
|
161 init_pair(4, FindColor(color1), FindColor(backselected)); |
|
162 break; |
|
163 case 5: |
|
164 init_pair(5, FindColor(color1), FindColor(background)); |
|
165 break; |
|
166 case 6: |
|
167 init_pair(6, FindColor(color1), FindColor(backselected)); |
|
168 break; |
|
169 case 7: |
|
170 init_pair(7, FindColor(color1), FindColor(background)); |
|
171 break; |
|
172 case 8: |
|
173 init_pair(8, FindColor(color1), FindColor(background)); |
|
174 break; |
|
175 } |
|
176 i++; |
|
177 } |
|
178 } |
|
179 |
|
180 |
151
|
181 window_entry_t *scr_CreateBuddyPanel(const char *title, int dont_show) |
24
|
182 { |
151
|
183 int x; |
|
184 int y; |
|
185 int lines; |
|
186 int cols; |
153
|
187 window_entry_t *tmp; |
|
188 |
|
189 do { |
|
190 tmp = calloc(1, sizeof(window_entry_t)); |
|
191 } while (!tmp); |
24
|
192 |
151
|
193 // Dimensions |
|
194 x = ROSTER_WIDTH; |
|
195 y = 0; |
|
196 lines = CHAT_WIN_HEIGHT; |
|
197 cols = maxX - ROSTER_WIDTH; |
|
198 |
24
|
199 tmp->win = newwin(lines, cols, y, x); |
154
|
200 while (!tmp->win) { |
|
201 usleep(250); |
|
202 tmp->win = newwin(lines, cols, y, x); |
|
203 } |
24
|
204 tmp->panel = new_panel(tmp->win); |
153
|
205 tmp->name = (char *) calloc(1, 96); |
|
206 strncpy(tmp->name, title, 96); |
76
|
207 scr_clear_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL); |
24
|
208 |
143
|
209 if (!dont_show) { |
24
|
210 currentWindow = tmp; |
|
211 } else { |
|
212 if (currentWindow) |
|
213 top_panel(currentWindow->panel); |
|
214 else |
|
215 top_panel(chatPanel); |
|
216 } |
143
|
217 update_panels(); |
24
|
218 |
|
219 list_add_tail(&tmp->list, &window_list); |
|
220 |
|
221 return tmp; |
|
222 } |
|
223 |
50
|
224 window_entry_t *scr_SearchWindow(const char *winId) |
24
|
225 { |
|
226 struct list_head *pos, *n; |
|
227 window_entry_t *search_entry = NULL; |
|
228 |
|
229 list_for_each_safe(pos, n, &window_list) { |
|
230 search_entry = window_entry(pos); |
|
231 if (search_entry->name) { |
|
232 if (!strcasecmp(search_entry->name, winId)) { |
|
233 return search_entry; |
|
234 } |
|
235 } |
|
236 } |
|
237 return NULL; |
|
238 } |
|
239 |
143
|
240 // scr_UpdateWindow() |
|
241 // (Re-)Display the given chat window. |
74
|
242 void scr_UpdateWindow(window_entry_t *win_entry) |
|
243 { |
|
244 int n; |
|
245 int width; |
|
246 char **lines; |
|
247 GList *hbuf_head; |
|
248 |
108
|
249 width = scr_WindowWidth(win_entry->win); |
|
250 |
|
251 // Should the window be empty? |
|
252 if (win_entry->cleared) { |
|
253 scr_clear_box(win_entry->win, 0, 0, CHAT_WIN_HEIGHT, width, COLOR_GENERAL); |
|
254 return; |
|
255 } |
|
256 |
105
|
257 // win_entry->top is the top message of the screen. If it set to NULL, we |
|
258 // are displaying the last messages. |
|
259 |
74
|
260 // We will show the last CHAT_WIN_HEIGHT lines. |
|
261 // Let's find out where it begins. |
105
|
262 if (!win_entry->top || |
|
263 (g_list_position(g_list_first(win_entry->hbuf), win_entry->top) == -1)) { |
|
264 // Move up CHAT_WIN_HEIGHT lines |
|
265 win_entry->hbuf = g_list_last(win_entry->hbuf); |
|
266 hbuf_head = win_entry->hbuf; |
|
267 win_entry->top = NULL; // (Just to make sure) |
|
268 n = 0; |
|
269 while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { |
|
270 hbuf_head = g_list_previous(hbuf_head); |
|
271 n++; |
|
272 } |
|
273 } else |
|
274 hbuf_head = win_entry->top; |
74
|
275 |
|
276 // Get the last CHAT_WIN_HEIGHT lines. |
|
277 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); |
|
278 |
|
279 // Display these lines |
|
280 wmove(win_entry->win, 0, 0); |
|
281 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { |
|
282 int r = width; |
75
|
283 if (*(lines+2*n)) { |
|
284 if (**(lines+2*n)) |
|
285 wprintw(win_entry->win, "%s", *(lines+2*n)); // prefix |
|
286 else { |
|
287 wprintw(win_entry->win, " "); |
|
288 r -= 12; |
|
289 } |
|
290 wprintw(win_entry->win, "%s", *(lines+2*n+1)); // line |
|
291 // Calculate the number of blank characters to empty the line |
|
292 r -= strlen(*(lines+2*n)) + strlen(*(lines+2*n+1)); |
|
293 } |
74
|
294 for ( ; r>0 ; r--) { |
|
295 wprintw(win_entry->win, " "); |
|
296 } |
|
297 //// wclrtoeol(win_entry->win); does not work :( |
|
298 } |
|
299 g_free(lines); |
|
300 } |
|
301 |
143
|
302 // scr_ShowWindow() |
|
303 // Display the chat window with the given identifier. |
50
|
304 void scr_ShowWindow(const char *winId) |
24
|
305 { |
74
|
306 window_entry_t *win_entry = scr_SearchWindow(winId); |
|
307 |
|
308 if (win_entry != NULL) { |
|
309 top_panel(win_entry->panel); |
|
310 currentWindow = win_entry; |
24
|
311 chatmode = TRUE; |
148
|
312 roster_msg_setflag(winId, FALSE); |
119
|
313 roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); |
30
|
314 update_roster = TRUE; |
74
|
315 |
105
|
316 // Refresh the window |
74
|
317 scr_UpdateWindow(win_entry); |
|
318 |
|
319 // Finished :) |
24
|
320 update_panels(); |
157
|
321 // doupdate(); (update_roster should be enough?) |
24
|
322 } else { |
|
323 top_panel(chatPanel); |
74
|
324 currentWindow = win_entry; // == NULL (current window empty) |
24
|
325 } |
142
|
326 |
|
327 top_panel(inputPanel); |
24
|
328 } |
|
329 |
143
|
330 // scr_ShowBuddyWindow() |
|
331 // Display the chat window buffer for the current buddy. |
24
|
332 void scr_ShowBuddyWindow(void) |
|
333 { |
105
|
334 const gchar *jid; |
140
|
335 |
105
|
336 if (!current_buddy) |
140
|
337 jid = NULL; |
|
338 else |
|
339 jid = CURRENT_JID; |
|
340 |
|
341 if (!jid) { |
|
342 top_panel(chatPanel); |
143
|
343 top_panel(inputPanel); |
140
|
344 currentWindow = NULL; |
105
|
345 return; |
140
|
346 } |
|
347 |
105
|
348 scr_ShowWindow(jid); |
24
|
349 } |
|
350 |
|
351 |
143
|
352 // scr_WriteInWindow() |
|
353 // Write some text in the winId window (this usually is a jid). |
|
354 // Lines are splitted when they are too long to fit in the chat window. |
|
355 // If this window doesn't exist, it is created. |
75
|
356 void scr_WriteInWindow(const char *winId, const char *text, int TimeStamp, |
|
357 const char *prefix, int force_show) |
24
|
358 { |
75
|
359 char *fullprefix = NULL; |
74
|
360 window_entry_t *win_entry; |
24
|
361 int dont_show = FALSE; |
|
362 |
75
|
363 // Prepare the prefix |
|
364 if (prefix || TimeStamp) { |
|
365 if (!prefix) prefix = ""; |
|
366 fullprefix = calloc(1, strlen(prefix)+16); |
|
367 if (TimeStamp) { |
|
368 time_t now = time(NULL); |
|
369 strftime(fullprefix, 12, "[%H:%M] ", localtime(&now)); |
|
370 } else { |
|
371 strcpy(fullprefix, " "); |
|
372 } |
|
373 strcat(fullprefix, prefix); |
74
|
374 } |
|
375 |
|
376 // Look for the window entry. |
|
377 win_entry = scr_SearchWindow(winId); |
|
378 |
|
379 // Do we have to really show the window? |
24
|
380 if (!chatmode) |
|
381 dont_show = TRUE; |
74
|
382 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24
|
383 dont_show = TRUE; |
|
384 |
74
|
385 // If the window entry doesn't exist yet, let's create it. |
|
386 if (win_entry == NULL) { |
151
|
387 win_entry = scr_CreateBuddyPanel(winId, dont_show); |
24
|
388 } |
|
389 |
75
|
390 hbuf_add_line(&win_entry->hbuf, text, fullprefix, |
74
|
391 maxX - scr_WindowWidth(rosterWnd) - 14); |
75
|
392 free(fullprefix); |
74
|
393 |
108
|
394 if (win_entry->cleared) { |
|
395 win_entry->cleared = 0; // The message must be displayed |
|
396 win_entry->top = g_list_last(win_entry->hbuf); |
|
397 } |
|
398 |
24
|
399 if (!dont_show) { |
74
|
400 // Show and refresh the window |
|
401 top_panel(win_entry->panel); |
|
402 scr_UpdateWindow(win_entry); |
142
|
403 top_panel(inputPanel); |
24
|
404 update_panels(); |
|
405 doupdate(); |
|
406 } else { |
148
|
407 roster_msg_setflag(winId, TRUE); |
30
|
408 update_roster = TRUE; |
24
|
409 } |
|
410 } |
|
411 |
|
412 void scr_InitCurses(void) |
|
413 { |
|
414 initscr(); |
|
415 noecho(); |
|
416 raw(); |
35
|
417 halfdelay(5); |
24
|
418 start_color(); |
|
419 use_default_colors(); |
|
420 |
|
421 ParseColors(); |
|
422 |
|
423 getmaxyx(stdscr, maxY, maxX); |
|
424 inputLine[0] = 0; |
|
425 ptr_inputline = inputLine; |
|
426 |
35
|
427 setlocale(LC_CTYPE, ""); |
24
|
428 |
|
429 return; |
|
430 } |
|
431 |
81
|
432 void scr_TerminateCurses(void) |
|
433 { |
|
434 clear(); |
|
435 refresh(); |
|
436 endwin(); |
|
437 return; |
|
438 } |
|
439 |
151
|
440 // scr_DrawMainWindow() |
157
|
441 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151
|
442 // |
|
443 // I think it could be improved a _lot_ but I'm really not an ncurses |
|
444 // expert... :-\ Mikael. |
|
445 // |
|
446 void scr_DrawMainWindow(unsigned int fullinit) |
24
|
447 { |
74
|
448 int l; |
|
449 |
157
|
450 if (fullinit) { |
|
451 /* Create windows */ |
|
452 rosterWnd = newwin(CHAT_WIN_HEIGHT, ROSTER_WIDTH, 0, 0); |
|
453 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH, 0, ROSTER_WIDTH); |
|
454 logWnd_border = newwin(LOG_WIN_HEIGHT, maxX, CHAT_WIN_HEIGHT, 0); |
|
455 logWnd = newwin(LOG_WIN_HEIGHT-2, maxX-2, CHAT_WIN_HEIGHT+1, 1); |
|
456 inputWnd = newwin(1, maxX, maxY-1, 0); |
|
457 } else { |
|
458 /* Resize windows */ |
|
459 wresize(rosterWnd, CHAT_WIN_HEIGHT, ROSTER_WIDTH); |
|
460 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH); |
|
461 |
|
462 wresize(logWnd_border, LOG_WIN_HEIGHT, maxX); |
|
463 wresize(logWnd, LOG_WIN_HEIGHT-2, maxX-2); |
|
464 mvwin(logWnd_border, CHAT_WIN_HEIGHT, 0); |
|
465 mvwin(logWnd, CHAT_WIN_HEIGHT+1, 1); |
|
466 |
|
467 wresize(inputWnd, 1, maxX); |
|
468 mvwin(inputWnd, maxY-1, 0); |
|
469 } |
151
|
470 |
|
471 /* Draw/init windows */ |
|
472 |
|
473 // - Clear roster and draw vertical line |
74
|
474 scr_clear_box(rosterWnd, 0, 0, CHAT_WIN_HEIGHT, ROSTER_WIDTH, |
|
475 COLOR_GENERAL); |
|
476 for (l=0 ; l < CHAT_WIN_HEIGHT ; l++) |
|
477 mvwaddch(rosterWnd, l, ROSTER_WIDTH-1, ACS_VLINE); |
24
|
478 |
151
|
479 // - Clear chat window |
74
|
480 scr_clear_box(chatWnd, 0, 0, CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH, |
|
481 COLOR_GENERAL); |
|
482 mvwprintw(chatWnd, 0, 0, "This is the status window"); |
24
|
483 |
151
|
484 // - Draw/clear the log window |
24
|
485 scr_draw_box(logWnd_border, 0, 0, LOG_WIN_HEIGHT, maxX, COLOR_GENERAL, 0, 0); |
|
486 wbkgd(logWnd, COLOR_PAIR(COLOR_GENERAL)); |
157
|
487 // Auto-scrolling in log window |
74
|
488 scrollok(logWnd, TRUE); |
24
|
489 |
|
490 |
151
|
491 if (fullinit) { |
157
|
492 // Enable keypad (+ special keys) |
|
493 keypad(inputWnd, TRUE); |
|
494 |
151
|
495 // Create panels |
|
496 rosterPanel = new_panel(rosterWnd); |
|
497 chatPanel = new_panel(chatWnd); |
|
498 logPanel_border = new_panel(logWnd_border); |
|
499 logPanel = new_panel(logWnd); |
|
500 inputPanel = new_panel(inputWnd); |
157
|
501 } else { |
|
502 // Update panels |
|
503 replace_panel(rosterPanel, rosterWnd); |
|
504 replace_panel(chatPanel, chatWnd); |
|
505 replace_panel(logPanel, logWnd); |
|
506 replace_panel(logPanel_border, logWnd_border); |
|
507 replace_panel(inputPanel, inputWnd); |
151
|
508 } |
|
509 |
|
510 // We'll need to redraw the roster |
149
|
511 update_roster = TRUE; |
24
|
512 return; |
|
513 } |
|
514 |
151
|
515 // scr_Resize() |
|
516 // Function called when the window is resized. |
157
|
517 // - Resize windows |
151
|
518 // - Rewrap lines in each buddy buffer |
|
519 void scr_Resize() |
|
520 { |
|
521 struct list_head *pos, *n; |
|
522 window_entry_t *search_entry; |
|
523 int x, y, lines, cols; |
|
524 |
|
525 // First, update the global variables |
|
526 getmaxyx(stdscr, maxY, maxX); |
|
527 // Make sure the cursor stays inside the window |
|
528 check_offset(0); |
|
529 |
157
|
530 // Resize windows and update panels |
151
|
531 scr_DrawMainWindow(FALSE); |
|
532 |
|
533 // Resize all buddy windows |
|
534 x = ROSTER_WIDTH; |
|
535 y = 0; |
|
536 lines = CHAT_WIN_HEIGHT; |
|
537 cols = maxX - ROSTER_WIDTH; |
|
538 |
|
539 list_for_each_safe(pos, n, &window_list) { |
|
540 search_entry = window_entry(pos); |
|
541 if (search_entry->win) { |
157
|
542 // Resize buddy window (no need to move it) |
|
543 wresize(search_entry->win, lines, cols); |
151
|
544 scr_clear_box(search_entry->win, 0, 0, lines, cols, COLOR_GENERAL); |
|
545 // If a panel exists, replace the old window with the new |
|
546 if (search_entry->panel) { |
|
547 replace_panel(search_entry->panel, search_entry->win); |
|
548 } |
|
549 // Redo line wrapping |
|
550 hbuf_rebuild(&search_entry->hbuf, |
|
551 maxX - scr_WindowWidth(rosterWnd) - 14); |
|
552 } |
|
553 } |
|
554 |
|
555 // Refresh current buddy window |
157
|
556 if (chatmode) |
151
|
557 scr_ShowBuddyWindow(); |
|
558 } |
|
559 |
143
|
560 // scr_DrawRoster() |
|
561 // Actually, display the buddylist on the screen. |
81
|
562 void scr_DrawRoster(void) |
24
|
563 { |
81
|
564 static guint offset = 0; |
|
565 char name[ROSTER_WIDTH]; |
|
566 int maxx, maxy; |
|
567 GList *buddy; |
|
568 int i, n; |
|
569 int rOffset; |
164
|
570 enum imstatus currentstatus = jb_getstatus(); |
81
|
571 |
123
|
572 // We can reset update_roster |
|
573 update_roster = FALSE; |
|
574 |
81
|
575 getmaxyx(rosterWnd, maxy, maxx); |
|
576 maxx --; // last char is for vertical border |
|
577 name[ROSTER_WIDTH-7] = 0; |
|
578 |
|
579 // cleanup of roster window |
|
580 wattrset(rosterWnd, COLOR_PAIR(COLOR_GENERAL)); |
|
581 for (i = 0; i < maxy; i++) { |
|
582 mvwprintw(rosterWnd, i, 0, ""); |
|
583 for (n = 0; n < maxx; n++) |
|
584 waddch(rosterWnd, ' '); |
|
585 } |
|
586 |
|
587 // Leave now if buddylist is empty |
|
588 if (!buddylist) { |
|
589 offset = 0; |
123
|
590 update_panels(); |
|
591 doupdate(); |
81
|
592 return; |
|
593 } |
|
594 |
84
|
595 // Update offset if necessary |
|
596 i = g_list_position(buddylist, current_buddy); |
|
597 if (i == -1) { // This is bad |
|
598 scr_LogPrint("Doh! Can't find current selected buddy!!"); |
123
|
599 update_panels(); |
|
600 doupdate(); |
84
|
601 return; |
|
602 } else if (i < offset) { |
|
603 offset = i; |
|
604 } else if (i+1 > offset + maxy) { |
|
605 offset = i + 1 - maxy; |
|
606 } |
81
|
607 |
|
608 buddy = buddylist; |
|
609 rOffset = offset; |
|
610 |
84
|
611 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { |
81
|
612 |
|
613 char status = '?'; |
|
614 char pending = ' '; |
|
615 enum imstatus budstate; |
149
|
616 unsigned short ismsg = buddy_getflags(BUDDATA(buddy)) & ROSTER_FLAG_MSG; |
|
617 unsigned short isgrp = buddy_gettype(BUDDATA(buddy)) & ROSTER_TYPE_GROUP; |
|
618 unsigned short ishid = buddy_getflags(BUDDATA(buddy)) & ROSTER_FLAG_HIDE; |
81
|
619 |
|
620 if (rOffset > 0) { |
|
621 rOffset--; |
|
622 continue; |
|
623 } |
|
624 |
149
|
625 // Display message notice if there is a message flag, but not |
|
626 // for unfolded groups. |
|
627 if (ismsg && (!isgrp || ishid)) { |
81
|
628 pending = '#'; |
|
629 } |
|
630 |
|
631 budstate = buddy_getstatus(BUDDATA(buddy)); |
164
|
632 if (budstate >= 0 && budstate < imstatus_size && currentstatus != offline) |
81
|
633 status = imstatus2char[budstate]; |
|
634 if (buddy == current_buddy) { |
|
635 wattrset(rosterWnd, COLOR_PAIR(COLOR_BD_DESSEL)); |
|
636 // The 3 following lines aim to color the whole line |
|
637 wmove(rosterWnd, i, 0); |
|
638 for (n = 0; n < maxx; n++) |
|
639 waddch(rosterWnd, ' '); |
|
640 } else { |
149
|
641 if (pending == '#') |
139
|
642 wattrset(rosterWnd, COLOR_PAIR(COLOR_NMSG)); |
|
643 else |
|
644 wattrset(rosterWnd, COLOR_PAIR(COLOR_BD_DES)); |
81
|
645 } |
|
646 |
|
647 strncpy(name, buddy_getname(BUDDATA(buddy)), ROSTER_WIDTH-7); |
149
|
648 if (isgrp) { |
133
|
649 char *sep; |
149
|
650 if (ishid) |
133
|
651 sep = "+++"; |
|
652 else |
|
653 sep = "---"; |
|
654 mvwprintw(rosterWnd, i, 0, " %c%s %s", pending, sep, name); |
|
655 } |
126
|
656 else |
|
657 mvwprintw(rosterWnd, i, 0, " %c[%c] %s", pending, status, name); |
84
|
658 |
|
659 i++; |
81
|
660 } |
|
661 |
142
|
662 top_panel(inputPanel); |
81
|
663 update_panels(); |
|
664 doupdate(); |
24
|
665 } |
|
666 |
50
|
667 void scr_WriteMessage(const char *jid, const char *text, char *prefix) |
24
|
668 { |
75
|
669 scr_WriteInWindow(jid, text, TRUE, prefix, FALSE); |
47
|
670 } |
|
671 |
50
|
672 void scr_WriteIncomingMessage(const char *jidfrom, const char *text) |
47
|
673 { |
75
|
674 // FIXME expand tabs / filter out special chars... |
115
|
675 scr_WriteMessage(jidfrom, text, "<== "); |
24
|
676 update_panels(); |
|
677 doupdate(); |
|
678 } |
|
679 |
50
|
680 void scr_WriteOutgoingMessage(const char *jidto, const char *text) |
47
|
681 { |
65
|
682 scr_WriteMessage(jidto, text, "--> "); |
47
|
683 scr_ShowWindow(jidto); |
|
684 } |
|
685 |
24
|
686 int scr_Getch(void) |
|
687 { |
|
688 int ch; |
|
689 ch = wgetch(inputWnd); |
|
690 return ch; |
|
691 } |
|
692 |
|
693 WINDOW *scr_GetRosterWindow(void) |
|
694 { |
|
695 return rosterWnd; |
|
696 } |
|
697 |
|
698 WINDOW *scr_GetStatusWindow(void) |
|
699 { |
|
700 return chatWnd; |
|
701 } |
|
702 |
|
703 WINDOW *scr_GetInputWindow(void) |
|
704 { |
|
705 return inputWnd; |
|
706 } |
|
707 |
143
|
708 // scr_RosterTop() |
|
709 // Go to the first buddy in the buddylist |
105
|
710 void scr_RosterTop(void) |
104
|
711 { |
143
|
712 enum imstatus prev_st = imstatus_size; // undef |
119
|
713 |
|
714 if (current_buddy) { |
|
715 prev_st = buddy_getstatus(BUDDATA(current_buddy)); |
|
716 if (chatmode) |
|
717 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
|
718 } |
104
|
719 current_buddy = buddylist; |
119
|
720 if (chatmode && current_buddy) |
|
721 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
722 |
|
723 // We should rebuild the buddylist but not everytime |
143
|
724 // Here we check if we were locking a buddy who is actually offline, |
|
725 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
120
|
726 if (current_buddy && prev_st == offline && |
|
727 buddylist_get_hide_offline_buddies()) |
119
|
728 buddylist_build(); |
104
|
729 if (chatmode) |
|
730 scr_ShowBuddyWindow(); |
143
|
731 update_roster = TRUE; |
104
|
732 } |
|
733 |
143
|
734 // scr_RosterBottom() |
|
735 // Go to the last buddy in the buddylist |
105
|
736 void scr_RosterBottom(void) |
104
|
737 { |
143
|
738 enum imstatus prev_st = imstatus_size; // undef |
119
|
739 |
|
740 if (current_buddy) { |
|
741 prev_st = buddy_getstatus(BUDDATA(current_buddy)); |
|
742 if (chatmode) |
|
743 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
|
744 } |
104
|
745 current_buddy = g_list_last(buddylist); |
143
|
746 // Lock the buddy in the buddylist if we're in chat mode |
119
|
747 if (chatmode && current_buddy) |
|
748 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
749 |
|
750 // We should rebuild the buddylist but not everytime |
143
|
751 // Here we check if we were locking a buddy who is actually offline, |
|
752 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
120
|
753 if (current_buddy && prev_st == offline && |
|
754 buddylist_get_hide_offline_buddies()) |
119
|
755 buddylist_build(); |
143
|
756 |
104
|
757 if (chatmode) |
|
758 scr_ShowBuddyWindow(); |
143
|
759 update_roster = TRUE; |
104
|
760 } |
|
761 |
143
|
762 // scr_RosterUp() |
|
763 // Go to the previous buddy in the buddylist |
105
|
764 void scr_RosterUp(void) |
81
|
765 { |
143
|
766 enum imstatus prev_st = imstatus_size; // undef |
119
|
767 |
81
|
768 if (current_buddy) { |
|
769 if (g_list_previous(current_buddy)) { |
120
|
770 prev_st = buddy_getstatus(BUDDATA(current_buddy)); |
119
|
771 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
81
|
772 current_buddy = g_list_previous(current_buddy); |
143
|
773 // Lock the buddy in the buddylist if we're in chat mode |
119
|
774 if (chatmode) |
|
775 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
776 // We should rebuild the buddylist but not everytime |
143
|
777 // Here we check if we were locking a buddy who is actually offline, |
|
778 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
120
|
779 if (prev_st == offline && buddylist_get_hide_offline_buddies()) |
119
|
780 buddylist_build(); |
143
|
781 update_roster = TRUE; |
81
|
782 } |
|
783 } |
104
|
784 |
|
785 if (chatmode) |
|
786 scr_ShowBuddyWindow(); |
81
|
787 } |
|
788 |
143
|
789 // scr_RosterDown() |
|
790 // Go to the next buddy in the buddylist |
105
|
791 void scr_RosterDown(void) |
81
|
792 { |
143
|
793 enum imstatus prev_st = imstatus_size; // undef |
119
|
794 |
81
|
795 if (current_buddy) { |
|
796 if (g_list_next(current_buddy)) { |
120
|
797 prev_st = buddy_getstatus(BUDDATA(current_buddy)); |
119
|
798 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
81
|
799 current_buddy = g_list_next(current_buddy); |
119
|
800 if (chatmode) |
|
801 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
802 // We should rebuild the buddylist but not everytime |
143
|
803 // Here we check if we were locking a buddy who is actually offline, |
|
804 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
120
|
805 if (prev_st == offline && buddylist_get_hide_offline_buddies()) |
119
|
806 buddylist_build(); |
143
|
807 update_roster = TRUE; |
81
|
808 } |
|
809 } |
104
|
810 |
|
811 if (chatmode) |
|
812 scr_ShowBuddyWindow(); |
81
|
813 } |
|
814 |
143
|
815 // scr_ScrollUp() |
|
816 // Scroll up the current buddy window, half a screen. |
105
|
817 void scr_ScrollUp(void) |
|
818 { |
|
819 const gchar *jid; |
|
820 window_entry_t *win_entry; |
|
821 int n, nblines; |
|
822 GList *hbuf_top; |
|
823 |
|
824 // Get win_entry |
|
825 if (!current_buddy) |
|
826 return; |
|
827 jid = CURRENT_JID; |
|
828 if (!jid) |
|
829 return; |
|
830 win_entry = scr_SearchWindow(jid); |
|
831 if (!win_entry) |
|
832 return; |
|
833 |
|
834 // Scroll up half a screen (or less) |
|
835 nblines = CHAT_WIN_HEIGHT/2-1; |
|
836 hbuf_top = win_entry->top; |
|
837 if (!hbuf_top) { |
|
838 hbuf_top = g_list_last(win_entry->hbuf); |
109
|
839 if (!win_entry->cleared) |
|
840 nblines *= 3; |
|
841 else |
|
842 win_entry->cleared = FALSE; |
105
|
843 } |
|
844 |
|
845 n = 0; |
|
846 while (hbuf_top && n < nblines && g_list_previous(hbuf_top)) { |
|
847 hbuf_top = g_list_previous(hbuf_top); |
|
848 n++; |
|
849 } |
|
850 win_entry->top = hbuf_top; |
|
851 |
|
852 // Refresh the window |
|
853 scr_UpdateWindow(win_entry); |
|
854 |
|
855 // Finished :) |
|
856 update_panels(); |
|
857 doupdate(); |
|
858 } |
|
859 |
143
|
860 // scr_ScrollDown() |
|
861 // Scroll down the current buddy window, half a screen. |
105
|
862 void scr_ScrollDown(void) |
|
863 { |
|
864 const gchar *jid; |
|
865 window_entry_t *win_entry; |
|
866 int n, nblines; |
|
867 GList *hbuf_top; |
|
868 |
|
869 // Get win_entry |
|
870 if (!current_buddy) |
|
871 return; |
|
872 jid = CURRENT_JID; |
|
873 if (!jid) |
|
874 return; |
|
875 win_entry = scr_SearchWindow(jid); |
|
876 if (!win_entry) |
|
877 return; |
|
878 |
|
879 // Scroll down half a screen (or less) |
|
880 nblines = CHAT_WIN_HEIGHT/2-1; |
|
881 hbuf_top = win_entry->top; |
|
882 |
|
883 for (n=0 ; hbuf_top && n < nblines ; n++) |
|
884 hbuf_top = g_list_next(hbuf_top); |
|
885 win_entry->top = hbuf_top; |
|
886 // Check if we are at the bottom |
|
887 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
|
888 hbuf_top = g_list_next(hbuf_top); |
|
889 if (!hbuf_top) |
|
890 win_entry->top = NULL; // End reached |
|
891 |
|
892 // Refresh the window |
|
893 scr_UpdateWindow(win_entry); |
|
894 |
|
895 // Finished :) |
|
896 update_panels(); |
|
897 doupdate(); |
|
898 } |
|
899 |
143
|
900 // scr_Clear() |
|
901 // Clear the current buddy window (used for the /clear command) |
108
|
902 void scr_Clear(void) |
|
903 { |
|
904 const gchar *jid; |
|
905 window_entry_t *win_entry; |
|
906 |
|
907 // Get win_entry |
|
908 if (!current_buddy) |
|
909 return; |
|
910 jid = CURRENT_JID; |
|
911 if (!jid) |
|
912 return; |
|
913 win_entry = scr_SearchWindow(jid); |
|
914 if (!win_entry) |
|
915 return; |
|
916 |
|
917 win_entry->cleared = TRUE; |
109
|
918 win_entry->top = NULL; |
108
|
919 |
|
920 // Refresh the window |
|
921 scr_UpdateWindow(win_entry); |
|
922 |
|
923 // Finished :) |
|
924 update_panels(); |
|
925 doupdate(); |
|
926 } |
|
927 |
44
|
928 // scr_LogPrint(...) |
|
929 // Display a message in the log window. |
24
|
930 void scr_LogPrint(const char *fmt, ...) |
|
931 { |
|
932 time_t timestamp; |
|
933 char *buffer; |
|
934 va_list ap; |
|
935 |
153
|
936 do { |
157
|
937 buffer = (char *) calloc(1, 1024); |
153
|
938 } while (!buffer); |
24
|
939 |
|
940 timestamp = time(NULL); |
|
941 strftime(buffer, 64, "[%H:%M:%S] ", localtime(×tamp)); |
|
942 wprintw(logWnd, "\n%s", buffer); |
|
943 |
|
944 va_start(ap, fmt); |
153
|
945 vsnprintf(buffer, 1024, fmt, ap); |
24
|
946 va_end(ap); |
|
947 |
|
948 wprintw(logWnd, "%s", buffer); |
|
949 free(buffer); |
|
950 |
|
951 update_panels(); |
|
952 doupdate(); |
|
953 } |
|
954 |
143
|
955 // scr_set_chatmode() |
|
956 // Public fonction to (un)set chatmode... |
129
|
957 inline void scr_set_chatmode(int enable) |
|
958 { |
|
959 chatmode = enable; |
|
960 } |
|
961 |
98
|
962 // which_row() |
|
963 // Tells which row our cursor is in, in the command line. |
|
964 // -1 -> normal text |
|
965 // 0 -> command |
|
966 // 1 -> parameter 1 (etc.) |
102
|
967 // If > 0, then *p_row is set to the beginning of the row |
|
968 int which_row(char **p_row) |
98
|
969 { |
|
970 int row = -1; |
|
971 char *p; |
|
972 int quote = FALSE; |
|
973 |
|
974 // Not a command? |
|
975 if ((ptr_inputline == inputLine) || (inputLine[0] != '/')) |
|
976 return -1; |
|
977 |
|
978 // This is a command |
|
979 row = 0; |
|
980 for (p = inputLine ; p < ptr_inputline ; p++) { |
|
981 if (quote) { |
|
982 if (*p == '"' && *(p-1) != '\\') |
|
983 quote = FALSE; |
|
984 continue; |
|
985 } |
|
986 if (*p == '"' && *(p-1) != '\\') { |
|
987 quote = TRUE; |
121
|
988 } else if (*p == ' ') { |
|
989 if (*(p-1) != ' ') |
|
990 row++; |
102
|
991 *p_row = p+1; |
|
992 } |
98
|
993 } |
|
994 return row; |
|
995 } |
|
996 |
143
|
997 // scr_insert_text() |
|
998 // Insert the given text at the current cursor position. |
|
999 // The cursor is moved. We don't check if the cursor still is in the screen |
|
1000 // after, the caller should do that. |
98
|
1001 void scr_insert_text(const char *text) |
|
1002 { |
|
1003 char tmpLine[INPUTLINE_LENGTH+1]; |
|
1004 int len = strlen(text); |
|
1005 // Check the line isn't too long |
|
1006 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { |
|
1007 scr_LogPrint("Cannot insert text, line too long."); |
|
1008 return; |
|
1009 } |
|
1010 |
|
1011 strcpy(tmpLine, ptr_inputline); |
|
1012 strcpy(ptr_inputline, text); ptr_inputline += len; |
|
1013 strcpy(ptr_inputline, tmpLine); |
|
1014 } |
|
1015 |
143
|
1016 // scr_handle_tab() |
|
1017 // Function called when tab is pressed. |
|
1018 // Initiate or continue a completion... |
98
|
1019 void scr_handle_tab(void) |
|
1020 { |
102
|
1021 int nrow; |
|
1022 char *row; |
|
1023 const char *cchar; |
103
|
1024 guint compl_categ; |
98
|
1025 |
102
|
1026 nrow = which_row(&row); |
98
|
1027 |
103
|
1028 // a) No completion if no leading slash ('cause not a command) |
|
1029 // b) We can't have more than 2 parameters (we use 2 flags) |
|
1030 if (nrow < 0 || nrow > 2) return; |
102
|
1031 |
103
|
1032 if (nrow == 0) { // Command completion |
|
1033 row = &inputLine[1]; |
|
1034 compl_categ = COMPL_CMD; |
|
1035 } else { // Other completion, depending on the command |
|
1036 cmd *com = cmd_get(inputLine); |
|
1037 if (!com || !row) { |
|
1038 scr_LogPrint("I cannot complete that..."); |
|
1039 return; |
|
1040 } |
|
1041 compl_categ = com->completion_flags[nrow-1]; |
|
1042 } |
|
1043 |
|
1044 if (!completion_started) { |
|
1045 GSList *list = compl_get_category_list(compl_categ); |
|
1046 if (list) { |
|
1047 char *prefix = g_strndup(row, ptr_inputline-row); |
|
1048 // Init completion |
|
1049 new_completion(prefix, list); |
|
1050 g_free(prefix); |
|
1051 // Now complete |
98
|
1052 cchar = complete(); |
|
1053 if (cchar) |
|
1054 scr_insert_text(cchar); |
103
|
1055 completion_started = TRUE; |
98
|
1056 } |
103
|
1057 } else { // Completion already initialized |
|
1058 char *c; |
|
1059 guint back = cancel_completion(); |
|
1060 // Remove $back chars |
|
1061 ptr_inputline -= back; |
|
1062 c = ptr_inputline; |
|
1063 for ( ; *c ; c++) |
|
1064 *c = *(c+back); |
|
1065 // Now complete again |
|
1066 cchar = complete(); |
|
1067 if (cchar) |
|
1068 scr_insert_text(cchar); |
102
|
1069 } |
98
|
1070 } |
|
1071 |
|
1072 void scr_cancel_current_completion(void) |
|
1073 { |
|
1074 char *c; |
|
1075 guint back = cancel_completion(); |
|
1076 // Remove $back chars |
|
1077 ptr_inputline -= back; |
|
1078 c = ptr_inputline; |
|
1079 for ( ; *c ; c++) |
|
1080 *c = *(c+back); |
|
1081 } |
|
1082 |
|
1083 void scr_end_current_completion(void) |
|
1084 { |
|
1085 done_completion(); |
|
1086 completion_started = FALSE; |
|
1087 } |
|
1088 |
24
|
1089 // check_offset(int direction) |
|
1090 // Check inputline_offset value, and make sure the cursor is inside the |
|
1091 // screen. |
|
1092 inline void check_offset(int direction) |
|
1093 { |
|
1094 // Left side |
|
1095 if (inputline_offset && direction <= 0) { |
|
1096 while (ptr_inputline <= (char*)&inputLine + inputline_offset) { |
|
1097 if (inputline_offset) { |
|
1098 inputline_offset -= 5; |
|
1099 if (inputline_offset < 0) |
|
1100 inputline_offset = 0; |
|
1101 } |
|
1102 } |
|
1103 } |
|
1104 // Right side |
|
1105 if (direction >= 0) { |
|
1106 while (ptr_inputline >= inputline_offset + (char*)&inputLine + maxX) |
|
1107 inputline_offset += 5; |
|
1108 } |
|
1109 } |
|
1110 |
44
|
1111 // process_key(key) |
|
1112 // Handle the pressed key, in the command line (bottom). |
29
|
1113 int process_key(int key) |
24
|
1114 { |
|
1115 if (isprint(key)) { |
|
1116 char tmpLine[INPUTLINE_LENGTH+1]; |
|
1117 |
|
1118 // Check the line isn't too long |
|
1119 if (strlen(inputLine) >= INPUTLINE_LENGTH) |
|
1120 return 0; |
|
1121 |
|
1122 // Insert char |
|
1123 strcpy(tmpLine, ptr_inputline); |
|
1124 *ptr_inputline++ = key; |
|
1125 strcpy(ptr_inputline, tmpLine); |
|
1126 check_offset(1); |
|
1127 } else { |
|
1128 switch(key) { |
|
1129 case KEY_BACKSPACE: |
|
1130 if (ptr_inputline != (char*)&inputLine) { |
42
|
1131 char *c = --ptr_inputline; |
|
1132 for ( ; *c ; c++) |
|
1133 *c = *(c+1); |
24
|
1134 check_offset(-1); |
|
1135 } |
|
1136 break; |
|
1137 case KEY_DC: |
|
1138 if (*ptr_inputline) |
|
1139 strcpy(ptr_inputline, ptr_inputline+1); |
|
1140 break; |
|
1141 case KEY_LEFT: |
|
1142 if (ptr_inputline != (char*)&inputLine) { |
|
1143 ptr_inputline--; |
|
1144 check_offset(-1); |
|
1145 } |
|
1146 break; |
|
1147 case KEY_RIGHT: |
|
1148 if (*ptr_inputline) |
|
1149 ptr_inputline++; |
|
1150 check_offset(1); |
|
1151 break; |
98
|
1152 case 7: // Ctrl-g |
|
1153 scr_cancel_current_completion(); |
|
1154 scr_end_current_completion(); |
|
1155 check_offset(-1); |
|
1156 break; |
24
|
1157 case 9: // Tab |
98
|
1158 scr_handle_tab(); |
|
1159 check_offset(0); |
24
|
1160 break; |
|
1161 case '\n': // Enter |
29
|
1162 if (process_line(inputLine)) |
24
|
1163 return 255; |
|
1164 ptr_inputline = inputLine; |
|
1165 *ptr_inputline = 0; |
|
1166 inputline_offset = 0; |
|
1167 break; |
|
1168 case KEY_UP: |
81
|
1169 scr_RosterUp(); |
24
|
1170 break; |
|
1171 case KEY_DOWN: |
81
|
1172 scr_RosterDown(); |
24
|
1173 break; |
|
1174 case KEY_PPAGE: |
105
|
1175 scr_ScrollUp(); |
24
|
1176 break; |
|
1177 case KEY_NPAGE: |
105
|
1178 scr_ScrollDown(); |
24
|
1179 break; |
|
1180 case KEY_HOME: |
|
1181 case 1: |
|
1182 ptr_inputline = inputLine; |
|
1183 inputline_offset = 0; |
|
1184 break; |
|
1185 case KEY_END: |
|
1186 case 5: |
|
1187 for (; *ptr_inputline; ptr_inputline++) ; |
|
1188 check_offset(1); |
|
1189 break; |
|
1190 case 21: // Ctrl-u |
|
1191 strcpy(inputLine, ptr_inputline); |
|
1192 ptr_inputline = inputLine; |
|
1193 inputline_offset = 0; |
|
1194 break; |
|
1195 case KEY_EOL: |
|
1196 case 11: // Ctrl-k |
|
1197 *ptr_inputline = 0; |
|
1198 break; |
|
1199 case 16: // Ctrl-p |
|
1200 scr_LogPrint("Ctrl-p not yet implemented"); |
|
1201 break; |
|
1202 case 14: // Ctrl-n |
|
1203 scr_LogPrint("Ctrl-n not yet implemented"); |
|
1204 break; |
|
1205 case 27: // ESC |
|
1206 currentWindow = NULL; |
|
1207 chatmode = FALSE; |
119
|
1208 if (current_buddy) |
|
1209 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
24
|
1210 top_panel(chatPanel); |
|
1211 top_panel(inputPanel); |
157
|
1212 update_panels(); |
24
|
1213 break; |
151
|
1214 case 12: // Ctrl-l |
|
1215 case KEY_RESIZE: |
|
1216 scr_Resize(); |
|
1217 break; |
24
|
1218 default: |
|
1219 scr_LogPrint("Unkown key=%d", key); |
|
1220 } |
|
1221 } |
157
|
1222 if (completion_started && key != 9 && key != KEY_RESIZE) |
98
|
1223 scr_end_current_completion(); |
24
|
1224 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset); |
|
1225 wclrtoeol(inputWnd); |
|
1226 if (*ptr_inputline) { |
|
1227 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset); |
|
1228 } |
157
|
1229 if (!update_roster) { |
|
1230 //update_panels(); |
|
1231 doupdate(); |
|
1232 } |
24
|
1233 return 0; |
|
1234 } |