From: Tom Tromey Date: Mon, 15 Jul 2019 21:28:56 +0000 (-0600) Subject: Simplify register display X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cdaa6eb4394c42b49b090181dbfaae4e327090de;p=binutils-gdb.git Simplify register display This patch starts with the observation that the code in tui_data_window::display_registers_from can all be replaced with a call to resize. To make this work propertly, it also changes tui_display_register to be the "rerender" method on tui_data_item_window. The refresh_window method is needed due to the use of nested windows here. The ncurses man page makes it sound like this is not very well supported; and experience bears this out: negelecting the touchwin call in this path will cause the register window to blank when switching focus. gdb/ChangeLog 2019-08-30 Tom Tromey * tui/tui-regs.h (struct tui_data_item_window) : Declare. * tui/tui-regs.c (tui_data_window::display_registers_from): Call resize. (tui_data_item_window::rerender): Rename from tui_display_register. (tui_data_item_window::refresh_window): New method. * tui/tui-layout.c (tui_gen_win_info::resize): Do nothing on no-op. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2a2c08cae46..388f5ebe929 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2019-08-30 Tom Tromey + + * tui/tui-regs.h (struct tui_data_item_window) : Declare. + * tui/tui-regs.c (tui_data_window::display_registers_from): Call + resize. + (tui_data_item_window::rerender): Rename from + tui_display_register. + (tui_data_item_window::refresh_window): New method. + * tui/tui-layout.c (tui_gen_win_info::resize): Do nothing on + no-op. + 2019-08-30 Tom Tromey * tui/tui-regs.h (struct tui_data_window) 1) diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 98096e2cdc4..f62ba065ebe 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -42,8 +42,6 @@ #include "gdb_curses.h" -static void tui_display_register (struct tui_data_item_window *data); - /* Get the register from the frame and return a printable representation of it. */ @@ -274,34 +272,9 @@ tui_data_window::display_registers_from (int start_element_no) j < regs_column_count && i < regs_content.size (); j++) { - struct tui_data_item_window *data_item_win; - /* Create the window if necessary. */ - data_item_win = ®s_content[i]; - if (data_item_win->handle != NULL - && (data_item_win->height != 1 - || data_item_win->width != item_win_width - || data_item_win->origin.x != (item_win_width * j) + 1 - || data_item_win->origin.y != cur_y)) - { - tui_delete_win (data_item_win->handle); - data_item_win->handle = 0; - } - - if (data_item_win->handle == NULL) - { - data_item_win->height = 1; - data_item_win->width = item_win_width; - data_item_win->origin.x = (item_win_width * j) + 1; - data_item_win->origin.y = cur_y; - data_item_win->make_visible (true); - scrollok (data_item_win->handle, FALSE); - } - touchwin (data_item_win->handle); - - /* Get the printable representation of the register - and display it. */ - tui_display_register (data_item_win); + regs_content[i].resize (1, item_win_width, + (item_win_width * j) + 1, cur_y); i++; /* Next register. */ } cur_y++; /* Next row. */ @@ -508,43 +481,54 @@ tui_data_window::check_register_values (struct frame_info *frame) &data_item_win.highlight); if (data_item_win.highlight || was_hilighted) - tui_display_register (&data_item_win); + data_item_win.rerender (); } } } /* Display a register in a window. If hilite is TRUE, then the value will be displayed in reverse video. */ -static void -tui_display_register (struct tui_data_item_window *data) +void +tui_data_item_window::rerender () { - if (data->handle != NULL) - { - int i; - - if (data->highlight) - /* We ignore the return value, casting it to void in order to avoid - a compiler warning. The warning itself was introduced by a patch - to ncurses 5.7 dated 2009-08-29, changing this macro to expand - to code that causes the compiler to generate an unused-value - warning. */ - (void) wstandout (data->handle); + int i; + + scrollok (handle, FALSE); + if (highlight) + /* We ignore the return value, casting it to void in order to avoid + a compiler warning. The warning itself was introduced by a patch + to ncurses 5.7 dated 2009-08-29, changing this macro to expand + to code that causes the compiler to generate an unused-value + warning. */ + (void) wstandout (handle); - wmove (data->handle, 0, 0); - for (i = 1; i < data->width; i++) - waddch (data->handle, ' '); - wmove (data->handle, 0, 0); - if (data->content) - waddstr (data->handle, data->content.get ()); - - if (data->highlight) - /* We ignore the return value, casting it to void in order to avoid - a compiler warning. The warning itself was introduced by a patch - to ncurses 5.7 dated 2009-08-29, changing this macro to expand - to code that causes the compiler to generate an unused-value - warning. */ - (void) wstandend (data->handle); - data->refresh_window (); + wmove (handle, 0, 0); + for (i = 1; i < width; i++) + waddch (handle, ' '); + wmove (handle, 0, 0); + if (content) + waddstr (handle, content.get ()); + + if (highlight) + /* We ignore the return value, casting it to void in order to avoid + a compiler warning. The warning itself was introduced by a patch + to ncurses 5.7 dated 2009-08-29, changing this macro to expand + to code that causes the compiler to generate an unused-value + warning. */ + (void) wstandend (handle); + refresh_window (); +} + +void +tui_data_item_window::refresh_window () +{ + if (handle != nullptr) + { + /* This seems to be needed because the data items are nested + windows, which according to the ncurses man pages aren't well + supported. */ + touchwin (handle); + wrefresh (handle); } } diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index 2606c39f5a1..1f9fa73f1cc 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -37,6 +37,10 @@ struct tui_data_item_window : public tui_gen_win_info tui_data_item_window (tui_data_item_window &&) = default; + void rerender () override; + + void refresh_window () override; + const char *name = nullptr; /* The register number, or data display number. */ int item_no = -1;