]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Delete invisible TUI windows
authorTom Tromey <tom@tromey.com>
Fri, 5 Jul 2019 18:46:23 +0000 (12:46 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 13 Aug 2019 20:52:09 +0000 (14:52 -0600)
This changes the TUI so that when the layout changes, any windows that
are invisible are now deleted.  This makes it simpler to understand
window lifetimes.

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

* tui/tui-win.c (tui_resize_all): Call
tui_delete_invisible_windows.
* tui/tui-layout.c (show_layout): Call
tui_delete_invisible_windows.
* tui/tui-data.h (tui_delete_invisible_windows): Declare.
* tui/tui-data.c (tui_delete_invisible_windows): New function.

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

index 50128426f0c31a79bb31405f376ff8e96d508007..48d3fc595fb5f4dbcbe8679d2363cf7f9b4c8a3d 100644 (file)
@@ -1,3 +1,12 @@
+2019-08-13  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-win.c (tui_resize_all): Call
+       tui_delete_invisible_windows.
+       * tui/tui-layout.c (show_layout): Call
+       tui_delete_invisible_windows.
+       * tui/tui-data.h (tui_delete_invisible_windows): Declare.
+       * tui/tui-data.c (tui_delete_invisible_windows): New function.
+
 2019-08-13  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-disasm.c (tui_show_disassem): Add assertion.  Don't call
index fd7649bdeab6effb40caa83e3051a590ef63d435..bb725c199ccfe79e9ca8388590c514eed76ecbfd 100644 (file)
@@ -269,6 +269,28 @@ tui_initialize_static_data ()
   win->title = 0;
 }
 
+/* See tui-data.h.  */
+
+void
+tui_delete_invisible_windows ()
+{
+  for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
+    {
+      if (tui_win_list[win_type] != NULL
+         && !tui_win_list[win_type]->is_visible)
+       {
+         /* This should always be made visible before a call to this
+            function.  */
+         gdb_assert (win_type != CMD_WIN);
+
+         if (win_with_focus == tui_win_list[win_type])
+           win_with_focus = nullptr;
+
+         delete tui_win_list[win_type];
+         tui_win_list[win_type] = NULL;
+       }
+    }
+}
 
 tui_win_info::tui_win_info (enum tui_win_type type)
   : tui_gen_win_info (type)
index dbae2fb3b0045d9589aa51a33065de188650eeaf..d3fa03657c5c54b9156ff290055f524e7187591d 100644 (file)
@@ -399,6 +399,11 @@ extern void tui_set_win_resized_to (int);
 extern struct tui_win_info *tui_next_win (struct tui_win_info *);
 extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
 
+/* Delete all the invisible windows.  Note that it is an error to call
+   this when the command window is invisible -- we don't allow the
+   command window to be removed from the layout.  */
+extern void tui_delete_invisible_windows ();
+
 extern unsigned int tui_tab_width;
 
 #endif /* TUI_TUI_DATA_H */
index f4f834dc83e2274fa5abb5ea049c963550d4ff78..2715d322dc7f68320a190329e176734af681ea79 100644 (file)
@@ -107,6 +107,8 @@ show_layout (enum tui_layout_type layout)
        default:
          break;
        }
+
+      tui_delete_invisible_windows ();
     }
 }
 
@@ -596,6 +598,7 @@ show_data (enum tui_layout_type new_layout)
   locator->make_visible (true);
   tui_show_locator_content ();
   tui_add_to_source_windows (base);
+  TUI_CMD_WIN->make_visible (true);
   current_layout = new_layout;
 }
 
index c03a8672fca3a8afe288239deb905764a6ec8b26..be01c150973eb4456d16c7bfcecc3c8cd3363ee3 100644 (file)
@@ -537,7 +537,6 @@ tui_resize_all (void)
       struct tui_win_info *second_win;
       tui_source_window_base *src_win;
       struct tui_locator_window *locator = tui_locator_win_info_ptr ();
-      int win_type;
       int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2;
 
 #ifdef HAVE_RESIZE_TERM
@@ -663,18 +662,8 @@ tui_resize_all (void)
            tui_erase_source_content (src_win);
          break;
        }
-      /* Now remove all invisible windows, and their content so that
-         they get created again when called for with the new size.  */
-      for (win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
-       {
-         if (win_type != CMD_WIN 
-             && (tui_win_list[win_type] != NULL)
-             && !tui_win_list[win_type]->is_visible)
-           {
-             delete tui_win_list[win_type];
-             tui_win_list[win_type] = NULL;
-           }
-       }
+
+      tui_delete_invisible_windows ();
       /* Turn keypad back on, unless focus is in the command
         window.  */
       if (win_with_focus != TUI_CMD_WIN)