set the input mode before turning the keypad on, and don't turn the

keypad on in a window before that window's initialized (oddly, ncurses
didn't segfault on the latter, but slang did)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1701 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-03-29 18:36:39 +00:00
parent fd1768a902
commit ce991bb3ad
3 changed files with 23 additions and 25 deletions

View File

@ -44,6 +44,7 @@ CVS code -
no longer needed. (David Benbennick) no longer needed. (David Benbennick)
- Rename several variables to make their use clearer and to - Rename several variables to make their use clearer and to
avoid conflicts. (DLR) avoid conflicts. (DLR)
- Set the input mode before turning the keypad on. (DLR)
- files.c: - files.c:
do_insertfile() do_insertfile()
- Wrap one reference to NANO_EXTCMD_KEY in a NANO_SMALL #ifdef. - Wrap one reference to NANO_EXTCMD_KEY in a NANO_SMALL #ifdef.
@ -114,6 +115,8 @@ CVS code -
curses setup routines, and turn the keypad on before setting curses setup routines, and turn the keypad on before setting
the input mode. (DLR) the input mode. (DLR)
- Remove stray HAVE_GETOPT_LONG #ifdefs. (DLR) - Remove stray HAVE_GETOPT_LONG #ifdefs. (DLR)
- Don't call keypad() before initializing the windows it needs
via window_init().
- nano.h: - nano.h:
- Move the NANO_H include guard up before the first #include. - Move the NANO_H include guard up before the first #include.
(DLR) (DLR)

View File

@ -225,21 +225,19 @@ void window_init(void)
if (editwinrows < MIN_EDITOR_ROWS) if (editwinrows < MIN_EDITOR_ROWS)
die_too_small(); die_too_small();
if (edit != NULL)
delwin(edit);
if (topwin != NULL) if (topwin != NULL)
delwin(topwin); delwin(topwin);
if (edit != NULL)
delwin(edit);
if (bottomwin != NULL) if (bottomwin != NULL)
delwin(bottomwin); delwin(bottomwin);
/* Set up the main text window. */ /* Set up the windows. */
edit = newwin(editwinrows, COLS, 2, 0);
/* And the other windows. */
topwin = newwin(2, COLS, 0, 0); topwin = newwin(2, COLS, 0, 0);
edit = newwin(editwinrows, COLS, 2, 0);
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0); bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
/* Turn the keypad on, so that it still works after a Meta-X. */ /* Turn the keypad on in the windows we'll be reading input from. */
keypad(edit, TRUE); keypad(edit, TRUE);
keypad(bottomwin, TRUE); keypad(bottomwin, TRUE);
} }
@ -2939,13 +2937,13 @@ void handle_sigwinch(int s)
/* Turn cursor back on for sure. */ /* Turn cursor back on for sure. */
curs_set(1); curs_set(1);
/* Turn the keypad on and switch to cbreak mode, so that the keypad /* Switch to cbreak mode and turn the keypad on, so that the keypad
* and input still work if we resized during verbatim input. */ * and input still work if we resized during verbatim input. */
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
#ifdef _POSIX_VDISABLE #ifdef _POSIX_VDISABLE
cbreak(); cbreak();
#endif #endif
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
/* Jump back to the main loop. */ /* Jump back to the main loop. */
siglongjmp(jmpbuf, 1); siglongjmp(jmpbuf, 1);
@ -2964,7 +2962,7 @@ void allow_pending_sigwinch(int allow)
#endif /* !NANO_SMALL */ #endif /* !NANO_SMALL */
/* If the NumLock key has made the keypad go awry, print an error /* If the NumLock key has made the keypad go awry, print an error
message; hopefully we can address it later. */ * message; hopefully we can address it later. */
void print_numlock_warning(void) void print_numlock_warning(void)
{ {
static int didmsg = 0; static int didmsg = 0;
@ -3428,17 +3426,14 @@ int main(int argc, char *argv[])
/* Curses initialization stuff: Start curses, save the state of the /* Curses initialization stuff: Start curses, save the state of the
* the terminal mode, disable translation of carriage return (^M) * the terminal mode, disable translation of carriage return (^M)
* into newline (^J) so we can catch the Enter key and use ^J for * into newline (^J) so we can catch the Enter key and use ^J for
* Justify, turn the keypad on for the windows that read input, put * Justify, put the terminal in cbreak mode (read one character at a
* the terminal in cbreak mode (read one character at a time and * time and interpret the special control keys) if we can selectively
* interpret the special control keys) if we can selectively disable * disable the special control keys or raw mode (read one character
* the special control keys or raw mode (read one character at a * at a time and don't interpret the special control keys) if we
* time and don't interpret the special control keys) if we
* can't, and turn off echoing of characters as they're typed. */ * can't, and turn off echoing of characters as they're typed. */
initscr(); initscr();
savetty(); savetty();
nonl(); nonl();
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
#ifdef _POSIX_VDISABLE #ifdef _POSIX_VDISABLE
cbreak(); cbreak();
#else #else

View File

@ -74,14 +74,14 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
allow_pending_sigwinch(TRUE); allow_pending_sigwinch(TRUE);
#endif #endif
/* Turn the keypad off so that we don't get extended keypad values, /* Switch to raw mode so that we can type ^C, ^Q, ^S, ^Z, and ^\
* all of which are outside the ASCII range, and switch to raw mode * (and ^Y on the Hurd) without getting interrupts, and Turn the
* so that we can type ^C, ^Q, ^S, ^Z, and ^\ (and ^Y on the Hurd) * keypad off so that we don't get extended keypad values all of
* without getting interrupts. */ * which are outside the ASCII range. */
keypad(win, FALSE);
#ifdef _POSIX_VDISABLE #ifdef _POSIX_VDISABLE
raw(); raw();
#endif #endif
keypad(win, FALSE);
kbinput = wgetch(win); kbinput = wgetch(win);
verbatim_kbinput = (int *)nmalloc(sizeof(int)); verbatim_kbinput = (int *)nmalloc(sizeof(int));
@ -103,12 +103,12 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
nodelay(win, FALSE); nodelay(win, FALSE);
} }
/* Turn the keypad back on and switch back to cbreak mode now that /* Switch back to cbreak mode and turn the keypad back on now that
* we're done. */ * we're done. */
keypad(win, TRUE);
#ifdef _POSIX_VDISABLE #ifdef _POSIX_VDISABLE
cbreak(); cbreak();
#endif #endif
keypad(win, TRUE);
#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);