simplify terminal handling by using raw mode instead of cbreak mode
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4202 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
8b9c91b80d
commit
7f6f5a64fb
|
@ -1,10 +1,13 @@
|
||||||
2007-12-17 David Lawrence Ramsey <pooka109@gmail.com>
|
2007-12-17 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
|
||||||
* ChangeLog.pre-2.1: Add missing attribution.
|
* nano.c (disable_signals, main): Simplify terminal handling by
|
||||||
* NEWS: Resync with NEWS from the 2.0 branch.
|
using raw mode instead of cbreak mode. This eliminates the need
|
||||||
|
for disable_signals().
|
||||||
* text.c (execute_command): Call terminal_init() instead of just
|
* text.c (execute_command): Call terminal_init() instead of just
|
||||||
disable_signals() after executing the command, as the command
|
disable_signals() after executing the command, as the command
|
||||||
may have changed the terminal settings.
|
may have changed the terminal settings.
|
||||||
|
* ChangeLog.pre-2.1: Add missing attribution.
|
||||||
|
* NEWS: Resync with NEWS from the 2.0 branch.
|
||||||
|
|
||||||
2007-12-10 David Lawrence Ramsey <pooka109@gmail.com>
|
2007-12-10 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
|
||||||
|
|
34
src/nano.c
34
src/nano.c
|
@ -1258,17 +1258,6 @@ void disable_extended_io(void)
|
||||||
tcsetattr(0, TCSANOW, &term);
|
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
|
#ifndef NANO_TINY
|
||||||
/* Enable interpretation of the special control keys in our terminal
|
/* Enable interpretation of the special control keys in our terminal
|
||||||
* settings. */
|
* settings. */
|
||||||
|
@ -1304,14 +1293,14 @@ void enable_flow_control(void)
|
||||||
tcsetattr(0, TCSANOW, &term);
|
tcsetattr(0, TCSANOW, &term);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up the terminal state. Put the terminal in cbreak mode (read one
|
/* Set up the terminal state. Put the terminal in raw mode (read one
|
||||||
* character at a time and interpret the special control keys), disable
|
* character at a time, disable the special control keys, and disable
|
||||||
* translation of carriage return (^M) into newline (^J) so that we can
|
* the flow control characters), disable translation of carriage return
|
||||||
* tell the difference between the Enter key and Ctrl-J, and disable
|
* (^M) into newline (^J) so that we can tell the difference between the
|
||||||
* echoing of characters as they're typed. Finally, disable extended
|
* Enter key and Ctrl-J, and disable echoing of characters as they're
|
||||||
* input and output processing, disable interpretation of the special
|
* typed. Finally, disable extended input and output processing, and,
|
||||||
* control keys, and if we're not in preserve mode, disable
|
* if we're not in preserve mode, reenable interpretation of the flow
|
||||||
* interpretation of the flow control characters too. */
|
* control characters. */
|
||||||
void terminal_init(void)
|
void terminal_init(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_SLANG
|
#ifdef USE_SLANG
|
||||||
|
@ -1326,13 +1315,12 @@ void terminal_init(void)
|
||||||
if (!newterm_set) {
|
if (!newterm_set) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cbreak();
|
raw();
|
||||||
nonl();
|
nonl();
|
||||||
noecho();
|
noecho();
|
||||||
disable_extended_io();
|
disable_extended_io();
|
||||||
disable_signals();
|
if (ISSET(PRESERVE))
|
||||||
if (!ISSET(PRESERVE))
|
enable_flow_control();
|
||||||
disable_flow_control();
|
|
||||||
|
|
||||||
#ifdef USE_SLANG
|
#ifdef USE_SLANG
|
||||||
tcgetattr(0, &newterm);
|
tcgetattr(0, &newterm);
|
||||||
|
|
|
@ -475,7 +475,6 @@ void allow_pending_sigwinch(bool allow);
|
||||||
void do_toggle(const toggle *which);
|
void do_toggle(const toggle *which);
|
||||||
#endif
|
#endif
|
||||||
void disable_extended_io(void);
|
void disable_extended_io(void);
|
||||||
void disable_signals(void);
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
void enable_signals(void);
|
void enable_signals(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue