- Add more intuitive Meta-key aliases for moving to the
beginning and ending lines of a paragraph at the search
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:
add_open_files()
- Make the saving of marked status in open_files->file_flags
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)
+ - Add more descriptive comments explaining the termios and
+ curses setup routines, and turn the keypad on before setting
+ the input mode. (DLR)
- search.c:
do_replace_loop()
- Fix segfault when doing a regex replace of a string that
#ifndef NANO_SMALL
act.sa_handler = handle_sigwinch;
sigaction(SIGWINCH, &act, NULL);
+ allow_pending_sigwinch(FALSE);
#endif
#ifdef _POSIX_VDISABLE
/* Jump back to the main loop. */
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 */
/* If the NumLock key has made the keypad go awry, print an error
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);
-
#ifdef _POSIX_VDISABLE
term = oldterm;
term.c_cc[VINTR] = _POSIX_VDISABLE;
tcsetattr(0, TCSANOW, &term);
#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();
savetty();
nonl();
+ keypad(edit, TRUE);
+ keypad(bottomwin, TRUE);
#ifdef _POSIX_VDISABLE
cbreak();
#else
- /* We're going to have to do it the old way, i.e, on Cygwin. */
raw();
#endif
noecho();
- /* Set up some global variables */
+ /* Set up the global variables and the shortcuts. */
global_init(0);
shortcut_init(0);
+
+ /* Set up the signal handlers. */
signal_init();
#ifdef DEBUG
mouse_init();
#endif
- /* Turn the keypad on */
- keypad(edit, TRUE);
- keypad(bottomwin, TRUE);
-
#ifdef DEBUG
fprintf(stderr, "Main: bottom win\n");
#endif
{
int kbinput, retval;
+#ifndef NANO_SMALL
+ allow_pending_sigwinch(TRUE);
+#endif
+
kbinput = get_ignored_kbinput(win);
retval = get_accepted_kbinput(win, kbinput, meta);
+#ifndef NANO_SMALL
+ allow_pending_sigwinch(FALSE);
+#endif
+
return retval;
}
{
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,
* 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)
#ifdef DEBUG
fprintf(stderr, "get_verbatim_kbinput(): verbatim_kbinput = %s\n", verbatim_kbinput);
#endif
+
+#ifndef NANO_SMALL
+ allow_pending_sigwinch(FALSE);
+#endif
+
return verbatim_kbinput;
}