go back to cbreak mode and disable_signals() instead of raw mode, as
disable_signals() doesn't take up much space and we need one fewer slang workaround that way git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1748 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
fd462b164e
commit
e608f94a6f
|
@ -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)
|
||||
|
|
30
src/nano.c
30
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue