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