diff --git a/ChangeLog b/ChangeLog index 55437d7ff5a56754aa9fc343c385203ff0468b5b..0f76cc76a64f1e6bcf626b3c703e0ea31aae2e22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -125,10 +125,8 @@ CVS code - mode should only affect how the "Read File" command behaves anyway. (DLR) - Remove the disabling of implementation-defined input - processing, as raw mode appears to turn it off anyway. (DLR) - - Use raw mode instead of cbreak mode, since it comes closest to - what we need by automatically disabling the special control - keys. (DLR) + processing, as cbreak mode appears to turn it off anyway. + (DLR) - After noecho(), call disable_signals() and disable_flow_control(), the latter only if PRESERVE is not set. (DLR) diff --git a/src/nano.c b/src/nano.c index 370e8f06077ca9e94e1fbded7b17d1ff6b3ce132..fb449a736022ba7b4e96bf76abdafb5c7d3d5199 100644 --- a/src/nano.c +++ b/src/nano.c @@ -829,6 +829,8 @@ int open_pipe(const char *command) /* Before we start reading the forked command's output, we set * things up so that ^C will cancel the new process. */ + /* Enable interpretation of the special control keys so that we get + * SIGINT when Ctrl-C is pressed. */ enable_signals(); if (sigaction(SIGINT, NULL, &newaction) == -1) { @@ -860,6 +862,8 @@ int open_pipe(const char *command) if (cancel_sigs != 1 && sigaction(SIGINT, &oldaction, NULL) == -1) nperror("sigaction"); + /* Disable interpretation of the special control keys so that we can + * use Ctrl-C for other things. */ disable_signals(); return 0; @@ -2954,7 +2958,6 @@ void do_toggle(const toggle *which) } #endif /* !NANO_SMALL */ -#if !defined(NANO_SMALL) || defined(USE_SLANG) void disable_signals(void) { struct termios term; @@ -2963,7 +2966,6 @@ void disable_signals(void) term.c_lflag &= ~ISIG; tcsetattr(0, TCSANOW, &term); } -#endif #ifndef NANO_SMALL void enable_signals(void) @@ -3401,25 +3403,21 @@ int main(int argc, char *argv[]) tcgetattr(0, &oldterm); /* Curses initialization stuff: Start curses, save the state of the - * terminal mode, put the terminal in raw mode (read one character at - * a time and don't interpret the special control keys), disable + * terminal mode, put the terminal in cbreak mode (read one character + * at a time and interpret the special control keys), disable * translation of carriage return (^M) into newline (^J) so that we * can tell the difference between the Enter key and Ctrl-J, and - * disable echoing of characters as they're typed. Finally, if we're - * in preserve mode, turn the flow control characters back on. */ + * disable echoing of characters as they're typed. Finally, disable + * interpretation of the special control keys, and if we're not in + * preserve mode, disable interpretation of the flow control + * characters too. */ initscr(); - raw(); -#ifdef USE_SLANG - /* Slang curses emulation brain damage, part 2: Raw mode acts just - * like cbreak mode here and doesn't disable interpretation of the - * special control keys. Work around this by manually disabling - * interpretation of the special control keys. */ - disable_signals(); -#endif + cbreak(); nonl(); noecho(); - if (ISSET(PRESERVE)) - enable_flow_control(); + disable_signals(); + if (!ISSET(PRESERVE)) + disable_flow_control(); #ifndef NANO_SMALL /* Save the terminal's current state, so that we can restore it diff --git a/src/nano.h b/src/nano.h index 5f711d04b68d4a6f66bf702ebf03d572428ff6b7..9207e6255fab2683ca9caf79dacc15afd9bee8f0 100644 --- a/src/nano.h +++ b/src/nano.h @@ -56,7 +56,7 @@ #ifdef USE_SLANG /* Slang support enabled. */ #include <slcurses.h> -/* Slang curses emulation brain damage, part 3: Slang doesn't define the +/* Slang curses emulation brain damage, part 2: Slang doesn't define the * curses equivalents of the Insert or Delete keys. */ #define KEY_DC SL_KEY_DELETE #define KEY_IC SL_KEY_IC