diff mbox

[07/15] Change tui_line_is_displayed to be a method

Message ID 20190814162132.31424-8-tom@tromey.com
State New
Headers show

Commit Message

Tom Tromey Aug. 14, 2019, 4:21 p.m. UTC
This changes tui_line_is_displayed to be a method on
tui_source_window, now that it is obvious that it can only be called
for this type.

gdb/ChangeLog
2019-08-14  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_line_is_displayed): Don't declare.
	* tui/tui-winsource.c (tui_line_is_displayed): Move to
	tui-source.c.
	* tui/tui-source.h (struct tui_source_window) <line_is_displayed>:
	Declare.
	* tui/tui-source.c (tui_source_window::line_is_displayed): New
	method.
	(tui_source_window::maybe_update): Update.
---
 gdb/ChangeLog           | 11 +++++++++++
 gdb/tui/tui-source.c    | 21 ++++++++++++++++++++-
 gdb/tui/tui-source.h    |  4 ++++
 gdb/tui/tui-winsource.c | 28 ----------------------------
 gdb/tui/tui-winsource.h |  3 ---
 5 files changed, 35 insertions(+), 32 deletions(-)
diff mbox

Patch

diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 34b8f54557d..7c173f8a6f9 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -294,6 +294,25 @@  tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
 			   symtab_to_fullname (loc->symtab)) == 0);
 }
 
+/* See tui-source.h.  */
+
+bool
+tui_source_window::line_is_displayed (int line) const
+{
+  bool is_displayed = false;
+  int threshold = SCROLL_THRESHOLD;
+  int i = 0;
+  while (i < content.size () - threshold && !is_displayed)
+    {
+      is_displayed
+	= (content[i].line_or_addr.loa == LOA_LINE
+	   && content[i].line_or_addr.u.line_no == line);
+      i++;
+    }
+
+  return is_displayed;
+}
+
 void
 tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
 				 int line_no, CORE_ADDR addr)
@@ -310,7 +329,7 @@  tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
   l.loa = LOA_LINE;
   l.u.line_no = start_line;
   if (!(source_already_displayed
-	&& tui_line_is_displayed (line_no, this, TRUE)))
+	&& line_is_displayed (line_no)))
     tui_update_source_window (this, get_frame_arch (fi),
 			      sal.symtab, l, TRUE);
   else
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index dc4470e9e5a..42338790947 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -59,6 +59,10 @@  private:
 
   void style_changed ();
 
+  /* Answer whether a particular line number or address is displayed
+     in the current source window.  */
+  bool line_is_displayed (int line) const;
+
   /* A token used to register and unregister an observer.  */
   gdb::observers::token m_observable;
 };
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index e8e7061d0f2..a85269657cf 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -640,31 +640,3 @@  tui_alloc_source_buffer (struct tui_source_window_base *win_info)
 	win_info->content[i].line = (char *) xmalloc (line_width);
     }
 }
-
-
-/* Answer whether a particular line number or address is displayed
-   in the current source window.  */
-int
-tui_line_is_displayed (int line, 
-		       struct tui_source_window_base *win_info,
-		       int check_threshold)
-{
-  int is_displayed = FALSE;
-  int i, threshold;
-
-  if (check_threshold)
-    threshold = SCROLL_THRESHOLD;
-  else
-    threshold = 0;
-  i = 0;
-  while (i < win_info->content.size () - threshold
-	 && !is_displayed)
-    {
-      is_displayed
-	= win_info->content[i].line_or_addr.loa == LOA_LINE
-	  && win_info->content[i].line_or_addr.u.line_no == line;
-      i++;
-    }
-
-  return is_displayed;
-}
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index fb9c05cadc8..f88f6b7de45 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -172,9 +172,6 @@  extern void tui_clear_source_content (struct tui_source_window_base *);
 extern void tui_erase_source_content (struct tui_source_window_base *);
 
 extern void tui_alloc_source_buffer (struct tui_source_window_base *);
-extern int tui_line_is_displayed (int,
-				  struct tui_source_window_base *,
-				  int);
 
 
 /* Constant definitions. */