diff options
author | Tom Tromey <tom@tromey.com> | 2019-06-26 16:13:39 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-07-17 12:18:59 -0600 |
commit | 517e9505fa563c83b4d5cb192e423a0d6baac752 (patch) | |
tree | bf3b2abd0e001814dc825b3fce8e917afd736a8a /gdb/tui | |
parent | f76d8b19e80b43a141ce31c0e0230e23f676182d (diff) | |
download | gdb-517e9505fa563c83b4d5cb192e423a0d6baac752.zip gdb-517e9505fa563c83b4d5cb192e423a0d6baac752.tar.gz gdb-517e9505fa563c83b4d5cb192e423a0d6baac752.tar.bz2 |
Introduce two more tui_data_window methods
This changes tui_display_registers_from and
tui_display_registers_from_line to be methods on tui_data_window,
allowing for the removal of more uses of the TUI_DATA_WIN global.
gdb/ChangeLog
2019-07-17 Tom Tromey <tom@tromey.com>
* tui/tui-regs.h (tui_display_registers_from)
(tui_display_registers_from_line): Don't declare.
* tui/tui-windata.c (tui_data_window::display_all_data)
(tui_data_window::refresh_all)
(tui_data_window::do_scroll_vertical): Update.
* tui/tui-regs.c (tui_data_window::display_registers_from): Rename
from tui_display_registers_from.
(tui_display_reg_element_at_line): Update.
(tui_data_window::display_registers_from_line): Rename from
tui_display_registers_from_line.
* tui/tui-data.h (struct tui_data_window) <display_registers_from,
display_registers_from_line>: New methods.
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-data.h | 11 | ||||
-rw-r--r-- | gdb/tui/tui-regs.c | 54 | ||||
-rw-r--r-- | gdb/tui/tui-regs.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-windata.c | 6 |
4 files changed, 37 insertions, 36 deletions
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 306f413..5220c4b 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -513,6 +513,17 @@ struct tui_data_window : public tui_win_info void erase_data_content (const char *prompt); + /* Display the registers in the content from 'start_element_no' + until the end of the register content or the end of the display + height. No checking for displaying past the end of the registers + is done here. */ + void display_registers_from (int start_element_no); + + /* Display the registers starting at line line_no in the data + window. Answers the line number that the display actually + started from. If nothing is displayed (-1) is returned. */ + int display_registers_from_line (int line_no); + protected: void do_scroll_vertical (int num_to_scroll) override; diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 9b396e4..05b4b55 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -244,19 +244,17 @@ tui_show_register_group (struct reggroup *group, } } -/* Function to display the registers in the content from - 'start_element_no' until the end of the register content or the end - of the display height. No checking for displaying past the end of - the registers is done here. */ +/* See tui-data.h. */ + void -tui_display_registers_from (int start_element_no) +tui_data_window::display_registers_from (int start_element_no) { - if (!TUI_DATA_WIN->regs_content.empty ()) + if (!regs_content.empty ()) { int j, item_win_width, cur_y; int max_len = 0; - for (auto &&data_item_win : TUI_DATA_WIN->regs_content) + for (auto &&data_item_win : regs_content) { char *p; int len; @@ -278,28 +276,25 @@ tui_display_registers_from (int start_element_no) item_win_width = max_len + 1; int i = start_element_no; - TUI_DATA_WIN->regs_column_count = - (TUI_DATA_WIN->width - 2) / item_win_width; - if (TUI_DATA_WIN->regs_column_count == 0) - TUI_DATA_WIN->regs_column_count = 1; - item_win_width = - (TUI_DATA_WIN->width - 2) / TUI_DATA_WIN->regs_column_count; + regs_column_count = (width - 2) / item_win_width; + if (regs_column_count == 0) + regs_column_count = 1; + item_win_width = (width - 2) / regs_column_count; /* Now create each data "sub" window, and write the display into it. */ cur_y = 1; - while (i < TUI_DATA_WIN->regs_content.size () - && cur_y <= TUI_DATA_WIN->viewport_height) + while (i < regs_content.size () + && cur_y <= viewport_height) { for (j = 0; - j < TUI_DATA_WIN->regs_column_count - && i < TUI_DATA_WIN->regs_content.size (); + 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 = TUI_DATA_WIN->regs_content[i].get (); + data_item_win = regs_content[i].get (); if (data_item_win->handle != NULL && (data_item_win->height != 1 || data_item_win->width != item_win_width @@ -362,20 +357,17 @@ tui_display_reg_element_at_line (int start_element_no, = (TUI_DATA_WIN->first_reg_element_no_inline (first_line_on_last_page)); } - tui_display_registers_from (element_no); + TUI_DATA_WIN->display_registers_from (element_no); } } +/* See tui-data.h. */ - -/* Function to display the registers starting at line line_no in the - data window. Answers the line number that the display actually - started from. If nothing is displayed (-1) is returned. */ int -tui_display_registers_from_line (int line_no) +tui_data_window::display_registers_from_line (int line_no) { - tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); - if (!TUI_DATA_WIN->regs_content.empty ()) + tui_check_and_display_highlight_if_needed (this); + if (!regs_content.empty ()) { int element_no; @@ -385,16 +377,16 @@ tui_display_registers_from_line (int line_no) { /* Make sure that we don't display off the end of the registers. */ - if (line_no >= TUI_DATA_WIN->last_regs_line_no ()) + if (line_no >= last_regs_line_no ()) { - if ((line_no = TUI_DATA_WIN->line_from_reg_element_no ( - TUI_DATA_WIN->regs_content.size () - 1)) < 0) + line_no = line_from_reg_element_no (regs_content.size () - 1); + if (line_no < 0) line_no = 0; } } - element_no = TUI_DATA_WIN->first_reg_element_no_inline (line_no); - if (element_no < TUI_DATA_WIN->regs_content.size ()) + element_no = first_reg_element_no_inline (line_no); + if (element_no < regs_content.size ()) tui_display_reg_element_at_line (element_no, line_no); else line_no = (-1); diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index c99910b..354605c 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -26,7 +26,5 @@ extern void tui_check_register_values (struct frame_info *); extern void tui_show_registers (struct reggroup *group); -extern void tui_display_registers_from (int); -extern int tui_display_registers_from_line (int); #endif /* TUI_TUI_REGS_H */ diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c index 47d777a..2ee259e 100644 --- a/gdb/tui/tui-windata.c +++ b/gdb/tui/tui-windata.c @@ -101,7 +101,7 @@ tui_data_window::display_all_data () erase_data_content (NULL); delete_data_content_windows (); tui_check_and_display_highlight_if_needed (this); - tui_display_registers_from (0); + display_registers_from (0); } } @@ -125,7 +125,7 @@ tui_data_window::refresh_all () if (first_line >= 0) { erase_data_content (NULL); - tui_display_registers_from_line (first_line); + display_registers_from_line (first_line); } } } @@ -152,7 +152,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll) first_line += num_to_scroll; erase_data_content (NULL); delete_data_content_windows (); - tui_display_registers_from_line (first_line); + display_registers_from_line (first_line); } } |