First use of tui_layout
authorTom Tromey <tom@tromey.com>
Wed, 9 Oct 2019 22:35:41 +0000 (16:35 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 11 Dec 2019 22:49:02 +0000 (15:49 -0700)
This patch introduces the first use of tui_layout, by changing
show_layout to clone and use the appropriate tui_layout.

This resulted in one minor layout change, and also in the unintended
-- but good -- side effect that the title of each boxed window is now
visible.

gdb/ChangeLog
2019-12-11  Tom Tromey  <tom@tromey.com>

* tui/tui-layout.h (tui_apply_current_layout): Declare.
* tui/tui-layout.c (standard_layouts, applied_layout): New
globals.
(tui_apply_current_layout): New function.
(show_layout): Set applied_layout.  Call
tui_apply_current_layout.
(show_source_command, show_disasm_command)
(show_source_disasm_command, show_data)
(show_source_or_disasm_and_command): Remove.
(initialize_layouts): New function.
(_initialize_tui_layout): Call initialize_layouts.

gdb/testsuite/ChangeLog
2019-12-11  Tom Tromey  <tom@tromey.com>

* gdb.tui/regs.exp: Update.
* gdb.tui/empty.exp (layouts): Update.
* gdb.tui/basic.exp: Update.
* lib/tuiterm.exp (_check_box): Don't check bottom border.

Change-Id: If1ee06ee58f4803e8c213f4ab0f5bb59f4650ec2

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.tui/basic.exp
gdb/testsuite/gdb.tui/empty.exp
gdb/testsuite/gdb.tui/regs.exp
gdb/testsuite/lib/tuiterm.exp
gdb/tui/tui-layout.c
gdb/tui/tui-layout.h

index 595b98743d629a9480a9b08aae0a19e6ba546f96..4c98df34d83a5da2293b4ba5aca5f5c5ad591fca 100644 (file)
@@ -1,3 +1,17 @@
+2019-12-11  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-layout.h (tui_apply_current_layout): Declare.
+       * tui/tui-layout.c (standard_layouts, applied_layout): New
+       globals.
+       (tui_apply_current_layout): New function.
+       (show_layout): Set applied_layout.  Call
+       tui_apply_current_layout.
+       (show_source_command, show_disasm_command)
+       (show_source_disasm_command, show_data)
+       (show_source_or_disasm_and_command): Remove.
+       (initialize_layouts): New function.
+       (_initialize_tui_layout): Call initialize_layouts.
+
 2019-12-11  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-layout.h (class tui_layout_base)
index 17d499388856424370b3ec7618d122cf027f5b82..9b7a81ec98657b2679464fc73470d85c70cc2424 100644 (file)
@@ -1,3 +1,10 @@
+2019-12-11  Tom Tromey  <tom@tromey.com>
+
+       * gdb.tui/regs.exp: Update.
+       * gdb.tui/empty.exp (layouts): Update.
+       * gdb.tui/basic.exp: Update.
+       * lib/tuiterm.exp (_check_box): Don't check bottom border.
+
 2019-12-11  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * gdb.base/options.exp: Add -raw-values in the print completion list.
index 716c52f68a6191923fe40b37ea43cafd38506eaf..f9d57d1cf6d6665a9464d8e99afd961f6d7b4a6e 100644 (file)
@@ -45,5 +45,5 @@ Term::check_box "asm box" 0 0 80 15
 Term::command "layout split"
 Term::check_contents "split layout contents" "21 *return 0.*$hex <main>"
 
-Term::check_box "source box in split layout" 0 0 80 8
-Term::check_box "asm box in split layout" 0 7 80 8
+Term::check_box "source box in split layout" 0 0 80 7
+Term::check_box "asm box in split layout" 0 6 80 9
index b6ee3505490ce1238320a25fc59788e8390062a1..861f56437ed9ef5382027bdb90371edfc7f3cd04 100644 (file)
@@ -34,7 +34,7 @@ if {![Term::enter_tui]} {
 set layouts {
     {src src {{0 0 80 15}} {{0 0 90 23}}
        {{"no source" "No Source Available"}}}
-    {regs src-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
+    {regs src-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 12} {0 11 90 14}}
        {
            {"no source" "No Source Available"}
            {"no regs" "Register Values Unavailable"}
@@ -43,17 +43,17 @@ set layouts {
        {
            {"no asm" "No Assembly Available"}
        }}
-    {regs asm-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
+    {regs asm-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 12} {0 11 90 14}}
        {
            {"no asm" "No Assembly Available"}
            {"no regs" "Register Values Unavailable"}
        }}
-    {split split {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
+    {split split {{0 0 80 7} {0 6 80 9}} {{0 0 90 12} {0 11 90 14}}
        {
            {"no source" "No Source Available"}
            {"no asm" "No Assembly Available"}
        }}
-    {regs split-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
+    {regs split-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 12} {0 11 90 14}}
        {
            {"no asm" "No Assembly Available"}
            {"no regs" "Register Values Unavailable"}
index 1af943dd152d775f2fbddc3d901a539dde926390..dcecd03af9affa88c848f87c1cbdb64e780376b1 100644 (file)
@@ -37,8 +37,8 @@ if {![Term::enter_tui]} {
 Term::check_contents "source at startup" ">|21 *return 0"
 
 Term::command "layout regs"
-Term::check_box "register box" 0 0 80 8
-Term::check_box "source box in regs layout" 0 7 80 8
+Term::check_box "register box" 0 0 80 7
+Term::check_box "source box in regs layout" 0 6 80 9
 
 set text [Term::get_line 1]
 # Just check for any register window content at all.
index dcba02889ec186e31415ea6527431526f8b6c702..81247d5d9a45d7072f105f431a9a3608a3cf9325 100644 (file)
@@ -555,13 +555,9 @@ namespace eval Term {
            return "lr corner"
        }
 
-       for {set i [expr {$x + 1}]} {$i < $x2 - 1} {incr i} {
-           # Note we do not check the top border of the box, because
-           # it will contain a title.
-           if {[get_char $i $y2] != "-"} {
-               return "bottom border $i"
-           }
-       }
+       # Note we do not check the horizonal borders of the box.  The
+       # top will contain a title, and the bottom may as well, if it
+       # is overlapped by some other border.
        for {set i [expr {$y + 1}]} {$i < $y2 - 1} {incr i} {
            if {[get_char $x $i] != "|"} {
                return "left side $i"
index 91f270dcfc302c03f3b940aaa985ba73576e1dcd..1884c2add7bc3eed75f8535d86dcf792ca099c0d 100644 (file)
 #include "gdb_curses.h"
 
 static void show_layout (enum tui_layout_type);
-static void show_source_or_disasm_and_command (enum tui_layout_type);
-static void show_source_command (void);
-static void show_disasm_command (void);
-static void show_source_disasm_command (void);
-static void show_data (enum tui_layout_type);
 static enum tui_layout_type next_layout (void);
 static enum tui_layout_type prev_layout (void);
 static void tui_layout_command (const char *, int);
 static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
 
 
+/* The pre-defined layouts.  */
+static tui_layout_split *standard_layouts[UNDEFINED_LAYOUT];
+
+/* The layout that is currently applied.  */
+static std::unique_ptr<tui_layout_base> applied_layout;
+
 static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
 
 /* Accessor for the current layout.  */
@@ -61,6 +62,13 @@ tui_current_layout (void)
   return current_layout;
 }
 
+/* See tui-layout.h.  */
+
+void
+tui_apply_current_layout ()
+{
+  applied_layout->apply (0, 0, tui_term_width (), tui_term_height ());
+}
 
 /* Show the screen layout defined.  */
 static void
@@ -71,26 +79,8 @@ show_layout (enum tui_layout_type layout)
   if (layout != cur_layout)
     {
       tui_make_all_invisible ();
-      switch (layout)
-       {
-       case SRC_DATA_COMMAND:
-       case DISASSEM_DATA_COMMAND:
-         show_data (layout);
-         break;
-         /* Now show the new layout.  */
-       case SRC_COMMAND:
-         show_source_command ();
-         break;
-       case DISASSEM_COMMAND:
-         show_disasm_command ();
-         break;
-       case SRC_DISASSEM_COMMAND:
-         show_source_disasm_command ();
-         break;
-       default:
-         break;
-       }
-
+      applied_layout = standard_layouts[layout]->clone ();
+      tui_apply_current_layout ();
       current_layout = layout;
       tui_delete_invisible_windows ();
     }
@@ -364,105 +354,6 @@ prev_layout (void)
   return (enum tui_layout_type) new_layout;
 }
 
-/* Show the Source/Command layout.  */
-static void
-show_source_command (void)
-{
-  show_source_or_disasm_and_command (SRC_COMMAND);
-}
-
-
-/* Show the Dissassem/Command layout.  */
-static void
-show_disasm_command (void)
-{
-  show_source_or_disasm_and_command (DISASSEM_COMMAND);
-}
-
-
-/* Show the Source/Disassem/Command layout.  */
-static void
-show_source_disasm_command (void)
-{
-  int cmd_height, src_height, asm_height;
-
-  if (TUI_CMD_WIN != NULL)
-    cmd_height = TUI_CMD_WIN->height;
-  else
-    cmd_height = tui_term_height () / 3;
-
-  src_height = (tui_term_height () - cmd_height) / 2;
-  asm_height = tui_term_height () - (src_height + cmd_height);
-
-  if (TUI_SRC_WIN == NULL)
-    tui_win_list[SRC_WIN] = new tui_source_window ();
-  TUI_SRC_WIN->resize (src_height,
-                      tui_term_width (),
-                      0,
-                      0);
-
-  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
-  gdb_assert (locator != nullptr);
-
-  if (TUI_DISASM_WIN == NULL)
-    tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
-  TUI_DISASM_WIN->resize (asm_height,
-                         tui_term_width (),
-                         0,
-                         src_height - 1);
-  locator->resize (1, tui_term_width (),
-                  0, (src_height + asm_height) - 1);
-
-  if (TUI_CMD_WIN == NULL)
-    tui_win_list[CMD_WIN] = new tui_cmd_window ();
-  TUI_CMD_WIN->resize (cmd_height,
-                      tui_term_width (),
-                      0,
-                      tui_term_height () - cmd_height);
-}
-
-
-/* Show the Source/Data/Command or the Dissassembly/Data/Command
-   layout.  */
-static void
-show_data (enum tui_layout_type new_layout)
-{
-  int total_height = (tui_term_height () - TUI_CMD_WIN->height);
-  int src_height, data_height;
-  enum tui_win_type win_type;
-
-  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
-  gdb_assert (locator != nullptr);
-
-  data_height = total_height / 2;
-  src_height = total_height - data_height;
-  if (tui_win_list[DATA_WIN] == nullptr)
-    tui_win_list[DATA_WIN] = new tui_data_window ();
-  tui_win_list[DATA_WIN]->resize (data_height, tui_term_width (), 0, 0);
-
-  if (new_layout == SRC_DATA_COMMAND)
-    win_type = SRC_WIN;
-  else
-    win_type = DISASSEM_WIN;
-
-  if (tui_win_list[win_type] == NULL)
-    {
-      if (win_type == SRC_WIN)
-       tui_win_list[win_type] = new tui_source_window ();
-      else
-       tui_win_list[win_type] = new tui_disasm_window ();
-    }
-
-  tui_win_list[win_type]->resize (src_height,
-                                 tui_term_width (),
-                                 0,
-                                 data_height - 1);
-  locator->resize (1, tui_term_width (),
-                  0, total_height - 1);
-  TUI_CMD_WIN->resize (TUI_CMD_WIN->height, tui_term_width (),
-                      0, total_height);
-}
-
 void
 tui_gen_win_info::resize (int height_, int width_,
                          int origin_x_, int origin_y_)
@@ -498,49 +389,6 @@ tui_gen_win_info::resize (int height_, int width_,
   rerender ();
 }
 
-/* Show the Source/Command or the Disassem layout.  */
-static void
-show_source_or_disasm_and_command (enum tui_layout_type layout_type)
-{
-  struct tui_source_window_base *win_info;
-  int src_height, cmd_height;
-  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
-  gdb_assert (locator != nullptr);
-
-  if (TUI_CMD_WIN != NULL)
-    cmd_height = TUI_CMD_WIN->height;
-  else
-    cmd_height = tui_term_height () / 3;
-  src_height = tui_term_height () - cmd_height;
-
-  if (layout_type == SRC_COMMAND)
-    {
-      if (tui_win_list[SRC_WIN] == nullptr)
-       tui_win_list[SRC_WIN] = new tui_source_window ();
-      win_info = TUI_SRC_WIN;
-    }
-  else
-    {
-      if (tui_win_list[DISASSEM_WIN] == nullptr)
-       tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
-      win_info = TUI_DISASM_WIN;
-    }
-
-  locator->resize (1, tui_term_width (),
-                  0, src_height - 1);
-  win_info->resize (src_height - 1,
-                   tui_term_width (),
-                   0,
-                   0);
-
-  if (TUI_CMD_WIN == NULL)
-    tui_win_list[CMD_WIN] = new tui_cmd_window ();
-  TUI_CMD_WIN->resize (cmd_height,
-                      tui_term_width (),
-                      0,
-                      src_height);
-}
-
 \f
 
 /* Helper function that returns a TUI window, given its name.  */
@@ -901,6 +749,38 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_)
   m_applied = true;
 }
 
+static void
+initialize_layouts ()
+{
+  standard_layouts[SRC_COMMAND] = new tui_layout_split ();
+  standard_layouts[SRC_COMMAND]->add_window ("src", 2);
+  standard_layouts[SRC_COMMAND]->add_window ("locator", 0);
+  standard_layouts[SRC_COMMAND]->add_window ("cmd", 1);
+
+  standard_layouts[DISASSEM_COMMAND] = new tui_layout_split ();
+  standard_layouts[DISASSEM_COMMAND]->add_window ("asm", 2);
+  standard_layouts[DISASSEM_COMMAND]->add_window ("locator", 0);
+  standard_layouts[DISASSEM_COMMAND]->add_window ("cmd", 1);
+
+  standard_layouts[SRC_DATA_COMMAND] = new tui_layout_split ();
+  standard_layouts[SRC_DATA_COMMAND]->add_window ("regs", 1);
+  standard_layouts[SRC_DATA_COMMAND]->add_window ("src", 1);
+  standard_layouts[SRC_DATA_COMMAND]->add_window ("locator", 0);
+  standard_layouts[SRC_DATA_COMMAND]->add_window ("cmd", 1);
+
+  standard_layouts[DISASSEM_DATA_COMMAND] = new tui_layout_split ();
+  standard_layouts[DISASSEM_DATA_COMMAND]->add_window ("regs", 1);
+  standard_layouts[DISASSEM_DATA_COMMAND]->add_window ("asm", 1);
+  standard_layouts[DISASSEM_DATA_COMMAND]->add_window ("locator", 0);
+  standard_layouts[DISASSEM_DATA_COMMAND]->add_window ("cmd", 1);
+
+  standard_layouts[SRC_DISASSEM_COMMAND] = new tui_layout_split ();
+  standard_layouts[SRC_DISASSEM_COMMAND]->add_window ("src", 1);
+  standard_layouts[SRC_DISASSEM_COMMAND]->add_window ("asm", 1);
+  standard_layouts[SRC_DISASSEM_COMMAND]->add_window ("locator", 0);
+  standard_layouts[SRC_DISASSEM_COMMAND]->add_window ("cmd", 1);
+}
+
 \f
 
 /* Function to initialize gdb commands, for tui window layout
@@ -925,4 +805,6 @@ Layout names are:\n\
            the register window is displayed with \n\
            the window that has current logical focus."));
   set_cmd_completer (cmd, layout_completer);
+
+  initialize_layouts ();
 }
index d7f0731e312dcced3760b27892cf7d139424b78e..a9346ef504b465bbe4b3168cbc5059863fa2e9ac 100644 (file)
@@ -174,4 +174,7 @@ private:
 extern void tui_add_win_to_layout (enum tui_win_type);
 extern void tui_set_layout (enum tui_layout_type);
 
+/* Apply the current layout.  */
+extern void tui_apply_current_layout ();
+
 #endif /* TUI_TUI_LAYOUT_H */
This page took 0.043215 seconds and 4 git commands to generate.