Change make_invisible_and_set_new_height to be a method

This changes make_invisible_and_set_new_height to be a method on
tui_win_info.  I felt that this was cleaner.

gdb/ChangeLog
2019-07-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_resize_all)
	(tui_source_window_base::update_tab_width)
	(tui_adjust_win_heights): Update.
	(tui_win_info::make_invisible_and_set_new_height): Rename from
	make_invisible_and_set_new_height.
	* tui/tui-data.h (struct tui_win_info)
	<make_invisible_and_set_new_height>: New method.
This commit is contained in:
Tom Tromey 2019-07-02 17:05:49 -06:00
parent bfad453707
commit daa15dde72
3 changed files with 50 additions and 43 deletions

View File

@ -1,3 +1,13 @@
2019-07-17 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_resize_all)
(tui_source_window_base::update_tab_width)
(tui_adjust_win_heights): Update.
(tui_win_info::make_invisible_and_set_new_height): Rename from
make_invisible_and_set_new_height.
* tui/tui-data.h (struct tui_win_info)
<make_invisible_and_set_new_height>: New method.
2019-07-17 Tom Tromey <tom@tromey.com> 2019-07-17 Tom Tromey <tom@tromey.com>
* tui/tui.c: Update. * tui/tui.c: Update.

View File

@ -299,6 +299,11 @@ public:
{ {
} }
/* Function make the target window (and auxiliary windows associated
with the target) invisible, and set the new height and
location. */
void make_invisible_and_set_new_height (int height);
/* Make the window visible after the height has been changed. */ /* Make the window visible after the height has been changed. */
void make_visible_with_new_height (); void make_visible_with_new_height ();

View File

@ -55,8 +55,6 @@
/******************************* /*******************************
** Static Local Decls ** Static Local Decls
********************************/ ********************************/
static void make_invisible_and_set_new_height (struct tui_win_info *,
int);
static enum tui_status tui_adjust_win_heights (struct tui_win_info *, static enum tui_status tui_adjust_win_heights (struct tui_win_info *,
int); int);
static int new_height_ok (struct tui_win_info *, int); static int new_height_ok (struct tui_win_info *, int);
@ -601,11 +599,11 @@ tui_resize_all (void)
new_height = first_win->height + split_diff; new_height = first_win->height + split_diff;
locator->origin.y = new_height + 1; locator->origin.y = new_height + 1;
make_invisible_and_set_new_height (first_win, new_height); first_win->make_invisible_and_set_new_height (new_height);
TUI_CMD_WIN->origin.y = locator->origin.y + 1; TUI_CMD_WIN->origin.y = locator->origin.y + 1;
TUI_CMD_WIN->width += width_diff; TUI_CMD_WIN->width += width_diff;
new_height = screenheight - TUI_CMD_WIN->origin.y; new_height = screenheight - TUI_CMD_WIN->origin.y;
make_invisible_and_set_new_height (TUI_CMD_WIN, new_height); TUI_CMD_WIN->make_invisible_and_set_new_height (new_height);
first_win->make_visible_with_new_height (); first_win->make_visible_with_new_height ();
TUI_CMD_WIN->make_visible_with_new_height (); TUI_CMD_WIN->make_visible_with_new_height ();
if (src_win->content.empty ()) if (src_win->content.empty ())
@ -640,7 +638,7 @@ tui_resize_all (void)
new_height = MIN_WIN_HEIGHT; new_height = MIN_WIN_HEIGHT;
else else
new_height = first_win->height + split_diff; new_height = first_win->height + split_diff;
make_invisible_and_set_new_height (first_win, new_height); first_win->make_invisible_and_set_new_height (new_height);
locator->width += width_diff; locator->width += width_diff;
@ -663,13 +661,12 @@ tui_resize_all (void)
else else
new_height = second_win->height + split_diff; new_height = second_win->height + split_diff;
second_win->origin.y = first_win->height - 1; second_win->origin.y = first_win->height - 1;
make_invisible_and_set_new_height (second_win, new_height); second_win->make_invisible_and_set_new_height (new_height);
/* Change the command window's height/width. */ /* Change the command window's height/width. */
TUI_CMD_WIN->origin.y = locator->origin.y + 1; TUI_CMD_WIN->origin.y = locator->origin.y + 1;
make_invisible_and_set_new_height (TUI_CMD_WIN, TUI_CMD_WIN->make_invisible_and_set_new_height (TUI_CMD_WIN->height
TUI_CMD_WIN->height + cmd_split_diff);
+ cmd_split_diff);
first_win->make_visible_with_new_height (); first_win->make_visible_with_new_height ();
second_win->make_visible_with_new_height (); second_win->make_visible_with_new_height ();
TUI_CMD_WIN->make_visible_with_new_height (); TUI_CMD_WIN->make_visible_with_new_height ();
@ -911,7 +908,7 @@ tui_source_window_base::update_tab_width ()
calling these 2 functions causes a complete regeneration calling these 2 functions causes a complete regeneration
and redisplay of the window's contents, which will take and redisplay of the window's contents, which will take
the new tab width into account. */ the new tab width into account. */
make_invisible_and_set_new_height (this, height); make_invisible_and_set_new_height (height);
make_visible_with_new_height (); make_visible_with_new_height ();
} }
@ -1081,7 +1078,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
{ {
struct tui_win_info *src_win_info; struct tui_win_info *src_win_info;
make_invisible_and_set_new_height (primary_win_info, new_height); primary_win_info->make_invisible_and_set_new_height (new_height);
if (primary_win_info->type == CMD_WIN) if (primary_win_info->type == CMD_WIN)
{ {
win_info = tui_source_windows ()[0]; win_info = tui_source_windows ()[0];
@ -1092,8 +1089,8 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
win_info = tui_win_list[CMD_WIN]; win_info = tui_win_list[CMD_WIN];
src_win_info = primary_win_info; src_win_info = primary_win_info;
} }
make_invisible_and_set_new_height (win_info, win_info->make_invisible_and_set_new_height
win_info->height + diff); (win_info->height + diff);
TUI_CMD_WIN->origin.y = locator->origin.y + 1; TUI_CMD_WIN->origin.y = locator->origin.y + 1;
win_info->make_visible_with_new_height (); win_info->make_visible_with_new_height ();
primary_win_info->make_visible_with_new_height (); primary_win_info->make_visible_with_new_height ();
@ -1159,15 +1156,13 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
second_split_diff++; second_split_diff++;
first_split_diff--; first_split_diff--;
} }
make_invisible_and_set_new_height ( first_win->make_invisible_and_set_new_height
first_win, (first_win->height + first_split_diff);
first_win->height + first_split_diff);
second_win->origin.y = first_win->height - 1; second_win->origin.y = first_win->height - 1;
make_invisible_and_set_new_height (second_win, second_win->make_invisible_and_set_new_height
second_win->height (second_win->height + second_split_diff);
+ second_split_diff);
TUI_CMD_WIN->origin.y = locator->origin.y + 1; TUI_CMD_WIN->origin.y = locator->origin.y + 1;
make_invisible_and_set_new_height (TUI_CMD_WIN, new_height); TUI_CMD_WIN->make_invisible_and_set_new_height (new_height);
} }
else else
{ {
@ -1188,23 +1183,22 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
} }
} }
if (primary_win_info == first_win) if (primary_win_info == first_win)
make_invisible_and_set_new_height (first_win, new_height); first_win->make_invisible_and_set_new_height (new_height);
else else
make_invisible_and_set_new_height ( first_win->make_invisible_and_set_new_height
first_win, (first_win->height);
first_win->height);
second_win->origin.y = first_win->height - 1; second_win->origin.y = first_win->height - 1;
if (primary_win_info == second_win) if (primary_win_info == second_win)
make_invisible_and_set_new_height (second_win, new_height); second_win->make_invisible_and_set_new_height (new_height);
else else
make_invisible_and_set_new_height ( second_win->make_invisible_and_set_new_height
second_win, second_win->height); (second_win->height);
TUI_CMD_WIN->origin.y = locator->origin.y + 1; TUI_CMD_WIN->origin.y = locator->origin.y + 1;
if ((TUI_CMD_WIN->height + diff) < 1) if ((TUI_CMD_WIN->height + diff) < 1)
make_invisible_and_set_new_height (TUI_CMD_WIN, 1); TUI_CMD_WIN->make_invisible_and_set_new_height (1);
else else
make_invisible_and_set_new_height (TUI_CMD_WIN, TUI_CMD_WIN->make_invisible_and_set_new_height
TUI_CMD_WIN->height + diff); (TUI_CMD_WIN->height + diff);
} }
TUI_CMD_WIN->make_visible_with_new_height (); TUI_CMD_WIN->make_visible_with_new_height ();
second_win->make_visible_with_new_height (); second_win->make_visible_with_new_height ();
@ -1243,24 +1237,22 @@ tui_source_window_base::set_new_height (int height)
} }
} }
/* Function make the target window (and auxiliary windows associated /* See tui-data.h. */
with the targer) invisible, and set the new height and
location. */ void
static void tui_win_info::make_invisible_and_set_new_height (int height)
make_invisible_and_set_new_height (struct tui_win_info *win_info,
int height)
{ {
win_info->make_visible (false); make_visible (false);
win_info->height = height; height = height;
if (height > 1) if (height > 1)
win_info->viewport_height = height - 1; viewport_height = height - 1;
else else
win_info->viewport_height = height; viewport_height = height;
if (win_info != TUI_CMD_WIN) if (this != TUI_CMD_WIN)
win_info->viewport_height--; viewport_height--;
/* Now deal with the auxiliary windows associated with win_info. */ /* Now deal with the auxiliary windows associated with win_info. */
win_info->set_new_height (height); set_new_height (height);
} }