From: David Lawrence Ramsey Date: Tue, 18 Dec 2007 02:03:00 +0000 (+0000) Subject: simplify terminal handling by using raw mode instead of cbreak mode X-Git-Tag: v2.0.7~9 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=9c2d8632efd7c15cb7d981611a713fe2e5e93a10;p=nano.git simplify terminal handling by using raw mode instead of cbreak mode git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_0_branch/nano@4202 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index dac981b8..94de6aa1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -46,6 +46,8 @@ CVS code - do_statusbar_mouse(), reset_statusbar_cursor(), update_statusbar_line(), and need_statusbar_horizontal_update(). (DLR) + - Simplify terminal handling by using raw mode instead of cbreak + mode. Changes to main(); removal of disable_signals(). (DLR) - chars.c: nstrncasecmp(), mbstrncasecmp() - For efficiency, return zero immediately if s1 and s2 point to diff --git a/src/nano.c b/src/nano.c index 045157ce..68c7cda0 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1256,17 +1256,6 @@ void disable_extended_io(void) tcsetattr(0, TCSANOW, &term); } -/* Disable interpretation of the special control keys in our terminal - * settings. */ -void disable_signals(void) -{ - struct termios term; - - tcgetattr(0, &term); - term.c_lflag &= ~ISIG; - tcsetattr(0, TCSANOW, &term); -} - #ifndef NANO_TINY /* Enable interpretation of the special control keys in our terminal * settings. */ @@ -1302,14 +1291,14 @@ void enable_flow_control(void) tcsetattr(0, TCSANOW, &term); } -/* Set up the terminal state. 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, disable extended - * input and output processing, disable interpretation of the special - * control keys, and if we're not in preserve mode, disable - * interpretation of the flow control characters too. */ +/* Set up the terminal state. Put the terminal in raw mode (read one + * character at a time, disable the special control keys, and disable + * the flow control characters), 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, disable extended input and output processing, and, + * if we're not in preserve mode, reenable interpretation of the flow + * control characters. */ void terminal_init(void) { #ifdef USE_SLANG @@ -1324,13 +1313,12 @@ void terminal_init(void) if (!newterm_set) { #endif - cbreak(); + raw(); nonl(); noecho(); disable_extended_io(); - disable_signals(); - if (!ISSET(PRESERVE)) - disable_flow_control(); + if (ISSET(PRESERVE)) + enable_flow_control(); #ifdef USE_SLANG tcgetattr(0, &newterm); diff --git a/src/proto.h b/src/proto.h index 0508d377..055e59dc 100644 --- a/src/proto.h +++ b/src/proto.h @@ -475,7 +475,6 @@ void allow_pending_sigwinch(bool allow); void do_toggle(const toggle *which); #endif void disable_extended_io(void); -void disable_signals(void); #ifndef NANO_TINY void enable_signals(void); #endif