+2020-02-22 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-wingeneral.h (tui_make_all_invisible): Don't declare.
+ * tui/tui-wingeneral.c (tui_make_all_invisible): Remove.
+ * tui/tui-win.c (tui_resize_all): Don't call
+ tui_delete_invisible_windows.
+ * tui/tui-layout.c (tui_apply_current_layout): Delete windows when
+ done.
+ (tui_set_layout): Update.
+ (tui_add_win_to_layout): Don't call tui_delete_invisible_windows.
+ * tui/tui-data.h (tui_delete_invisible_windows): Don't declare.
+ * tui/tui-data.c (tui_delete_invisible_windows): Remove.
+
2020-02-22 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_partial_win_by_name): Handle ambiguity
}
-/* 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)
{
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 */
void
tui_apply_current_layout ()
{
+ struct gdbarch *gdbarch;
+ CORE_ADDR addr;
+
+ extract_display_start_addr (&gdbarch, &addr);
+
+ std::vector<tui_win_info *> saved_windows = std::move (tui_windows);
tui_windows.clear ();
+
+ for (tui_win_info *win_info : saved_windows)
+ win_info->make_visible (false);
+
applied_layout->apply (0, 0, tui_term_width (), tui_term_height ());
+
+ /* Keep the list of internal windows up-to-date. */
+ for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
+ if (tui_win_list[win_type] != nullptr
+ && !tui_win_list[win_type]->is_visible ())
+ tui_win_list[win_type] = nullptr;
+
+ /* This should always be made visible by a layout. */
+ gdb_assert (TUI_CMD_WIN->is_visible ());
+
+ /* Now delete any window that was not re-applied. */
+ tui_win_info *focus = tui_win_with_focus ();
+ for (tui_win_info *win_info : saved_windows)
+ {
+ if (!win_info->is_visible ())
+ {
+ if (focus == win_info)
+ tui_set_win_focus_to (tui_windows[0]);
+ delete win_info;
+ }
+ }
+
+ if (gdbarch == nullptr && TUI_DISASM_WIN != nullptr)
+ tui_get_begin_asm_address (&gdbarch, &addr);
+ tui_update_source_windows_with_addr (gdbarch, addr);
}
/* See tui-layout. */
static void
tui_set_layout (tui_layout_split *layout)
{
- struct gdbarch *gdbarch;
- CORE_ADDR addr;
-
- extract_display_start_addr (&gdbarch, &addr);
- tui_make_all_invisible ();
applied_skeleton = layout;
applied_layout = layout->clone ();
tui_apply_current_layout ();
- tui_delete_invisible_windows ();
-
- if (gdbarch == nullptr && TUI_DISASM_WIN != nullptr)
- tui_get_begin_asm_address (&gdbarch, &addr);
- tui_update_source_windows_with_addr (gdbarch, addr);
}
/* See tui-layout.h. */
const char *name = type == SRC_WIN ? SRC_NAME : DISASSEM_NAME;
applied_layout->replace_window (tui_win_list[other]->name (), name);
tui_apply_current_layout ();
- tui_delete_invisible_windows ();
}
/* Find LAYOUT in the "layouts" global and return its index. */
erase ();
clearok (curscr, TRUE);
tui_apply_current_layout ();
- tui_delete_invisible_windows ();
/* Turn keypad back on, unless focus is in the command
window. */
if (win_with_focus != TUI_CMD_WIN)
handle.reset (nullptr);
}
-/* See tui-wingeneral.h. */
-
-void
-tui_make_all_invisible (void)
-{
- for (tui_win_info *win_info : all_tui_windows ())
- win_info->make_visible (false);
-}
-
/* Function to refresh all the windows currently displayed. */
void
struct tui_win_info;
-/* Makes all windows invisible. */
-extern void tui_make_all_invisible (void);
-
extern void tui_unhighlight_win (struct tui_win_info *);
extern void tui_highlight_win (struct tui_win_info *);
extern void tui_refresh_all ();