handle pending sigwinches better, etc.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1652 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-02-16 20:32:40 +00:00
parent 795a16b959
commit 369732ff81
4 changed files with 56 additions and 9 deletions

View File

@ -15,6 +15,11 @@ CVS code -
- Add more intuitive Meta-key aliases for moving to the - Add more intuitive Meta-key aliases for moving to the
beginning and ending lines of a paragraph at the search beginning and ending lines of a paragraph at the search
prompt: Meta-P and Meta-N. (DLR) prompt: Meta-P and Meta-N. (DLR)
- Block SIGWINCH after setting up its handler, and only unblock
and handle it when we're in a stable state, i.e, when we're
waiting for input from the user. New function
allow_pending_sigwinch(); changes to signal_init(),
get_kbinput(), and get_verbatim_kbinput(). (DLR)
- files.c: - files.c:
add_open_files() add_open_files()
- Make the saving of marked status in open_files->file_flags - Make the saving of marked status in open_files->file_flags
@ -50,6 +55,9 @@ CVS code -
doesn't need to be called every time through the loop. Call it doesn't need to be called every time through the loop. Call it
instead of cbreak() on such systems, as it overrides cbreak() instead of cbreak() on such systems, as it overrides cbreak()
anyway. (DLR) anyway. (DLR)
- Add more descriptive comments explaining the termios and
curses setup routines, and turn the keypad on before setting
the input mode. (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

View File

@ -2815,6 +2815,7 @@ void signal_init(void)
#ifndef NANO_SMALL #ifndef NANO_SMALL
act.sa_handler = handle_sigwinch; act.sa_handler = handle_sigwinch;
sigaction(SIGWINCH, &act, NULL); sigaction(SIGWINCH, &act, NULL);
allow_pending_sigwinch(FALSE);
#endif #endif
#ifdef _POSIX_VDISABLE #ifdef _POSIX_VDISABLE
@ -2988,6 +2989,17 @@ void handle_sigwinch(int s)
/* Jump back to the main loop. */ /* Jump back to the main loop. */
siglongjmp(jmpbuf, 1); siglongjmp(jmpbuf, 1);
} }
void allow_pending_sigwinch(int allow)
{
sigset_t winch;
sigemptyset(&winch);
sigaddset(&winch, SIGWINCH);
if (allow)
sigprocmask(SIG_UNBLOCK, &winch, NULL);
else
sigprocmask(SIG_BLOCK, &winch, NULL);
}
#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
@ -3419,9 +3431,11 @@ int main(int argc, char *argv[])
filename = mallocstrcpy(filename, argv[optind]); filename = mallocstrcpy(filename, argv[optind]);
} }
/* First back up the old settings so they can be restored, duh */ /* Termios initialization stuff: Back up the old settings so that
* they can be restored, disable SIGINT on ^C and SIGQUIT on ^\,
* since we need them for Cancel and Replace, and disable
* implementation-defined input processing. */
tcgetattr(0, &oldterm); tcgetattr(0, &oldterm);
#ifdef _POSIX_VDISABLE #ifdef _POSIX_VDISABLE
term = oldterm; term = oldterm;
term.c_cc[VINTR] = _POSIX_VDISABLE; term.c_cc[VINTR] = _POSIX_VDISABLE;
@ -3430,21 +3444,32 @@ int main(int argc, char *argv[])
tcsetattr(0, TCSANOW, &term); tcsetattr(0, TCSANOW, &term);
#endif #endif
/* now ncurses init stuff... */ /* 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
* 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
/* We're going to have to do it the old way, i.e, on Cygwin. */
raw(); raw();
#endif #endif
noecho(); noecho();
/* Set up some global variables */ /* Set up the global variables and the shortcuts. */
global_init(0); global_init(0);
shortcut_init(0); shortcut_init(0);
/* Set up the signal handlers. */
signal_init(); signal_init();
#ifdef DEBUG #ifdef DEBUG
@ -3456,10 +3481,6 @@ int main(int argc, char *argv[])
mouse_init(); mouse_init();
#endif #endif
/* Turn the keypad on */
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Main: bottom win\n"); fprintf(stderr, "Main: bottom win\n");
#endif #endif

View File

@ -331,6 +331,7 @@ RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_cont(int signal); RETSIGTYPE do_cont(int signal);
#ifndef NANO_SMALL #ifndef NANO_SMALL
void handle_sigwinch(int s); void handle_sigwinch(int s);
void allow_pending_sigwinch(int allow);
#endif #endif
void print_numlock_warning(void); void print_numlock_warning(void);
#ifndef NANO_SMALL #ifndef NANO_SMALL

View File

@ -45,9 +45,17 @@ int get_kbinput(WINDOW *win, int *meta)
{ {
int kbinput, retval; int kbinput, retval;
#ifndef NANO_SMALL
allow_pending_sigwinch(TRUE);
#endif
kbinput = get_ignored_kbinput(win); kbinput = get_ignored_kbinput(win);
retval = get_accepted_kbinput(win, kbinput, meta); retval = get_accepted_kbinput(win, kbinput, meta);
#ifndef NANO_SMALL
allow_pending_sigwinch(FALSE);
#endif
return retval; return retval;
} }
@ -59,6 +67,10 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
{ {
int kbinput, *verbatim_kbinput; int kbinput, *verbatim_kbinput;
#ifndef NANO_SMALL
allow_pending_sigwinch(TRUE);
#endif
/* 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, and switch to raw mode * 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) * so that we can type ^C, ^Q, ^S, ^Z, and ^\ (and ^Y on the Hurd)
@ -98,6 +110,11 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
#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);
#endif #endif
#ifndef NANO_SMALL
allow_pending_sigwinch(FALSE);
#endif
return verbatim_kbinput; return verbatim_kbinput;
} }