[PATCH 23/66] Introduce the refresh method

Tom Tromey tom@tromey.com
Sun Jun 23 22:44:00 GMT 2019


This adds tui_win_info::refresh and updates tui_source_window_base to
implement it as well.  This lets us simplify tui_refresh_all, removing
a check of the window type.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_win_info::refresh)
	(tui_source_window_base::refresh): New methods.
	(tui_refresh_all): Call the refresh method.
	* tui/tui-data.h (struct tui_win_info)
	(struct tui_source_window_base) <refresh>: New method.
---
 gdb/ChangeLog            |  8 ++++++++
 gdb/tui/tui-data.h       |  4 ++++
 gdb/tui/tui-wingeneral.c | 31 ++++++++++++++++++++-----------
 3 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 34de67757b0..e25f8888c92 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -258,6 +258,9 @@ public:
   /* Make this window visible or invisible.  */
   virtual void make_visible (bool visible);
 
+  /* Refresh this window and any associated windows.  */
+  virtual void refresh ();
+
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
      obvious "scroll_forward" is defined as a macro in term.h.  */
@@ -299,6 +302,7 @@ public:
   }
 
   void make_visible (bool visible) override;
+  void refresh () override;
 
   /* Does locator belongs to this window?  */
   bool m_has_locator = false;
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index e802e52ca5b..4d168af0c09 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -256,6 +256,25 @@ tui_make_all_invisible (void)
   make_all_visible (false);
 }
 
+/* See tui-data.h.  */
+
+void
+tui_win_info::refresh ()
+{
+  touchwin (generic.handle);
+  tui_refresh_win (&generic);
+}
+
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::refresh ()
+{
+  touchwin (execution_info->handle);
+  tui_refresh_win (execution_info);
+  tui_win_info::refresh ();
+}
+
 /* Function to refresh all the windows currently displayed.  */
 
 void
@@ -267,17 +286,7 @@ tui_refresh_all (struct tui_win_info **list)
   for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
     {
       if (list[type] && list[type]->generic.is_visible)
-	{
-	  if (type == SRC_WIN || type == DISASSEM_WIN)
-	    {
-	      tui_source_window_base *base
-		= (tui_source_window_base *) list[type];
-	      touchwin (base->execution_info->handle);
-	      tui_refresh_win (base->execution_info);
-	    }
-	  touchwin (list[type]->generic.handle);
-	  tui_refresh_win (&list[type]->generic);
-	}
+	list[type]->refresh ();
     }
   if (locator->is_visible)
     {
-- 
2.17.2



More information about the Gdb-patches mailing list