mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-25 20:06:52 +03:00
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
This commit is contained in:
parent
fd1768a902
commit
ce991bb3ad
@ -44,6 +44,7 @@ CVS code -
|
||||
no longer needed. (David Benbennick)
|
||||
- Rename several variables to make their use clearer and to
|
||||
avoid conflicts. (DLR)
|
||||
- Set the input mode before turning the keypad on. (DLR)
|
||||
- files.c:
|
||||
do_insertfile()
|
||||
- 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
|
||||
the input mode. (DLR)
|
||||
- Remove stray HAVE_GETOPT_LONG #ifdefs. (DLR)
|
||||
- Don't call keypad() before initializing the windows it needs
|
||||
via window_init().
|
||||
- nano.h:
|
||||
- Move the NANO_H include guard up before the first #include.
|
||||
(DLR)
|
||||
|
31
src/nano.c
31
src/nano.c
@ -225,21 +225,19 @@ void window_init(void)
|
||||
if (editwinrows < MIN_EDITOR_ROWS)
|
||||
die_too_small();
|
||||
|
||||
if (edit != NULL)
|
||||
delwin(edit);
|
||||
if (topwin != NULL)
|
||||
delwin(topwin);
|
||||
if (edit != NULL)
|
||||
delwin(edit);
|
||||
if (bottomwin != NULL)
|
||||
delwin(bottomwin);
|
||||
|
||||
/* Set up the main text window. */
|
||||
edit = newwin(editwinrows, COLS, 2, 0);
|
||||
|
||||
/* And the other windows. */
|
||||
/* Set up the windows. */
|
||||
topwin = newwin(2, COLS, 0, 0);
|
||||
edit = newwin(editwinrows, COLS, 2, 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(bottomwin, TRUE);
|
||||
}
|
||||
@ -2939,13 +2937,13 @@ void handle_sigwinch(int s)
|
||||
/* Turn cursor back on for sure. */
|
||||
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. */
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
#ifdef _POSIX_VDISABLE
|
||||
cbreak();
|
||||
#endif
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
|
||||
/* Jump back to the main loop. */
|
||||
siglongjmp(jmpbuf, 1);
|
||||
@ -2964,7 +2962,7 @@ void allow_pending_sigwinch(int allow)
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
/* 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)
|
||||
{
|
||||
static int didmsg = 0;
|
||||
@ -3428,17 +3426,14 @@ int main(int argc, char *argv[])
|
||||
/* Curses initialization stuff: Start curses, save the state of the
|
||||
* the terminal mode, disable translation of carriage return (^M)
|
||||
* 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
|
||||
* the terminal in cbreak mode (read one character at a time and
|
||||
* interpret the special control keys) if we can selectively disable
|
||||
* the special control keys or raw mode (read one character at a
|
||||
* time and don't interpret the special control keys) if we
|
||||
* Justify, put the terminal in cbreak mode (read one character at a
|
||||
* time and interpret the special control keys) if we can selectively
|
||||
* disable the special control keys or raw mode (read one character
|
||||
* at a time and don't interpret the special control keys) if we
|
||||
* can't, and turn off echoing of characters as they're typed. */
|
||||
initscr();
|
||||
savetty();
|
||||
nonl();
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
#ifdef _POSIX_VDISABLE
|
||||
cbreak();
|
||||
#else
|
||||
|
14
src/winio.c
14
src/winio.c
@ -74,14 +74,14 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
|
||||
allow_pending_sigwinch(TRUE);
|
||||
#endif
|
||||
|
||||
/* Turn the keypad off so that we don't get extended keypad values,
|
||||
* all of which are outside the ASCII range, and switch to raw mode
|
||||
* so that we can type ^C, ^Q, ^S, ^Z, and ^\ (and ^Y on the Hurd)
|
||||
* without getting interrupts. */
|
||||
keypad(win, FALSE);
|
||||
/* Switch to raw mode so that we can type ^C, ^Q, ^S, ^Z, and ^\
|
||||
* (and ^Y on the Hurd) without getting interrupts, and Turn the
|
||||
* keypad off so that we don't get extended keypad values all of
|
||||
* which are outside the ASCII range. */
|
||||
#ifdef _POSIX_VDISABLE
|
||||
raw();
|
||||
#endif
|
||||
keypad(win, FALSE);
|
||||
|
||||
kbinput = wgetch(win);
|
||||
verbatim_kbinput = (int *)nmalloc(sizeof(int));
|
||||
@ -103,12 +103,12 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
|
||||
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. */
|
||||
keypad(win, TRUE);
|
||||
#ifdef _POSIX_VDISABLE
|
||||
cbreak();
|
||||
#endif
|
||||
keypad(win, TRUE);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_verbatim_kbinput(): verbatim_kbinput = %s\n", verbatim_kbinput);
|
||||
|
Loading…
Reference in New Issue
Block a user