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