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"
|
|
11 #include "utils.h"
|
47
|
12 #include "commands.h"
|
24
|
13 #include "buddies.h"
|
|
14 #include "parsecfg.h"
|
|
15 #include "lang.h"
|
|
16 #include "list.h"
|
47
|
17 #include "utf8.h"
|
74
|
18 #include "hbuf.h"
|
24
|
19
|
|
20 #define window_entry(n) list_entry(n, window_entry_t, list)
|
|
21
|
|
22 LIST_HEAD(window_list);
|
|
23
|
|
24 typedef struct _window_entry_t {
|
|
25 WINDOW *win;
|
|
26 PANEL *panel;
|
|
27 char *name;
|
74
|
28 GList *hbuf;
|
24
|
29 int hidden_msg;
|
|
30 struct list_head list;
|
|
31 } window_entry_t;
|
|
32
|
|
33
|
|
34 /* Variables globales a SCREEN.C */
|
|
35 static WINDOW *rosterWnd, *chatWnd, *inputWnd;
|
|
36 static WINDOW *logWnd, *logWnd_border;
|
|
37 static PANEL *rosterPanel, *chatPanel, *inputPanel;
|
|
38 static PANEL *logPanel, *logPanel_border;
|
|
39 static int maxY, maxX;
|
|
40 static window_entry_t *currentWindow;
|
|
41
|
|
42 static int chatmode;
|
30
|
43 int update_roster;
|
24
|
44
|
|
45 static char inputLine[INPUTLINE_LENGTH+1];
|
|
46 static char *ptr_inputline;
|
|
47 static short int inputline_offset;
|
|
48
|
|
49
|
|
50 /* Funciones */
|
|
51
|
74
|
52 int scr_WindowWidth(WINDOW * win)
|
24
|
53 {
|
|
54 int x, y;
|
|
55 getmaxyx(win, y, x);
|
|
56 return x;
|
|
57 }
|
|
58
|
74
|
59 void scr_clear_box(WINDOW *win, int y, int x, int height, int width, int Color)
|
|
60 {
|
|
61 int i, j;
|
|
62
|
|
63 wattrset(win, COLOR_PAIR(Color));
|
|
64 for (i = 0; i < height; i++) {
|
|
65 wmove(win, y + i, x);
|
|
66 for (j = 0; j < width; j++)
|
|
67 wprintw(win, " ");
|
|
68 }
|
|
69 }
|
|
70
|
24
|
71 void scr_draw_box(WINDOW * win, int y, int x, int height, int width,
|
|
72 int Color, chtype box, chtype border)
|
|
73 {
|
|
74 int i, j;
|
|
75
|
|
76 wattrset(win, COLOR_PAIR(Color));
|
|
77 for (i = 0; i < height; i++) {
|
|
78 wmove(win, y + i, x);
|
|
79 for (j = 0; j < width; j++)
|
|
80 if (!i && !j)
|
|
81 waddch(win, border | ACS_ULCORNER);
|
|
82 else if (i == height - 1 && !j)
|
|
83 waddch(win, border | ACS_LLCORNER);
|
|
84 else if (!i && j == width - 1)
|
|
85 waddch(win, box | ACS_URCORNER);
|
|
86 else if (i == height - 1 && j == width - 1)
|
|
87 waddch(win, box | ACS_LRCORNER);
|
|
88 else if (!i)
|
|
89 waddch(win, border | ACS_HLINE);
|
|
90 else if (i == height - 1)
|
|
91 waddch(win, box | ACS_HLINE);
|
|
92 else if (!j)
|
|
93 waddch(win, border | ACS_VLINE);
|
|
94 else if (j == width - 1)
|
|
95 waddch(win, box | ACS_VLINE);
|
|
96 else
|
|
97 waddch(win, box | ' ');
|
|
98 }
|
|
99 }
|
|
100
|
|
101 int FindColor(char *name)
|
|
102 {
|
|
103 if (!strcmp(name, "default"))
|
|
104 return -1;
|
|
105 if (!strcmp(name, "black"))
|
|
106 return COLOR_BLACK;
|
|
107 if (!strcmp(name, "red"))
|
|
108 return COLOR_RED;
|
|
109 if (!strcmp(name, "green"))
|
|
110 return COLOR_GREEN;
|
|
111 if (!strcmp(name, "yellow"))
|
|
112 return COLOR_YELLOW;
|
|
113 if (!strcmp(name, "blue"))
|
|
114 return COLOR_BLUE;
|
|
115 if (!strcmp(name, "magenta"))
|
|
116 return COLOR_MAGENTA;
|
|
117 if (!strcmp(name, "cyan"))
|
|
118 return COLOR_CYAN;
|
|
119 if (!strcmp(name, "white"))
|
|
120 return COLOR_WHITE;
|
|
121
|
|
122 return -1;
|
|
123 }
|
|
124
|
|
125 void ParseColors(void)
|
|
126 {
|
|
127 char *colors[11] = {
|
|
128 "", "",
|
|
129 "borderlines",
|
|
130 "jidonlineselected",
|
|
131 "jidonline",
|
|
132 "jidofflineselected",
|
|
133 "jidoffline",
|
|
134 "text",
|
|
135 NULL
|
|
136 };
|
|
137
|
|
138 char *tmp = malloc(1024);
|
|
139 char *color1;
|
|
140 char *background = cfg_read("color_background");
|
|
141 char *backselected = cfg_read("color_backselected");
|
|
142 int i = 0;
|
|
143
|
|
144 while (colors[i]) {
|
|
145 sprintf(tmp, "color_%s", colors[i]);
|
|
146 color1 = cfg_read(tmp);
|
|
147
|
|
148 switch (i + 1) {
|
|
149 case 1:
|
|
150 init_pair(1, COLOR_BLACK, COLOR_WHITE);
|
|
151 break;
|
|
152 case 2:
|
|
153 init_pair(2, COLOR_WHITE, COLOR_BLACK);
|
|
154 break;
|
|
155 case 3:
|
|
156 init_pair(3, FindColor(color1), FindColor(background));
|
|
157 break;
|
|
158 case 4:
|
|
159 init_pair(4, FindColor(color1), FindColor(backselected));
|
|
160 break;
|
|
161 case 5:
|
|
162 init_pair(5, FindColor(color1), FindColor(background));
|
|
163 break;
|
|
164 case 6:
|
|
165 init_pair(6, FindColor(color1), FindColor(backselected));
|
|
166 break;
|
|
167 case 7:
|
|
168 init_pair(7, FindColor(color1), FindColor(background));
|
|
169 break;
|
|
170 case 8:
|
|
171 init_pair(8, FindColor(color1), FindColor(background));
|
|
172 break;
|
|
173 }
|
|
174 i++;
|
|
175 }
|
|
176 }
|
|
177
|
|
178
|
50
|
179 window_entry_t *scr_CreatePanel(const char *title, int x, int y,
|
|
180 int lines, int cols, int dont_show)
|
24
|
181 {
|
|
182 window_entry_t *tmp = calloc(1, sizeof(window_entry_t));
|
|
183
|
|
184 tmp->win = newwin(lines, cols, y, x);
|
|
185 tmp->panel = new_panel(tmp->win);
|
|
186 tmp->name = (char *) calloc(1, 1024);
|
|
187 strncpy(tmp->name, title, 1024);
|
76
|
188 scr_clear_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL);
|
24
|
189
|
|
190 if ((!dont_show)) {
|
|
191 currentWindow = tmp;
|
|
192 } else {
|
|
193 if (currentWindow)
|
|
194 top_panel(currentWindow->panel);
|
|
195 else
|
|
196 top_panel(chatPanel);
|
|
197 }
|
|
198
|
|
199 list_add_tail(&tmp->list, &window_list);
|
|
200 update_panels();
|
|
201
|
|
202 return tmp;
|
|
203 }
|
|
204
|
|
205 void scr_RoolWindow(void)
|
|
206 {
|
|
207 }
|
|
208
|
50
|
209 window_entry_t *scr_SearchWindow(const char *winId)
|
24
|
210 {
|
|
211 struct list_head *pos, *n;
|
|
212 window_entry_t *search_entry = NULL;
|
|
213
|
|
214 list_for_each_safe(pos, n, &window_list) {
|
|
215 search_entry = window_entry(pos);
|
|
216 if (search_entry->name) {
|
|
217 if (!strcasecmp(search_entry->name, winId)) {
|
|
218 return search_entry;
|
|
219 }
|
|
220 }
|
|
221 }
|
|
222 return NULL;
|
|
223 }
|
|
224
|
74
|
225 void scr_UpdateWindow(window_entry_t *win_entry)
|
|
226 {
|
|
227 int n;
|
|
228 int width;
|
|
229 char **lines;
|
|
230 GList *hbuf_head;
|
|
231
|
|
232 // We will show the last CHAT_WIN_HEIGHT lines.
|
|
233 // Let's find out where it begins.
|
|
234 win_entry->hbuf = g_list_last(win_entry->hbuf);
|
|
235 hbuf_head = win_entry->hbuf;
|
|
236 for (n=0; hbuf_head && n<(CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head); n++)
|
|
237 hbuf_head = g_list_previous(hbuf_head);
|
|
238
|
|
239 // Get the last CHAT_WIN_HEIGHT lines.
|
|
240 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT);
|
|
241
|
|
242 // Display these lines
|
|
243 width = scr_WindowWidth(win_entry->win);
|
|
244 wmove(win_entry->win, 0, 0);
|
|
245 for (n = 0; n < CHAT_WIN_HEIGHT; n++) {
|
|
246 int r = width;
|
75
|
247 if (*(lines+2*n)) {
|
|
248 if (**(lines+2*n))
|
|
249 wprintw(win_entry->win, "%s", *(lines+2*n)); // prefix
|
|
250 else {
|
|
251 wprintw(win_entry->win, " ");
|
|
252 r -= 12;
|
|
253 }
|
|
254 wprintw(win_entry->win, "%s", *(lines+2*n+1)); // line
|
|
255 // Calculate the number of blank characters to empty the line
|
|
256 r -= strlen(*(lines+2*n)) + strlen(*(lines+2*n+1));
|
|
257 }
|
74
|
258 for ( ; r>0 ; r--) {
|
|
259 wprintw(win_entry->win, " ");
|
|
260 }
|
|
261 //// wclrtoeol(win_entry->win); does not work :(
|
|
262 }
|
|
263 g_free(lines);
|
|
264 }
|
|
265
|
50
|
266 void scr_ShowWindow(const char *winId)
|
24
|
267 {
|
74
|
268 window_entry_t *win_entry = scr_SearchWindow(winId);
|
|
269
|
|
270 if (win_entry != NULL) {
|
|
271 top_panel(win_entry->panel);
|
|
272 currentWindow = win_entry;
|
24
|
273 chatmode = TRUE;
|
74
|
274 win_entry->hidden_msg = FALSE;
|
30
|
275 update_roster = TRUE;
|
74
|
276
|
|
277 // Refresh the window entry
|
|
278 scr_UpdateWindow(win_entry);
|
|
279
|
|
280 // Finished :)
|
24
|
281 update_panels();
|
|
282 doupdate();
|
|
283 } else {
|
|
284 top_panel(chatPanel);
|
74
|
285 currentWindow = win_entry; // == NULL (current window empty)
|
24
|
286 }
|
|
287 }
|
|
288
|
|
289 void scr_ShowBuddyWindow(void)
|
|
290 {
|
|
291 buddy_entry_t *tmp = bud_SelectedInfo();
|
|
292 if (tmp->jid != NULL)
|
|
293 scr_ShowWindow(tmp->jid);
|
|
294 top_panel(inputPanel);
|
|
295 }
|
|
296
|
|
297
|
75
|
298 void scr_WriteInWindow(const char *winId, const char *text, int TimeStamp,
|
|
299 const char *prefix, int force_show)
|
24
|
300 {
|
75
|
301 char *fullprefix = NULL;
|
74
|
302 window_entry_t *win_entry;
|
24
|
303 int dont_show = FALSE;
|
|
304
|
75
|
305 // Prepare the prefix
|
|
306 if (prefix || TimeStamp) {
|
|
307 if (!prefix) prefix = "";
|
|
308 fullprefix = calloc(1, strlen(prefix)+16);
|
|
309 if (TimeStamp) {
|
|
310 time_t now = time(NULL);
|
|
311 strftime(fullprefix, 12, "[%H:%M] ", localtime(&now));
|
|
312 } else {
|
|
313 strcpy(fullprefix, " ");
|
|
314 }
|
|
315 strcat(fullprefix, prefix);
|
74
|
316 }
|
|
317
|
|
318 // Look for the window entry.
|
|
319 win_entry = scr_SearchWindow(winId);
|
|
320
|
|
321 // Do we have to really show the window?
|
24
|
322 if (!chatmode)
|
|
323 dont_show = TRUE;
|
74
|
324 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry))))
|
24
|
325 dont_show = TRUE;
|
|
326
|
74
|
327 // If the window entry doesn't exist yet, let's create it.
|
|
328 if (win_entry == NULL) {
|
|
329 win_entry = scr_CreatePanel(winId, ROSTER_WIDTH, 0, CHAT_WIN_HEIGHT,
|
|
330 maxX - ROSTER_WIDTH, dont_show);
|
24
|
331 }
|
|
332
|
75
|
333 hbuf_add_line(&win_entry->hbuf, text, fullprefix,
|
74
|
334 maxX - scr_WindowWidth(rosterWnd) - 14);
|
75
|
335 free(fullprefix);
|
74
|
336
|
24
|
337 if (!dont_show) {
|
74
|
338 // Show and refresh the window
|
|
339 top_panel(win_entry->panel);
|
|
340 scr_UpdateWindow(win_entry);
|
24
|
341 update_panels();
|
|
342 doupdate();
|
|
343 } else {
|
74
|
344 win_entry->hidden_msg = TRUE;
|
30
|
345 update_roster = TRUE;
|
24
|
346 }
|
|
347 }
|
|
348
|
|
349 void scr_InitCurses(void)
|
|
350 {
|
|
351 initscr();
|
|
352 noecho();
|
|
353 raw();
|
35
|
354 halfdelay(5);
|
24
|
355 start_color();
|
|
356 use_default_colors();
|
|
357
|
|
358 ParseColors();
|
|
359
|
|
360 getmaxyx(stdscr, maxY, maxX);
|
|
361 inputLine[0] = 0;
|
|
362 ptr_inputline = inputLine;
|
|
363
|
35
|
364 setlocale(LC_CTYPE, "");
|
24
|
365
|
|
366 return;
|
|
367 }
|
|
368
|
|
369 void scr_DrawMainWindow(void)
|
|
370 {
|
74
|
371 int l;
|
|
372
|
24
|
373 /* Draw main panels */
|
74
|
374 rosterWnd = newwin(CHAT_WIN_HEIGHT, ROSTER_WIDTH, 0, 0);
|
24
|
375 rosterPanel = new_panel(rosterWnd);
|
74
|
376 scr_clear_box(rosterWnd, 0, 0, CHAT_WIN_HEIGHT, ROSTER_WIDTH,
|
|
377 COLOR_GENERAL);
|
|
378 for (l=0 ; l < CHAT_WIN_HEIGHT ; l++)
|
|
379 mvwaddch(rosterWnd, l, ROSTER_WIDTH-1, ACS_VLINE);
|
24
|
380
|
74
|
381 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH, 0, ROSTER_WIDTH);
|
24
|
382 chatPanel = new_panel(chatWnd);
|
74
|
383 scr_clear_box(chatWnd, 0, 0, CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH,
|
|
384 COLOR_GENERAL);
|
|
385 scrollok(chatWnd, TRUE);
|
|
386 mvwprintw(chatWnd, 0, 0, "This is the status window");
|
24
|
387
|
|
388 logWnd_border = newwin(LOG_WIN_HEIGHT, maxX, CHAT_WIN_HEIGHT, 0);
|
|
389 logPanel_border = new_panel(logWnd_border);
|
|
390 scr_draw_box(logWnd_border, 0, 0, LOG_WIN_HEIGHT, maxX, COLOR_GENERAL, 0, 0);
|
|
391 logWnd = derwin(logWnd_border, LOG_WIN_HEIGHT-2, maxX-2, 1, 1);
|
|
392 logPanel = new_panel(logWnd);
|
|
393 wbkgd(logWnd, COLOR_PAIR(COLOR_GENERAL));
|
|
394
|
74
|
395 scrollok(logWnd, TRUE);
|
24
|
396
|
|
397 inputWnd = newwin(1, maxX, maxY-1, 0);
|
|
398 inputPanel = new_panel(inputWnd);
|
|
399
|
|
400 bud_DrawRoster(rosterWnd);
|
|
401 update_panels();
|
|
402 doupdate();
|
|
403 return;
|
|
404 }
|
|
405
|
|
406 void scr_TerminateCurses(void)
|
|
407 {
|
|
408 clear();
|
|
409 refresh();
|
|
410 endwin();
|
|
411 return;
|
|
412 }
|
|
413
|
50
|
414 void scr_WriteMessage(const char *jid, const char *text, char *prefix)
|
24
|
415 {
|
75
|
416 scr_WriteInWindow(jid, text, TRUE, prefix, FALSE);
|
47
|
417 }
|
|
418
|
50
|
419 void scr_WriteIncomingMessage(const char *jidfrom, const char *text)
|
47
|
420 {
|
|
421 char *buffer = utf8_decode(text);
|
75
|
422 // FIXME expand tabs / filter out special chars...
|
47
|
423 scr_WriteMessage(jidfrom, buffer, "<== ");
|
|
424 free(buffer);
|
65
|
425 top_panel(inputPanel);
|
24
|
426 update_panels();
|
|
427 doupdate();
|
|
428 }
|
|
429
|
50
|
430 void scr_WriteOutgoingMessage(const char *jidto, const char *text)
|
47
|
431 {
|
65
|
432 scr_WriteMessage(jidto, text, "--> ");
|
47
|
433 scr_ShowWindow(jidto);
|
65
|
434 top_panel(inputPanel);
|
47
|
435 }
|
|
436
|
24
|
437 int scr_Getch(void)
|
|
438 {
|
|
439 int ch;
|
|
440 // keypad(inputWnd, TRUE);
|
|
441 ch = wgetch(inputWnd);
|
|
442 return ch;
|
|
443 }
|
|
444
|
|
445 WINDOW *scr_GetRosterWindow(void)
|
|
446 {
|
|
447 return rosterWnd;
|
|
448 }
|
|
449
|
|
450 WINDOW *scr_GetStatusWindow(void)
|
|
451 {
|
|
452 return chatWnd;
|
|
453 }
|
|
454
|
|
455 WINDOW *scr_GetInputWindow(void)
|
|
456 {
|
|
457 return inputWnd;
|
|
458 }
|
|
459
|
44
|
460 // scr_LogPrint(...)
|
|
461 // Display a message in the log window.
|
24
|
462 void scr_LogPrint(const char *fmt, ...)
|
|
463 {
|
|
464 time_t timestamp;
|
|
465 char *buffer;
|
|
466 va_list ap;
|
|
467
|
|
468 buffer = (char *) calloc(1, 4096);
|
|
469
|
|
470 timestamp = time(NULL);
|
|
471 strftime(buffer, 64, "[%H:%M:%S] ", localtime(×tamp));
|
|
472 wprintw(logWnd, "\n%s", buffer);
|
|
473
|
|
474 va_start(ap, fmt);
|
|
475 vsnprintf(buffer, 4096, fmt, ap);
|
|
476 va_end(ap);
|
|
477
|
|
478 wprintw(logWnd, "%s", buffer);
|
|
479 free(buffer);
|
|
480
|
|
481 update_panels();
|
|
482 doupdate();
|
|
483 }
|
|
484
|
|
485 // scr_IsHiddenMessage(jid)
|
|
486 // Returns TRUE if there is a hidden message in the window
|
|
487 // for the jid contact.
|
50
|
488 int scr_IsHiddenMessage(const char *jid) {
|
24
|
489 window_entry_t *wintmp;
|
|
490
|
|
491 wintmp = scr_SearchWindow(jid);
|
|
492 if ((wintmp) && (wintmp->hidden_msg))
|
|
493 return TRUE;
|
|
494
|
|
495 return FALSE;
|
|
496 }
|
|
497
|
|
498 // check_offset(int direction)
|
|
499 // Check inputline_offset value, and make sure the cursor is inside the
|
|
500 // screen.
|
|
501 inline void check_offset(int direction)
|
|
502 {
|
|
503 // Left side
|
|
504 if (inputline_offset && direction <= 0) {
|
|
505 while (ptr_inputline <= (char*)&inputLine + inputline_offset) {
|
|
506 if (inputline_offset) {
|
|
507 inputline_offset -= 5;
|
|
508 if (inputline_offset < 0)
|
|
509 inputline_offset = 0;
|
|
510 }
|
|
511 }
|
|
512 }
|
|
513 // Right side
|
|
514 if (direction >= 0) {
|
|
515 while (ptr_inputline >= inputline_offset + (char*)&inputLine + maxX)
|
|
516 inputline_offset += 5;
|
|
517 }
|
|
518 }
|
|
519
|
44
|
520 // process_key(key)
|
|
521 // Handle the pressed key, in the command line (bottom).
|
29
|
522 int process_key(int key)
|
24
|
523 {
|
|
524 if (isprint(key)) {
|
|
525 char tmpLine[INPUTLINE_LENGTH+1];
|
|
526
|
|
527 // Check the line isn't too long
|
|
528 if (strlen(inputLine) >= INPUTLINE_LENGTH)
|
|
529 return 0;
|
|
530
|
|
531 // Insert char
|
|
532 strcpy(tmpLine, ptr_inputline);
|
|
533 *ptr_inputline++ = key;
|
|
534 strcpy(ptr_inputline, tmpLine);
|
|
535 check_offset(1);
|
|
536 } else {
|
|
537 switch(key) {
|
|
538 case KEY_BACKSPACE:
|
|
539 if (ptr_inputline != (char*)&inputLine) {
|
42
|
540 char *c = --ptr_inputline;
|
|
541 for ( ; *c ; c++)
|
|
542 *c = *(c+1);
|
24
|
543 check_offset(-1);
|
|
544 }
|
|
545 break;
|
|
546 case KEY_DC:
|
|
547 if (*ptr_inputline)
|
|
548 strcpy(ptr_inputline, ptr_inputline+1);
|
|
549 break;
|
|
550 case KEY_LEFT:
|
|
551 if (ptr_inputline != (char*)&inputLine) {
|
|
552 ptr_inputline--;
|
|
553 check_offset(-1);
|
|
554 }
|
|
555 break;
|
|
556 case KEY_RIGHT:
|
|
557 if (*ptr_inputline)
|
|
558 ptr_inputline++;
|
|
559 check_offset(1);
|
|
560 break;
|
|
561 case 9: // Tab
|
|
562 scr_LogPrint("I'm unable to complete yet");
|
|
563 break;
|
|
564 case '\n': // Enter
|
|
565 chatmode = TRUE;
|
|
566 if (inputLine[0] == 0) {
|
|
567 scr_ShowBuddyWindow();
|
|
568 break;
|
|
569 }
|
29
|
570 if (process_line(inputLine))
|
24
|
571 return 255;
|
|
572 ptr_inputline = inputLine;
|
|
573 *ptr_inputline = 0;
|
|
574 inputline_offset = 0;
|
|
575 break;
|
|
576 case KEY_UP:
|
|
577 bud_RosterUp();
|
|
578 if (chatmode)
|
|
579 scr_ShowBuddyWindow();
|
|
580 break;
|
|
581 case KEY_DOWN:
|
|
582 bud_RosterDown();
|
|
583 if (chatmode)
|
|
584 scr_ShowBuddyWindow();
|
|
585 break;
|
|
586 case KEY_PPAGE:
|
|
587 scr_LogPrint("PageUp??");
|
|
588 break;
|
|
589 case KEY_NPAGE:
|
|
590 scr_LogPrint("PageDown??");
|
|
591 break;
|
|
592 case KEY_HOME:
|
|
593 case 1:
|
|
594 ptr_inputline = inputLine;
|
|
595 inputline_offset = 0;
|
|
596 break;
|
|
597 case KEY_END:
|
|
598 case 5:
|
|
599 for (; *ptr_inputline; ptr_inputline++) ;
|
|
600 check_offset(1);
|
|
601 break;
|
|
602 case 21: // Ctrl-u
|
|
603 strcpy(inputLine, ptr_inputline);
|
|
604 ptr_inputline = inputLine;
|
|
605 inputline_offset = 0;
|
|
606 break;
|
|
607 case KEY_EOL:
|
|
608 case 11: // Ctrl-k
|
|
609 *ptr_inputline = 0;
|
|
610 break;
|
|
611 case 16: // Ctrl-p
|
|
612 scr_LogPrint("Ctrl-p not yet implemented");
|
|
613 break;
|
|
614 case 14: // Ctrl-n
|
|
615 scr_LogPrint("Ctrl-n not yet implemented");
|
|
616 break;
|
|
617 case 27: // ESC
|
|
618 currentWindow = NULL;
|
|
619 chatmode = FALSE;
|
|
620 top_panel(chatPanel);
|
|
621 top_panel(inputPanel);
|
|
622 break;
|
|
623 default:
|
|
624 scr_LogPrint("Unkown key=%d", key);
|
|
625 }
|
|
626 }
|
|
627 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset);
|
|
628 wclrtoeol(inputWnd);
|
|
629 if (*ptr_inputline) {
|
|
630 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset);
|
|
631 }
|
|
632 update_panels();
|
|
633 doupdate();
|
|
634 return 0;
|
|
635 }
|