nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] formatter: instead of leaving curses, use full_refresh() to wipe


From: Benno Schulenberg
Subject: [PATCH] formatter: instead of leaving curses, use full_refresh() to wipe messages
Date: Fri, 22 Jul 2022 08:32:51 +0200

This makes invoking the formatter cleaner, by giving feedback and *not*
leaving curses mode.  Leaving curses mode had the small advantage that
any messages from the formatter would be on the terminal after closing
nano.  But it had the disadvantage that invoking the formatter flashed
the screen.

  [If you use the formatter in a way that is incompatible with this
   change -- like using an interactive formatter -- please speak up.]

This fulfills https://savannah.gnu.org/bugs/?62789.
Requested-by: Gert Cuykens <gert.cuykens@gmail.com>
---
 src/text.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/text.c b/src/text.c
index 4103f7ed..a2399f86 100644
--- a/src/text.c
+++ b/src/text.c
@@ -2117,8 +2117,11 @@ void treat(char *tempfile_name, char *theprogram, bool 
spelling)
                timestamp_nsec = (long)fileinfo.st_mtim.tv_nsec;
        }
 
-       /* Exit from curses mode to give the program control of the terminal. */
-       endwin();
+       /* The spell checker needs the screen, so exit from curses mode. */
+       if (spelling)
+               endwin();
+       else
+               statusbar(_("Invoking formatter..."));
 
        construct_argument_list(&arguments, theprogram, tempfile_name);
 
@@ -2138,9 +2141,13 @@ void treat(char *tempfile_name, char *theprogram, bool 
spelling)
 
        errornumber = errno;
 
-       /* Restore the terminal state and reenter curses mode. */
-       terminal_init();
-       doupdate();
+       /* After spell checking, restore terminal state and reenter curses mode;
+        * after formatting, make sure that any formatter output is wiped. */
+       if (spelling) {
+               terminal_init();
+               doupdate();
+       } else
+               full_refresh();
 
        if (thepid < 0) {
                statusline(ALERT, _("Could not fork: %s"), 
strerror(errornumber));
-- 
2.35.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]