use raw mode in get_verbatim_kbinput(), so that we don't have to deal

with interrupt-generating keys there


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1638 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-01-28 18:21:21 +00:00
parent 58f6d836d9
commit d03216a1ac
3 changed files with 29 additions and 31 deletions

View File

@ -14,6 +14,10 @@ CVS code -
- New function used to write the current marked selection to a - New function used to write the current marked selection to a
file, split out from do_writeout(). (DLR) file, split out from do_writeout(). (DLR)
- nano.c: - nano.c:
do_verbatim_input()
- Remove the now-unneeded code to disable XON, XOFF, and
suspend, since we now go into raw mode in
get_verbatim_kbinput() and bypass them. (DLR)
do_spell(), do_int_speller(), do_alt_speller() do_spell(), do_int_speller(), do_alt_speller()
- Modify to write only the current selection from a file to the - Modify to write only the current selection from a file to the
temporary file used for spell checking when the mark is on, temporary file used for spell checking when the mark is on,
@ -26,7 +30,9 @@ CVS code -
main() main()
- Move the call to raw() on systems that don't define - Move the call to raw() on systems that don't define
_POSIX_VDISABLE outside the main input/output loop, as it _POSIX_VDISABLE outside the main input/output loop, as it
doesn't need to be called every time through the loop. (DLR) doesn't need to be called every time through the loop. Call it
instead of cbreak() on such systems, as it overrides cbreak()
anyway. (DLR)
- search.c: - search.c:
do_replace_loop() do_replace_loop()
- Fix segfault when doing a regex replace of a string that - Fix segfault when doing a regex replace of a string that
@ -34,12 +40,16 @@ CVS code -
anything). (David Benbennick) anything). (David Benbennick)
- winio.c: - winio.c:
get_verbatim_kbinput() get_verbatim_kbinput()
- Set keypad() to FALSE while reading input, and set it back to - Set keypad() to FALSE and switch to raw mode while reading
TRUE afterwards. This ensures that we don't end up reading in input, and set it keypad() back to TRUE and go back into
extended keypad values that are outside the ASCII range. cbreak mode afterwards. (Note that if _POSIX_VDISABLE isn't
(Also, with keypad() set to TRUE, xterm generates defined, we don't need to change to or from raw mode since
we're already in it exclusively.) This ensures that we don't
end up reading in extended keypad values that are outside the
ASCII range or having to deal with interrupt-generating key
values. Also, with keypad() set to TRUE, xterm generates
KEY_BACKSPACE when the user hits Ctrl-H, which, when cut down KEY_BACKSPACE when the user hits Ctrl-H, which, when cut down
to ASCII range, ends up being Ctrl-G, which can be confusing.) to ASCII range, ends up being Ctrl-G, which can be confusing.
(DLR) (DLR)
get_accepted_kbinput() get_accepted_kbinput()
- Don't use "kbinput = wgetch(win)" as a switch value. (DLR) - Don't use "kbinput = wgetch(win)" as a switch value. (DLR)

View File

@ -1003,19 +1003,8 @@ int do_verbatim_input(void)
{ {
char *verbatim_kbinput; /* Used to hold verbatim input */ char *verbatim_kbinput; /* Used to hold verbatim input */
int verbatim_len; /* Length of verbatim input */ int verbatim_len; /* Length of verbatim input */
int old_preserve = ISSET(PRESERVE), old_suspend = ISSET(SUSPEND);
int i; int i;
/* Turn off Ctrl-Q (XON), Ctrl-S (XOFF), and Ctrl-Z (suspend) if
* they're on, so that we can use them to insert ^Q, ^S, and ^Z
* verbatim. */
if (old_preserve)
UNSET(PRESERVE);
if (old_suspend)
UNSET(SUSPEND);
if (old_preserve || old_suspend)
signal_init();
statusbar(_("Verbatim input")); statusbar(_("Verbatim input"));
verbatim_kbinput = get_verbatim_kbinput(edit, &verbatim_len, 1); verbatim_kbinput = get_verbatim_kbinput(edit, &verbatim_len, 1);
@ -1029,15 +1018,6 @@ int do_verbatim_input(void)
free(verbatim_kbinput); free(verbatim_kbinput);
/* Turn Ctrl-Q, Ctrl-S, and Ctrl-Z back on if they were on
* before. */
if (old_preserve)
SET(PRESERVE);
if (old_suspend)
SET(SUSPEND);
if (old_preserve || old_suspend)
signal_init();
return 1; return 1;
} }
@ -3447,13 +3427,13 @@ int main(int argc, char *argv[])
initscr(); initscr();
savetty(); savetty();
nonl(); nonl();
cbreak();
noecho();
#ifndef _POSIX_VDISABLE #ifndef _POSIX_VDISABLE
/* We're going to have to do it the old way, i.e, on Cygwin. */ /* We're going to have to do it the old way, i.e, on Cygwin. */
raw(); raw();
#else
cbreak();
#endif #endif
noecho();
/* Set up some global variables */ /* Set up some global variables */
global_init(0); global_init(0);

View File

@ -61,8 +61,12 @@ char *get_verbatim_kbinput(WINDOW *win, int *kbinput_len,
int kbinput; int kbinput;
/* Turn the keypad off so that we don't get extended keypad values, /* Turn the keypad off so that we don't get extended keypad values,
* all of which are outside the ASCII range. */ * all of which are outside the ASCII range, and switch to raw mode
* so that we can type ^Q, ^S, and ^Z without getting interrupts. */
keypad(win, FALSE); keypad(win, FALSE);
#ifndef _POSIX_VDISABLE
raw();
#endif
kbinput = wgetch(win); kbinput = wgetch(win);
verbatim_kbinput = charalloc(1); verbatim_kbinput = charalloc(1);
@ -84,8 +88,12 @@ char *get_verbatim_kbinput(WINDOW *win, int *kbinput_len,
nodelay(win, FALSE); nodelay(win, FALSE);
} }
/* Turn the keypad back on now that we're done. */ /* Turn the keypad back on and switch back to cbreak mode now that
* we're done. */
keypad(win, TRUE); keypad(win, TRUE);
#ifndef _POSIX_VDISABLE
cbreak();
#endif
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "get_verbatim_kbinput(): verbatim_kbinput = %s\n", verbatim_kbinput); fprintf(stderr, "get_verbatim_kbinput(): verbatim_kbinput = %s\n", verbatim_kbinput);