public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 10/11] Remove tui_gen_win_info
Date: Wed, 17 Jun 2020 20:15:22 -0600	[thread overview]
Message-ID: <20200618021523.10681-11-tom@tromey.com> (raw)
In-Reply-To: <20200618021523.10681-1-tom@tromey.com>

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


  parent reply	other threads:[~2020-06-18  2:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Tom Tromey [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200618021523.10681-11-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).