diff options
author | Tom Tromey <tom@tromey.com> | 2019-06-16 15:12:25 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-06-25 07:48:34 -0600 |
commit | 3f02ce1e3df15731872befd2e711854b2b259745 (patch) | |
tree | 4533dea0d713965b61ea43397d6c1dfc9b3e3a2e | |
parent | 1825f487ae903438eb2a9b6f461337d8ec1b06c0 (diff) | |
download | binutils-3f02ce1e3df15731872befd2e711854b2b259745.zip binutils-3f02ce1e3df15731872befd2e711854b2b259745.tar.gz binutils-3f02ce1e3df15731872befd2e711854b2b259745.tar.bz2 |
Introduce set_new_height method
This introduces tui_win_info::set_new_height and implements it in the
subclasses as appropriate. This removes another switch on the window
type.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_source_window_base::set_new_height)
(tui_data_window::set_new_height): New methods.
(make_invisible_and_set_new_height): Call set_new_height method.
* tui/tui-data.h (struct tui_win_info)
(struct tui_source_window_base, struct tui_data_window)
<set_new_height>: New method.
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/tui/tui-data.h | 10 | ||||
-rw-r--r-- | gdb/tui/tui-win.c | 78 |
3 files changed, 57 insertions, 40 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 595a76a..c8850c1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2019-06-25 Tom Tromey <tom@tromey.com> + * tui/tui-win.c (tui_source_window_base::set_new_height) + (tui_data_window::set_new_height): New methods. + (make_invisible_and_set_new_height): Call set_new_height method. + * tui/tui-data.h (struct tui_win_info) + (struct tui_source_window_base, struct tui_data_window) + <set_new_height>: New method. + +2019-06-25 Tom Tromey <tom@tromey.com> + * tui/tui.c (tui_rl_other_window): Call the refresh_all method. * tui/tui-windata.c (tui_data_window::refresh_all): Rename from tui_refresh_data_win. diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index e45c9fa..07ec977 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -267,6 +267,12 @@ public: { } + /* Called after a TUI window is given a new height; this updates any + related auxiliary windows. */ + virtual void set_new_height (int height) + { + } + /* Methods to scroll the contents of this window. Note that they are named with "_scroll" coming at the end because the more obvious "scroll_forward" is defined as a macro in term.h. */ @@ -318,6 +324,8 @@ public: /* Set the location of the execution point. */ void set_is_exec_point_at (struct tui_line_or_address l); + void set_new_height (int height) override; + /* Does the locator belong to this window? */ bool m_has_locator = false; /* Execution information window. */ @@ -380,6 +388,8 @@ struct tui_data_window : public tui_win_info void clear_detail () override; void refresh_all () override; + void set_new_height (int height) override; + /* Start of data display content. */ tui_win_content data_content = NULL; int data_content_count = 0; diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 383487e..fe1e901 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -1242,6 +1242,43 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info, } +/* See tui-data.h. */ + +void +tui_source_window_base::set_new_height (int height) +{ + tui_make_invisible (execution_info); + execution_info->height = height; + execution_info->origin.y = generic.origin.y; + if (height > 1) + execution_info->viewport_height = height - 1; + else + execution_info->viewport_height = height; + execution_info->viewport_height--; + + if (has_locator ()) + { + tui_gen_win_info *gen_win_info = tui_locator_win_info_ptr (); + tui_make_invisible (gen_win_info); + gen_win_info->origin.y = generic.origin.y + height; + } +} + +/* See tui-data.h. */ + +void +tui_data_window::set_new_height (int height) +{ + /* Delete all data item windows. */ + for (int i = 0; i < generic.content_size; i++) + { + struct tui_gen_win_info *gen_win_info + = &generic.content[i]->which_element.data_window; + tui_delete_win (gen_win_info->handle); + gen_win_info->handle = NULL; + } +} + /* Function make the target window (and auxillary windows associated with the targer) invisible, and set the new height and location. */ @@ -1249,9 +1286,6 @@ static void make_invisible_and_set_new_height (struct tui_win_info *win_info, int height) { - int i; - struct tui_gen_win_info *gen_win_info; - tui_make_invisible (&win_info->generic); win_info->generic.height = height; if (height > 1) @@ -1262,43 +1296,7 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info, win_info->generic.viewport_height--; /* Now deal with the auxillary windows associated with win_info. */ - tui_source_window_base *base; - switch (win_info->generic.type) - { - case SRC_WIN: - case DISASSEM_WIN: - base = (tui_source_window_base *) win_info; - gen_win_info = base->execution_info; - tui_make_invisible (gen_win_info); - gen_win_info->height = height; - gen_win_info->origin.y = win_info->generic.origin.y; - if (height > 1) - gen_win_info->viewport_height = height - 1; - else - gen_win_info->viewport_height = height; - if (win_info != TUI_CMD_WIN) - gen_win_info->viewport_height--; - - if (win_info->has_locator ()) - { - gen_win_info = tui_locator_win_info_ptr (); - tui_make_invisible (gen_win_info); - gen_win_info->origin.y = win_info->generic.origin.y + height; - } - break; - case DATA_WIN: - /* Delete all data item windows. */ - for (i = 0; i < win_info->generic.content_size; i++) - { - gen_win_info - = &win_info->generic.content[i]->which_element.data_window; - tui_delete_win (gen_win_info->handle); - gen_win_info->handle = NULL; - } - break; - default: - break; - } + win_info->set_new_height (height); } |