]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify TUI boxing
authorTom Tromey <tom@tromey.com>
Sat, 6 Jul 2019 14:21:38 +0000 (08:21 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 15 Aug 2019 18:29:28 +0000 (12:29 -0600)
In the TUI, whether or not a window can be boxed is a property of the
window's type.  This adds a can_box method to the window classes, and
changes tui_make_window to defer to this, removing the "box_it"
paramter.  This also lets us remove "enum tui_box", as it is no longer
used.

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

* tui/tui-wingeneral.h (tui_make_window): Update.
* tui/tui-wingeneral.c (tui_make_window): Remove "box_it"
parameter.
(tui_gen_win_info::make_visible): Update.
* tui/tui-regs.c (tui_data_window::display_registers_from):
Update.
* tui/tui-layout.c (show_source_disasm_command)
(show_source_or_disasm_and_command): Update.
* tui/tui-data.h (struct tui_gen_win_info) <can_box>: New method.
(enum tui_box): Remove.
(struct tui_win_info) <can_box>: New method.
* tui/tui-command.h (struct tui_cmd_window) <can_box>: New
method.

gdb/ChangeLog
gdb/tui/tui-command.h
gdb/tui/tui-data.h
gdb/tui/tui-layout.c
gdb/tui/tui-regs.c
gdb/tui/tui-wingeneral.c
gdb/tui/tui-wingeneral.h

index b6953b015ac824e823fc4522cf96469d0ee7162f..77f4ca07638952b19e3214595c7fd1a4cf604f63 100644 (file)
@@ -1,3 +1,19 @@
+2019-08-15  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-wingeneral.h (tui_make_window): Update.
+       * tui/tui-wingeneral.c (tui_make_window): Remove "box_it"
+       parameter.
+       (tui_gen_win_info::make_visible): Update.
+       * tui/tui-regs.c (tui_data_window::display_registers_from):
+       Update.
+       * tui/tui-layout.c (show_source_disasm_command)
+       (show_source_or_disasm_and_command): Update.
+       * tui/tui-data.h (struct tui_gen_win_info) <can_box>: New method.
+       (enum tui_box): Remove.
+       (struct tui_win_info) <can_box>: New method.
+       * tui/tui-command.h (struct tui_cmd_window) <can_box>: New
+       method.
+
 2019-08-15  Tom de Vries  <tdevries@suse.de>
 
        * linux-nat-trad.c: Include gdbarch.h.
index af80b1449fae993c4e428f2ce61f942d8bd3f937..14d775008823db22c9a6d195e721000919b1c29c 100644 (file)
@@ -55,6 +55,11 @@ struct tui_cmd_window : public tui_win_info
     return false;
   }
 
+  bool can_box () const override
+  {
+    return false;
+  }
+
   int start_line = 0;
 
 protected:
index 3493b5ed68b593b4f4d27a278ea64832f572c05f..017e7a40f52bce80892bda24889e54c2d6f81018 100644 (file)
@@ -67,6 +67,12 @@ public:
   virtual void reset (int height, int width,
                      int origin_x, int origin_y);
 
+  /* Return true if this can be boxed.  */
+  virtual bool can_box () const
+  {
+    return false;
+  }
+
   /* Window handle.  */
   WINDOW *handle = nullptr;
   /* Type of window.  */
@@ -85,13 +91,6 @@ public:
   char *title = nullptr;
 };
 
-/* Whether or not a window should be drawn with a box.  */
-enum tui_box
-{
-  DONT_BOX_WINDOW = 0,
-  BOX_WINDOW
-};
-
 /* Constant definitions.  */
 #define DEFAULT_TAB_LEN         8
 #define NO_SRC_STRING           "[ No Source Available ]"
@@ -248,6 +247,11 @@ public:
     return true;
   }
 
+  bool can_box () const override
+  {
+    return true;
+  }
+
   void check_and_display_highlight_if_needed ();
 
   /* Can this window ever be highlighted?  */
index 3683835954d0edce2e9dc919c98e8ee508af250e..69b929d37b28000c0cf1ec73dce6911735e4ad3d 100644 (file)
@@ -546,7 +546,7 @@ show_source_disasm_command (void)
                      tui_term_height () - cmd_height);
   /* FIXME tui_cmd_window won't recreate the handle on
      make_visible, so we need this instead.  */
-  tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
+  tui_make_window (TUI_CMD_WIN);
   current_layout = SRC_DISASSEM_COMMAND;
 }
 
@@ -674,6 +674,6 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
                      src_height);
   /* FIXME tui_cmd_window won't recreate the handle on
      make_visible, so we need this instead.  */
-  tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
+  tui_make_window (TUI_CMD_WIN);
   current_layout = layout_type;
 }
index aaba94da46785ede7c276d6c5c41f8e8f6fbcd76..bb8d545c47b579e94a5ead35a6f6238d9fcb50bf 100644 (file)
@@ -320,7 +320,7 @@ tui_data_window::display_registers_from (int start_element_no)
                  data_item_win->width = item_win_width;
                  data_item_win->origin.x = (item_win_width * j) + 1;
                  data_item_win->origin.y = cur_y;
-                 tui_make_window (data_item_win, DONT_BOX_WINDOW);
+                 tui_make_window (data_item_win);
                   scrollok (data_item_win->handle, FALSE);
                }
               touchwin (data_item_win->handle);
index 8ff5aa5fce8e40ab84b6b7f69e060f587da07b72..e2d06bcebad77962bf93799efb20035e00360413 100644 (file)
@@ -125,7 +125,7 @@ tui_win_info::check_and_display_highlight_if_needed ()
 
 
 void
-tui_make_window (struct tui_gen_win_info *win_info, enum tui_box box_it)
+tui_make_window (struct tui_gen_win_info *win_info)
 {
   WINDOW *handle;
 
@@ -136,7 +136,7 @@ tui_make_window (struct tui_gen_win_info *win_info, enum tui_box box_it)
   win_info->handle = handle;
   if (handle != NULL)
     {
-      if (box_it == BOX_WINDOW)
+      if (win_info->can_box ())
        box_win (win_info, NO_HILITE);
       win_info->is_visible = true;
       scrollok (handle, TRUE);
@@ -155,8 +155,7 @@ tui_gen_win_info::make_visible (bool visible)
   is_visible = visible;
 
   if (visible)
-    tui_make_window (this, (tui_win_is_auxiliary (type)
-                           ? DONT_BOX_WINDOW : BOX_WINDOW));
+    tui_make_window (this);
   else
     {
       tui_delete_win (handle);
index 54d6eb684f7a2c419de441eafef14cd33cc55999..6a9de4c9b1c86acbdc0028d4cc90b3d22da7bdee 100644 (file)
@@ -31,7 +31,7 @@ struct tui_gen_win_info;
 extern void tui_make_all_invisible (void);
 
 extern void tui_unhighlight_win (struct tui_win_info *);
-extern void tui_make_window (struct tui_gen_win_info *, enum tui_box);
+extern void tui_make_window (struct tui_gen_win_info *);
 extern void tui_highlight_win (struct tui_win_info *);
 extern void tui_refresh_all ();
 extern void tui_delete_win (WINDOW *window);