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