Remove separate visibility flag

TUI windows keep track of their visibility in a boolean field.
However, this is not needed, because a window is visible if and only
if it has an underlying curses handle.  So, we can remove this
separate field.

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

	* tui/tui.c (tui_is_window_visible): Update.
	* tui/tui-wingeneral.c (tui_make_window)
	(tui_gen_win_info::make_visible, tui_refresh_all): Update.
	* tui/tui-win.c (window_name_completer, tui_refresh_all_win)
	(tui_set_focus_command, tui_all_windows_info, update_tab_width)
	(tui_set_win_height_command, parse_scrolling_args): Update.
	* tui/tui-source.c (tui_source_window::style_changed): Update.
	* tui/tui-regs.c (tui_show_registers)
	(tui_data_window::first_data_item_displayed)
	(tui_data_window::delete_data_content_windows)
	(tui_check_register_values, tui_reg_command): Update.
	* tui/tui-disasm.c (tui_show_disassem): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <is_visible>: New
	method.
	<is_visible>: Remove field.
	* tui/tui-data.c (tui_next_win, tui_prev_win)
	(tui_delete_invisible_windows): Update.
This commit is contained in:
Tom Tromey 2019-07-11 18:03:45 -06:00
parent d4ab829a24
commit 2d83e710a1
9 changed files with 46 additions and 25 deletions

View File

@ -1,3 +1,23 @@
2019-08-16 Tom Tromey <tom@tromey.com>
* tui/tui.c (tui_is_window_visible): Update.
* tui/tui-wingeneral.c (tui_make_window)
(tui_gen_win_info::make_visible, tui_refresh_all): Update.
* tui/tui-win.c (window_name_completer, tui_refresh_all_win)
(tui_set_focus_command, tui_all_windows_info, update_tab_width)
(tui_set_win_height_command, parse_scrolling_args): Update.
* tui/tui-source.c (tui_source_window::style_changed): Update.
* tui/tui-regs.c (tui_show_registers)
(tui_data_window::first_data_item_displayed)
(tui_data_window::delete_data_content_windows)
(tui_check_register_values, tui_reg_command): Update.
* tui/tui-disasm.c (tui_show_disassem): Update.
* tui/tui-data.h (struct tui_gen_win_info) <is_visible>: New
method.
<is_visible>: Remove field.
* tui/tui-data.c (tui_next_win, tui_prev_win)
(tui_delete_invisible_windows): Update.
2019-08-16 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (struct tui_source_window_base)

View File

@ -148,7 +148,7 @@ tui_next_win (struct tui_win_info *cur_win)
while (type != cur_win->type && (next_win == NULL))
{
if (tui_win_list[type]
&& tui_win_list[type]->is_visible)
&& tui_win_list[type]->is_visible ())
next_win = tui_win_list[type];
else
{
@ -178,7 +178,7 @@ tui_prev_win (struct tui_win_info *cur_win)
while (type != cur_win->type && (prev == NULL))
{
if (tui_win_list[type]
&& tui_win_list[type]->is_visible)
&& tui_win_list[type]->is_visible ())
prev = tui_win_list[type];
else
{
@ -220,7 +220,7 @@ 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)
&& !tui_win_list[win_type]->is_visible ())
{
/* This should always be made visible before a call to this
function. */

View File

@ -79,6 +79,12 @@ public:
return false;
}
/* Return true if this window is visible. */
bool is_visible () const
{
return handle != nullptr;
}
/* Window handle. */
WINDOW *handle = nullptr;
/* Type of window. */
@ -91,8 +97,6 @@ public:
struct tui_point origin = {0, 0};
/* Viewport height. */
int viewport_height = 0;
/* Whether the window is visible or not. */
bool is_visible = false;
/* Window title to display. */
char *title = nullptr;
};

View File

@ -253,7 +253,7 @@ tui_show_disassem (struct gdbarch *gdbarch, CORE_ADDR start_addr)
struct tui_win_info *win_with_focus = tui_win_with_focus ();
struct tui_line_or_address val;
gdb_assert (TUI_DISASM_WIN != nullptr && TUI_DISASM_WIN->is_visible);
gdb_assert (TUI_DISASM_WIN != nullptr && TUI_DISASM_WIN->is_visible ());
val.loa = LOA_ADDRESS;
val.u.addr = start_addr;

View File

@ -138,7 +138,7 @@ tui_show_registers (struct reggroup *group)
/* Make sure the register window is visible. If not, select an
appropriate layout. */
if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible ())
tui_reg_layout ();
if (group == 0)
@ -411,7 +411,7 @@ tui_data_window::first_data_item_displayed ()
struct tui_gen_win_info *data_item_win;
data_item_win = regs_content[i].get ();
if (data_item_win->handle != NULL && data_item_win->is_visible)
if (data_item_win->is_visible ())
return i;
}
@ -427,7 +427,6 @@ tui_data_window::delete_data_content_windows ()
{
tui_delete_win (win->handle);
win->handle = NULL;
win->is_visible = false;
}
}
@ -552,7 +551,7 @@ void
tui_check_register_values (struct frame_info *frame)
{
if (TUI_DATA_WIN != NULL
&& TUI_DATA_WIN->is_visible)
&& TUI_DATA_WIN->is_visible ())
{
if (TUI_DATA_WIN->regs_content.empty ()
&& TUI_DATA_WIN->display_regs)
@ -667,7 +666,7 @@ tui_reg_command (const char *args, int from_tty)
/* Make sure the register window is visible. If not, select an
appropriate layout. We need to do this before trying to run the
'next' or 'prev' commands. */
if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible ())
tui_reg_layout ();
struct reggroup *current_group = NULL;

View File

@ -279,7 +279,7 @@ tui_source_window::~tui_source_window ()
void
tui_source_window::style_changed ()
{
if (tui_active && is_visible)
if (tui_active && is_visible ())
refill ();
}

View File

@ -367,7 +367,7 @@ window_name_completer (completion_tracker &tracker,
const char *completion_name = NULL;
/* We can't focus on an invisible window. */
if (!win_info->is_visible)
if (!win_info->is_visible ())
continue;
completion_name = win_info->name ();
@ -506,7 +506,7 @@ tui_refresh_all_win (void)
tui_refresh_all ();
for (tui_win_info *win_info : all_tui_windows ())
{
if (win_info->is_visible)
if (win_info->is_visible ())
win_info->refresh_all ();
}
tui_show_locator_content ();
@ -813,7 +813,7 @@ tui_set_focus_command (const char *arg, int from_tty)
else
win_info = tui_partial_win_by_name (buf_ptr);
if (win_info == NULL || !win_info->is_visible)
if (win_info == NULL || !win_info->is_visible ())
warning (_("Invalid window specified. \n\
The window name specified must be valid and visible.\n"));
else
@ -836,7 +836,7 @@ tui_all_windows_info (const char *arg, int from_tty)
struct tui_win_info *win_with_focus = tui_win_with_focus ();
for (tui_win_info *win_info : all_tui_windows ())
if (win_info->is_visible)
if (win_info->is_visible ())
{
if (win_with_focus == win_info)
printf_filtered (" %s\t(%d lines) <has focus>\n",
@ -875,7 +875,7 @@ update_tab_width ()
{
for (tui_win_info *win_info : all_tui_windows ())
{
if (win_info->is_visible)
if (win_info->is_visible ())
win_info->update_tab_width ();
}
}
@ -956,7 +956,7 @@ tui_set_win_height_command (const char *arg, int from_tty)
wname[i] = tolower (wname[i]);
win_info = tui_partial_win_by_name (wname);
if (win_info == NULL || !win_info->is_visible)
if (win_info == NULL || !win_info->is_visible ())
warning (_("Invalid window specified. \n\
The window name specified must be valid and visible.\n"));
else
@ -1347,7 +1347,7 @@ parse_scrolling_args (const char *arg,
if (*win_to_scroll == NULL)
error (_("Unrecognized window `%s'"), wname);
if (!(*win_to_scroll)->is_visible)
if (!(*win_to_scroll)->is_visible ())
error (_("Window is not visible"));
else if (*win_to_scroll == TUI_CMD_WIN)
*win_to_scroll = *(tui_source_windows ().begin ());

View File

@ -139,7 +139,6 @@ tui_make_window (struct tui_gen_win_info *win_info)
{
if (win_info->can_box ())
box_win (win_info, NO_HILITE);
win_info->is_visible = true;
scrollok (handle, TRUE);
}
}
@ -151,9 +150,8 @@ tui_make_window (struct tui_gen_win_info *win_info)
void
tui_gen_win_info::make_visible (bool visible)
{
if (is_visible == visible)
if (is_visible () == visible)
return;
is_visible = visible;
if (visible)
tui_make_window (this);
@ -182,10 +180,10 @@ tui_refresh_all ()
for (tui_win_info *win_info : all_tui_windows ())
{
if (win_info->is_visible)
if (win_info->is_visible ())
win_info->refresh_window ();
}
if (locator->is_visible)
if (locator->is_visible ())
locator->refresh_window ();
}

View File

@ -661,7 +661,7 @@ tui_is_window_visible (enum tui_win_type type)
if (tui_win_list[type] == 0)
return false;
return tui_win_list[type]->is_visible;
return tui_win_list[type]->is_visible ();
}
int