public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/11] TUI cleanups
@ 2020-06-18  2:15 Tom Tromey
  2020-06-18  2:15 ` [PATCH 01/11] Use complete_on_enum in tui_reggroup_completer Tom Tromey
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches

I started looking more seriously at fixing the TUI's UTF-8 problem.  I
think I have an answer to that -- use pads for the source window to
avoid the truncation problem on both ends -- but before starting, I
found a number of small oddities remaining in the TUI.  So, this
series cleans up various small issues I found, removing more unneeded
TUI code in the process.

Let me know what you think.

More cleanups could be done -- some methods are in the wrong file, and
some things (especially the "locator" window and its associated files)
are misnamed.  However, I wasn't sure if a big rearrangement +
renaming would be welcome, so I didn't do that.  It's easy enough to
do in the future if desired.

Tom



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 01/11] Use complete_on_enum in tui_reggroup_completer
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 02/11] Remove tui_expand_tabs Tom Tromey
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_reggroup_completer has an "XXXX" comment suggesting the use of
complete_on_enum.  This patch implements this suggestion.

2020-06-14  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_reggroup_completer): Use complete_on_enum.
---
 gdb/ChangeLog      |  4 ++++
 gdb/tui/tui-regs.c | 11 ++---------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index d33f0aadef8..b99e29972de 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -631,18 +631,11 @@ tui_reggroup_completer (struct cmd_list_element *ignore,
 			completion_tracker &tracker,
 			const char *text, const char *word)
 {
-  static const char *extra[] = { "next", "prev", NULL };
-  size_t len = strlen (word);
-  const char **tmp;
+  static const char * const extra[] = { "next", "prev", NULL };
 
   reggroup_completer (ignore, tracker, text, word);
 
-  /* XXXX use complete_on_enum instead?  */
-  for (tmp = extra; *tmp != NULL; ++tmp)
-    {
-      if (strncmp (word, *tmp, len) == 0)
-	tracker.add_completion (make_unique_xstrdup (*tmp));
-    }
+  complete_on_enum (tracker, extra, text, word);
 }
 
 void _initialize_tui_regs ();
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 02/11] Remove tui_expand_tabs
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
  2020-06-18  2:15 ` [PATCH 01/11] Use complete_on_enum in tui_reggroup_completer Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 03/11] Move some code out of tui-data.h Tom Tromey
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_expand_tabs only has a single caller.  This patch removes this
function, in favor of a tab-expanding variant of string_file.  This
simplifies the code somewhat.

2020-06-14  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_item_window) <content>: Now a
	std::string.
	* tui/tui-regs.c (class tab_expansion_file): New.
	(tab_expansion_file::write): New method.
	(tui_register_format): Change return type.  Use
	tab_expansion_file.
	(tui_get_register, tui_data_window::display_registers_from)
	(tui_data_item_window::rerender): Update.
	* tui/tui-io.h (tui_expand_tabs): Don't declare.
	* tui/tui-io.c (tui_expand_tabs): Remove.
---
 gdb/ChangeLog      | 13 ++++++++++
 gdb/tui/tui-io.c   | 52 -------------------------------------
 gdb/tui/tui-io.h   |  3 ---
 gdb/tui/tui-regs.c | 64 ++++++++++++++++++++++++++++++++++------------
 gdb/tui/tui-regs.h |  2 +-
 5 files changed, 61 insertions(+), 73 deletions(-)

diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 277b560af4f..7698d7903f1 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -1050,55 +1050,3 @@ tui_getc (FILE *fp)
       return 0;
     }
 }
-
-/* See tui-io.h.  */
-
-gdb::unique_xmalloc_ptr<char>
-tui_expand_tabs (const char *string)
-{
-  int n_adjust, ncol;
-  const char *s;
-  char *ret, *q;
-
-  /* 1. How many additional characters do we need?  */
-  for (ncol = 0, n_adjust = 0, s = string; s; )
-    {
-      s = strpbrk (s, "\t");
-      if (s)
-	{
-	  ncol += (s - string) + n_adjust;
-	  /* Adjustment for the next tab stop, minus one for the TAB
-	     we replace with spaces.  */
-	  n_adjust += 8 - (ncol % 8) - 1;
-	  s++;
-	}
-    }
-
-  /* Allocate the copy.  */
-  ret = q = (char *) xmalloc (strlen (string) + n_adjust + 1);
-
-  /* 2. Copy the original string while replacing TABs with spaces.  */
-  for (ncol = 0, s = string; s; )
-    {
-      const char *s1 = strpbrk (s, "\t");
-      if (s1)
-	{
-	  if (s1 > s)
-	    {
-	      strncpy (q, s, s1 - s);
-	      q += s1 - s;
-	      ncol += s1 - s;
-	    }
-	  do {
-	    *q++ = ' ';
-	    ncol++;
-	  } while ((ncol % 8) != 0);
-	  s1++;
-	}
-      else
-	strcpy (q, s);
-      s = s1;
-    }
-
-  return gdb::unique_xmalloc_ptr<char> (ret);
-}
diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h
index f28cf4e12db..2cc47ba4beb 100644
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -45,9 +45,6 @@ extern void tui_initialize_io (void);
    changed the edited text.  */
 extern void tui_redisplay_readline (void);
 
-/* Expand TABs into spaces.  */
-extern gdb::unique_xmalloc_ptr<char> tui_expand_tabs (const char *);
-
 /* Enter/leave reverse video mode.  */
 extern void tui_set_reverse_mode (WINDOW *w, bool reverse);
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index b99e29972de..15ce7a02226 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -42,15 +42,55 @@
 
 #include "gdb_curses.h"
 
+/* A subclass of string_file that expands tab characters.  */
+class tab_expansion_file : public string_file
+{
+public:
+
+  tab_expansion_file () = default;
+
+  void write (const char *buf, long length_buf) override;
+
+private:
+
+  int m_column = 0;
+};
+
+void
+tab_expansion_file::write (const char *buf, long length_buf)
+{
+  for (long i = 0; i < length_buf; ++i)
+    {
+      if (buf[i] == '\t')
+	{
+	  do
+	    {
+	      string_file::write (" ", 1);
+	      ++m_column;
+	    }
+	  while ((m_column % 8) != 0);
+	}
+      else
+	{
+	  string_file::write (&buf[i], 1);
+	  if (buf[i] == '\n')
+	    m_column = 0;
+	  else
+	    ++m_column;
+	}
+    }
+}
+
 /* Get the register from the frame and return a printable
    representation of it.  */
 
-static gdb::unique_xmalloc_ptr<char>
+static std::string
 tui_register_format (struct frame_info *frame, int regnum)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
 
-  string_file stream;
+  /* Expand tabs into spaces, since ncurses on MS-Windows doesn't.  */
+  tab_expansion_file stream;
 
   scoped_restore save_pagination
     = make_scoped_restore (&pagination_enabled, 0);
@@ -64,8 +104,7 @@ tui_register_format (struct frame_info *frame, int regnum)
   if (!str.empty () && str.back () == '\n')
     str.resize (str.size () - 1);
 
-  /* Expand tabs into spaces, since ncurses on MS-Windows doesn't.  */
-  return tui_expand_tabs (str.c_str ());
+  return str;
 }
 
 /* Get the register value from the given frame and format it for the
@@ -80,11 +119,9 @@ tui_get_register (struct frame_info *frame,
     *changedp = false;
   if (target_has_registers)
     {
-      gdb::unique_xmalloc_ptr<char> new_content
-	= tui_register_format (frame, regnum);
+      std::string new_content = tui_register_format (frame, regnum);
 
-      if (changedp != NULL
-	  && strcmp (data->content.get (), new_content.get ()) != 0)
+      if (changedp != NULL && data->content != new_content)
 	*changedp = true;
 
       data->content = std::move (new_content);
@@ -244,13 +281,7 @@ tui_data_window::display_registers_from (int start_element_no)
   int max_len = 0;
   for (auto &&data_item_win : m_regs_content)
     {
-      const char *p;
-      int len;
-
-      len = 0;
-      p = data_item_win.content.get ();
-      if (p != 0)
-	len = strlen (p);
+      int len = data_item_win.content.size ();
 
       if (len > max_len)
 	max_len = len;
@@ -488,8 +519,7 @@ tui_data_item_window::rerender ()
   for (i = 1; i < width; i++)
     waddch (handle.get (), ' ');
   wmove (handle.get (), 0, 0);
-  if (content)
-    waddstr (handle.get (), content.get ());
+  waddstr (handle.get (), content.c_str ());
 
   if (highlight)
     /* We ignore the return value, casting it to void in order to avoid
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index df8c27305cd..250f4e74667 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -52,7 +52,7 @@ struct tui_data_item_window : public tui_gen_win_info
   /* The register number, or data display number.  */
   int item_no = -1;
   bool highlight = false;
-  gdb::unique_xmalloc_ptr<char> content;
+  std::string content;
 };
 
 /* The TUI registers window.  */
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 03/11] Move some code out of tui-data.h
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
  2020-06-18  2:15 ` [PATCH 01/11] Use complete_on_enum in tui_reggroup_completer Tom Tromey
  2020-06-18  2:15 ` [PATCH 02/11] Remove tui_expand_tabs Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 04/11] Remove tui_data_window::name Tom Tromey
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves some code out of tui-data.h, to more closely related
places.  Some unused forward declarations are also removed.

2020-06-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-stack.c (SINGLE_KEY): Move from tui-data.h
	* tui/tui-winsource.h (enum tui_line_or_address_kind)
	(struct tui_line_or_address): Move from tui-data.h.
	* tui/tui-win.c (DEFAULT_TAB_LEN): Move from tui-data.h.
	* tui/tui-data.h (DEFAULT_TAB_LEN): Move to tui-win.c.
	(tui_cmd_window, tui_source_window_base, tui_source_window)
	(tui_disasm_window): Don't declare.
	(enum tui_line_or_address_kind, struct tui_line_or_address): Move
	to tui-winsource.h.
	(SINGLE_KEY): Move to tui-stack.c.
---
 gdb/ChangeLog           | 13 +++++++++++++
 gdb/tui/tui-data.h      | 26 --------------------------
 gdb/tui/tui-stack.c     |  3 +++
 gdb/tui/tui-win.c       |  2 ++
 gdb/tui/tui-winsource.h | 17 +++++++++++++++++
 5 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 1accf3683d4..d96384f6ce7 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -26,11 +26,6 @@
 #include "gdb_curses.h"	/* For WINDOW.  */
 #include "observable.h"
 
-struct tui_cmd_window;
-struct tui_source_window_base;
-struct tui_source_window;
-struct tui_disasm_window;
-
 /* A deleter that calls delwin.  */
 struct curses_deleter
 {
@@ -125,7 +120,6 @@ struct tui_gen_win_info
 };
 
 /* Constant definitions.  */
-#define DEFAULT_TAB_LEN         8
 #define SRC_NAME                "src"
 #define CMD_NAME                "cmd"
 #define DATA_NAME               "regs"
@@ -133,26 +127,6 @@ struct tui_gen_win_info
 #define STATUS_NAME		"status"
 #define MIN_WIN_HEIGHT          3
 
-/* Strings to display in the TUI status line.  */
-#define SINGLE_KEY              "(SingleKey)"
-
-enum tui_line_or_address_kind
-{
-  LOA_LINE,
-  LOA_ADDRESS
-};
-
-/* Structure describing source line or line address.  */
-struct tui_line_or_address
-{
-  enum tui_line_or_address_kind loa;
-  union
-    {
-      int line_no;
-      CORE_ADDR addr;
-    } u;
-};
-
 /* This defines information about each logical window.  */
 struct tui_win_info : public tui_gen_win_info
 {
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index f1e075a3d20..8bd7880f89a 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -43,6 +43,9 @@
 #define LINE_PREFIX             "L"
 #define PC_PREFIX               "PC: "
 
+/* Strings to display in the TUI status line.  */
+#define SINGLE_KEY              "(SingleKey)"
+
 /* Minimum/Maximum length of some fields displayed in the TUI status
    line.  */
 #define MIN_LINE_WIDTH     4	/* Use at least 4 digits for line
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a78837fe689..5f56eca3b2f 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -753,6 +753,8 @@ tui_refresh_all_command (const char *arg, int from_tty)
   tui_refresh_all_win ();
 }
 
+#define DEFAULT_TAB_LEN         8
+
 /* The tab width that should be used by the TUI.  */
 
 unsigned int tui_tab_width = DEFAULT_TAB_LEN;
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 501dd31ccfd..fab1487f637 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -25,6 +25,23 @@
 #include "tui/tui-data.h"
 #include "symtab.h"
 
+enum tui_line_or_address_kind
+{
+  LOA_LINE,
+  LOA_ADDRESS
+};
+
+/* Structure describing source line or line address.  */
+struct tui_line_or_address
+{
+  enum tui_line_or_address_kind loa;
+  union
+    {
+      int line_no;
+      CORE_ADDR addr;
+    } u;
+};
+
 /* Flags to tell what kind of breakpoint is at current line.  */
 enum tui_bp_flag
 {
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 04/11] Remove tui_data_window::name
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (2 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 03/11] Move some code out of tui-data.h Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 05/11] Remove useless "if' from tui-regs.c Tom Tromey
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The "name" member of tui_data_window was set, but never used.  This
removes it.

2020-06-14  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_data_window::show_register_group): Update.
	* tui/tui-regs.h (struct tui_data_item_window) <name>: Remove.
---
 gdb/ChangeLog      | 5 +++++
 gdb/tui/tui-regs.c | 1 -
 gdb/tui/tui-regs.h | 1 -
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 15ce7a02226..39f5d736392 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -262,7 +262,6 @@ tui_data_window::show_register_group (struct reggroup *group,
 	  if (!refresh_values_only)
 	    {
 	      data_item_win->item_no = regnum;
-	      data_item_win->name = name;
 	      data_item_win->highlight = false;
 	    }
 	  tui_get_register (frame, data_item_win, regnum, 0);
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 250f4e74667..7acc0c7bd62 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -48,7 +48,6 @@ struct tui_data_item_window : public tui_gen_win_info
     return 1;
   }
 
-  const char *name = nullptr;
   /* The register number, or data display number.  */
   int item_no = -1;
   bool highlight = false;
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 05/11] Remove useless "if' from tui-regs.c
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (3 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 04/11] Remove tui_data_window::name Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 06/11] Rename tui_data_item_window::item_no Tom Tromey
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_data_window::show_register_group had a useless "if" -- the
condition could never be false.  This patch removes it.

2020-06-14  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_data_window::show_register_group): Remove
	useless "if".
---
 gdb/ChangeLog      |  5 +++++
 gdb/tui/tui-regs.c | 11 ++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 39f5d736392..51fc475beda 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -257,15 +257,12 @@ tui_data_window::show_register_group (struct reggroup *group,
 	continue;
 
       data_item_win = &m_regs_content[pos];
-      if (data_item_win)
+      if (!refresh_values_only)
 	{
-	  if (!refresh_values_only)
-	    {
-	      data_item_win->item_no = regnum;
-	      data_item_win->highlight = false;
-	    }
-	  tui_get_register (frame, data_item_win, regnum, 0);
+	  data_item_win->item_no = regnum;
+	  data_item_win->highlight = false;
 	}
+      tui_get_register (frame, data_item_win, regnum, 0);
       pos++;
     }
 }
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 06/11] Rename tui_data_item_window::item_no
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (4 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 05/11] Remove useless "if' from tui-regs.c Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 07/11] Don't derive tui_data_item_window from tui_gen_win_info Tom Tromey
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_data_item_window::item_no is misnamed -- it only can be used for a
register, but it references a "display" number as well.  (Based on
other comments I've seen in the past -- most since deleted -- I think
there were plans at one point to display variables in this window as
well.  However, this was never implemented.)

This patch renames this member to be more correct.

2020-06-14  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_data_window::show_register_group)
	(tui_data_window::check_register_values): Update.
	* tui/tui-regs.h (struct tui_data_item_window) <regno>: Rename
	from item_no.
---
 gdb/ChangeLog      | 7 +++++++
 gdb/tui/tui-regs.c | 4 ++--
 gdb/tui/tui-regs.h | 4 ++--
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 51fc475beda..fcabe73a5ea 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -259,7 +259,7 @@ tui_data_window::show_register_group (struct reggroup *group,
       data_item_win = &m_regs_content[pos];
       if (!refresh_values_only)
 	{
-	  data_item_win->item_no = regnum;
+	  data_item_win->regno = regnum;
 	  data_item_win->highlight = false;
 	}
       tui_get_register (frame, data_item_win, regnum, 0);
@@ -486,7 +486,7 @@ tui_data_window::check_register_values (struct frame_info *frame)
 	  was_hilighted = data_item_win.highlight;
 
 	  tui_get_register (frame, &data_item_win,
-			    data_item_win.item_no,
+			    data_item_win.regno,
 			    &data_item_win.highlight);
 
 	  if (data_item_win.highlight || was_hilighted)
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 7acc0c7bd62..8b5e941a0a0 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -48,8 +48,8 @@ struct tui_data_item_window : public tui_gen_win_info
     return 1;
   }
 
-  /* The register number, or data display number.  */
-  int item_no = -1;
+  /* The register number.  */
+  int regno = -1;
   bool highlight = false;
   std::string content;
 };
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 07/11] Don't derive tui_data_item_window from tui_gen_win_info
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (5 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 06/11] Rename tui_data_item_window::item_no Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 08/11] Remove body of tui_locator_window constructor Tom Tromey
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

There's no deep reason that tui_data_item_window should derive from
tui_gen_win_info -- it currently uses a curses window to render, but
that isn't truly needed, and it adds some hacks to other parts of the
TUI.

This patch changes tui_data_item_window so that it doesn't have a base
class, and updates the register window.  This simplifies the code and
enables a subsequent cleanup.

2020-06-15  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_data_window::display_registers_from)
	(tui_data_window::display_registers_from)
	(tui_data_window::first_data_item_displayed)
	(tui_data_window::delete_data_content_windows): Update.
	(tui_data_window::refresh_window, tui_data_window::no_refresh):
	Remove.
	(tui_data_window::check_register_values): Update.
	(tui_data_item_window::rerender): Add parameters.  Update.
	(tui_data_item_window::refresh_window): Remove.
	* tui/tui-data.h (struct tui_gen_win_info) <no_refresh>: No longer
	virtual.
	* tui/tui-regs.h (struct tui_data_item_window): Don't derive from
	tui_gen_win_info.
	<refresh_window, max_height, min_height>: Remove.
	<rerender>: Add parameters.
	<x, y, visible>: New members.
	(struct tui_data_window) <refresh_window, no_refresh>: Remove.
	<m_item_width>: New member.
---
 gdb/ChangeLog      | 21 ++++++++++++
 gdb/tui/tui-data.h |  2 +-
 gdb/tui/tui-regs.c | 79 ++++++++++++----------------------------------
 gdb/tui/tui-regs.h | 27 ++++++----------
 4 files changed, 51 insertions(+), 78 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index d96384f6ce7..10dd0aedcff 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -102,7 +102,7 @@ struct tui_gen_win_info
   }
 
   /* Disable output until the next call to doupdate.  */
-  virtual void no_refresh ()
+  void no_refresh ()
   {
     if (handle != nullptr)
       wnoutrefresh (handle.get ());
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index fcabe73a5ea..04d7469de5a 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -272,8 +272,6 @@ tui_data_window::show_register_group (struct reggroup *group,
 void
 tui_data_window::display_registers_from (int start_element_no)
 {
-  int j, item_win_width, cur_y;
-
   int max_len = 0;
   for (auto &&data_item_win : m_regs_content)
     {
@@ -282,26 +280,28 @@ tui_data_window::display_registers_from (int start_element_no)
       if (len > max_len)
 	max_len = len;
     }
-  item_win_width = max_len + 1;
+  m_item_width = max_len + 1;
   int i = start_element_no;
 
-  m_regs_column_count = (width - 2) / item_win_width;
+  m_regs_column_count = (width - 2) / m_item_width;
   if (m_regs_column_count == 0)
     m_regs_column_count = 1;
-  item_win_width = (width - 2) / m_regs_column_count;
+  m_item_width = (width - 2) / m_regs_column_count;
 
   /* Now create each data "sub" window, and write the display into
      it.  */
-  cur_y = 1;
+  int cur_y = 1;
   while (i < m_regs_content.size () && cur_y <= height - 2)
     {
-      for (j = 0;
+      for (int j = 0;
 	   j < m_regs_column_count && i < m_regs_content.size ();
 	   j++)
 	{
 	  /* Create the window if necessary.  */
-	  m_regs_content[i].resize (1, item_win_width,
-				    x + (item_win_width * j) + 1, y + cur_y);
+	  m_regs_content[i].x = (m_item_width * j) + 1;
+	  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.  */
 	}
       cur_y++;		/* Next row.  */
@@ -372,10 +372,7 @@ tui_data_window::first_data_item_displayed ()
 {
   for (int i = 0; i < m_regs_content.size (); i++)
     {
-      struct tui_gen_win_info *data_item_win;
-
-      data_item_win = &m_regs_content[i];
-      if (data_item_win->is_visible ())
+      if (m_regs_content[i].visible)
 	return i;
     }
 
@@ -387,8 +384,8 @@ tui_data_window::first_data_item_displayed ()
 void
 tui_data_window::delete_data_content_windows ()
 {
-  for (auto &&win : m_regs_content)
-    win.handle.reset (nullptr);
+  for (auto &win : m_regs_content)
+    win.visible = false;
 }
 
 
@@ -451,24 +448,6 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
     }
 }
 
-/* See tui-regs.h.  */
-
-void
-tui_data_window::refresh_window ()
-{
-  tui_gen_win_info::refresh_window ();
-  for (auto &&win : m_regs_content)
-    win.refresh_window ();
-}
-
-void
-tui_data_window::no_refresh ()
-{
-  tui_gen_win_info::no_refresh ();
-  for (auto &&win : m_regs_content)
-    win.no_refresh ();
-}
-
 /* This function check all displayed registers for changes in values,
    given a particular frame.  If the values have changed, they are
    updated with the new value and highlighted.  */
@@ -490,32 +469,28 @@ tui_data_window::check_register_values (struct frame_info *frame)
 			    &data_item_win.highlight);
 
 	  if (data_item_win.highlight || was_hilighted)
-	    data_item_win.rerender ();
+	    data_item_win.rerender (handle.get (), m_item_width);
 	}
     }
+
+  tui_wrefresh (handle.get ());
 }
 
 /* Display a register in a window.  If hilite is TRUE, then the value
    will be displayed in reverse video.  */
 void
-tui_data_item_window::rerender ()
+tui_data_item_window::rerender (WINDOW *handle, int field_width)
 {
-  int i;
-
-  scrollok (handle.get (), FALSE);
   if (highlight)
     /* We ignore the return value, casting it to void in order to avoid
        a compiler warning.  The warning itself was introduced by a patch
        to ncurses 5.7 dated 2009-08-29, changing this macro to expand
        to code that causes the compiler to generate an unused-value
        warning.  */
-    (void) wstandout (handle.get ());
+    (void) wstandout (handle);
       
-  wmove (handle.get (), 0, 0);
-  for (i = 1; i < width; i++)
-    waddch (handle.get (), ' ');
-  wmove (handle.get (), 0, 0);
-  waddstr (handle.get (), content.c_str ());
+  mvwaddnstr (handle, y, x, content.c_str (), field_width - 1);
+  waddstr (handle, n_spaces (field_width - content.size ()));
 
   if (highlight)
     /* We ignore the return value, casting it to void in order to avoid
@@ -523,21 +498,7 @@ tui_data_item_window::rerender ()
        to ncurses 5.7 dated 2009-08-29, changing this macro to expand
        to code that causes the compiler to generate an unused-value
        warning.  */
-    (void) wstandend (handle.get ());
-  refresh_window ();
-}
-
-void
-tui_data_item_window::refresh_window ()
-{
-  if (handle != nullptr)
-    {
-      /* This seems to be needed because the data items are nested
-	 windows, which according to the ncurses man pages aren't well
-	 supported.  */
-      touchwin (handle.get ());
-      tui_wrefresh (handle.get ());
-    }
+    (void) wstandend (handle);
 }
 
 /* Helper for "tui reg next", wraps a call to REGGROUP_NEXT, but adds wrap
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 8b5e941a0a0..29b54a53ef3 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -26,7 +26,7 @@
 
 /* A data item window.  */
 
-struct tui_data_item_window : public tui_gen_win_info
+struct tui_data_item_window
 {
   tui_data_item_window () = default;
 
@@ -34,23 +34,15 @@ struct tui_data_item_window : public tui_gen_win_info
 
   tui_data_item_window (tui_data_item_window &&) = default;
 
-  void rerender () override;
-
-  void refresh_window () override;
-
-  int max_height () const override
-  {
-    return 1;
-  }
-
-  int min_height () const override
-  {
-    return 1;
-  }
+  void rerender (WINDOW *handle, int field_width);
 
+  /* Location.  */
+  int x = 0;
+  int y = 0;
   /* The register number.  */
   int regno = -1;
   bool highlight = false;
+  bool visible = false;
   std::string content;
 };
 
@@ -61,10 +53,6 @@ struct tui_data_window : public tui_win_info
 
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
-  void refresh_window () override;
-
-  void no_refresh () override;
-
   const char *name () const override
   {
     return DATA_NAME;
@@ -138,6 +126,9 @@ struct tui_data_window : public tui_win_info
   std::vector<tui_data_item_window> m_regs_content;
   int m_regs_column_count = 0;
   struct reggroup *m_current_group = nullptr;
+
+  /* Width of each register's display area.  */
+  int m_item_width = 0;
 };
 
 #endif /* TUI_TUI_REGS_H */
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 08/11] Remove body of tui_locator_window constructor
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (6 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 07/11] Don't derive tui_data_item_window from tui_gen_win_info Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 09/11] Derive tui_locator_window from tui_win_info Tom Tromey
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The tui_locator_window constructor initializes the first character of
two of its members.  However, this is actually an error, since these
were changed to be std::string.  This removes the erroneous code.

2020-06-15  Tom Tromey  <tom@tromey.com>

	* tui/tui-stack.h (struct tui_locator_window): Remove body.
---
 gdb/ChangeLog       | 4 ++++
 gdb/tui/tui-stack.h | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h
index fde7c6dd2c9..0253767ad98 100644
--- a/gdb/tui/tui-stack.h
+++ b/gdb/tui/tui-stack.h
@@ -30,11 +30,7 @@ struct frame_info;
 
 struct tui_locator_window : public tui_gen_win_info
 {
-  tui_locator_window ()
-  {
-    full_name[0] = 0;
-    proc_name[0] = 0;
-  }
+  tui_locator_window () = default;
 
   int max_height () const override
   {
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 09/11] Derive tui_locator_window from tui_win_info
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (7 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 08/11] Remove body of tui_locator_window constructor Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-09-20  0:58   ` Simon Marchi
  2020-06-18  2:15 ` [PATCH 10/11] Remove tui_gen_win_info Tom Tromey
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_locator_window is the last remaining concrete child class of
tui_gen_win_info.  It seems a bit cleaner to me to flatten the
hierarchy a bit; this patch prepares for that by changing
tui_locator_window to derive from tui_win_info.

2020-06-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-stack.h (struct tui_locator_window): Derive from
	tui_win_info.
	<do_scroll_horizontal, do_scroll_vertical>: New methods.
	<can_box>: New method.
---
 gdb/ChangeLog       |  7 +++++++
 gdb/tui/tui-stack.h | 17 ++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h
index 0253767ad98..564ac22495c 100644
--- a/gdb/tui/tui-stack.h
+++ b/gdb/tui/tui-stack.h
@@ -28,7 +28,7 @@ struct frame_info;
 
 /* Locator window class.  */
 
-struct tui_locator_window : public tui_gen_win_info
+struct tui_locator_window : public tui_win_info
 {
   tui_locator_window () = default;
 
@@ -42,6 +42,11 @@ struct tui_locator_window : public tui_gen_win_info
     return 1;
   }
 
+  bool can_box () const override
+  {
+    return false;
+  }
+
   void rerender () override;
 
   /* Update the locator, with the provided arguments.
@@ -62,6 +67,16 @@ struct tui_locator_window : public tui_gen_win_info
   /* Architecture associated with code at this location.  */
   struct gdbarch *gdbarch = nullptr;
 
+protected:
+
+  void do_scroll_vertical (int n) override
+  {
+  }
+
+  void do_scroll_horizontal (int n) override
+  {
+  }
+
 private:
 
   /* Create the status line to display as much information as we can
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 10/11] Remove tui_gen_win_info
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (8 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 09/11] Derive tui_locator_window from tui_win_info Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-06-18  2:15 ` [PATCH 11/11] Make tui_win_info::name pure virtual Tom Tromey
  2020-07-02  3:24 ` [PATCH 00/11] TUI cleanups Tom Tromey
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This merges the tui_gen_win_info base class with tui_win_info;
renaming the resulting class to tui_win_info.

gdb/ChangeLog
2020-06-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_win_info::refresh_window): Move from
	tui_gen_win_info.
	(tui_win_info::make_window): Merge with
	tui_gen_win_info::make_window.
	(tui_win_info::make_visible): Move from tui_gen_win_info.
	* tui/tui-win.c (tui_win_info::max_width): Move from
	tui_gen_win_info.
	* tui/tui-layout.h (class tui_layout_window) <m_window>: Change
	type.
	<window_factory>: Likewise.
	* tui/tui-layout.c (tui_win_info::resize): Move from
	tui_gen_win_info.
	(make_standard_window): Change return type.
	(get_locator_window, tui_get_window_by_name): Likewise.
	(tui_layout_window::apply): Remove a cast.
	* tui/tui-data.h (MIN_WIN_HEIGHT): Move earlier.
	(struct tui_win_info): Merge with tui_gen_win_info.
	(struct tui_gen_win_info): Remove.
---
 gdb/ChangeLog            |  21 ++++++++
 gdb/tui/tui-data.h       | 110 ++++++++++++++-------------------------
 gdb/tui/tui-layout.c     |  15 +++---
 gdb/tui/tui-layout.h     |   4 +-
 gdb/tui/tui-win.c        |   2 +-
 gdb/tui/tui-wingeneral.c |  17 ++----
 6 files changed, 76 insertions(+), 93 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 10dd0aedcff..3c14b2654ee 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -35,27 +35,25 @@ struct curses_deleter
   }
 };
 
+#define MIN_WIN_HEIGHT          3
+
 /* Generic window information.  */
-struct tui_gen_win_info
+struct tui_win_info
 {
 protected:
 
-  tui_gen_win_info () = default;
+  tui_win_info () = default;
+  DISABLE_COPY_AND_ASSIGN (tui_win_info);
 
   /* This is called after the window is resized, and should update the
      window's contents.  */
-  virtual void rerender ()
-  {
-  }
+  virtual void rerender ();
 
   virtual void make_window ();
 
 public:
-  tui_gen_win_info (tui_gen_win_info &&) = default;
-
-  virtual ~tui_gen_win_info ()
-  {
-  }
+  tui_win_info (tui_win_info &&) = default;
+  virtual ~tui_win_info () = default;
 
   /* Call to refresh this window.  */
   virtual void refresh_window ();
@@ -70,10 +68,13 @@ struct tui_gen_win_info
   }
 
   /* Compute the maximum height of this window.  */
-  virtual int max_height () const = 0;
+  virtual int max_height () const;
 
   /* Compute the minimum height of this window.  */
-  virtual int min_height () const = 0;
+  virtual int min_height () const
+  {
+    return MIN_WIN_HEIGHT;
+  }
 
   /* Compute the maximum width of this window.  */
   int max_width () const;
@@ -87,7 +88,7 @@ struct tui_gen_win_info
   /* Return true if this window can be boxed.  */
   virtual bool can_box () const
   {
-    return false;
+    return true;
   }
 
   /* Resize this window.  The parameters are used to set the window's
@@ -108,58 +109,6 @@ struct tui_gen_win_info
       wnoutrefresh (handle.get ());
   }
 
-  /* Window handle.  */
-  std::unique_ptr<WINDOW, curses_deleter> handle;
-  /* Window width.  */
-  int width = 0;
-  /* Window height.  */
-  int height = 0;
-  /* Origin of window.  */
-  int x = 0;
-  int y = 0;
-};
-
-/* Constant definitions.  */
-#define SRC_NAME                "src"
-#define CMD_NAME                "cmd"
-#define DATA_NAME               "regs"
-#define DISASSEM_NAME           "asm"
-#define STATUS_NAME		"status"
-#define MIN_WIN_HEIGHT          3
-
-/* This defines information about each logical window.  */
-struct tui_win_info : public tui_gen_win_info
-{
-protected:
-
-  tui_win_info () = default;
-  DISABLE_COPY_AND_ASSIGN (tui_win_info);
-
-  /* Scroll the contents vertically.  This is only called via
-     forward_scroll and backward_scroll.  */
-  virtual void do_scroll_vertical (int num_to_scroll) = 0;
-
-  /* Scroll the contents horizontally.  This is only called via
-     left_scroll and right_scroll.  */
-  virtual void do_scroll_horizontal (int num_to_scroll) = 0;
-
-  void rerender () override;
-
-  void make_window () override;
-
-public:
-
-  ~tui_win_info () override
-  {
-  }
-
-  int max_height () const override;
-
-  int min_height () const override
-  {
-    return MIN_WIN_HEIGHT;
-  }
-
   /* Called after the tab width has been changed.  */
   virtual void update_tab_width ()
   {
@@ -185,20 +134,41 @@ struct tui_win_info : public tui_gen_win_info
     return true;
   }
 
-  bool can_box () const override
-  {
-    return true;
-  }
-
   void check_and_display_highlight_if_needed ();
 
+  /* Window handle.  */
+  std::unique_ptr<WINDOW, curses_deleter> handle;
+  /* Window width.  */
+  int width = 0;
+  /* Window height.  */
+  int height = 0;
+  /* Origin of window.  */
+  int x = 0;
+  int y = 0;
+
   /* Window title to display.  */
   std::string title;
 
   /* Is this window highlighted?  */
   bool is_highlighted = false;
+
+protected:
+
+  /* Scroll the contents vertically.  This is only called via
+     forward_scroll and backward_scroll.  */
+  virtual void do_scroll_vertical (int num_to_scroll) = 0;
+
+  /* Scroll the contents horizontally.  This is only called via
+     left_scroll and right_scroll.  */
+  virtual void do_scroll_horizontal (int num_to_scroll) = 0;
 };
 
+/* Constant definitions.  */
+#define SRC_NAME                "src"
+#define CMD_NAME                "cmd"
+#define DATA_NAME               "regs"
+#define DISASSEM_NAME           "asm"
+#define STATUS_NAME		"status"
 
 /* Global Data.  */
 extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 8164b346370..a568fa6c116 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -285,8 +285,8 @@ extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
 }
 
 void
-tui_gen_win_info::resize (int height_, int width_,
-			  int origin_x_, int origin_y_)
+tui_win_info::resize (int height_, int width_,
+		      int origin_x_, int origin_y_)
 {
   if (width == width_ && height == height_
       && x == origin_x_ && y == origin_y_
@@ -321,7 +321,7 @@ tui_gen_win_info::resize (int height_, int width_,
    windows.  */
 
 template<enum tui_win_type V, class T>
-static tui_gen_win_info *
+static tui_win_info *
 make_standard_window (const char *)
 {
   if (tui_win_list[V] == nullptr)
@@ -332,7 +332,7 @@ make_standard_window (const char *)
 /* Helper function to wrap tui_locator_win_info_ptr for
    tui_get_window_by_name.  */
 
-static tui_gen_win_info *
+static tui_win_info *
 get_locator_window (const char *)
 {
   return tui_locator_win_info_ptr ();
@@ -349,7 +349,7 @@ static std::unordered_map<std::string, window_factory> *known_window_types;
 
 /* Helper function that returns a TUI window, given its name.  */
 
-static tui_gen_win_info *
+static tui_win_info *
 tui_get_window_by_name (const std::string &name)
 {
   for (tui_win_info *window : saved_tui_windows)
@@ -360,7 +360,7 @@ tui_get_window_by_name (const std::string &name)
   if (iter == known_window_types->end ())
     error (_("Unknown window type \"%s\""), name.c_str ());
 
-  tui_gen_win_info *result = iter->second (name.c_str ());
+  tui_win_info *result = iter->second (name.c_str ());
   if (result == nullptr)
     error (_("Could not create window \"%s\""), name.c_str ());
   return result;
@@ -422,8 +422,7 @@ tui_layout_window::apply (int x_, int y_, int width_, int height_)
   height = height_;
   gdb_assert (m_window != nullptr);
   m_window->resize (height, width, x, y);
-  if (dynamic_cast<tui_win_info *> (m_window) != nullptr)
-    tui_windows.push_back ((tui_win_info *) m_window);
+  tui_windows.push_back (m_window);
 }
 
 /* See tui-layout.h.  */
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index 90618377e17..ee4caf89cb4 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -152,7 +152,7 @@ class tui_layout_window : public tui_layout_base
 
   /* When a layout is applied, this is updated to point to the window
      object.  */
-  tui_gen_win_info *m_window = nullptr;
+  tui_win_info *m_window = nullptr;
 };
 
 /* A TUI layout that holds other layouts.  */
@@ -251,7 +251,7 @@ extern void tui_adjust_window_height (struct tui_win_info *win,
 
 /* The type of a function that is used to create a TUI window.  */
 
-typedef std::function<tui_gen_win_info * (const char *name)> window_factory;
+typedef std::function<tui_win_info * (const char *name)> window_factory;
 
 /* Register a new TUI window type.  NAME is the name of the window
    type.  FACTORY is a function that can be called to instantiate the
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 5f56eca3b2f..336571f158e 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -921,7 +921,7 @@ tui_win_info::max_height () const
 /* See tui-data.h.  */
 
 int
-tui_gen_win_info::max_width () const
+tui_win_info::max_width () const
 {
   return tui_term_width () - 2;
 }
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 35468d43abc..504f9159abb 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -71,7 +71,7 @@ tui_wrefresh (WINDOW *win)
 /* See tui-data.h.  */
 
 void
-tui_gen_win_info::refresh_window ()
+tui_win_info::refresh_window ()
 {
   if (handle != NULL)
     tui_wrefresh (handle.get ());
@@ -166,9 +166,8 @@ tui_win_info::check_and_display_highlight_if_needed ()
     }
 }
 
-
 void
-tui_gen_win_info::make_window ()
+tui_win_info::make_window ()
 {
   handle.reset (newwin (height, width, y, x));
   if (handle != NULL)
@@ -176,22 +175,16 @@ tui_gen_win_info::make_window ()
       if (suppress_output)
 	wnoutrefresh (handle.get ());
       scrollok (handle.get (), TRUE);
+      if (can_box ())
+	box_win (this, false);
     }
 }
 
-void
-tui_win_info::make_window ()
-{
-  tui_gen_win_info::make_window ();
-  if (handle != NULL && can_box ())
-    box_win (this, false);
-}
-
 /* We can't really make windows visible, or invisible.  So we have to
    delete the entire window when making it visible, and create it
    again when making it visible.  */
 void
-tui_gen_win_info::make_visible (bool visible)
+tui_win_info::make_visible (bool visible)
 {
   if (is_visible () == visible)
     return;
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 11/11] Make tui_win_info::name pure virtual
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (9 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 10/11] Remove tui_gen_win_info Tom Tromey
@ 2020-06-18  2:15 ` Tom Tromey
  2020-07-02  3:24 ` [PATCH 00/11] TUI cleanups Tom Tromey
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-06-18  2:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

It seemed cleaner to me for tui_win_info::name to be pure virtual.
This meant adding a name method to the locator window; but this too
seems like an improvement.

2020-06-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_win_info) <name>: Now pure virtual.
	* tui/tui-stack.h (struct tui_locator_window) <name>: New method.
---
 gdb/ChangeLog       | 5 +++++
 gdb/tui/tui-data.h  | 5 +----
 gdb/tui/tui-stack.h | 5 +++++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 3c14b2654ee..5e7a12293c9 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -62,10 +62,7 @@ struct tui_win_info
   virtual void make_visible (bool visible);
 
   /* Return the name of this type of window.  */
-  virtual const char *name () const
-  {
-    return "";
-  }
+  virtual const char *name () const = 0;
 
   /* Compute the maximum height of this window.  */
   virtual int max_height () const;
diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h
index 564ac22495c..9ff57b1ba73 100644
--- a/gdb/tui/tui-stack.h
+++ b/gdb/tui/tui-stack.h
@@ -32,6 +32,11 @@ struct tui_locator_window : public tui_win_info
 {
   tui_locator_window () = default;
 
+  const char *name () const override
+  {
+    return STATUS_NAME;
+  }
+
   int max_height () const override
   {
     return 1;
-- 
2.17.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 00/11] TUI cleanups
  2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
                   ` (10 preceding siblings ...)
  2020-06-18  2:15 ` [PATCH 11/11] Make tui_win_info::name pure virtual Tom Tromey
@ 2020-07-02  3:24 ` Tom Tromey
  11 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-07-02  3:24 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> I started looking more seriously at fixing the TUI's UTF-8 problem.  I
Tom> think I have an answer to that -- use pads for the source window to
Tom> avoid the truncation problem on both ends -- but before starting, I
Tom> found a number of small oddities remaining in the TUI.  So, this
Tom> series cleans up various small issues I found, removing more unneeded
Tom> TUI code in the process.

I'm checking this in now.

Tom> More cleanups could be done -- some methods are in the wrong file, and
Tom> some things (especially the "locator" window and its associated files)
Tom> are misnamed.  However, I wasn't sure if a big rearrangement +
Tom> renaming would be welcome, so I didn't do that.  It's easy enough to
Tom> do in the future if desired.

I still haven't done this.  On the one hand, it would improve the
discoverability of the source.  On the other, it would be
history-confusing churn.

Tom

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 09/11] Derive tui_locator_window from tui_win_info
  2020-06-18  2:15 ` [PATCH 09/11] Derive tui_locator_window from tui_win_info Tom Tromey
@ 2020-09-20  0:58   ` Simon Marchi
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2020-09-20  0:58 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2020-06-17 10:15 p.m., Tom Tromey wrote:
> tui_locator_window is the last remaining concrete child class of
> tui_gen_win_info.  It seems a bit cleaner to me to flatten the
> hierarchy a bit; this patch prepares for that by changing
> tui_locator_window to derive from tui_win_info.

Hi Tom,

I stumbled on a behavior change in the TUI that I think is unexpected,
introduced by this patch.  I filed a bug here:

https://sourceware.org/bugzilla/show_bug.cgi?id=26638

Simon

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-09-20  0:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18  2:15 [PATCH 00/11] TUI cleanups Tom Tromey
2020-06-18  2:15 ` [PATCH 01/11] Use complete_on_enum in tui_reggroup_completer Tom Tromey
2020-06-18  2:15 ` [PATCH 02/11] Remove tui_expand_tabs Tom Tromey
2020-06-18  2:15 ` [PATCH 03/11] Move some code out of tui-data.h Tom Tromey
2020-06-18  2:15 ` [PATCH 04/11] Remove tui_data_window::name Tom Tromey
2020-06-18  2:15 ` [PATCH 05/11] Remove useless "if' from tui-regs.c Tom Tromey
2020-06-18  2:15 ` [PATCH 06/11] Rename tui_data_item_window::item_no Tom Tromey
2020-06-18  2:15 ` [PATCH 07/11] Don't derive tui_data_item_window from tui_gen_win_info Tom Tromey
2020-06-18  2:15 ` [PATCH 08/11] Remove body of tui_locator_window constructor Tom Tromey
2020-06-18  2:15 ` [PATCH 09/11] Derive tui_locator_window from tui_win_info Tom Tromey
2020-09-20  0:58   ` Simon Marchi
2020-06-18  2:15 ` [PATCH 10/11] Remove tui_gen_win_info Tom Tromey
2020-06-18  2:15 ` [PATCH 11/11] Make tui_win_info::name pure virtual Tom Tromey
2020-07-02  3:24 ` [PATCH 00/11] TUI cleanups 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).