aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-layout.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-02-22 11:48:26 -0700
committerTom Tromey <tom@tromey.com>2020-02-22 11:48:29 -0700
commit5afe342e2a61dcc49e42e68a86432e7f240af51d (patch)
tree8aa116a10a603ea5cdb8f36c576f8c73879347ea /gdb/tui/tui-layout.c
parent427326a826888b39a38c9f1b497aa981f37b72af (diff)
downloadfsf-binutils-gdb-5afe342e2a61dcc49e42e68a86432e7f240af51d.zip
fsf-binutils-gdb-5afe342e2a61dcc49e42e68a86432e7f240af51d.tar.gz
fsf-binutils-gdb-5afe342e2a61dcc49e42e68a86432e7f240af51d.tar.bz2
Reimplement TUI "C-x 1" binding
The TUI "C-x 1" key binding removes TUI windows, based on the current layout. With user-defined layouts, this is no longer easy to do. This patch changes "C-x 1" to simply delete windows, leaving just the focus window, the locator, and the command window. gdb/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * tui/tui.c (tui_rl_delete_other_windows): Call tui_remove_some_windows. * tui/tui-layout.h (class tui_layout_base) <remove_windows>: Declare method. (class tui_layout_window) <remove_windows>: New method. (class tui_layout_split) <remove_windows>: Declare. (tui_remove_some_windows): Declare. * tui/tui-layout.c (tui_remove_some_windows): New function. (tui_layout_split::remove_windows): New method. Change-Id: If186f9c3f263913e963b965204481d1b4385c6d4
Diffstat (limited to 'gdb/tui/tui-layout.c')
-rw-r--r--gdb/tui/tui-layout.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 6a998e8..e964258 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -286,6 +286,28 @@ tui_next_layout ()
tui_layout_command ("next", 0);
}
+/* See tui-layout.h. */
+
+void
+tui_remove_some_windows ()
+{
+ tui_win_info *focus = tui_win_with_focus ();
+
+ if (strcmp (focus->name (), "cmd") == 0)
+ {
+ /* Try leaving the source or disassembly window. If neither
+ exists, just do nothing. */
+ focus = TUI_SRC_WIN;
+ if (focus == nullptr)
+ focus = TUI_DISASM_WIN;
+ if (focus == nullptr)
+ return;
+ }
+
+ applied_layout->remove_windows (focus->name ());
+ tui_apply_current_layout ();
+}
+
static void
extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
{
@@ -751,6 +773,29 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_)
m_applied = true;
}
+/* See tui-layout.h. */
+
+void
+tui_layout_split::remove_windows (const char *name)
+{
+ for (int i = 0; i < m_splits.size (); ++i)
+ {
+ const char *this_name = m_splits[i].layout->get_name ();
+ if (this_name == nullptr)
+ m_splits[i].layout->remove_windows (name);
+ else
+ {
+ if (strcmp (this_name, name) == 0
+ || strcmp (this_name, "cmd") == 0)
+ {
+ /* Keep. */
+ }
+ m_splits.erase (m_splits.begin () + i);
+ --i;
+ }
+ }
+}
+
static void
initialize_layouts ()
{