This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 33/66] Introduce refresh_window method


This replaces tui_refresh_win with a new refresh_window method.  This
removes another spot that was checking the window's type.

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

	* tui/tui-winsource.c (tui_erase_source_content)
	(tui_show_source_content, tui_show_exec_info_content)
	(tui_erase_exec_info_content): Use refresh_window method.
	* tui/tui-wingeneral.h (tui_refresh_win): Don't declare.
	* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Rename
	from tui_refresh_win.
	(tui_data_window::refresh_window): New method.
	(tui_win_info::refresh, tui_source_window_base::refresh)
	(tui_refresh_all): Use refresh_window method.
	* tui/tui-stack.c (tui_show_locator_content): Call refresh_window
	method.
	* tui/tui-regs.c (tui_display_register): Call refresh_window
	method.
	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Call refresh_window method.
	* tui/tui-data.h (struct tui_gen_win_info)
	(struct tui_data_window, struct tui_cmd_window) <refresh_window>:
	New method.
---
 gdb/ChangeLog            | 21 +++++++++++++++++++++
 gdb/tui/tui-data.h       |  9 +++++++++
 gdb/tui/tui-layout.c     |  4 ++--
 gdb/tui/tui-regs.c       |  2 +-
 gdb/tui/tui-stack.c      |  2 +-
 gdb/tui/tui-wingeneral.c | 40 +++++++++++++++++++---------------------
 gdb/tui/tui-wingeneral.h |  1 -
 gdb/tui/tui-winsource.c  | 10 +++++-----
 8 files changed, 58 insertions(+), 31 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 4d2f447c942..78c17102218 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -48,6 +48,9 @@ struct tui_gen_win_info
   {
   }
 
+  /* Call to refresh this window.  */
+  virtual void refresh_window ();
+
   /* Window handle.  */
   WINDOW *handle = nullptr;
   /* Type of window.  */
@@ -418,6 +421,8 @@ struct tui_data_window : public tui_win_info
 
   void set_new_height (int height) override;
 
+  void refresh_window () override;
+
   /* Start of data display content.  */
   tui_win_content data_content = NULL;
   int data_content_count = 0;
@@ -456,6 +461,10 @@ struct tui_cmd_window : public tui_win_info
 
   int max_height () const override;
 
+  void refresh_window () override
+  {
+  }
+
   int start_line = 0;
 
 protected:
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 9685d7fc4e5..d9e1617f19a 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -701,7 +701,7 @@ show_source_disasm_command (void)
 	  TUI_CMD_WIN->can_highlight = false;
 	  tui_make_visible (TUI_CMD_WIN);
 	}
-      tui_refresh_win (TUI_CMD_WIN);
+      TUI_CMD_WIN->refresh_window ();
       tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
     }
 }
@@ -956,7 +956,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	{
 	  tui_win_list[CMD_WIN] = make_command_window (cmd_height,
 						       src_height);
-	  tui_refresh_win (TUI_CMD_WIN);
+	  TUI_CMD_WIN->refresh_window ();
 	}
       else
 	{
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index cfb735c81d5..c748d513fc3 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -534,7 +534,7 @@ tui_display_register (struct tui_data_element *data,
 	   to code that causes the compiler to generate an unused-value
 	   warning.  */
 	(void) wstandend (win_info->handle);
-      tui_refresh_win (win_info);
+      win_info->refresh_window ();
     }
 }
 
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index a38971542eb..efa24453b65 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -267,7 +267,7 @@ tui_show_locator_content (void)
       waddstr (locator->handle, string);
       wclrtoeol (locator->handle);
       (void) wstandend (locator->handle);
-      tui_refresh_win (locator);
+      locator->refresh_window ();
       wmove (locator->handle, 0, 0);
       xfree (string);
       locator->content_in_use = TRUE;
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 06d7ad5a030..f1089a9f38a 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -31,38 +31,36 @@
 ** PUBLIC FUNCTIONS
 ***********************/
 
-/* Refresh the window.  */
+/* See tui-data.h.  */
+
 void
-tui_refresh_win (struct tui_gen_win_info *win_info)
+tui_gen_win_info::refresh_window ()
 {
-  if (win_info->type == DATA_WIN && win_info->content_size > 0)
-    {
-      int i;
+  if (handle != NULL)
+    wrefresh (handle);
+}
 
-      for (i = 0; (i < win_info->content_size); i++)
+/* See tui-data.h.  */
+
+void
+tui_data_window::refresh_window ()
+{
+  if (content_size > 0)
+    {
+      for (int i = 0; i < content_size; i++)
 	{
 	  struct tui_gen_win_info *data_item_win_ptr;
 
-	  data_item_win_ptr = win_info->content[i]->which_element.data_window;
+	  data_item_win_ptr = content[i]->which_element.data_window;
 	  if (data_item_win_ptr != NULL
 	      && data_item_win_ptr->handle != NULL)
 	    wrefresh (data_item_win_ptr->handle);
 	}
     }
-  else if (win_info->type == CMD_WIN)
-    {
-      /* Do nothing.  */
-    }
   else
-    {
-      if (win_info->handle != NULL)
-	wrefresh (win_info->handle);
-    }
-
-  return;
+    tui_gen_win_info::refresh_window ();
 }
 
-
 /* Function to delete the curses window, checking for NULL.  */
 void
 tui_delete_win (WINDOW *window)
@@ -260,7 +258,7 @@ void
 tui_win_info::refresh ()
 {
   touchwin (handle);
-  tui_refresh_win (this);
+  refresh_window ();
 }
 
 /* See tui-data.h.  */
@@ -269,7 +267,7 @@ void
 tui_source_window_base::refresh ()
 {
   touchwin (execution_info->handle);
-  tui_refresh_win (execution_info);
+  execution_info->refresh_window ();
   tui_win_info::refresh ();
 }
 
@@ -289,7 +287,7 @@ tui_refresh_all (struct tui_win_info **list)
   if (locator->is_visible)
     {
       touchwin (locator->handle);
-      tui_refresh_win (locator);
+      locator->refresh_window ();
     }
 }
 
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 73b10d21311..15e61c94166 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -39,6 +39,5 @@ extern void tui_highlight_win (struct tui_win_info *);
 extern void tui_check_and_display_highlight_if_needed (struct tui_win_info *);
 extern void tui_refresh_all (struct tui_win_info **);
 extern void tui_delete_win (WINDOW *window);
-extern void tui_refresh_win (struct tui_gen_win_info *);
 
 #endif /* TUI_TUI_WINGENERAL_H */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index f63526bb446..254c7e00dcb 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -260,7 +260,7 @@ tui_erase_source_content (struct tui_win_info *win_info,
 
 	  tui_set_source_content_nil (win_info, no_src_str);
 	}
-      tui_refresh_win (win_info);
+      win_info->refresh_window ();
     }
 }
 
@@ -305,7 +305,7 @@ tui_show_source_content (struct tui_win_info *win_info)
     tui_erase_source_content (win_info, TRUE);
 
   tui_check_and_display_highlight_if_needed (win_info);
-  tui_refresh_win (win_info);
+  win_info->refresh_window ();
   win_info->content_in_use = TRUE;
 }
 
@@ -550,14 +550,14 @@ tui_show_exec_info_content (struct tui_win_info *win_info)
   int cur_line;
 
   werase (exec_info->handle);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
   for (cur_line = 1; (cur_line <= exec_info->content_size); cur_line++)
     mvwaddstr (exec_info->handle,
 	       cur_line,
 	       0,
 	       (char *) exec_info->content[cur_line - 1]
 			  ->which_element.simple_string);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
   exec_info->content_in_use = TRUE;
 }
 
@@ -569,7 +569,7 @@ tui_erase_exec_info_content (struct tui_win_info *win_info)
   struct tui_gen_win_info *exec_info = base->execution_info;
 
   werase (exec_info->handle);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
 }
 
 void
-- 
2.17.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]