From: Tom Tromey Date: Mon, 15 Jul 2019 21:28:56 +0000 (-0600) Subject: Simplify register display X-Git-Tag: binutils-2_33~74 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cdaa6eb4394c42b49b090181dbfaae4e327090de;p=external%2Fbinutils.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 2a2c08c..388f5eb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 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) : Move later. Now private. : New method. diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 387a4f5..7ec704e 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -580,6 +580,11 @@ void tui_gen_win_info::resize (int height_, int width_, int origin_x_, int origin_y_) { + if (width == width_ && height == height_ + && origin.x == origin_x_ && origin.y == origin_y_ + && handle != nullptr) + return; + width = width_; height = height_; if (height > 1) diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 98096e2..f62ba06 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 2606c39..1f9fa73 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;