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(); |
|
321 doupdate(); |
|
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() |
|
441 // Set fullinit to TRUE to also create panels |
|
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 |
151
|
450 /* Create windows */ |
74
|
451 rosterWnd = newwin(CHAT_WIN_HEIGHT, ROSTER_WIDTH, 0, 0); |
151
|
452 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH, 0, ROSTER_WIDTH); |
|
453 logWnd_border = newwin(LOG_WIN_HEIGHT, maxX, CHAT_WIN_HEIGHT, 0); |
|
454 logWnd = derwin(logWnd_border, LOG_WIN_HEIGHT-2, maxX-2, 1, 1); |
|
455 inputWnd = newwin(1, maxX, maxY-1, 0); |
|
456 |
|
457 /* Draw/init windows */ |
|
458 |
|
459 // - Clear roster and draw vertical line |
74
|
460 scr_clear_box(rosterWnd, 0, 0, CHAT_WIN_HEIGHT, ROSTER_WIDTH, |
|
461 COLOR_GENERAL); |
|
462 for (l=0 ; l < CHAT_WIN_HEIGHT ; l++) |
|
463 mvwaddch(rosterWnd, l, ROSTER_WIDTH-1, ACS_VLINE); |
24
|
464 |
151
|
465 // - Clear chat window |
74
|
466 scr_clear_box(chatWnd, 0, 0, CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH, |
|
467 COLOR_GENERAL); |
|
468 mvwprintw(chatWnd, 0, 0, "This is the status window"); |
24
|
469 |
151
|
470 // - Draw/clear the log window |
24
|
471 scr_draw_box(logWnd_border, 0, 0, LOG_WIN_HEIGHT, maxX, COLOR_GENERAL, 0, 0); |
|
472 wbkgd(logWnd, COLOR_PAIR(COLOR_GENERAL)); |
74
|
473 scrollok(logWnd, TRUE); |
24
|
474 |
151
|
475 // Enable keypad (+ special keys) |
|
476 keypad(inputWnd, TRUE); |
24
|
477 |
151
|
478 if (fullinit) { |
|
479 // Create panels |
|
480 rosterPanel = new_panel(rosterWnd); |
|
481 chatPanel = new_panel(chatWnd); |
|
482 logPanel_border = new_panel(logWnd_border); |
|
483 logPanel = new_panel(logWnd); |
|
484 inputPanel = new_panel(inputWnd); |
|
485 } |
|
486 |
|
487 // We'll need to redraw the roster |
149
|
488 update_roster = TRUE; |
24
|
489 return; |
|
490 } |
|
491 |
151
|
492 // scr_Resize() |
|
493 // Function called when the window is resized. |
|
494 // - Recreate windows |
|
495 // - Update panels |
|
496 // - Rewrap lines in each buddy buffer |
|
497 void scr_Resize() |
|
498 { |
|
499 WINDOW *w_roster, *w_chat, *w_log, *w_log_bord, *w_input; |
|
500 |
|
501 struct list_head *pos, *n; |
|
502 window_entry_t *search_entry; |
|
503 int x, y, lines, cols; |
|
504 |
|
505 // First, update the global variables |
|
506 getmaxyx(stdscr, maxY, maxX); |
|
507 // Make sure the cursor stays inside the window |
|
508 check_offset(0); |
|
509 |
|
510 // Backup pointers |
|
511 w_roster = rosterWnd; |
|
512 w_chat = chatWnd; |
|
513 w_log = logWnd; |
|
514 w_log_bord = logWnd_border; |
|
515 w_input = inputWnd; |
|
516 |
|
517 // Recreate windows |
|
518 scr_DrawMainWindow(FALSE); |
|
519 |
|
520 // Replace windows for panels |
|
521 replace_panel(rosterPanel, rosterWnd); |
|
522 replace_panel(chatPanel, chatWnd); |
|
523 replace_panel(logPanel, logWnd); |
|
524 replace_panel(logPanel_border, logWnd_border); |
|
525 replace_panel(inputPanel, inputWnd); |
|
526 |
|
527 // Destroy old windows |
|
528 delwin(w_roster); |
|
529 delwin(w_chat); |
|
530 delwin(w_log); |
|
531 delwin(w_log_bord); |
|
532 delwin(w_input); |
|
533 |
|
534 // Resize all buddy windows |
|
535 x = ROSTER_WIDTH; |
|
536 y = 0; |
|
537 lines = CHAT_WIN_HEIGHT; |
|
538 cols = maxX - ROSTER_WIDTH; |
|
539 |
|
540 list_for_each_safe(pos, n, &window_list) { |
|
541 search_entry = window_entry(pos); |
|
542 if (search_entry->win) { |
|
543 WINDOW *w_buddy = search_entry->win; |
|
544 // Create new window |
|
545 search_entry->win = newwin(lines, cols, y, x); |
|
546 scr_clear_box(search_entry->win, 0, 0, lines, cols, COLOR_GENERAL); |
|
547 // If a panel exists, replace the old window with the new |
|
548 if (search_entry->panel) { |
|
549 replace_panel(search_entry->panel, search_entry->win); |
|
550 } |
|
551 // Redo line wrapping |
|
552 hbuf_rebuild(&search_entry->hbuf, |
|
553 maxX - scr_WindowWidth(rosterWnd) - 14); |
|
554 // Delete old buddy window |
|
555 delwin(w_buddy); |
|
556 } |
|
557 } |
|
558 |
|
559 // Refresh current buddy window |
154
|
560 if (chatmode) { |
|
561 usleep(100); |
151
|
562 scr_ShowBuddyWindow(); |
154
|
563 } |
|
564 // NCurses is very bad wrt memory (can lead to segfaults) so let's slow |
|
565 // things down... |
|
566 usleep(200); |
151
|
567 } |
|
568 |
143
|
569 // scr_DrawRoster() |
|
570 // Actually, display the buddylist on the screen. |
81
|
571 void scr_DrawRoster(void) |
24
|
572 { |
81
|
573 static guint offset = 0; |
|
574 char name[ROSTER_WIDTH]; |
|
575 int maxx, maxy; |
|
576 GList *buddy; |
|
577 int i, n; |
|
578 int rOffset; |
|
579 |
123
|
580 // We can reset update_roster |
|
581 update_roster = FALSE; |
|
582 |
81
|
583 getmaxyx(rosterWnd, maxy, maxx); |
|
584 maxx --; // last char is for vertical border |
|
585 name[ROSTER_WIDTH-7] = 0; |
|
586 |
|
587 // cleanup of roster window |
|
588 wattrset(rosterWnd, COLOR_PAIR(COLOR_GENERAL)); |
|
589 for (i = 0; i < maxy; i++) { |
|
590 mvwprintw(rosterWnd, i, 0, ""); |
|
591 for (n = 0; n < maxx; n++) |
|
592 waddch(rosterWnd, ' '); |
|
593 } |
|
594 |
|
595 // Leave now if buddylist is empty |
|
596 if (!buddylist) { |
|
597 offset = 0; |
123
|
598 update_panels(); |
|
599 doupdate(); |
81
|
600 return; |
|
601 } |
|
602 |
84
|
603 // Update offset if necessary |
|
604 i = g_list_position(buddylist, current_buddy); |
|
605 if (i == -1) { // This is bad |
|
606 scr_LogPrint("Doh! Can't find current selected buddy!!"); |
123
|
607 update_panels(); |
|
608 doupdate(); |
84
|
609 return; |
|
610 } else if (i < offset) { |
|
611 offset = i; |
|
612 } else if (i+1 > offset + maxy) { |
|
613 offset = i + 1 - maxy; |
|
614 } |
81
|
615 |
|
616 buddy = buddylist; |
|
617 rOffset = offset; |
|
618 |
84
|
619 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { |
81
|
620 |
|
621 char status = '?'; |
|
622 char pending = ' '; |
|
623 enum imstatus budstate; |
149
|
624 unsigned short ismsg = buddy_getflags(BUDDATA(buddy)) & ROSTER_FLAG_MSG; |
|
625 unsigned short isgrp = buddy_gettype(BUDDATA(buddy)) & ROSTER_TYPE_GROUP; |
|
626 unsigned short ishid = buddy_getflags(BUDDATA(buddy)) & ROSTER_FLAG_HIDE; |
81
|
627 |
|
628 if (rOffset > 0) { |
|
629 rOffset--; |
|
630 continue; |
|
631 } |
|
632 |
149
|
633 // Display message notice if there is a message flag, but not |
|
634 // for unfolded groups. |
|
635 if (ismsg && (!isgrp || ishid)) { |
81
|
636 pending = '#'; |
|
637 } |
|
638 |
|
639 budstate = buddy_getstatus(BUDDATA(buddy)); |
|
640 if (budstate >= 0 && budstate < imstatus_size) |
|
641 status = imstatus2char[budstate]; |
|
642 if (buddy == current_buddy) { |
|
643 wattrset(rosterWnd, COLOR_PAIR(COLOR_BD_DESSEL)); |
|
644 // The 3 following lines aim to color the whole line |
|
645 wmove(rosterWnd, i, 0); |
|
646 for (n = 0; n < maxx; n++) |
|
647 waddch(rosterWnd, ' '); |
|
648 } else { |
149
|
649 if (pending == '#') |
139
|
650 wattrset(rosterWnd, COLOR_PAIR(COLOR_NMSG)); |
|
651 else |
|
652 wattrset(rosterWnd, COLOR_PAIR(COLOR_BD_DES)); |
81
|
653 } |
|
654 |
|
655 strncpy(name, buddy_getname(BUDDATA(buddy)), ROSTER_WIDTH-7); |
149
|
656 if (isgrp) { |
133
|
657 char *sep; |
149
|
658 if (ishid) |
133
|
659 sep = "+++"; |
|
660 else |
|
661 sep = "---"; |
|
662 mvwprintw(rosterWnd, i, 0, " %c%s %s", pending, sep, name); |
|
663 } |
126
|
664 else |
|
665 mvwprintw(rosterWnd, i, 0, " %c[%c] %s", pending, status, name); |
84
|
666 |
|
667 i++; |
81
|
668 } |
|
669 |
142
|
670 top_panel(inputPanel); |
81
|
671 update_panels(); |
|
672 doupdate(); |
24
|
673 } |
|
674 |
50
|
675 void scr_WriteMessage(const char *jid, const char *text, char *prefix) |
24
|
676 { |
75
|
677 scr_WriteInWindow(jid, text, TRUE, prefix, FALSE); |
47
|
678 } |
|
679 |
50
|
680 void scr_WriteIncomingMessage(const char *jidfrom, const char *text) |
47
|
681 { |
75
|
682 // FIXME expand tabs / filter out special chars... |
115
|
683 scr_WriteMessage(jidfrom, text, "<== "); |
24
|
684 update_panels(); |
|
685 doupdate(); |
|
686 } |
|
687 |
50
|
688 void scr_WriteOutgoingMessage(const char *jidto, const char *text) |
47
|
689 { |
65
|
690 scr_WriteMessage(jidto, text, "--> "); |
47
|
691 scr_ShowWindow(jidto); |
|
692 } |
|
693 |
24
|
694 int scr_Getch(void) |
|
695 { |
|
696 int ch; |
|
697 ch = wgetch(inputWnd); |
|
698 return ch; |
|
699 } |
|
700 |
|
701 WINDOW *scr_GetRosterWindow(void) |
|
702 { |
|
703 return rosterWnd; |
|
704 } |
|
705 |
|
706 WINDOW *scr_GetStatusWindow(void) |
|
707 { |
|
708 return chatWnd; |
|
709 } |
|
710 |
|
711 WINDOW *scr_GetInputWindow(void) |
|
712 { |
|
713 return inputWnd; |
|
714 } |
|
715 |
143
|
716 // scr_RosterTop() |
|
717 // Go to the first buddy in the buddylist |
105
|
718 void scr_RosterTop(void) |
104
|
719 { |
143
|
720 enum imstatus prev_st = imstatus_size; // undef |
119
|
721 |
|
722 if (current_buddy) { |
|
723 prev_st = buddy_getstatus(BUDDATA(current_buddy)); |
|
724 if (chatmode) |
|
725 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
|
726 } |
104
|
727 current_buddy = buddylist; |
119
|
728 if (chatmode && current_buddy) |
|
729 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
730 |
|
731 // We should rebuild the buddylist but not everytime |
143
|
732 // Here we check if we were locking a buddy who is actually offline, |
|
733 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
120
|
734 if (current_buddy && prev_st == offline && |
|
735 buddylist_get_hide_offline_buddies()) |
119
|
736 buddylist_build(); |
104
|
737 if (chatmode) |
|
738 scr_ShowBuddyWindow(); |
143
|
739 update_roster = TRUE; |
104
|
740 } |
|
741 |
143
|
742 // scr_RosterBottom() |
|
743 // Go to the last buddy in the buddylist |
105
|
744 void scr_RosterBottom(void) |
104
|
745 { |
143
|
746 enum imstatus prev_st = imstatus_size; // undef |
119
|
747 |
|
748 if (current_buddy) { |
|
749 prev_st = buddy_getstatus(BUDDATA(current_buddy)); |
|
750 if (chatmode) |
|
751 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
|
752 } |
104
|
753 current_buddy = g_list_last(buddylist); |
143
|
754 // Lock the buddy in the buddylist if we're in chat mode |
119
|
755 if (chatmode && current_buddy) |
|
756 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
757 |
|
758 // We should rebuild the buddylist but not everytime |
143
|
759 // Here we check if we were locking a buddy who is actually offline, |
|
760 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
120
|
761 if (current_buddy && prev_st == offline && |
|
762 buddylist_get_hide_offline_buddies()) |
119
|
763 buddylist_build(); |
143
|
764 |
104
|
765 if (chatmode) |
|
766 scr_ShowBuddyWindow(); |
143
|
767 update_roster = TRUE; |
104
|
768 } |
|
769 |
143
|
770 // scr_RosterUp() |
|
771 // Go to the previous buddy in the buddylist |
105
|
772 void scr_RosterUp(void) |
81
|
773 { |
143
|
774 enum imstatus prev_st = imstatus_size; // undef |
119
|
775 |
81
|
776 if (current_buddy) { |
|
777 if (g_list_previous(current_buddy)) { |
120
|
778 prev_st = buddy_getstatus(BUDDATA(current_buddy)); |
119
|
779 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
81
|
780 current_buddy = g_list_previous(current_buddy); |
143
|
781 // Lock the buddy in the buddylist if we're in chat mode |
119
|
782 if (chatmode) |
|
783 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
784 // We should rebuild the buddylist but not everytime |
143
|
785 // Here we check if we were locking a buddy who is actually offline, |
|
786 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
120
|
787 if (prev_st == offline && buddylist_get_hide_offline_buddies()) |
119
|
788 buddylist_build(); |
143
|
789 update_roster = TRUE; |
81
|
790 } |
|
791 } |
104
|
792 |
|
793 if (chatmode) |
|
794 scr_ShowBuddyWindow(); |
81
|
795 } |
|
796 |
143
|
797 // scr_RosterDown() |
|
798 // Go to the next buddy in the buddylist |
105
|
799 void scr_RosterDown(void) |
81
|
800 { |
143
|
801 enum imstatus prev_st = imstatus_size; // undef |
119
|
802 |
81
|
803 if (current_buddy) { |
|
804 if (g_list_next(current_buddy)) { |
120
|
805 prev_st = buddy_getstatus(BUDDATA(current_buddy)); |
119
|
806 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
81
|
807 current_buddy = g_list_next(current_buddy); |
119
|
808 if (chatmode) |
|
809 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
810 // We should rebuild the buddylist but not everytime |
143
|
811 // Here we check if we were locking a buddy who is actually offline, |
|
812 // and hide_offline_buddies is TRUE. In which case we need to rebuild. |
120
|
813 if (prev_st == offline && buddylist_get_hide_offline_buddies()) |
119
|
814 buddylist_build(); |
143
|
815 update_roster = TRUE; |
81
|
816 } |
|
817 } |
104
|
818 |
|
819 if (chatmode) |
|
820 scr_ShowBuddyWindow(); |
81
|
821 } |
|
822 |
143
|
823 // scr_ScrollUp() |
|
824 // Scroll up the current buddy window, half a screen. |
105
|
825 void scr_ScrollUp(void) |
|
826 { |
|
827 const gchar *jid; |
|
828 window_entry_t *win_entry; |
|
829 int n, nblines; |
|
830 GList *hbuf_top; |
|
831 |
|
832 // Get win_entry |
|
833 if (!current_buddy) |
|
834 return; |
|
835 jid = CURRENT_JID; |
|
836 if (!jid) |
|
837 return; |
|
838 win_entry = scr_SearchWindow(jid); |
|
839 if (!win_entry) |
|
840 return; |
|
841 |
|
842 // Scroll up half a screen (or less) |
|
843 nblines = CHAT_WIN_HEIGHT/2-1; |
|
844 hbuf_top = win_entry->top; |
|
845 if (!hbuf_top) { |
|
846 hbuf_top = g_list_last(win_entry->hbuf); |
109
|
847 if (!win_entry->cleared) |
|
848 nblines *= 3; |
|
849 else |
|
850 win_entry->cleared = FALSE; |
105
|
851 } |
|
852 |
|
853 n = 0; |
|
854 while (hbuf_top && n < nblines && g_list_previous(hbuf_top)) { |
|
855 hbuf_top = g_list_previous(hbuf_top); |
|
856 n++; |
|
857 } |
|
858 win_entry->top = hbuf_top; |
|
859 |
|
860 // Refresh the window |
|
861 scr_UpdateWindow(win_entry); |
|
862 |
|
863 // Finished :) |
|
864 update_panels(); |
|
865 doupdate(); |
|
866 } |
|
867 |
143
|
868 // scr_ScrollDown() |
|
869 // Scroll down the current buddy window, half a screen. |
105
|
870 void scr_ScrollDown(void) |
|
871 { |
|
872 const gchar *jid; |
|
873 window_entry_t *win_entry; |
|
874 int n, nblines; |
|
875 GList *hbuf_top; |
|
876 |
|
877 // Get win_entry |
|
878 if (!current_buddy) |
|
879 return; |
|
880 jid = CURRENT_JID; |
|
881 if (!jid) |
|
882 return; |
|
883 win_entry = scr_SearchWindow(jid); |
|
884 if (!win_entry) |
|
885 return; |
|
886 |
|
887 // Scroll down half a screen (or less) |
|
888 nblines = CHAT_WIN_HEIGHT/2-1; |
|
889 hbuf_top = win_entry->top; |
|
890 |
|
891 for (n=0 ; hbuf_top && n < nblines ; n++) |
|
892 hbuf_top = g_list_next(hbuf_top); |
|
893 win_entry->top = hbuf_top; |
|
894 // Check if we are at the bottom |
|
895 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
|
896 hbuf_top = g_list_next(hbuf_top); |
|
897 if (!hbuf_top) |
|
898 win_entry->top = NULL; // End reached |
|
899 |
|
900 // Refresh the window |
|
901 scr_UpdateWindow(win_entry); |
|
902 |
|
903 // Finished :) |
|
904 update_panels(); |
|
905 doupdate(); |
|
906 } |
|
907 |
143
|
908 // scr_Clear() |
|
909 // Clear the current buddy window (used for the /clear command) |
108
|
910 void scr_Clear(void) |
|
911 { |
|
912 const gchar *jid; |
|
913 window_entry_t *win_entry; |
|
914 |
|
915 // Get win_entry |
|
916 if (!current_buddy) |
|
917 return; |
|
918 jid = CURRENT_JID; |
|
919 if (!jid) |
|
920 return; |
|
921 win_entry = scr_SearchWindow(jid); |
|
922 if (!win_entry) |
|
923 return; |
|
924 |
|
925 win_entry->cleared = TRUE; |
109
|
926 win_entry->top = NULL; |
108
|
927 |
|
928 // Refresh the window |
|
929 scr_UpdateWindow(win_entry); |
|
930 |
|
931 // Finished :) |
|
932 update_panels(); |
|
933 doupdate(); |
|
934 } |
|
935 |
44
|
936 // scr_LogPrint(...) |
|
937 // Display a message in the log window. |
24
|
938 void scr_LogPrint(const char *fmt, ...) |
|
939 { |
|
940 time_t timestamp; |
|
941 char *buffer; |
|
942 va_list ap; |
|
943 |
153
|
944 do { |
|
945 buffer = (char *) calloc(1, 1024); |
|
946 } while (!buffer); |
24
|
947 |
|
948 timestamp = time(NULL); |
|
949 strftime(buffer, 64, "[%H:%M:%S] ", localtime(×tamp)); |
|
950 wprintw(logWnd, "\n%s", buffer); |
|
951 |
|
952 va_start(ap, fmt); |
153
|
953 vsnprintf(buffer, 1024, fmt, ap); |
24
|
954 va_end(ap); |
|
955 |
|
956 wprintw(logWnd, "%s", buffer); |
|
957 free(buffer); |
|
958 |
|
959 update_panels(); |
|
960 doupdate(); |
|
961 } |
|
962 |
143
|
963 // scr_set_chatmode() |
|
964 // Public fonction to (un)set chatmode... |
129
|
965 inline void scr_set_chatmode(int enable) |
|
966 { |
|
967 chatmode = enable; |
|
968 } |
|
969 |
98
|
970 // which_row() |
|
971 // Tells which row our cursor is in, in the command line. |
|
972 // -1 -> normal text |
|
973 // 0 -> command |
|
974 // 1 -> parameter 1 (etc.) |
102
|
975 // If > 0, then *p_row is set to the beginning of the row |
|
976 int which_row(char **p_row) |
98
|
977 { |
|
978 int row = -1; |
|
979 char *p; |
|
980 int quote = FALSE; |
|
981 |
|
982 // Not a command? |
|
983 if ((ptr_inputline == inputLine) || (inputLine[0] != '/')) |
|
984 return -1; |
|
985 |
|
986 // This is a command |
|
987 row = 0; |
|
988 for (p = inputLine ; p < ptr_inputline ; p++) { |
|
989 if (quote) { |
|
990 if (*p == '"' && *(p-1) != '\\') |
|
991 quote = FALSE; |
|
992 continue; |
|
993 } |
|
994 if (*p == '"' && *(p-1) != '\\') { |
|
995 quote = TRUE; |
121
|
996 } else if (*p == ' ') { |
|
997 if (*(p-1) != ' ') |
|
998 row++; |
102
|
999 *p_row = p+1; |
|
1000 } |
98
|
1001 } |
|
1002 return row; |
|
1003 } |
|
1004 |
143
|
1005 // scr_insert_text() |
|
1006 // Insert the given text at the current cursor position. |
|
1007 // The cursor is moved. We don't check if the cursor still is in the screen |
|
1008 // after, the caller should do that. |
98
|
1009 void scr_insert_text(const char *text) |
|
1010 { |
|
1011 char tmpLine[INPUTLINE_LENGTH+1]; |
|
1012 int len = strlen(text); |
|
1013 // Check the line isn't too long |
|
1014 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { |
|
1015 scr_LogPrint("Cannot insert text, line too long."); |
|
1016 return; |
|
1017 } |
|
1018 |
|
1019 strcpy(tmpLine, ptr_inputline); |
|
1020 strcpy(ptr_inputline, text); ptr_inputline += len; |
|
1021 strcpy(ptr_inputline, tmpLine); |
|
1022 } |
|
1023 |
143
|
1024 // scr_handle_tab() |
|
1025 // Function called when tab is pressed. |
|
1026 // Initiate or continue a completion... |
98
|
1027 void scr_handle_tab(void) |
|
1028 { |
102
|
1029 int nrow; |
|
1030 char *row; |
|
1031 const char *cchar; |
103
|
1032 guint compl_categ; |
98
|
1033 |
102
|
1034 nrow = which_row(&row); |
98
|
1035 |
103
|
1036 // a) No completion if no leading slash ('cause not a command) |
|
1037 // b) We can't have more than 2 parameters (we use 2 flags) |
|
1038 if (nrow < 0 || nrow > 2) return; |
102
|
1039 |
103
|
1040 if (nrow == 0) { // Command completion |
|
1041 row = &inputLine[1]; |
|
1042 compl_categ = COMPL_CMD; |
|
1043 } else { // Other completion, depending on the command |
|
1044 cmd *com = cmd_get(inputLine); |
|
1045 if (!com || !row) { |
|
1046 scr_LogPrint("I cannot complete that..."); |
|
1047 return; |
|
1048 } |
|
1049 compl_categ = com->completion_flags[nrow-1]; |
|
1050 } |
|
1051 |
|
1052 if (!completion_started) { |
|
1053 GSList *list = compl_get_category_list(compl_categ); |
|
1054 if (list) { |
|
1055 char *prefix = g_strndup(row, ptr_inputline-row); |
|
1056 // Init completion |
|
1057 new_completion(prefix, list); |
|
1058 g_free(prefix); |
|
1059 // Now complete |
98
|
1060 cchar = complete(); |
|
1061 if (cchar) |
|
1062 scr_insert_text(cchar); |
103
|
1063 completion_started = TRUE; |
98
|
1064 } |
103
|
1065 } else { // Completion already initialized |
|
1066 char *c; |
|
1067 guint back = cancel_completion(); |
|
1068 // Remove $back chars |
|
1069 ptr_inputline -= back; |
|
1070 c = ptr_inputline; |
|
1071 for ( ; *c ; c++) |
|
1072 *c = *(c+back); |
|
1073 // Now complete again |
|
1074 cchar = complete(); |
|
1075 if (cchar) |
|
1076 scr_insert_text(cchar); |
102
|
1077 } |
98
|
1078 } |
|
1079 |
|
1080 void scr_cancel_current_completion(void) |
|
1081 { |
|
1082 char *c; |
|
1083 guint back = cancel_completion(); |
|
1084 // Remove $back chars |
|
1085 ptr_inputline -= back; |
|
1086 c = ptr_inputline; |
|
1087 for ( ; *c ; c++) |
|
1088 *c = *(c+back); |
|
1089 } |
|
1090 |
|
1091 void scr_end_current_completion(void) |
|
1092 { |
|
1093 done_completion(); |
|
1094 completion_started = FALSE; |
|
1095 } |
|
1096 |
24
|
1097 // check_offset(int direction) |
|
1098 // Check inputline_offset value, and make sure the cursor is inside the |
|
1099 // screen. |
|
1100 inline void check_offset(int direction) |
|
1101 { |
|
1102 // Left side |
|
1103 if (inputline_offset && direction <= 0) { |
|
1104 while (ptr_inputline <= (char*)&inputLine + inputline_offset) { |
|
1105 if (inputline_offset) { |
|
1106 inputline_offset -= 5; |
|
1107 if (inputline_offset < 0) |
|
1108 inputline_offset = 0; |
|
1109 } |
|
1110 } |
|
1111 } |
|
1112 // Right side |
|
1113 if (direction >= 0) { |
|
1114 while (ptr_inputline >= inputline_offset + (char*)&inputLine + maxX) |
|
1115 inputline_offset += 5; |
|
1116 } |
|
1117 } |
|
1118 |
44
|
1119 // process_key(key) |
|
1120 // Handle the pressed key, in the command line (bottom). |
29
|
1121 int process_key(int key) |
24
|
1122 { |
|
1123 if (isprint(key)) { |
|
1124 char tmpLine[INPUTLINE_LENGTH+1]; |
|
1125 |
|
1126 // Check the line isn't too long |
|
1127 if (strlen(inputLine) >= INPUTLINE_LENGTH) |
|
1128 return 0; |
|
1129 |
|
1130 // Insert char |
|
1131 strcpy(tmpLine, ptr_inputline); |
|
1132 *ptr_inputline++ = key; |
|
1133 strcpy(ptr_inputline, tmpLine); |
|
1134 check_offset(1); |
|
1135 } else { |
|
1136 switch(key) { |
|
1137 case KEY_BACKSPACE: |
|
1138 if (ptr_inputline != (char*)&inputLine) { |
42
|
1139 char *c = --ptr_inputline; |
|
1140 for ( ; *c ; c++) |
|
1141 *c = *(c+1); |
24
|
1142 check_offset(-1); |
|
1143 } |
|
1144 break; |
|
1145 case KEY_DC: |
|
1146 if (*ptr_inputline) |
|
1147 strcpy(ptr_inputline, ptr_inputline+1); |
|
1148 break; |
|
1149 case KEY_LEFT: |
|
1150 if (ptr_inputline != (char*)&inputLine) { |
|
1151 ptr_inputline--; |
|
1152 check_offset(-1); |
|
1153 } |
|
1154 break; |
|
1155 case KEY_RIGHT: |
|
1156 if (*ptr_inputline) |
|
1157 ptr_inputline++; |
|
1158 check_offset(1); |
|
1159 break; |
98
|
1160 case 7: // Ctrl-g |
|
1161 scr_cancel_current_completion(); |
|
1162 scr_end_current_completion(); |
|
1163 check_offset(-1); |
|
1164 break; |
24
|
1165 case 9: // Tab |
98
|
1166 scr_handle_tab(); |
|
1167 check_offset(0); |
24
|
1168 break; |
|
1169 case '\n': // Enter |
29
|
1170 if (process_line(inputLine)) |
24
|
1171 return 255; |
|
1172 ptr_inputline = inputLine; |
|
1173 *ptr_inputline = 0; |
|
1174 inputline_offset = 0; |
|
1175 break; |
|
1176 case KEY_UP: |
81
|
1177 scr_RosterUp(); |
24
|
1178 break; |
|
1179 case KEY_DOWN: |
81
|
1180 scr_RosterDown(); |
24
|
1181 break; |
|
1182 case KEY_PPAGE: |
105
|
1183 scr_ScrollUp(); |
24
|
1184 break; |
|
1185 case KEY_NPAGE: |
105
|
1186 scr_ScrollDown(); |
24
|
1187 break; |
|
1188 case KEY_HOME: |
|
1189 case 1: |
|
1190 ptr_inputline = inputLine; |
|
1191 inputline_offset = 0; |
|
1192 break; |
|
1193 case KEY_END: |
|
1194 case 5: |
|
1195 for (; *ptr_inputline; ptr_inputline++) ; |
|
1196 check_offset(1); |
|
1197 break; |
|
1198 case 21: // Ctrl-u |
|
1199 strcpy(inputLine, ptr_inputline); |
|
1200 ptr_inputline = inputLine; |
|
1201 inputline_offset = 0; |
|
1202 break; |
|
1203 case KEY_EOL: |
|
1204 case 11: // Ctrl-k |
|
1205 *ptr_inputline = 0; |
|
1206 break; |
|
1207 case 16: // Ctrl-p |
|
1208 scr_LogPrint("Ctrl-p not yet implemented"); |
|
1209 break; |
|
1210 case 14: // Ctrl-n |
|
1211 scr_LogPrint("Ctrl-n not yet implemented"); |
|
1212 break; |
|
1213 case 27: // ESC |
|
1214 currentWindow = NULL; |
|
1215 chatmode = FALSE; |
119
|
1216 if (current_buddy) |
|
1217 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
24
|
1218 top_panel(chatPanel); |
|
1219 top_panel(inputPanel); |
|
1220 break; |
151
|
1221 case 12: // Ctrl-l |
|
1222 case KEY_RESIZE: |
|
1223 scr_Resize(); |
|
1224 break; |
24
|
1225 default: |
|
1226 scr_LogPrint("Unkown key=%d", key); |
|
1227 } |
|
1228 } |
98
|
1229 if (completion_started && key != 9) |
|
1230 scr_end_current_completion(); |
24
|
1231 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset); |
|
1232 wclrtoeol(inputWnd); |
|
1233 if (*ptr_inputline) { |
|
1234 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset); |
|
1235 } |
|
1236 update_panels(); |
|
1237 doupdate(); |
|
1238 return 0; |
|
1239 } |