Change tui_check_and_display_highlight_if_needed to be a method

This changes tui_check_and_display_highlight_if_needed to be a method
on tui_win_info.  This makes it clear that the NULL check in that
function is not needed, so it is removed here.

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

	* tui/tui-winsource.c (tui_erase_source_content)
	(tui_show_source_content, tui_source_window_base::refresh_all):
	Update.
	* tui/tui-wingeneral.h
	(tui_check_and_display_highlight_if_needed): Don't declare.
	* tui/tui-wingeneral.c
	(tui_win_info::check_and_display_highlight_if_needed): Rename from
	check_and_display_highlight_if_needed.
	* tui/tui-win.c (tui_rehighlight_all)
	(tui_win_info::make_visible_with_new_height): Update.
	* tui/tui-regs.c (tui_data_window::display_registers_from_line)
	(tui_data_window::erase_data_content)
	(tui_data_window::display_all_data): Update.
	* tui/tui-data.h (struct tui_win_info)
	<check_and_display_highlight_if_needed>: Declare.
This commit is contained in:
Tom Tromey
2019-07-05 17:14:46 -06:00
parent fede52738f
commit b4ef5aeb3a
7 changed files with 33 additions and 15 deletions

View File

@ -1,3 +1,21 @@
2019-08-13 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.c (tui_erase_source_content)
(tui_show_source_content, tui_source_window_base::refresh_all):
Update.
* tui/tui-wingeneral.h
(tui_check_and_display_highlight_if_needed): Don't declare.
* tui/tui-wingeneral.c
(tui_win_info::check_and_display_highlight_if_needed): Rename from
check_and_display_highlight_if_needed.
* tui/tui-win.c (tui_rehighlight_all)
(tui_win_info::make_visible_with_new_height): Update.
* tui/tui-regs.c (tui_data_window::display_registers_from_line)
(tui_data_window::erase_data_content)
(tui_data_window::display_all_data): Update.
* tui/tui-data.h (struct tui_win_info)
<check_and_display_highlight_if_needed>: Declare.
2019-08-13 Tom Tromey <tom@tromey.com> 2019-08-13 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_resize_all): Call * tui/tui-win.c (tui_resize_all): Call

View File

@ -291,6 +291,8 @@ public:
return true; return true;
} }
void check_and_display_highlight_if_needed ();
/* Can this window ever be highlighted? */ /* Can this window ever be highlighted? */
bool can_highlight = true; bool can_highlight = true;

View File

@ -369,7 +369,7 @@ tui_data_window::display_reg_element_at_line (int start_element_no,
int int
tui_data_window::display_registers_from_line (int line_no) tui_data_window::display_registers_from_line (int line_no)
{ {
tui_check_and_display_highlight_if_needed (this); check_and_display_highlight_if_needed ();
if (!regs_content.empty ()) if (!regs_content.empty ())
{ {
int element_no; int element_no;
@ -436,7 +436,7 @@ void
tui_data_window::erase_data_content (const char *prompt) tui_data_window::erase_data_content (const char *prompt)
{ {
werase (handle); werase (handle);
tui_check_and_display_highlight_if_needed (this); check_and_display_highlight_if_needed ();
if (prompt != NULL) if (prompt != NULL)
{ {
int half_width = (width - 2) / 2; int half_width = (width - 2) / 2;
@ -462,7 +462,7 @@ tui_data_window::display_all_data ()
{ {
erase_data_content (NULL); erase_data_content (NULL);
delete_data_content_windows (); delete_data_content_windows ();
tui_check_and_display_highlight_if_needed (this); check_and_display_highlight_if_needed ();
display_registers_from (0); display_registers_from (0);
} }
} }

View File

@ -515,7 +515,7 @@ void
tui_rehighlight_all (void) tui_rehighlight_all (void)
{ {
for (tui_win_info *win_info : all_tui_windows ()) for (tui_win_info *win_info : all_tui_windows ())
tui_check_and_display_highlight_if_needed (win_info); win_info->check_and_display_highlight_if_needed ();
} }
/* Resize all the windows based on the terminal size. This function /* Resize all the windows based on the terminal size. This function
@ -1205,7 +1205,7 @@ void
tui_win_info::make_visible_with_new_height () tui_win_info::make_visible_with_new_height ()
{ {
make_visible (true); make_visible (true);
tui_check_and_display_highlight_if_needed (this); check_and_display_highlight_if_needed ();
do_make_visible_with_new_height (); do_make_visible_with_new_height ();
} }

View File

@ -112,15 +112,14 @@ tui_highlight_win (struct tui_win_info *win_info)
} }
void void
tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info) tui_win_info::check_and_display_highlight_if_needed ()
{ {
if (win_info != NULL && win_info->can_highlight) if (can_highlight)
{ {
if (win_info->is_highlighted) if (is_highlighted)
tui_highlight_win (win_info); tui_highlight_win (this);
else else
tui_unhighlight_win (win_info); tui_unhighlight_win (this);
} }
} }

View File

@ -33,7 +33,6 @@ extern void tui_make_all_invisible (void);
extern void tui_unhighlight_win (struct tui_win_info *); extern void tui_unhighlight_win (struct tui_win_info *);
extern void tui_make_window (struct tui_gen_win_info *, enum tui_box); extern void tui_make_window (struct tui_gen_win_info *, enum tui_box);
extern void tui_highlight_win (struct tui_win_info *); 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_refresh_all (); extern void tui_refresh_all ();
extern void tui_delete_win (WINDOW *window); extern void tui_delete_win (WINDOW *window);

View File

@ -225,7 +225,7 @@ tui_erase_source_content (struct tui_source_window_base *win_info)
if (win_info->handle != NULL) if (win_info->handle != NULL)
{ {
werase (win_info->handle); werase (win_info->handle);
tui_check_and_display_highlight_if_needed (win_info); win_info->check_and_display_highlight_if_needed ();
const char *no_src_str; const char *no_src_str;
@ -287,7 +287,7 @@ tui_show_source_content (struct tui_source_window_base *win_info)
else else
tui_erase_source_content (win_info); tui_erase_source_content (win_info);
tui_check_and_display_highlight_if_needed (win_info); win_info->check_and_display_highlight_if_needed ();
win_info->refresh_window (); win_info->refresh_window ();
} }
@ -333,7 +333,7 @@ void
tui_source_window_base::refresh_all () tui_source_window_base::refresh_all ()
{ {
tui_show_source_content (this); tui_show_source_content (this);
tui_check_and_display_highlight_if_needed (this); check_and_display_highlight_if_needed ();
tui_erase_exec_info_content (this); tui_erase_exec_info_content (this);
tui_update_exec_info (this); tui_update_exec_info (this);
} }