# HG changeset patch # User Mikael Berthe # Date 1122716206 -3600 # Node ID 6e895f39747410750d3a543caa9e49ea1efbc7e8 # Parent f211238d581204c03bb6d68540cb62185681c739 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 diff -r f211238d5812 -r 6e895f397474 mcabber/src/main.c --- a/mcabber/src/main.c Fri Jul 29 20:28:06 2005 +0100 +++ b/mcabber/src/main.c Sat Jul 30 10:36:46 2005 +0100 @@ -114,17 +114,8 @@ signal(SIGCHLD, sig_handler); } else if (signum == SIGTERM) { mcabber_disconnect("Killed by SIGTERM"); - } else if (signum == SIGINT) { // Ctrl-C - static time_t LastSigtermTime; - time_t now; - time(&now); - /* Terminate if 2 consecutive SIGTERMs */ - if (now - LastSigtermTime < 2) - mcabber_disconnect("Killed by SIGINT"); - LastSigtermTime = now; - signal(SIGINT, sig_handler); - scr_handle_sigint(); - scr_LogPrint(LPRINT_NORMAL, "Hit Ctrl-C twice to leave mcabber"); + } else if (signum == SIGINT) { + mcabber_disconnect("Killed by SIGINT"); } else { scr_LogPrint(LPRINT_LOGNORM, "Caught signal: %d", signum); } diff -r f211238d5812 -r 6e895f397474 mcabber/src/screen.c --- a/mcabber/src/screen.c Fri Jul 29 20:28:06 2005 +0100 +++ b/mcabber/src/screen.c Sat Jul 30 10:36:46 2005 +0100 @@ -202,6 +202,8 @@ initscr(); raw(); noecho(); + nonl(); + intrflush(stdscr, FALSE); start_color(); use_default_colors(); Curses = TRUE; @@ -1432,7 +1434,7 @@ wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset); } -void scr_handle_sigint(void) +void scr_handle_CtrlC(void) { if (!Curses) return; // Leave multi-line mode @@ -1503,7 +1505,7 @@ scr_handle_tab(); check_offset(0); break; - case '\n': // Enter + case 13: // Enter case 15: // Ctrl-o ("accept-line-and-down-history") scr_CheckAutoAway(TRUE); if (process_line(inputLine)) @@ -1515,7 +1517,7 @@ *ptr_inputline = 0; inputline_offset = 0; - if (key == '\n') // Enter + if (key == 13) // Enter { // Reset history line pointer cmdhisto_cur = NULL; @@ -1559,6 +1561,9 @@ ptr_inputline = inputLine; inputline_offset = 0; break; + case 3: // Ctrl-C + scr_handle_CtrlC(); + break; case KEY_END: case 5: for (; *ptr_inputline; ptr_inputline++) ; diff -r f211238d5812 -r 6e895f397474 mcabber/src/screen.h --- a/mcabber/src/screen.h Fri Jul 29 20:28:06 2005 +0100 +++ b/mcabber/src/screen.h Sat Jul 30 10:36:46 2005 +0100 @@ -38,7 +38,6 @@ inline int scr_get_multimode(); void scr_append_multiline(const char *line); inline const char *scr_get_multiline(); -void scr_handle_sigint(void); int scr_Getch(void);