aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-win.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-06-16 15:16:52 -0600
committerTom Tromey <tom@tromey.com>2019-06-25 07:48:35 -0600
commit8903bd8a37f905f5d77d2e04219e1a1eddaa6133 (patch)
tree18b361687cd3700d12e228b3e7c704b212a01e9e /gdb/tui/tui-win.c
parent3f02ce1e3df15731872befd2e711854b2b259745 (diff)
downloadgdb-8903bd8a37f905f5d77d2e04219e1a1eddaa6133.zip
gdb-8903bd8a37f905f5d77d2e04219e1a1eddaa6133.tar.gz
gdb-8903bd8a37f905f5d77d2e04219e1a1eddaa6133.tar.bz2
Introduce max_height method
This introduces the tui_win_info::max_height method and changes new_height_ok to use it, rather than checking the window type directly. gdb/ChangeLog 2019-06-25 Tom Tromey <tom@tromey.com> * tui/tui-win.c (tui_win_info::max_height) (tui_cmd_window::max_height): New methods. (new_height_ok): Call max_height. * tui/tui-data.h (struct tui_win_info, struct tui_cmd_window) <max_height>: New method.
Diffstat (limited to 'gdb/tui/tui-win.c')
-rw-r--r--gdb/tui/tui-win.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index fe1e901..dc40ab7 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1377,6 +1377,22 @@ make_visible_with_new_height (struct tui_win_info *win_info)
}
+/* See tui-data.h. */
+
+int
+tui_win_info::max_height () const
+{
+ return tui_term_height () - 2;
+}
+
+/* See tui-data.h. */
+
+int
+tui_cmd_window::max_height () const
+{
+ return tui_term_height () - 4;
+}
+
static int
new_height_ok (struct tui_win_info *primary_win_info,
int new_height)
@@ -1391,12 +1407,8 @@ new_height_ok (struct tui_win_info *primary_win_info,
diff = (new_height - primary_win_info->generic.height) * (-1);
if (cur_layout == SRC_COMMAND || cur_layout == DISASSEM_COMMAND)
{
- ok = ((primary_win_info->generic.type == CMD_WIN
- && new_height <= (tui_term_height () - 4)
- && new_height >= MIN_CMD_WIN_HEIGHT)
- || (primary_win_info->generic.type != CMD_WIN
- && new_height <= (tui_term_height () - 2)
- && new_height >= MIN_WIN_HEIGHT));
+ ok = (new_height <= primary_win_info->max_height ()
+ && new_height >= MIN_CMD_WIN_HEIGHT);
if (ok)
{ /* Check the total height. */
struct tui_win_info *win_info;