Introduce refresh_window method

This replaces tui_refresh_win with a new refresh_window method.  This
removes another spot that was checking the window's type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_erase_source_content)
	(tui_show_source_content, tui_show_exec_info_content)
	(tui_erase_exec_info_content): Use refresh_window method.
	* tui/tui-wingeneral.h (tui_refresh_win): Don't declare.
	* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Rename
	from tui_refresh_win.
	(tui_data_window::refresh_window): New method.
	(tui_win_info::refresh, tui_source_window_base::refresh)
	(tui_refresh_all): Use refresh_window method.
	* tui/tui-stack.c (tui_show_locator_content): Call refresh_window
	method.
	* tui/tui-regs.c (tui_display_register): Call refresh_window
	method.
	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Call refresh_window method.
	* tui/tui-data.h (struct tui_gen_win_info)
	(struct tui_data_window, struct tui_cmd_window) <refresh_window>:
	New method.
This commit is contained in:
Tom Tromey
2019-06-16 16:28:12 -06:00
parent cb2ce89305
commit 5b81daba91
8 changed files with 60 additions and 33 deletions

View File

@ -1,3 +1,24 @@
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.c (tui_erase_source_content)
(tui_show_source_content, tui_show_exec_info_content)
(tui_erase_exec_info_content): Use refresh_window method.
* tui/tui-wingeneral.h (tui_refresh_win): Don't declare.
* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Rename
from tui_refresh_win.
(tui_data_window::refresh_window): New method.
(tui_win_info::refresh, tui_source_window_base::refresh)
(tui_refresh_all): Use refresh_window method.
* tui/tui-stack.c (tui_show_locator_content): Call refresh_window
method.
* tui/tui-regs.c (tui_display_register): Call refresh_window
method.
* tui/tui-layout.c (show_source_disasm_command)
(show_source_or_disasm_and_command): Call refresh_window method.
* tui/tui-data.h (struct tui_gen_win_info)
(struct tui_data_window, struct tui_cmd_window) <refresh_window>:
New method.
2019-06-25 Tom Tromey <tom@tromey.com> 2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui.c (tui_rl_other_window, tui_enable) * tui/tui.c (tui_rl_other_window, tui_enable)

View File

@ -48,6 +48,9 @@ struct tui_gen_win_info
{ {
} }
/* Call to refresh this window. */
virtual void refresh_window ();
/* Window handle. */ /* Window handle. */
WINDOW *handle = nullptr; WINDOW *handle = nullptr;
/* Type of window. */ /* Type of window. */
@ -418,6 +421,8 @@ struct tui_data_window : public tui_win_info
void set_new_height (int height) override; void set_new_height (int height) override;
void refresh_window () override;
/* Start of data display content. */ /* Start of data display content. */
tui_win_content data_content = NULL; tui_win_content data_content = NULL;
int data_content_count = 0; int data_content_count = 0;
@ -456,6 +461,10 @@ struct tui_cmd_window : public tui_win_info
int max_height () const override; int max_height () const override;
void refresh_window () override
{
}
int start_line = 0; int start_line = 0;
protected: protected:

View File

@ -701,7 +701,7 @@ show_source_disasm_command (void)
TUI_CMD_WIN->can_highlight = false; TUI_CMD_WIN->can_highlight = false;
tui_make_visible (TUI_CMD_WIN); tui_make_visible (TUI_CMD_WIN);
} }
tui_refresh_win (TUI_CMD_WIN); TUI_CMD_WIN->refresh_window ();
tui_set_current_layout_to (SRC_DISASSEM_COMMAND); tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
} }
} }
@ -956,7 +956,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
{ {
tui_win_list[CMD_WIN] = make_command_window (cmd_height, tui_win_list[CMD_WIN] = make_command_window (cmd_height,
src_height); src_height);
tui_refresh_win (TUI_CMD_WIN); TUI_CMD_WIN->refresh_window ();
} }
else else
{ {

View File

@ -534,7 +534,7 @@ tui_display_register (struct tui_data_element *data,
to code that causes the compiler to generate an unused-value to code that causes the compiler to generate an unused-value
warning. */ warning. */
(void) wstandend (win_info->handle); (void) wstandend (win_info->handle);
tui_refresh_win (win_info); win_info->refresh_window ();
} }
} }

View File

@ -267,7 +267,7 @@ tui_show_locator_content (void)
waddstr (locator->handle, string); waddstr (locator->handle, string);
wclrtoeol (locator->handle); wclrtoeol (locator->handle);
(void) wstandend (locator->handle); (void) wstandend (locator->handle);
tui_refresh_win (locator); locator->refresh_window ();
wmove (locator->handle, 0, 0); wmove (locator->handle, 0, 0);
xfree (string); xfree (string);
locator->content_in_use = TRUE; locator->content_in_use = TRUE;

View File

@ -31,38 +31,36 @@
** PUBLIC FUNCTIONS ** PUBLIC FUNCTIONS
***********************/ ***********************/
/* Refresh the window. */ /* See tui-data.h. */
void
tui_refresh_win (struct tui_gen_win_info *win_info)
{
if (win_info->type == DATA_WIN && win_info->content_size > 0)
{
int i;
for (i = 0; (i < win_info->content_size); i++) void
tui_gen_win_info::refresh_window ()
{
if (handle != NULL)
wrefresh (handle);
}
/* See tui-data.h. */
void
tui_data_window::refresh_window ()
{
if (content_size > 0)
{
for (int i = 0; i < content_size; i++)
{ {
struct tui_gen_win_info *data_item_win_ptr; struct tui_gen_win_info *data_item_win_ptr;
data_item_win_ptr = win_info->content[i]->which_element.data_window; data_item_win_ptr = content[i]->which_element.data_window;
if (data_item_win_ptr != NULL if (data_item_win_ptr != NULL
&& data_item_win_ptr->handle != NULL) && data_item_win_ptr->handle != NULL)
wrefresh (data_item_win_ptr->handle); wrefresh (data_item_win_ptr->handle);
} }
} }
else if (win_info->type == CMD_WIN)
{
/* Do nothing. */
}
else else
{ tui_gen_win_info::refresh_window ();
if (win_info->handle != NULL)
wrefresh (win_info->handle);
}
return;
} }
/* Function to delete the curses window, checking for NULL. */ /* Function to delete the curses window, checking for NULL. */
void void
tui_delete_win (WINDOW *window) tui_delete_win (WINDOW *window)
@ -260,7 +258,7 @@ void
tui_win_info::refresh () tui_win_info::refresh ()
{ {
touchwin (handle); touchwin (handle);
tui_refresh_win (this); refresh_window ();
} }
/* See tui-data.h. */ /* See tui-data.h. */
@ -269,7 +267,7 @@ void
tui_source_window_base::refresh () tui_source_window_base::refresh ()
{ {
touchwin (execution_info->handle); touchwin (execution_info->handle);
tui_refresh_win (execution_info); execution_info->refresh_window ();
tui_win_info::refresh (); tui_win_info::refresh ();
} }
@ -289,7 +287,7 @@ tui_refresh_all (struct tui_win_info **list)
if (locator->is_visible) if (locator->is_visible)
{ {
touchwin (locator->handle); touchwin (locator->handle);
tui_refresh_win (locator); locator->refresh_window ();
} }
} }

View File

@ -39,6 +39,5 @@ extern void tui_highlight_win (struct tui_win_info *);
extern void tui_check_and_display_highlight_if_needed (struct tui_win_info *); extern void tui_check_and_display_highlight_if_needed (struct tui_win_info *);
extern void tui_refresh_all (struct tui_win_info **); extern void tui_refresh_all (struct tui_win_info **);
extern void tui_delete_win (WINDOW *window); extern void tui_delete_win (WINDOW *window);
extern void tui_refresh_win (struct tui_gen_win_info *);
#endif /* TUI_TUI_WINGENERAL_H */ #endif /* TUI_TUI_WINGENERAL_H */

View File

@ -260,7 +260,7 @@ tui_erase_source_content (struct tui_win_info *win_info,
tui_set_source_content_nil (win_info, no_src_str); tui_set_source_content_nil (win_info, no_src_str);
} }
tui_refresh_win (win_info); win_info->refresh_window ();
} }
} }
@ -305,7 +305,7 @@ tui_show_source_content (struct tui_win_info *win_info)
tui_erase_source_content (win_info, TRUE); tui_erase_source_content (win_info, TRUE);
tui_check_and_display_highlight_if_needed (win_info); tui_check_and_display_highlight_if_needed (win_info);
tui_refresh_win (win_info); win_info->refresh_window ();
win_info->content_in_use = TRUE; win_info->content_in_use = TRUE;
} }
@ -550,14 +550,14 @@ tui_show_exec_info_content (struct tui_win_info *win_info)
int cur_line; int cur_line;
werase (exec_info->handle); werase (exec_info->handle);
tui_refresh_win (exec_info); exec_info->refresh_window ();
for (cur_line = 1; (cur_line <= exec_info->content_size); cur_line++) for (cur_line = 1; (cur_line <= exec_info->content_size); cur_line++)
mvwaddstr (exec_info->handle, mvwaddstr (exec_info->handle,
cur_line, cur_line,
0, 0,
(char *) exec_info->content[cur_line - 1] (char *) exec_info->content[cur_line - 1]
->which_element.simple_string); ->which_element.simple_string);
tui_refresh_win (exec_info); exec_info->refresh_window ();
exec_info->content_in_use = TRUE; exec_info->content_in_use = TRUE;
} }
@ -569,7 +569,7 @@ tui_erase_exec_info_content (struct tui_win_info *win_info)
struct tui_gen_win_info *exec_info = base->execution_info; struct tui_gen_win_info *exec_info = base->execution_info;
werase (exec_info->handle); werase (exec_info->handle);
tui_refresh_win (exec_info); exec_info->refresh_window ();
} }
void void