move the main terminal initialization functions, aside from initscr(),
into a new terminal_init() function, and convert nano to use it; also, when reloading the newly spell-checked temporary file in do_alt_speller(), 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 git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1866 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
ad1fd0d968
commit
8aaf03000b
|
@ -45,6 +45,9 @@ CVS code -
|
||||||
Benbennick)
|
Benbennick)
|
||||||
- Include <sys/types.h> in proto.h. (David Benbennick) DLR:
|
- Include <sys/types.h> in proto.h. (David Benbennick) DLR:
|
||||||
Remove some redundant inclusions of <sys/types.h> elsewhere.
|
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:
|
- files.c:
|
||||||
close_open_file()
|
close_open_file()
|
||||||
- Tweak to no longer rely on the return values of
|
- Tweak to no longer rely on the return values of
|
||||||
|
@ -69,6 +72,11 @@ CVS code -
|
||||||
thanks_for_all_the_fish()
|
thanks_for_all_the_fish()
|
||||||
- Delete topwin, edit, and bottomwin. (David Benbennick)
|
- Delete topwin, edit, and bottomwin. (David Benbennick)
|
||||||
- nano.c:
|
- 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()
|
do_justify()
|
||||||
- Add allow_respacing flag, used to indicate when we've moved to
|
- Add allow_respacing flag, used to indicate when we've moved to
|
||||||
the next line after justifying the current line, and only run
|
the next line after justifying the current line, and only run
|
||||||
|
|
49
src/nano.c
49
src/nano.c
|
@ -1796,6 +1796,7 @@ const char *do_alt_speller(char *tempfile_name)
|
||||||
/* Only reload the temp file if it isn't a marked selection. */
|
/* Only reload the temp file if it isn't a marked selection. */
|
||||||
#endif
|
#endif
|
||||||
free_filestruct(fileage);
|
free_filestruct(fileage);
|
||||||
|
terminal_init();
|
||||||
global_init(TRUE);
|
global_init(TRUE);
|
||||||
open_file(tempfile_name, FALSE, TRUE);
|
open_file(tempfile_name, FALSE, TRUE);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
@ -2893,6 +2894,9 @@ void handle_sigwinch(int s)
|
||||||
refresh();
|
refresh();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Restore the terminal to its previous state. */
|
||||||
|
terminal_init();
|
||||||
|
|
||||||
/* Do the equivalent of what both mutt and Minimum Profit do:
|
/* Do the equivalent of what both mutt and Minimum Profit do:
|
||||||
* Reinitialize all the windows based on the new screen
|
* Reinitialize all the windows based on the new screen
|
||||||
* dimensions. */
|
* dimensions. */
|
||||||
|
@ -2906,9 +2910,6 @@ void handle_sigwinch(int s)
|
||||||
/* Turn cursor back on for sure. */
|
/* Turn cursor back on for sure. */
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
|
||||||
/* Restore the terminal to its previously saved state. */
|
|
||||||
resetty();
|
|
||||||
|
|
||||||
/* Reset all the input routines that rely on character sequences. */
|
/* Reset all the input routines that rely on character sequences. */
|
||||||
reset_kbinput();
|
reset_kbinput();
|
||||||
|
|
||||||
|
@ -3019,6 +3020,24 @@ void enable_flow_control(void)
|
||||||
tcsetattr(0, TCSANOW, &term);
|
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 main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int optchr;
|
int optchr;
|
||||||
|
@ -3442,28 +3461,10 @@ int main(int argc, char *argv[])
|
||||||
/* Back up the old terminal settings so that they can be restored. */
|
/* Back up the old terminal settings so that they can be restored. */
|
||||||
tcgetattr(0, &oldterm);
|
tcgetattr(0, &oldterm);
|
||||||
|
|
||||||
/* Curses initialization stuff: Start curses, save the state of the
|
/* Curses initialization stuff: Start curses and set up the
|
||||||
* terminal mode, put the terminal in cbreak mode (read one character
|
* terminal state. */
|
||||||
* 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. */
|
|
||||||
initscr();
|
initscr();
|
||||||
cbreak();
|
terminal_init();
|
||||||
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
|
|
||||||
|
|
||||||
/* Set up the global variables and the shortcuts. */
|
/* Set up the global variables and the shortcuts. */
|
||||||
global_init(FALSE);
|
global_init(FALSE);
|
||||||
|
|
|
@ -360,6 +360,7 @@ void enable_signals(void);
|
||||||
#endif
|
#endif
|
||||||
void disable_flow_control(void);
|
void disable_flow_control(void);
|
||||||
void enable_flow_control(void);
|
void enable_flow_control(void);
|
||||||
|
void terminal_init(void);
|
||||||
|
|
||||||
/* Public functions in rcfile.c */
|
/* Public functions in rcfile.c */
|
||||||
#ifdef ENABLE_NANORC
|
#ifdef ENABLE_NANORC
|
||||||
|
|
Loading…
Reference in New Issue