]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify TUI C-x 2 binding
authorTom Tromey <tom@tromey.com>
Sat, 22 Feb 2020 18:48:26 +0000 (11:48 -0700)
committerTom Tromey <tom@tromey.com>
Sat, 22 Feb 2020 18:48:28 +0000 (11:48 -0700)
The TUI "C-x 2" binding tries to switch to a different layout based on
the current layout.  Once user-defined layouts are available, this
won't really make sense.  I wasn't entirely sure how to handle this.

This patch changes the binding to simply cycle through the existing
layouts.  I considered this a reasonable, though not ideal,
compromise.

gdb/ChangeLog
2020-02-22  Tom Tromey  <tom@tromey.com>

* tui/tui.c (tui_rl_change_windows): Call tui_next_layout.
* tui/tui-layout.h (tui_next_layout): Declare.
* tui/tui-layout.c (tui_next_layout): New function.

Change-Id: Ic101f0e3831a4235a048b3090ef60f025f7449bb

gdb/ChangeLog
gdb/tui/tui-layout.c
gdb/tui/tui-layout.h
gdb/tui/tui.c

index e35d5c5bc30c5b5aa91926685b54784c7f698049..4ab0309dc2a08451235ac820789e120d1c8fa181 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-22  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui.c (tui_rl_change_windows): Call tui_next_layout.
+       * tui/tui-layout.h (tui_next_layout): Declare.
+       * tui/tui-layout.c (tui_next_layout): New function.
+
 2020-02-22  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-regs.c (tui_data_window::display_registers_from): Use
index ce1f6a74d08a2a567c4bfc86fb9789c54411b70f..6a998e8b7d10bc03c4e251a27944fbe77e21bd3c 100644 (file)
@@ -278,6 +278,13 @@ tui_layout_command (const char *layout_name, int from_tty)
   tui_set_layout (new_layout);
 }
 
+/* See tui-layout.h.  */
+
+void
+tui_next_layout ()
+{
+  tui_layout_command ("next", 0);
+}
 
 static void
 extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
index 37f07c24e4fbfb357b5f5c1bc943437b4a7883b0..7e4b7b7a816771a6615f754f6ff34fd0ad6d185e 100644 (file)
@@ -181,6 +181,9 @@ extern void tui_add_win_to_layout (enum tui_win_type);
 
 extern void tui_set_layout (enum tui_layout_type);
 
+/* Switch to the next layout.  */
+extern void tui_next_layout ();
+
 /* Apply the current layout.  */
 extern void tui_apply_current_layout ();
 
index 0a598373ce681024e3f9ac2ff777a98345f482d8..74bf32d53b724abfb96feb4e8862851241191461 100644 (file)
@@ -140,8 +140,7 @@ tui_rl_switch_mode (int notused1, int notused2)
 /* TUI readline command.
    Change the TUI layout to show a next layout.
    This function is bound to CTRL-X 2.  It is intended to provide
-   a functionality close to the Emacs split-window command.  We
-   always show two windows (src+asm), (src+regs) or (asm+regs).  */
+   a functionality close to the Emacs split-window command.  */
 static int
 tui_rl_change_windows (int notused1, int notused2)
 {
@@ -149,41 +148,8 @@ tui_rl_change_windows (int notused1, int notused2)
     tui_rl_switch_mode (0 /* notused */, 0 /* notused */);
 
   if (tui_active)
-    {
-      enum tui_layout_type new_layout;
-
-      new_layout = tui_current_layout ();
-
-      /* Select a new layout to have a rolling layout behavior with
-        always two windows (except when undefined).  */
-      switch (new_layout)
-       {
-       case SRC_COMMAND:
-         new_layout = SRC_DISASSEM_COMMAND;
-         break;
-
-       case DISASSEM_COMMAND:
-         new_layout = SRC_DISASSEM_COMMAND;
-         break;
-
-       case SRC_DATA_COMMAND:
-         new_layout = SRC_DISASSEM_COMMAND;
-         break;
-
-       case SRC_DISASSEM_COMMAND:
-         new_layout = DISASSEM_DATA_COMMAND;
-         break;
-         
-       case DISASSEM_DATA_COMMAND:
-         new_layout = SRC_DATA_COMMAND;
-         break;
+    tui_next_layout ();
 
-       default:
-         new_layout = SRC_COMMAND;
-         break;
-       }
-      tui_set_layout (new_layout);
-    }
   return 0;
 }