From 6d8e495c370265a4d0ae90255566143cbae497c9 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 26 Jul 2005 14:42:57 +0000
Subject: [PATCH] remove still more redundant screen updates; change all
 wrefresh() calls to wnoutrefresh() calls, except for those in total_update()
 and do_credits(); call doupdate() just before using blocking input, since
 nano spends the most time using it, for blocking input; and only do constant
 sursor position display if we're just about to use blocking input

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2943 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 10 ++++++++++
 src/files.c |  6 +++---
 src/nano.c  | 18 +++++-------------
 src/winio.c | 22 +++++++++++++---------
 4 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0400aa5b..e52c099f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -115,6 +115,16 @@ CVS code -
 	  redrawing the screen.  Changes to window_init(), main(), and
 	  do_alt_speller(); removal of check_die_too_small() and
 	  window_size_init(). (DLR)
+	- Remove still more redundant screen updates.  Change all
+	  wrefresh() calls to wnoutrefresh() calls, except for those in
+	  total_update() and do_credits(); call doupdate() just before
+	  using blocking input, since nano spends the most time using
+	  it, for blocking input; and only do constant sursor position
+	  display if we're just about to use blocking input.  Changes to
+	  input_tab(), do_browser(), finish(), do_output(), main(),
+	  get_key_buffer(), check_statusblank(), nanogetstr(),
+	  titlebar(), statusbar(), bottombars(), edit_refresh(),
+	  do_yesno(), and do_help(). (DLR)
 - color.c:
 	- Remove unneeded string.h and fcntl.h includes. (DLR)
 - chars.c:
diff --git a/src/files.c b/src/files.c
index c8a49e67..afadc3bb 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2143,7 +2143,7 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
 		    editline++;
 	    }
 
-	    wrefresh(edit);
+	    wnoutrefresh(edit);
 	    *list = TRUE;
 	}
 
@@ -2266,7 +2266,7 @@ char *do_browser(char *path, DIR *dir)
     curs_set(0);
     blank_statusbar();
     bottombars(browser_list);
-    wrefresh(bottomwin);
+    wnoutrefresh(bottomwin);
 
 #if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
     /* Set currshortcut so the user can click in the shortcut area, and
@@ -2612,7 +2612,7 @@ char *do_browser(char *path, DIR *dir)
 	    free(foo);
 	}
 
-	wrefresh(edit);
+	wnoutrefresh(edit);
     } while ((kbinput = get_kbinput(edit, &meta_key, &func_key)) !=
 	NANO_EXIT_KEY && kbinput != NANO_EXIT_FKEY);
 
diff --git a/src/nano.c b/src/nano.c
index 1968c051..b1051fbc 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -526,7 +526,7 @@ void finish(void)
     else
 	blank_statusbar();
 
-    wrefresh(bottomwin);
+    wnoutrefresh(bottomwin);
     endwin();
 
     /* Restore the old terminal settings. */
@@ -1748,7 +1748,6 @@ bool do_mouse(void)
 void do_output(char *output, size_t output_len, bool allow_cntrls)
 {
     size_t current_len, i = 0;
-    bool old_const_update = ISSET(CONST_UPDATE);
     bool do_refresh = FALSE;
 	/* Do we have to call edit_refresh(), or can we get away with
 	 * update_line()? */
@@ -1760,9 +1759,6 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
 
     current_len = strlen(openfile->current->data);
 
-    /* Turn off constant cursor position display. */
-    UNSET(CONST_UPDATE);
-
     while (i < output_len) {
 	/* If allow_cntrls is FALSE, filter out nulls and newlines,
 	 * since they're control characters. */
@@ -1840,11 +1836,6 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
 #endif
     }
 
-    /* Turn constant cursor position display back on if it was on
-     * before. */
-    if (old_const_update)
-	SET(CONST_UPDATE);
-
     free(char_buf);
 
     openfile->placewewant = xplustabs();
@@ -2404,9 +2395,10 @@ int main(int argc, char **argv)
 	/* Make sure the cursor is in the edit window. */
 	reset_cursor();
 
-	/* If constant cursor position display is on, display the
-	 * current cursor position on the statusbar. */
-	if (ISSET(CONST_UPDATE))
+	/* If constant cursor position display is on, and there are no
+	 * keys waiting in the input buffer, display the current cursor
+	 * position on the statusbar. */
+	if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
 	    do_cursorpos(TRUE);
 
 	currshortcut = main_list;
diff --git a/src/winio.c b/src/winio.c
index 54fcdbc8..e32fd79a 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -138,6 +138,10 @@ void get_key_buffer(WINDOW *win)
     allow_pending_sigwinch(TRUE);
 #endif
 
+    /* Just before reading in the first character, display any pending
+     * screen updates. */
+    doupdate();
+
     input = wgetch(win);
 
     /* If we get ERR when using blocking input, it means that the input
@@ -2251,7 +2255,7 @@ void check_statusblank(void)
 	blank_statusbar();
 	wnoutrefresh(bottomwin);
 	reset_cursor();
-	wrefresh(edit);
+	wnoutrefresh(edit);
     }
 }
 
@@ -2507,7 +2511,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
     /* Refresh the edit window and the statusbar before getting
      * input. */
     wnoutrefresh(edit);
-    wrefresh(bottomwin);
+    wnoutrefresh(bottomwin);
 
     /* If we're using restricted mode, we aren't allowed to change the
      * name of a file once it has one because that would allow writing
@@ -2612,7 +2616,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
 #endif
 
 	nanoget_repaint(buf, answer, statusbar_x);
-	wrefresh(bottomwin);
+	wnoutrefresh(bottomwin);
     }
 
 #ifndef NANO_SMALL
@@ -2863,7 +2867,7 @@ void titlebar(const char *path)
 
     wnoutrefresh(topwin);
     reset_cursor();
-    wrefresh(edit);
+    wnoutrefresh(edit);
 }
 
 /* Set the modified flag if it isn't already set, and then update the
@@ -2926,7 +2930,7 @@ void statusbar(const char *msg, ...)
 	wattroff(bottomwin, A_REVERSE);
 	wnoutrefresh(bottomwin);
 	reset_cursor();
-	wrefresh(edit);
+	wnoutrefresh(edit);
 	    /* Leave the cursor at its position in the edit window, not
 	     * in the statusbar. */
     }
@@ -2993,7 +2997,7 @@ void bottombars(const shortcut *s)
 
     wnoutrefresh(bottomwin);
     reset_cursor();
-    wrefresh(edit);
+    wnoutrefresh(edit);
 }
 
 /* Write a shortcut key to the help area at the bottom of the window.
@@ -3639,7 +3643,7 @@ void edit_refresh(void)
 	blank_line(edit, nlines, 0, COLS);
 
     reset_cursor();
-    wrefresh(edit);
+    wnoutrefresh(edit);
 }
 
 /* Move edittop to put it in range of current, keeping current in the
@@ -3734,7 +3738,7 @@ int do_yesno(bool all, const char *msg)
     /* Refresh the edit window and the statusbar before getting
      * input. */
     wnoutrefresh(edit);
-    wrefresh(bottomwin);
+    wnoutrefresh(bottomwin);
 
     do {
 	int kbinput;
@@ -4011,7 +4015,7 @@ void do_help(void)
 
     if (old_no_help) {
 	blank_bottombars();
-	wrefresh(bottomwin);
+	wnoutrefresh(bottomwin);
 	SET(NO_HELP);
 	window_init();
     } else
-- 
GitLab