public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Change tui_make_status_line to be a method
@ 2019-09-20 20:06 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-09-20 20:06 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=71a25ed2e77fd72e01d38aa84f5a0fbe5f081474

commit 71a25ed2e77fd72e01d38aa84f5a0fbe5f081474
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Jul 23 16:43:20 2019 -0600

    Change tui_make_status_line to be a method
    
    This changes tui_make_status_line to be a method on
    tui_locator_window.  This is a minor cleanup.
    
    This also changes the new method to use the locator's width, rather
    than the terminal width.  This is important if we ever want to allow
    windows to be made more narrow.
    
    gdb/ChangeLog
    2019-09-20  Tom Tromey  <tom@tromey.com>
    
    	* tui/tui-stack.h (struct tui_locator_window) <make_status_line>:
    	Declare.
    	* tui/tui-stack.c (tui_locator_window::make_status_line): Rename
    	from tui_make_status_line.
    	(tui_locator_window::rerender): Update.

Diff:
---
 gdb/ChangeLog       |  8 ++++++++
 gdb/tui/tui-stack.c | 30 ++++++++++++------------------
 gdb/tui/tui-stack.h |  8 ++++++++
 3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 862748e..b6a1534 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
 2019-09-20  Tom Tromey  <tom@tromey.com>
 
+	* tui/tui-stack.h (struct tui_locator_window) <make_status_line>:
+	Declare.
+	* tui/tui-stack.c (tui_locator_window::make_status_line): Rename
+	from tui_make_status_line.
+	(tui_locator_window::rerender): Update.
+
+2019-09-20  Tom Tromey  <tom@tromey.com>
+
 	* tui/tui-stack.c (tui_make_status_line): Return std::string.
 	(tui_locator_window::rerender): Update.
 
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index a2e4a16..163a5ad 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -63,13 +63,10 @@ tui_locator_win_info_ptr (void)
   return &_locator;
 }
 
-/* Create the status line to display as much information as we can on
-   this single line: target name, process number, current function,
-   current line, current PC, SingleKey mode.  */
-static std::string
-tui_make_status_line (struct tui_locator_window *loc)
+std::string
+tui_locator_window::make_status_line () const
 {
-  char line_buf[50], *pname;
+  char line_buf[50];
   int status_size;
   int proc_width;
   const char *pid_name;
@@ -94,11 +91,11 @@ tui_make_status_line (struct tui_locator_window *loc)
   if (pid_width > MAX_PID_WIDTH)
     pid_width = MAX_PID_WIDTH;
 
-  status_size = tui_term_width ();
+  status_size = width;
 
   /* Translate line number and obtain its size.  */
-  if (loc->line_no > 0)
-    xsnprintf (line_buf, sizeof (line_buf), "%d", loc->line_no);
+  if (line_no > 0)
+    xsnprintf (line_buf, sizeof (line_buf), "%d", line_no);
   else
     strcpy (line_buf, "??");
   line_width = strlen (line_buf);
@@ -106,8 +103,8 @@ tui_make_status_line (struct tui_locator_window *loc)
     line_width = MIN_LINE_WIDTH;
 
   /* Translate PC address.  */
-  std::string pc_out (loc->gdbarch
-		      ? paddress (loc->gdbarch, loc->addr)
+  std::string pc_out (gdbarch
+		      ? paddress (gdbarch, addr)
 		      : "??");
   const char *pc_buf = pc_out.c_str ();
   int pc_width = pc_out.size ();
@@ -150,9 +147,6 @@ tui_make_status_line (struct tui_locator_window *loc)
         }
     }
 
-  /* Now convert elements to string form.  */
-  pname = loc->proc_name;
-
   /* Now create the locator line from the string version of the
      elements.  */
   string_file string;
@@ -172,12 +166,12 @@ tui_make_status_line (struct tui_locator_window *loc)
   /* Procedure/class name.  */
   if (proc_width > 0)
     {
-      if (strlen (pname) > proc_width)
+      if (strlen (proc_name) > proc_width)
         string.printf ("%s%*.*s* ", PROC_PREFIX,
-		       1 - proc_width, proc_width - 1, pname);
+		       1 - proc_width, proc_width - 1, proc_name);
       else
         string.printf ("%s%*.*s ", PROC_PREFIX,
-		       -proc_width, proc_width, pname);
+		       -proc_width, proc_width, proc_name);
     }
 
   if (line_width > 0)
@@ -234,7 +228,7 @@ tui_locator_window::rerender ()
 {
   if (handle != NULL)
     {
-      std::string string = tui_make_status_line (this);
+      std::string string = make_status_line ();
       wmove (handle, 0, 0);
       /* We ignore the return value from wstandout and wstandend, casting
 	 them to void in order to avoid a compiler warning.  The warning
diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h
index 86239b0..b6ffa98 100644
--- a/gdb/tui/tui-stack.h
+++ b/gdb/tui/tui-stack.h
@@ -63,6 +63,14 @@ struct tui_locator_window : public tui_gen_win_info
   CORE_ADDR addr = 0;
   /* Architecture associated with code at this location.  */
   struct gdbarch *gdbarch = nullptr;
+
+private:
+
+  /* Create the status line to display as much information as we can
+     on this single line: target name, process number, current
+     function, current line, current PC, SingleKey mode.  */
+
+  std::string make_status_line () const;
 };
 
 extern void tui_update_locator_fullname (const char *);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-20 20:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20 20:06 [binutils-gdb] Change tui_make_status_line to be a method Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).