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 56/66] Turn tui_first_data_item_displayed into a method


tui_first_data_item_displayed is only called from tui_data_window
methods, so turn it into a method as well.

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

	* tui/tui-windata.h (tui_first_data_item_displayed): Don't
	declare.
	* tui/tui-windata.c (tui_data_window::first_data_item_displayed):
	Rename from tui_first_data_item_displayed.  Update.
	(tui_data_window::refresh_all)
	(tui_data_window::do_scroll_vertical): Update.
	* tui/tui-data.h (struct tui_data_window)
	<first_data_item_displayed>: Declare new method.
---
 gdb/ChangeLog         | 11 +++++++++++
 gdb/tui/tui-data.h    |  4 ++++
 gdb/tui/tui-windata.c | 23 ++++++++---------------
 gdb/tui/tui-windata.h |  1 -
 4 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 2306abe1292..3416c413dc2 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -505,6 +505,10 @@ protected:
   {
   }
   void do_make_visible_with_new_height () override;
+
+  /* Return the index of the first element displayed.  If none are
+     displayed, then return -1.  */
+  int first_data_item_displayed ();
 };
 
 struct tui_cmd_window : public tui_win_info
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index c5593454580..82436a31d92 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -42,25 +42,18 @@
 /* Answer the index first element displayed.  If none are displayed,
    then return (-1).  */
 int
-tui_first_data_item_displayed (void)
+tui_data_window::first_data_item_displayed ()
 {
-  int element_no = (-1);
-  int i;
-
-  for (i = 0; 
-       i < TUI_DATA_WIN->content_size && element_no < 0;
-       i++)
+  for (int i = 0; i < content_size; i++)
     {
       struct tui_gen_win_info *data_item_win;
 
-      data_item_win
-	= TUI_DATA_WIN->content[i]->which_element.data_window;
-      if (data_item_win->handle != NULL
-	  && data_item_win->is_visible)
-	element_no = i;
+      data_item_win = content[i]->which_element.data_window;
+      if (data_item_win->handle != NULL && data_item_win->is_visible)
+	return i;
     }
 
-  return element_no;
+  return -1;
 }
 
 
@@ -198,7 +191,7 @@ tui_data_window::refresh_all ()
   tui_erase_data_content (NULL);
   if (content_size > 0)
     {
-      int first_element = tui_first_data_item_displayed ();
+      int first_element = first_data_item_displayed ();
 
       if (first_element >= 0)	/* Re-use existing windows.  */
 	tui_display_data_from (first_element, TRUE);
@@ -248,7 +241,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
   int first_element_no;
   int first_line = (-1);
 
-  first_element_no = tui_first_data_item_displayed ();
+  first_element_no = first_data_item_displayed ();
   if (first_element_no < regs_content_count)
     first_line = tui_line_from_reg_element_no (first_element_no);
   else
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index c070f76c392..4aa8cb0b38c 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -28,7 +28,6 @@ extern void tui_erase_data_content (const char *);
 extern void tui_display_all_data (void);
 extern void tui_check_data_values (struct frame_info *);
 extern void tui_display_data_from_line (int);
-extern int tui_first_data_item_displayed (void);
 extern void tui_delete_data_content_windows (void);
 extern void tui_refresh_data_win (void);
 extern void tui_display_data_from (int, int);
-- 
2.17.2


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