Benbennick)
- Include <sys/types.h> in proto.h. (David Benbennick) DLR:
Remove some redundant inclusions of <sys/types.h> elsewhere.
+ - Move the main terminal initialization functions, aside from
+ initscr(), into a new terminal_init() function, and convert
+ nano to use it. (DLR)
- files.c:
close_open_file()
- Tweak to no longer rely on the return values of
thanks_for_all_the_fish()
- Delete topwin, edit, and bottomwin. (David Benbennick)
- nano.c:
+ do_alt_speller()
+ - When reloading the newly spell-checked temporary file, call
+ terminal_init() to make sure that all the original terminal
+ settings are restored, as a curses-based alternative spell
+ checker (e.g. aspell) can change them. (DLR)
do_justify()
- Add allow_respacing flag, used to indicate when we've moved to
the next line after justifying the current line, and only run
/* Only reload the temp file if it isn't a marked selection. */
#endif
free_filestruct(fileage);
+ terminal_init();
global_init(TRUE);
open_file(tempfile_name, FALSE, TRUE);
#ifndef NANO_SMALL
refresh();
#endif
+ /* Restore the terminal to its previous state. */
+ terminal_init();
+
/* Do the equivalent of what both mutt and Minimum Profit do:
* Reinitialize all the windows based on the new screen
* dimensions. */
/* Turn cursor back on for sure. */
curs_set(1);
- /* Restore the terminal to its previously saved state. */
- resetty();
-
/* Reset all the input routines that rely on character sequences. */
reset_kbinput();
tcsetattr(0, TCSANOW, &term);
}
+/* Set up the terminal state. Put the terminal in cbreak mode (read one
+ * character at a time and interpret the special control keys), disable
+ * translation of carriage return (^M) into newline (^J) so that we can
+ * tell the difference between the Enter key and Ctrl-J, and disable
+ * echoing of characters as they're typed. Finally, disable
+ * interpretation of the special control keys, and if we're not in
+ * preserve mode, disable interpretation of the flow control characters
+ * too. */
+void terminal_init(void)
+{
+ cbreak();
+ nonl();
+ noecho();
+ disable_signals();
+ if (!ISSET(PRESERVE))
+ disable_flow_control();
+}
+
int main(int argc, char *argv[])
{
int optchr;
/* Back up the old terminal settings so that they can be restored. */
tcgetattr(0, &oldterm);
- /* Curses initialization stuff: Start curses, save the state of the
- * terminal mode, put the terminal in cbreak mode (read one character
- * at a time and interpret the special control keys), disable
- * translation of carriage return (^M) into newline (^J) so that we
- * can tell the difference between the Enter key and Ctrl-J, and
- * disable echoing of characters as they're typed. Finally, disable
- * interpretation of the special control keys, and if we're not in
- * preserve mode, disable interpretation of the flow control
- * characters too. */
+ /* Curses initialization stuff: Start curses and set up the
+ * terminal state. */
initscr();
- cbreak();
- nonl();
- noecho();
- disable_signals();
- if (!ISSET(PRESERVE))
- disable_flow_control();
-
-#ifndef NANO_SMALL
- /* Save the terminal's current state, so that we can restore it
- * after a resize. */
- savetty();
-#endif
+ terminal_init();
/* Set up the global variables and the shortcuts. */
global_init(FALSE);