[v2,05/14] Change tui_register_info::visible to a method

Message ID 20240120-tui-regs-cleanup-v2-5-a3cccc6a3573@tromey.com
State New
Headers
Series Cleanups for the TUi register window |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Jan. 20, 2024, 6:23 p.m. UTC
  tui_register_info::visible is redundant with the fact that y==0 means
that the register is not visible.  This patch changes this member in
favor of having a single indication of the register's visibility -- a
method with the same name.  This change makes it clear that
delete_data_content_windows is not needed, so this is removed as well.
---
 gdb/tui/tui-regs.c | 17 ++---------------
 gdb/tui/tui-regs.h |  8 +++-----
 2 files changed, 5 insertions(+), 20 deletions(-)
  

Patch

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index bacb23ab298..12301552c34 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -268,7 +268,6 @@  tui_data_window::display_registers_from (int start_element_no)
 	  /* Create the window if necessary.  */
 	  m_regs_content[i].x = box_width () + (m_item_width * j);
 	  m_regs_content[i].y = cur_y;
-	  m_regs_content[i].visible = true;
 	  m_regs_content[i].rerender (handle.get (), m_item_width);
 	  i++;		/* Next register.  */
 	}
@@ -346,23 +345,13 @@  tui_data_window::first_data_item_displayed ()
 {
   for (int i = 0; i < m_regs_content.size (); i++)
     {
-      if (m_regs_content[i].visible)
+      if (m_regs_content[i].visible ())
 	return i;
     }
 
   return -1;
 }
 
-/* See tui-regs.h.  */
-
-void
-tui_data_window::delete_data_content_windows ()
-{
-  for (auto &win : m_regs_content)
-    win.visible = false;
-}
-
-
 void
 tui_data_window::erase_data_content (const char *prompt)
 {
@@ -400,7 +389,6 @@  tui_data_window::rerender (bool toplevel)
   else
     {
       erase_data_content (NULL);
-      delete_data_content_windows ();
       display_registers_from (0);
     }
 }
@@ -425,7 +413,6 @@  tui_data_window::do_scroll_vertical (int num_to_scroll)
     {
       first_line += num_to_scroll;
       erase_data_content (NULL);
-      delete_data_content_windows ();
       display_registers_from_line (first_line);
     }
 }
@@ -448,7 +435,7 @@  tui_data_window::check_register_values (frame_info_ptr frame)
 
 	  /* Register windows whose y == 0 are outside the visible area.  */
 	  if ((data_item_win.highlight || was_hilighted)
-	      && data_item_win.y > 0)
+	      && data_item_win.visible ())
 	    data_item_win.rerender (handle.get (), m_item_width);
 	}
     }
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index e7125e457f5..1b0eaa2033b 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -44,11 +44,13 @@  struct tui_register_info
 
   void rerender (WINDOW *handle, int field_width);
 
+  bool visible () const
+  { return y > 0; }
+
   /* Location.  */
   int x = 0;
   int y = 0;
   bool highlight = false;
-  bool visible = false;
   std::string content;
 
 private:
@@ -130,10 +132,6 @@  struct tui_data_window : public tui_win_info
      past the register area (-1) is returned.  */
   int first_reg_element_no_inline (int line_no) const;
 
-  /* Delete all the item windows in the data window.  This is usually
-     done when the data window is scrolled.  */
-  void delete_data_content_windows ();
-
   void erase_data_content (const char *prompt);
 
   /* Information about each register in the current register group.  */