comparison mcabber/src/screen.c @ 232:9a6ba4b38e63

[/trunk] Changeset 245 by mikael * Fix backspace handling (KEY_BACKSPACE isn't reliable) * UTF-8 locale detection * Display a warning when the locale is UTF-8 * Display log notice when sending a notification request message * Update TODO * Update INSTALL and mcabberrc.example files for better explanations
author mikael
date Wed, 08 Jun 2005 18:33:28 +0000
parents 8dfdc6f1778e
children 72fd1273f2b7
comparison
equal deleted inserted replaced
231:193c08454aac 232:9a6ba4b38e63
4 #include <ncurses.h> 4 #include <ncurses.h>
5 #include <panel.h> 5 #include <panel.h>
6 #include <time.h> 6 #include <time.h>
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <locale.h> 8 #include <locale.h>
9 #include <langinfo.h>
9 10
10 #include "screen.h" 11 #include "screen.h"
11 #include "hbuf.h" 12 #include "hbuf.h"
12 #include "commands.h" 13 #include "commands.h"
13 #include "compl.h" 14 #include "compl.h"
41 static int maxY, maxX; 42 static int maxY, maxX;
42 static window_entry_t *currentWindow; 43 static window_entry_t *currentWindow;
43 44
44 static int chatmode; 45 static int chatmode;
45 int update_roster; 46 int update_roster;
47 int utf8_mode = 0;
46 48
47 static char inputLine[INPUTLINE_LENGTH+1]; 49 static char inputLine[INPUTLINE_LENGTH+1];
48 static char *ptr_inputline; 50 static char *ptr_inputline;
49 static short int inputline_offset; 51 static short int inputline_offset;
50 static int completion_started; 52 static int completion_started;
443 maxY = LOG_WIN_HEIGHT+2; 445 maxY = LOG_WIN_HEIGHT+2;
444 inputLine[0] = 0; 446 inputLine[0] = 0;
445 ptr_inputline = inputLine; 447 ptr_inputline = inputLine;
446 448
447 setlocale(LC_CTYPE, ""); 449 setlocale(LC_CTYPE, "");
450 utf8_mode = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0);
448 451
449 return; 452 return;
450 } 453 }
451 454
452 void scr_TerminateCurses(void) 455 void scr_TerminateCurses(void)
510 rosterPanel = new_panel(rosterWnd); 513 rosterPanel = new_panel(rosterWnd);
511 chatPanel = new_panel(chatWnd); 514 chatPanel = new_panel(chatWnd);
512 logPanel_border = new_panel(logWnd_border); 515 logPanel_border = new_panel(logWnd_border);
513 logPanel = new_panel(logWnd); 516 logPanel = new_panel(logWnd);
514 inputPanel = new_panel(inputWnd); 517 inputPanel = new_panel(inputWnd);
518
519 if (utf8_mode)
520 scr_LogPrint("WARNING: UTF-8 not yet supported!");
515 } else { 521 } else {
516 // Update panels 522 // Update panels
517 replace_panel(rosterPanel, rosterWnd); 523 replace_panel(rosterPanel, rosterWnd);
518 replace_panel(chatPanel, chatWnd); 524 replace_panel(chatPanel, chatWnd);
519 replace_panel(logPanel, logWnd); 525 replace_panel(logPanel, logWnd);
1307 *ptr_inputline++ = key; 1313 *ptr_inputline++ = key;
1308 strcpy(ptr_inputline, tmpLine); 1314 strcpy(ptr_inputline, tmpLine);
1309 check_offset(1); 1315 check_offset(1);
1310 } else { 1316 } else {
1311 switch(key) { 1317 switch(key) {
1318 case 8: // Ctrl-h
1319 case 127: // Backspace too
1312 case KEY_BACKSPACE: 1320 case KEY_BACKSPACE:
1313 if (ptr_inputline != (char*)&inputLine) { 1321 if (ptr_inputline != (char*)&inputLine) {
1314 char *c = --ptr_inputline; 1322 char *c = --ptr_inputline;
1315 for ( ; *c ; c++) 1323 for ( ; *c ; c++)
1316 *c = *(c+1); 1324 *c = *(c+1);
1423 case KEY_RESIZE: 1431 case KEY_RESIZE:
1424 scr_Resize(); 1432 scr_Resize();
1425 break; 1433 break;
1426 default: 1434 default:
1427 scr_LogPrint("Unkown key=%d", key); 1435 scr_LogPrint("Unkown key=%d", key);
1436 if (utf8_mode)
1437 scr_LogPrint("WARNING: UTF-8 not yet supported!");
1428 } 1438 }
1429 } 1439 }
1430 if (completion_started && key != 9 && key != KEY_RESIZE) 1440 if (completion_started && key != 9 && key != KEY_RESIZE)
1431 scr_end_current_completion(); 1441 scr_end_current_completion();
1432 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset); 1442 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset);