diff options
author | Tom Tromey <tom@tromey.com> | 2019-06-26 15:44:51 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-07-17 12:18:53 -0600 |
commit | 0b5ec21882bcc27e93144882b84935497da6e7fe (patch) | |
tree | 12d45778eaac85d03d3f0b5e60e4a78241ff4ee1 /gdb/tui | |
parent | 0807ab7b88fa5ffb138ba1ee22b33d26e239de2f (diff) | |
download | gdb-0b5ec21882bcc27e93144882b84935497da6e7fe.zip gdb-0b5ec21882bcc27e93144882b84935497da6e7fe.tar.gz gdb-0b5ec21882bcc27e93144882b84935497da6e7fe.tar.bz2 |
Introduce tui_data_window::last_regs_line_no method
This changes tui_last_regs_line_no into a method on tui_data_window,
allowing the removal of uses of the TUI_DATA_WIN global.
gdb/ChangeLog
2019-07-17 Tom Tromey <tom@tromey.com>
* tui/tui-regs.h (tui_last_regs_line_no): Don't declare.
* tui/tui-regs.c (tui_data_window::last_regs_line_no): Rename from
tui_last_regs_line_no.
(tui_display_reg_element_at_line)
(tui_display_registers_from_line): Update.
* tui/tui-data.h (struct tui_data_window) <last_regs_line_no>: New
method.
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-data.h | 4 | ||||
-rw-r--r-- | gdb/tui/tui-regs.c | 17 | ||||
-rw-r--r-- | gdb/tui/tui-regs.h | 1 |
3 files changed, 12 insertions, 10 deletions
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 6a243c3..9b1e892 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -490,6 +490,10 @@ struct tui_data_window : public tui_win_info bool display_regs = false; struct reggroup *current_group = nullptr; + /* Answer the number of the last line in the regs display. If there + are no registers (-1) is returned. */ + int last_regs_line_no () const; + 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 32e82b2..e9fbf4b 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -63,18 +63,17 @@ static enum tui_status tui_get_register (struct frame_info *frame, ** PUBLIC FUNCTIONS ** ******************************************/ -/* Answer the number of the last line in the regs display. If there - are no registers (-1) is returned. */ +/* See tui-data.h. */ + int -tui_last_regs_line_no (void) +tui_data_window::last_regs_line_no () const { int num_lines = (-1); - if (!TUI_DATA_WIN->regs_content.empty ()) + if (!regs_content.empty ()) { - num_lines = (TUI_DATA_WIN->regs_content.size () - / TUI_DATA_WIN->regs_column_count); - if (TUI_DATA_WIN->regs_content.size () % TUI_DATA_WIN->regs_column_count) + num_lines = regs_content.size () / regs_column_count; + if (regs_content.size () % regs_column_count) num_lines++; } return num_lines; @@ -354,7 +353,7 @@ tui_display_reg_element_at_line (int start_element_no, { int last_line_no, first_line_on_last_page; - last_line_no = tui_last_regs_line_no (); + last_line_no = TUI_DATA_WIN->last_regs_line_no (); first_line_on_last_page = last_line_no - (TUI_DATA_WIN->height - 2); if (first_line_on_last_page < 0) @@ -390,7 +389,7 @@ tui_display_registers_from_line (int line_no, { /* If we must display regs (force_display is true), then make sure that we don't display off the end of the registers. */ - if (line_no >= tui_last_regs_line_no ()) + if (line_no >= TUI_DATA_WIN->last_regs_line_no ()) { if ((line = tui_line_from_reg_element_no ( TUI_DATA_WIN->regs_content.size () - 1)) < 0) diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index 54b1b08..fcb440d 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -28,7 +28,6 @@ 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, int); -extern int tui_last_regs_line_no (void); extern int tui_first_reg_element_inline (int); extern int tui_line_from_reg_element_no (int); extern int tui_first_reg_element_no_inline (int lineno); |