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
|
mode should only affect how the "Read File" command behaves
|
||||||
anyway. (DLR)
|
anyway. (DLR)
|
||||||
- Remove the disabling of implementation-defined input
|
- Remove the disabling of implementation-defined input
|
||||||
processing, as raw mode appears to turn it off anyway. (DLR)
|
processing, as cbreak mode appears to turn it off anyway.
|
||||||
- Use raw mode instead of cbreak mode, since it comes closest to
|
(DLR)
|
||||||
what we need by automatically disabling the special control
|
|
||||||
keys. (DLR)
|
|
||||||
- After noecho(), call disable_signals() and
|
- After noecho(), call disable_signals() and
|
||||||
disable_flow_control(), the latter only if PRESERVE is not
|
disable_flow_control(), the latter only if PRESERVE is not
|
||||||
set. (DLR)
|
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
|
/* Before we start reading the forked command's output, we set
|
||||||
* things up so that ^C will cancel the new process. */
|
* 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();
|
enable_signals();
|
||||||
|
|
||||||
if (sigaction(SIGINT, NULL, &newaction) == -1) {
|
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)
|
if (cancel_sigs != 1 && sigaction(SIGINT, &oldaction, NULL) == -1)
|
||||||
nperror("sigaction");
|
nperror("sigaction");
|
||||||
|
|
||||||
|
/* Disable interpretation of the special control keys so that we can
|
||||||
|
* use Ctrl-C for other things. */
|
||||||
disable_signals();
|
disable_signals();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2954,7 +2958,6 @@ void do_toggle(const toggle *which)
|
||||||
}
|
}
|
||||||
#endif /* !NANO_SMALL */
|
#endif /* !NANO_SMALL */
|
||||||
|
|
||||||
#if !defined(NANO_SMALL) || defined(USE_SLANG)
|
|
||||||
void disable_signals(void)
|
void disable_signals(void)
|
||||||
{
|
{
|
||||||
struct termios term;
|
struct termios term;
|
||||||
|
@ -2963,7 +2966,6 @@ void disable_signals(void)
|
||||||
term.c_lflag &= ~ISIG;
|
term.c_lflag &= ~ISIG;
|
||||||
tcsetattr(0, TCSANOW, &term);
|
tcsetattr(0, TCSANOW, &term);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void enable_signals(void)
|
void enable_signals(void)
|
||||||
|
@ -3401,25 +3403,21 @@ int main(int argc, char *argv[])
|
||||||
tcgetattr(0, &oldterm);
|
tcgetattr(0, &oldterm);
|
||||||
|
|
||||||
/* Curses initialization stuff: Start curses, save the state of the
|
/* Curses initialization stuff: Start curses, save the state of the
|
||||||
* terminal mode, put the terminal in raw mode (read one character at
|
* terminal mode, put the terminal in cbreak mode (read one character
|
||||||
* a time and don't interpret the special control keys), disable
|
* at a time and interpret the special control keys), disable
|
||||||
* translation of carriage return (^M) into newline (^J) so that we
|
* translation of carriage return (^M) into newline (^J) so that we
|
||||||
* can tell the difference between the Enter key and Ctrl-J, and
|
* can tell the difference between the Enter key and Ctrl-J, and
|
||||||
* disable echoing of characters as they're typed. Finally, if we're
|
* disable echoing of characters as they're typed. Finally, disable
|
||||||
* in preserve mode, turn the flow control characters back on. */
|
* interpretation of the special control keys, and if we're not in
|
||||||
|
* preserve mode, disable interpretation of the flow control
|
||||||
|
* characters too. */
|
||||||
initscr();
|
initscr();
|
||||||
raw();
|
cbreak();
|
||||||
#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
|
|
||||||
nonl();
|
nonl();
|
||||||
noecho();
|
noecho();
|
||||||
if (ISSET(PRESERVE))
|
disable_signals();
|
||||||
enable_flow_control();
|
if (!ISSET(PRESERVE))
|
||||||
|
disable_flow_control();
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* Save the terminal's current state, so that we can restore it
|
/* Save the terminal's current state, so that we can restore it
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
#ifdef USE_SLANG
|
#ifdef USE_SLANG
|
||||||
/* Slang support enabled. */
|
/* Slang support enabled. */
|
||||||
#include <slcurses.h>
|
#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. */
|
* curses equivalents of the Insert or Delete keys. */
|
||||||
#define KEY_DC SL_KEY_DELETE
|
#define KEY_DC SL_KEY_DELETE
|
||||||
#define KEY_IC SL_KEY_IC
|
#define KEY_IC SL_KEY_IC
|
||||||
|
|
Loading…
Reference in New Issue