comparison mcabber/src/screen.c @ 389:6e895f397474

Ncurses changes + Ctrl-C does not send a signal anylore * Use nonl() when initializing ncurses * Ctrl-C does not send a signal in raw mode, so we handle it as a normal key
author Mikael Berthe <mikael@lilotux.net>
date Sat, 30 Jul 2005 10:36:46 +0100
parents f211238d5812
children f8f3c7493457
comparison
equal deleted inserted replaced
388:f211238d5812 389:6e895f397474
200 void scr_InitCurses(void) 200 void scr_InitCurses(void)
201 { 201 {
202 initscr(); 202 initscr();
203 raw(); 203 raw();
204 noecho(); 204 noecho();
205 nonl();
206 intrflush(stdscr, FALSE);
205 start_color(); 207 start_color();
206 use_default_colors(); 208 use_default_colors();
207 Curses = TRUE; 209 Curses = TRUE;
208 210
209 ParseColors(); 211 ParseColors();
1430 wclrtoeol(inputWnd); 1432 wclrtoeol(inputWnd);
1431 if (*ptr_inputline) 1433 if (*ptr_inputline)
1432 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset); 1434 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset);
1433 } 1435 }
1434 1436
1435 void scr_handle_sigint(void) 1437 void scr_handle_CtrlC(void)
1436 { 1438 {
1437 if (!Curses) return; 1439 if (!Curses) return;
1438 // Leave multi-line mode 1440 // Leave multi-line mode
1439 process_command("/msay abort"); 1441 process_command("/msay abort");
1440 // Same as Ctrl-g, now 1442 // Same as Ctrl-g, now
1501 break; 1503 break;
1502 case 9: // Tab 1504 case 9: // Tab
1503 scr_handle_tab(); 1505 scr_handle_tab();
1504 check_offset(0); 1506 check_offset(0);
1505 break; 1507 break;
1506 case '\n': // Enter 1508 case 13: // Enter
1507 case 15: // Ctrl-o ("accept-line-and-down-history") 1509 case 15: // Ctrl-o ("accept-line-and-down-history")
1508 scr_CheckAutoAway(TRUE); 1510 scr_CheckAutoAway(TRUE);
1509 if (process_line(inputLine)) 1511 if (process_line(inputLine))
1510 return 255; 1512 return 255;
1511 // Add line to history 1513 // Add line to history
1513 // Reset the line 1515 // Reset the line
1514 ptr_inputline = inputLine; 1516 ptr_inputline = inputLine;
1515 *ptr_inputline = 0; 1517 *ptr_inputline = 0;
1516 inputline_offset = 0; 1518 inputline_offset = 0;
1517 1519
1518 if (key == '\n') // Enter 1520 if (key == 13) // Enter
1519 { 1521 {
1520 // Reset history line pointer 1522 // Reset history line pointer
1521 cmdhisto_cur = NULL; 1523 cmdhisto_cur = NULL;
1522 } else { // down-history 1524 } else { // down-history
1523 // Use next history line instead of a blank line 1525 // Use next history line instead of a blank line
1556 break; 1558 break;
1557 case KEY_HOME: 1559 case KEY_HOME:
1558 case 1: 1560 case 1:
1559 ptr_inputline = inputLine; 1561 ptr_inputline = inputLine;
1560 inputline_offset = 0; 1562 inputline_offset = 0;
1563 break;
1564 case 3: // Ctrl-C
1565 scr_handle_CtrlC();
1561 break; 1566 break;
1562 case KEY_END: 1567 case KEY_END:
1563 case 5: 1568 case 5:
1564 for (; *ptr_inputline; ptr_inputline++) ; 1569 for (; *ptr_inputline; ptr_inputline++) ;
1565 check_offset(1); 1570 check_offset(1);