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);
|
|
188
|
74
|
189 //scr_draw_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL, 0, 0);
|
|
190 scr_clear_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL);
|
24
|
191 //mvwprintw(tmp->win, 0, (cols - (2 + strlen(title))) / 2, " %s ", title);
|
|
192 if ((!dont_show)) {
|
|
193 currentWindow = tmp;
|
|
194 } else {
|
|
195 if (currentWindow)
|
|
196 top_panel(currentWindow->panel);
|
|
197 else
|
|
198 top_panel(chatPanel);
|
|
199 }
|
|
200
|
|
201 list_add_tail(&tmp->list, &window_list);
|
|
202 update_panels();
|
|
203
|
|
204 return tmp;
|
|
205 }
|
|
206
|
|
207 void scr_RoolWindow(void)
|
|
208 {
|
|
209 }
|
|
210
|
50
|
211 window_entry_t *scr_SearchWindow(const char *winId)
|
24
|
212 {
|
|
213 struct list_head *pos, *n;
|
|
214 window_entry_t *search_entry = NULL;
|
|
215
|
|
216 list_for_each_safe(pos, n, &window_list) {
|
|
217 search_entry = window_entry(pos);
|
|
218 if (search_entry->name) {
|
|
219 if (!strcasecmp(search_entry->name, winId)) {
|
|
220 return search_entry;
|
|
221 }
|
|
222 }
|
|
223 }
|
|
224 return NULL;
|
|
225 }
|
|
226
|
74
|
227 void scr_UpdateWindow(window_entry_t *win_entry)
|
|
228 {
|
|
229 int n;
|
|
230 int width;
|
|
231 char **lines;
|
|
232 GList *hbuf_head;
|
|
233
|
|
234 // We will show the last CHAT_WIN_HEIGHT lines.
|
|
235 // Let's find out where it begins.
|
|
236 win_entry->hbuf = g_list_last(win_entry->hbuf);
|
|
237 hbuf_head = win_entry->hbuf;
|
|
238 for (n=0; hbuf_head && n<(CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head); n++)
|
|
239 hbuf_head = g_list_previous(hbuf_head);
|
|
240
|
|
241 // Get the last CHAT_WIN_HEIGHT lines.
|
|
242 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT);
|
|
243
|
|
244 // Display these lines
|
|
245 width = scr_WindowWidth(win_entry->win);
|
|
246 wmove(win_entry->win, 0, 0);
|
|
247 for (n = 0; n < CHAT_WIN_HEIGHT; n++) {
|
|
248 int r = width;
|
|
249 if (*(lines+n)) {
|
|
250 wprintw(win_entry->win, "%s", *(lines+n));
|
|
251 r -= strlen(*(lines+n));
|
|
252 }// else
|
|
253 // wmove(win_entry->win, n, 0);
|
|
254 for ( ; r>0 ; r--) {
|
|
255 wprintw(win_entry->win, " ");
|
|
256 }
|
|
257 //// wclrtoeol(win_entry->win); does not work :(
|
|
258 }
|
|
259 g_free(lines);
|
|
260 }
|
|
261
|
50
|
262 void scr_ShowWindow(const char *winId)
|
24
|
263 {
|
74
|
264 window_entry_t *win_entry = scr_SearchWindow(winId);
|
|
265
|
|
266 if (win_entry != NULL) {
|
|
267 top_panel(win_entry->panel);
|
|
268 currentWindow = win_entry;
|
24
|
269 chatmode = TRUE;
|
74
|
270 win_entry->hidden_msg = FALSE;
|
30
|
271 update_roster = TRUE;
|
74
|
272
|
|
273 // Refresh the window entry
|
|
274 scr_UpdateWindow(win_entry);
|
|
275
|
|
276 // Finished :)
|
24
|
277 update_panels();
|
|
278 doupdate();
|
|
279 } else {
|
|
280 top_panel(chatPanel);
|
74
|
281 currentWindow = win_entry; // == NULL (current window empty)
|
24
|
282 }
|
|
283 }
|
|
284
|
|
285 void scr_ShowBuddyWindow(void)
|
|
286 {
|
|
287 buddy_entry_t *tmp = bud_SelectedInfo();
|
|
288 if (tmp->jid != NULL)
|
|
289 scr_ShowWindow(tmp->jid);
|
|
290 top_panel(inputPanel);
|
|
291 }
|
|
292
|
|
293
|
74
|
294 void scr_WriteInWindow(const char *winId, char *text, int TimeStamp,
|
|
295 int force_show)
|
24
|
296 {
|
74
|
297 char *line;
|
|
298 window_entry_t *win_entry;
|
24
|
299 int dont_show = FALSE;
|
|
300
|
74
|
301 line = calloc(1, strlen(text)+16);
|
24
|
302
|
74
|
303 // Prepare line (timestamp + text)
|
|
304 // FIXME: actually timestamp and text should not be merged, there is a prefix
|
|
305 // field in the hbuf_block structure just for that.
|
|
306 if (TimeStamp) {
|
|
307 time_t now = time(NULL);
|
|
308 strftime(line, 12, "[%H:%M] ", localtime(&now));
|
|
309 } else {
|
|
310 strcpy(line, " ");
|
|
311 }
|
|
312 strcat(line, text);
|
|
313
|
|
314 // Look for the window entry.
|
|
315 win_entry = scr_SearchWindow(winId);
|
|
316
|
|
317 // Do we have to really show the window?
|
24
|
318 if (!chatmode)
|
|
319 dont_show = TRUE;
|
74
|
320 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry))))
|
24
|
321 dont_show = TRUE;
|
|
322
|
74
|
323 // If the window entry doesn't exist yet, let's create it.
|
|
324 if (win_entry == NULL) {
|
|
325 win_entry = scr_CreatePanel(winId, ROSTER_WIDTH, 0, CHAT_WIN_HEIGHT,
|
|
326 maxX - ROSTER_WIDTH, dont_show);
|
24
|
327 }
|
|
328
|
74
|
329 hbuf_add_line(&win_entry->hbuf, line,
|
|
330 maxX - scr_WindowWidth(rosterWnd) - 14);
|
|
331 free(line);
|
|
332
|
24
|
333 if (!dont_show) {
|
74
|
334 // Show and refresh the window
|
|
335 top_panel(win_entry->panel);
|
|
336 scr_UpdateWindow(win_entry);
|
24
|
337 update_panels();
|
|
338 doupdate();
|
|
339 } else {
|
74
|
340 win_entry->hidden_msg = TRUE;
|
30
|
341 update_roster = TRUE;
|
24
|
342 }
|
|
343 }
|
|
344
|
|
345 void scr_InitCurses(void)
|
|
346 {
|
|
347 initscr();
|
|
348 noecho();
|
|
349 raw();
|
35
|
350 halfdelay(5);
|
24
|
351 start_color();
|
|
352 use_default_colors();
|
|
353
|
|
354 ParseColors();
|
|
355
|
|
356 getmaxyx(stdscr, maxY, maxX);
|
|
357 inputLine[0] = 0;
|
|
358 ptr_inputline = inputLine;
|
|
359
|
35
|
360 setlocale(LC_CTYPE, "");
|
24
|
361
|
|
362 return;
|
|
363 }
|
|
364
|
|
365 void scr_DrawMainWindow(void)
|
|
366 {
|
74
|
367 int l;
|
|
368
|
24
|
369 /* Draw main panels */
|
74
|
370 rosterWnd = newwin(CHAT_WIN_HEIGHT, ROSTER_WIDTH, 0, 0);
|
24
|
371 rosterPanel = new_panel(rosterWnd);
|
74
|
372 scr_clear_box(rosterWnd, 0, 0, CHAT_WIN_HEIGHT, ROSTER_WIDTH,
|
|
373 COLOR_GENERAL);
|
|
374 for (l=0 ; l < CHAT_WIN_HEIGHT ; l++)
|
|
375 mvwaddch(rosterWnd, l, ROSTER_WIDTH-1, ACS_VLINE);
|
24
|
376
|
74
|
377 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH, 0, ROSTER_WIDTH);
|
24
|
378 chatPanel = new_panel(chatWnd);
|
74
|
379 scr_clear_box(chatWnd, 0, 0, CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH,
|
|
380 COLOR_GENERAL);
|
|
381 scrollok(chatWnd, TRUE);
|
|
382 mvwprintw(chatWnd, 0, 0, "This is the status window");
|
24
|
383
|
|
384 logWnd_border = newwin(LOG_WIN_HEIGHT, maxX, CHAT_WIN_HEIGHT, 0);
|
|
385 logPanel_border = new_panel(logWnd_border);
|
|
386 scr_draw_box(logWnd_border, 0, 0, LOG_WIN_HEIGHT, maxX, COLOR_GENERAL, 0, 0);
|
|
387 logWnd = derwin(logWnd_border, LOG_WIN_HEIGHT-2, maxX-2, 1, 1);
|
|
388 logPanel = new_panel(logWnd);
|
|
389 wbkgd(logWnd, COLOR_PAIR(COLOR_GENERAL));
|
|
390
|
74
|
391 scrollok(logWnd, TRUE);
|
24
|
392
|
|
393 inputWnd = newwin(1, maxX, maxY-1, 0);
|
|
394 inputPanel = new_panel(inputWnd);
|
|
395
|
|
396 bud_DrawRoster(rosterWnd);
|
|
397 update_panels();
|
|
398 doupdate();
|
|
399 return;
|
|
400 }
|
|
401
|
|
402 void scr_TerminateCurses(void)
|
|
403 {
|
|
404 clear();
|
|
405 refresh();
|
|
406 endwin();
|
|
407 return;
|
|
408 }
|
|
409
|
74
|
410 // XXX This function is almost useless now. Once we handle properly
|
|
411 // the prefix in scr_WriteInWindow(), we can remove it...
|
50
|
412 void scr_WriteMessage(const char *jid, const char *text, char *prefix)
|
24
|
413 {
|
74
|
414 char *buffer = (char *) malloc(strlen(prefix) + strlen(text) + 1);
|
24
|
415
|
47
|
416 if (prefix)
|
|
417 strcpy(buffer, prefix);
|
|
418 else
|
|
419 *buffer = 0;
|
|
420
|
|
421 strcat(buffer, text);
|
24
|
422
|
74
|
423 scr_WriteInWindow(jid, buffer, TRUE, FALSE);
|
24
|
424
|
|
425 free(buffer);
|
47
|
426 }
|
|
427
|
50
|
428 void scr_WriteIncomingMessage(const char *jidfrom, const char *text)
|
47
|
429 {
|
|
430 char *buffer = utf8_decode(text);
|
74
|
431 // FIXME expand tabs...
|
47
|
432 scr_WriteMessage(jidfrom, buffer, "<== ");
|
|
433 free(buffer);
|
65
|
434 top_panel(inputPanel);
|
24
|
435 update_panels();
|
|
436 doupdate();
|
|
437 }
|
|
438
|
50
|
439 void scr_WriteOutgoingMessage(const char *jidto, const char *text)
|
47
|
440 {
|
65
|
441 scr_WriteMessage(jidto, text, "--> ");
|
47
|
442 scr_ShowWindow(jidto);
|
65
|
443 top_panel(inputPanel);
|
47
|
444 //refresh(); // XXX ?
|
|
445 }
|
|
446
|
24
|
447 int scr_Getch(void)
|
|
448 {
|
|
449 int ch;
|
|
450 // keypad(inputWnd, TRUE);
|
|
451 ch = wgetch(inputWnd);
|
|
452 return ch;
|
|
453 }
|
|
454
|
|
455 WINDOW *scr_GetRosterWindow(void)
|
|
456 {
|
|
457 return rosterWnd;
|
|
458 }
|
|
459
|
|
460 WINDOW *scr_GetStatusWindow(void)
|
|
461 {
|
|
462 return chatWnd;
|
|
463 }
|
|
464
|
|
465 WINDOW *scr_GetInputWindow(void)
|
|
466 {
|
|
467 return inputWnd;
|
|
468 }
|
|
469
|
44
|
470 // scr_LogPrint(...)
|
|
471 // Display a message in the log window.
|
24
|
472 void scr_LogPrint(const char *fmt, ...)
|
|
473 {
|
|
474 time_t timestamp;
|
|
475 char *buffer;
|
|
476 va_list ap;
|
|
477
|
|
478 buffer = (char *) calloc(1, 4096);
|
|
479
|
|
480 timestamp = time(NULL);
|
|
481 strftime(buffer, 64, "[%H:%M:%S] ", localtime(×tamp));
|
|
482 wprintw(logWnd, "\n%s", buffer);
|
|
483
|
|
484 va_start(ap, fmt);
|
|
485 vsnprintf(buffer, 4096, fmt, ap);
|
|
486 va_end(ap);
|
|
487
|
|
488 wprintw(logWnd, "%s", buffer);
|
|
489 free(buffer);
|
|
490
|
|
491 update_panels();
|
|
492 doupdate();
|
|
493 }
|
|
494
|
|
495 // scr_IsHiddenMessage(jid)
|
|
496 // Returns TRUE if there is a hidden message in the window
|
|
497 // for the jid contact.
|
50
|
498 int scr_IsHiddenMessage(const char *jid) {
|
24
|
499 window_entry_t *wintmp;
|
|
500
|
|
501 wintmp = scr_SearchWindow(jid);
|
|
502 if ((wintmp) && (wintmp->hidden_msg))
|
|
503 return TRUE;
|
|
504
|
|
505 return FALSE;
|
|
506 }
|
|
507
|
|
508 // check_offset(int direction)
|
|
509 // Check inputline_offset value, and make sure the cursor is inside the
|
|
510 // screen.
|
|
511 inline void check_offset(int direction)
|
|
512 {
|
|
513 // Left side
|
|
514 if (inputline_offset && direction <= 0) {
|
|
515 while (ptr_inputline <= (char*)&inputLine + inputline_offset) {
|
|
516 if (inputline_offset) {
|
|
517 inputline_offset -= 5;
|
|
518 if (inputline_offset < 0)
|
|
519 inputline_offset = 0;
|
|
520 }
|
|
521 }
|
|
522 }
|
|
523 // Right side
|
|
524 if (direction >= 0) {
|
|
525 while (ptr_inputline >= inputline_offset + (char*)&inputLine + maxX)
|
|
526 inputline_offset += 5;
|
|
527 }
|
|
528 }
|
|
529
|
44
|
530 // process_key(key)
|
|
531 // Handle the pressed key, in the command line (bottom).
|
29
|
532 int process_key(int key)
|
24
|
533 {
|
|
534 if (isprint(key)) {
|
|
535 char tmpLine[INPUTLINE_LENGTH+1];
|
|
536
|
|
537 // Check the line isn't too long
|
|
538 if (strlen(inputLine) >= INPUTLINE_LENGTH)
|
|
539 return 0;
|
|
540
|
|
541 // Insert char
|
|
542 strcpy(tmpLine, ptr_inputline);
|
|
543 *ptr_inputline++ = key;
|
|
544 strcpy(ptr_inputline, tmpLine);
|
|
545 check_offset(1);
|
|
546 } else {
|
|
547 switch(key) {
|
|
548 case KEY_BACKSPACE:
|
|
549 if (ptr_inputline != (char*)&inputLine) {
|
42
|
550 char *c = --ptr_inputline;
|
|
551 for ( ; *c ; c++)
|
|
552 *c = *(c+1);
|
24
|
553 check_offset(-1);
|
|
554 }
|
|
555 break;
|
|
556 case KEY_DC:
|
|
557 if (*ptr_inputline)
|
|
558 strcpy(ptr_inputline, ptr_inputline+1);
|
|
559 break;
|
|
560 case KEY_LEFT:
|
|
561 if (ptr_inputline != (char*)&inputLine) {
|
|
562 ptr_inputline--;
|
|
563 check_offset(-1);
|
|
564 }
|
|
565 break;
|
|
566 case KEY_RIGHT:
|
|
567 if (*ptr_inputline)
|
|
568 ptr_inputline++;
|
|
569 check_offset(1);
|
|
570 break;
|
|
571 case 9: // Tab
|
|
572 scr_LogPrint("I'm unable to complete yet");
|
|
573 break;
|
|
574 case '\n': // Enter
|
|
575 chatmode = TRUE;
|
|
576 if (inputLine[0] == 0) {
|
|
577 scr_ShowBuddyWindow();
|
|
578 break;
|
|
579 }
|
29
|
580 if (process_line(inputLine))
|
24
|
581 return 255;
|
|
582 ptr_inputline = inputLine;
|
|
583 *ptr_inputline = 0;
|
|
584 inputline_offset = 0;
|
|
585 break;
|
|
586 case KEY_UP:
|
|
587 bud_RosterUp();
|
|
588 if (chatmode)
|
|
589 scr_ShowBuddyWindow();
|
|
590 break;
|
|
591 case KEY_DOWN:
|
|
592 bud_RosterDown();
|
|
593 if (chatmode)
|
|
594 scr_ShowBuddyWindow();
|
|
595 break;
|
|
596 case KEY_PPAGE:
|
|
597 scr_LogPrint("PageUp??");
|
|
598 break;
|
|
599 case KEY_NPAGE:
|
|
600 scr_LogPrint("PageDown??");
|
|
601 break;
|
|
602 case KEY_HOME:
|
|
603 case 1:
|
|
604 ptr_inputline = inputLine;
|
|
605 inputline_offset = 0;
|
|
606 break;
|
|
607 case KEY_END:
|
|
608 case 5:
|
|
609 for (; *ptr_inputline; ptr_inputline++) ;
|
|
610 check_offset(1);
|
|
611 break;
|
|
612 case 21: // Ctrl-u
|
|
613 strcpy(inputLine, ptr_inputline);
|
|
614 ptr_inputline = inputLine;
|
|
615 inputline_offset = 0;
|
|
616 break;
|
|
617 case KEY_EOL:
|
|
618 case 11: // Ctrl-k
|
|
619 *ptr_inputline = 0;
|
|
620 break;
|
|
621 case 16: // Ctrl-p
|
|
622 scr_LogPrint("Ctrl-p not yet implemented");
|
|
623 break;
|
|
624 case 14: // Ctrl-n
|
|
625 scr_LogPrint("Ctrl-n not yet implemented");
|
|
626 break;
|
|
627 case 27: // ESC
|
|
628 currentWindow = NULL;
|
|
629 chatmode = FALSE;
|
|
630 top_panel(chatPanel);
|
|
631 top_panel(inputPanel);
|
|
632 break;
|
|
633 default:
|
|
634 scr_LogPrint("Unkown key=%d", key);
|
|
635 }
|
|
636 }
|
|
637 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset);
|
|
638 wclrtoeol(inputWnd);
|
|
639 if (*ptr_inputline) {
|
|
640 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset);
|
|
641 }
|
|
642 update_panels();
|
|
643 doupdate();
|
|
644 return 0;
|
|
645 }
|