tweaks: gather four calls that are always done together into a function
Этот коммит содержится в:
родитель
0e21baf611
Коммит
f571d6ba36
43
src/nano.c
43
src/nano.c
@ -304,11 +304,17 @@ void say_there_is_no_help(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Tell the terminal to disable bracketed pastes. */
|
/* Make sure the cursor is visible, then exit from curses mode, disable
|
||||||
void disable_bracketed_paste(void)
|
* bracketed-paste mode, and restore the original terminal settings. */
|
||||||
|
void restore_terminal(void)
|
||||||
{
|
{
|
||||||
|
curs_set(1);
|
||||||
|
endwin();
|
||||||
|
|
||||||
printf("\e[?2004l");
|
printf("\e[?2004l");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
tcsetattr(0, TCSANOW, &original_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Exit normally: restore the terminal state and save history files. */
|
/* Exit normally: restore the terminal state and save history files. */
|
||||||
@ -326,14 +332,8 @@ void finish(void)
|
|||||||
delwin(edit);
|
delwin(edit);
|
||||||
delwin(bottomwin);
|
delwin(bottomwin);
|
||||||
#endif
|
#endif
|
||||||
/* Switch on the cursor and exit from curses mode. */
|
/* Switch the cursor on, exit from curses, and restore terminal settings. */
|
||||||
curs_set(1);
|
restore_terminal();
|
||||||
endwin();
|
|
||||||
|
|
||||||
disable_bracketed_paste();
|
|
||||||
|
|
||||||
/* Restore the old terminal settings. */
|
|
||||||
tcsetattr(0, TCSANOW, &original_state);
|
|
||||||
|
|
||||||
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
|
||||||
display_rcfile_errors();
|
display_rcfile_errors();
|
||||||
@ -359,14 +359,7 @@ void die(const char *msg, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
openfilestruct *firstone = openfile;
|
openfilestruct *firstone = openfile;
|
||||||
|
|
||||||
/* Switch on the cursor and leave curses mode. */
|
restore_terminal();
|
||||||
curs_set(1);
|
|
||||||
endwin();
|
|
||||||
|
|
||||||
disable_bracketed_paste();
|
|
||||||
|
|
||||||
/* Restore the old terminal settings. */
|
|
||||||
tcsetattr(0, TCSANOW, &original_state);
|
|
||||||
|
|
||||||
#ifdef ENABLE_NANORC
|
#ifdef ENABLE_NANORC
|
||||||
display_rcfile_errors();
|
display_rcfile_errors();
|
||||||
@ -930,11 +923,7 @@ bool scoop_stdin(void)
|
|||||||
{
|
{
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
|
|
||||||
/* Exit from curses mode and put the terminal into its original state. */
|
restore_terminal();
|
||||||
endwin();
|
|
||||||
tcsetattr(0, TCSANOW, &original_state);
|
|
||||||
|
|
||||||
disable_bracketed_paste();
|
|
||||||
|
|
||||||
/* When input comes from a terminal, show a helpful message. */
|
/* When input comes from a terminal, show a helpful message. */
|
||||||
if (isatty(STANDARD_INPUT))
|
if (isatty(STANDARD_INPUT))
|
||||||
@ -1049,10 +1038,7 @@ RETSIGTYPE do_suspend(int signal)
|
|||||||
#ifdef ENABLE_MOUSE
|
#ifdef ENABLE_MOUSE
|
||||||
disable_mouse_support();
|
disable_mouse_support();
|
||||||
#endif
|
#endif
|
||||||
curs_set(1);
|
restore_terminal();
|
||||||
endwin();
|
|
||||||
|
|
||||||
disable_bracketed_paste();
|
|
||||||
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
|
||||||
@ -1060,9 +1046,6 @@ RETSIGTYPE do_suspend(int signal)
|
|||||||
printf(_("Use \"fg\" to return to nano.\n"));
|
printf(_("Use \"fg\" to return to nano.\n"));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
/* Restore the old terminal settings. */
|
|
||||||
tcsetattr(0, TCSANOW, &original_state);
|
|
||||||
|
|
||||||
/* The suspend keystroke must not elicit cursor-position display. */
|
/* The suspend keystroke must not elicit cursor-position display. */
|
||||||
suppress_cursorpos=TRUE;
|
suppress_cursorpos=TRUE;
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user