formatter: don't let output from the program pollute the screen

Run the formatting program outside of curses mode, so that any output
(complaints) that it produces will be on the terminal after exiting
from nano -- at least on a terminal emulator, not on a Linux VT.

This also allows the formatter to be an interactive program.

The disadvantage is that the screen flickers when typing M-F.

This fixes https://savannah.gnu.org/bugs/?57104.
master
Benno Schulenberg 2019-10-25 19:02:07 +02:00
parent 631defb8b2
commit 2b9f06194f
1 changed files with 5 additions and 8 deletions

View File

@ -2565,9 +2565,8 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling)
if (fileinfo.st_size == 0) if (fileinfo.st_size == 0)
return NULL; return NULL;
/* The spell checker needs the screen, so exit from curses mode. */ /* Exit from curses mode to give the program control of the terminal. */
if (spelling) endwin();
endwin();
construct_argument_list(&arguments, theprogram, tempfile_name); construct_argument_list(&arguments, theprogram, tempfile_name);
@ -2586,11 +2585,9 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling)
wait(&program_status); wait(&program_status);
block_sigwinch(FALSE); block_sigwinch(FALSE);
/* When needed, restore the terminal state and reenter curses mode. */ /* Restore the terminal state and reenter curses mode. */
if (spelling) { terminal_init();
terminal_init(); doupdate();
doupdate();
}
if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2) if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2)
return invocation_error(theprogram); return invocation_error(theprogram);