[14/61] Introduce tui_data_window::erase_data_content method

Message ID 20190704170311.15982-15-tom@tromey.com
State New
Headers show
Series
  • More TUI refactorings
Related show

Commit Message

Tom Tromey July 4, 2019, 5:02 p.m.
This changes tui_erase_data_content to be a method on tui_data_window,
allowing for the removal of some uses of the TUI_DATA_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.h (tui_erase_data_content): Don't declare.
	* tui/tui-windata.c (tui_data_window::erase_data_content): Rename
	from tui_erase_data_content.
	(tui_data_window::display_all_data)
	(tui_data_window::refresh_all)
	(tui_data_window::do_scroll_vertical): Update.
	* tui/tui-regs.c (tui_show_registers): Update.
	* tui/tui-data.h (struct tui_data_window) <erase_data_content>:
	New method.
---
 gdb/ChangeLog         | 12 ++++++++++++
 gdb/tui/tui-data.h    |  2 ++
 gdb/tui/tui-regs.c    |  2 +-
 gdb/tui/tui-windata.c | 25 +++++++++++--------------
 gdb/tui/tui-windata.h |  2 --
 5 files changed, 26 insertions(+), 17 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 9a908115231..e1c85df31bf 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -511,6 +511,8 @@  struct tui_data_window : public tui_win_info
      is usually done when the data window is scrolled.  */
   void delete_data_content_windows ();
 
+  void erase_data_content (const char *prompt);
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 59933639f6f..9b396e429e2 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -146,7 +146,7 @@  tui_show_registers (struct reggroup *group)
   if (ret == TUI_FAILURE)
     {
       TUI_DATA_WIN->current_group = 0;
-      tui_erase_data_content (NO_REGS_STRING);
+      TUI_DATA_WIN->erase_data_content (NO_REGS_STRING);
     }
   else
     {
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 02cd6d0b727..abbed3f16a1 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -72,25 +72,22 @@  tui_data_window::delete_data_content_windows ()
 
 
 void
-tui_erase_data_content (const char *prompt)
+tui_data_window::erase_data_content (const char *prompt)
 {
-  werase (TUI_DATA_WIN->handle);
-  tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
+  werase (handle);
+  tui_check_and_display_highlight_if_needed (this);
   if (prompt != NULL)
     {
-      int half_width = (TUI_DATA_WIN->width - 2) / 2;
+      int half_width = (width - 2) / 2;
       int x_pos;
 
       if (strlen (prompt) >= half_width)
 	x_pos = 1;
       else
 	x_pos = half_width - strlen (prompt);
-      mvwaddstr (TUI_DATA_WIN->handle,
-		 (TUI_DATA_WIN->height / 2),
-		 x_pos,
-		 (char *) prompt);
+      mvwaddstr (handle, (height / 2), x_pos, (char *) prompt);
     }
-  wrefresh (TUI_DATA_WIN->handle);
+  wrefresh (handle);
 }
 
 
@@ -100,10 +97,10 @@  void
 tui_data_window::display_all_data ()
 {
   if (regs_content.empty ())
-    tui_erase_data_content (NO_DATA_STRING);
+    erase_data_content (NO_DATA_STRING);
   else
     {
-      tui_erase_data_content (NULL);
+      erase_data_content (NULL);
       delete_data_content_windows ();
       tui_check_and_display_highlight_if_needed (this);
       tui_display_registers_from (0);
@@ -115,7 +112,7 @@  tui_data_window::display_all_data ()
 void
 tui_data_window::refresh_all ()
 {
-  tui_erase_data_content (NULL);
+  erase_data_content (NULL);
   if (!regs_content.empty ())
     {
       int first_element = first_data_item_displayed ();
@@ -129,7 +126,7 @@  tui_data_window::refresh_all ()
 
 	  if (first_line >= 0)
 	    {
-	      tui_erase_data_content (NULL);
+	      erase_data_content (NULL);
 	      tui_display_registers_from_line (first_line);
 	    }
 	}
@@ -155,7 +152,7 @@  tui_data_window::do_scroll_vertical (int num_to_scroll)
   if (first_line >= 0)
     {
       first_line += num_to_scroll;
-      tui_erase_data_content (NULL);
+      erase_data_content (NULL);
       delete_data_content_windows ();
       tui_display_registers_from_line (first_line);
     }
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index 419b22f3658..3b89eefabc0 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -24,6 +24,4 @@ 
 
 #include "tui/tui-data.h"
 
-extern void tui_erase_data_content (const char *);
-
 #endif /* TUI_TUI_WINDATA_H */