diff options
author | Tom Tromey <tom@tromey.com> | 2019-06-16 11:22:38 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-06-25 07:48:28 -0600 |
commit | 13446e05a363db17f0140b1450fc7df509d2ca37 (patch) | |
tree | 53c7c5c1185dc018da379af4297d812040e60a37 /gdb/tui/tui-win.c | |
parent | 5cf82909a7047cee471ee40cfe623250c258d76e (diff) | |
download | gdb-13446e05a363db17f0140b1450fc7df509d2ca37.zip gdb-13446e05a363db17f0140b1450fc7df509d2ca37.tar.gz gdb-13446e05a363db17f0140b1450fc7df509d2ca37.tar.bz2 |
Introduce methods for scrolling
This changes the TUI to use virtual methods on the various window
types for scrolling. Window-specific functions for this purpose are
renamed to be methods, and the generic tui_scroll function is removed
as it is no longer called.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (tui_horizontal_source_scroll): Don't
declare.
* tui/tui-winsource.c
(tui_source_window_base::do_scroll_horizontal): Rename from
tui_horizontal_source_scroll.
* tui/tui-windata.h (tui_vertical_data_scroll): Don't declare.
* tui/tui-windata.c (tui_data_window::do_scroll_vertical): Rename
from tui_vertical_data_scroll.
* tui/tui-win.h (tui_scroll): Don't declare.
* tui/tui-win.c (tui_win_info::forward_scroll)
(tui_win_info::backward_scroll, tui_win_info::left_scroll)
(tui_win_info::right_scroll): Rename and update.
(tui_scroll_forward_command, tui_scroll_backward_command)
(tui_scroll_left_command, tui_scroll_right_command): Update.
(tui_scroll): Remove.
* tui/tui-source.h: Don't declare tui_vertical_source_scroll.
* tui/tui-source.c (tui_source_window::do_scroll_vertical): Rename
from tui_vertical_source_scroll.
* tui/tui-disasm.h (tui_vertical_disassem_scroll): Don't declare.
* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Rename
from tui_vertical_disassem_scroll.
* tui/tui-data.h (struct tui_win_info) <do_scroll_vertical,
do_scroll_horizontal>: New methods.
<forward_scroll, backward_scroll, left_scroll, right_scroll>:
Likewise.
(struct tui_source_window_base): Add do_scroll_horizontal.
(struct tui_source_window, struct tui_disasm_window): Add
do_scroll_vertical.
(struct tui_data_window, struct tui_cmd_window): Add
do_scroll_horizontal and do_scroll_vertical.
* tui/tui-command.c (tui_dispatch_ctrl_char): Use method calls.
Diffstat (limited to 'gdb/tui/tui-win.c')
-rw-r--r-- | gdb/tui/tui-win.c | 130 |
1 files changed, 23 insertions, 107 deletions
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 21a9946..4dad144 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -470,125 +470,41 @@ tui_set_win_focus_to (struct tui_win_info *win_info) void -tui_scroll_forward (struct tui_win_info *win_to_scroll, - int num_to_scroll) +tui_win_info::forward_scroll (int num_to_scroll) { - if (win_to_scroll != TUI_CMD_WIN) - { - int _num_to_scroll = num_to_scroll; - - if (num_to_scroll == 0) - _num_to_scroll = win_to_scroll->generic.height - 3; - - /* If we are scrolling the source or disassembly window, do a - "psuedo" scroll since not all of the source is in memory, - only what is in the viewport. If win_to_scroll is the - command window do nothing since the term should handle - it. */ - if (win_to_scroll == TUI_SRC_WIN) - tui_vertical_source_scroll (FORWARD_SCROLL, _num_to_scroll); - else if (win_to_scroll == TUI_DISASM_WIN) - tui_vertical_disassem_scroll (FORWARD_SCROLL, _num_to_scroll); - else if (win_to_scroll == TUI_DATA_WIN) - tui_vertical_data_scroll (FORWARD_SCROLL, _num_to_scroll); - } -} + if (num_to_scroll == 0) + num_to_scroll = generic.height - 3; -void -tui_scroll_backward (struct tui_win_info *win_to_scroll, - int num_to_scroll) -{ - if (win_to_scroll != TUI_CMD_WIN) - { - int _num_to_scroll = num_to_scroll; - - if (num_to_scroll == 0) - _num_to_scroll = win_to_scroll->generic.height - 3; - - /* If we are scrolling the source or disassembly window, do a - "psuedo" scroll since not all of the source is in memory, - only what is in the viewport. If win_to_scroll is the - command window do nothing since the term should handle - it. */ - if (win_to_scroll == TUI_SRC_WIN) - tui_vertical_source_scroll (BACKWARD_SCROLL, _num_to_scroll); - else if (win_to_scroll == TUI_DISASM_WIN) - tui_vertical_disassem_scroll (BACKWARD_SCROLL, _num_to_scroll); - else if (win_to_scroll == TUI_DATA_WIN) - tui_vertical_data_scroll (BACKWARD_SCROLL, _num_to_scroll); - } + do_scroll_vertical (FORWARD_SCROLL, num_to_scroll); } - void -tui_scroll_left (struct tui_win_info *win_to_scroll, - int num_to_scroll) +tui_win_info::backward_scroll (int num_to_scroll) { - if (win_to_scroll != TUI_CMD_WIN) - { - int _num_to_scroll = num_to_scroll; - - if (_num_to_scroll == 0) - _num_to_scroll = 1; - - /* If we are scrolling the source or disassembly window, do a - "psuedo" scroll since not all of the source is in memory, - only what is in the viewport. If win_to_scroll is the command - window do nothing since the term should handle it. */ - if (win_to_scroll == TUI_SRC_WIN - || win_to_scroll == TUI_DISASM_WIN) - tui_horizontal_source_scroll (win_to_scroll, LEFT_SCROLL, - _num_to_scroll); - } + if (num_to_scroll == 0) + num_to_scroll = generic.height - 3; + + do_scroll_vertical (BACKWARD_SCROLL, num_to_scroll); } void -tui_scroll_right (struct tui_win_info *win_to_scroll, - int num_to_scroll) +tui_win_info::left_scroll (int num_to_scroll) { - if (win_to_scroll != TUI_CMD_WIN) - { - int _num_to_scroll = num_to_scroll; - - if (_num_to_scroll == 0) - _num_to_scroll = 1; - - /* If we are scrolling the source or disassembly window, do a - "psuedo" scroll since not all of the source is in memory, - only what is in the viewport. If win_to_scroll is the command - window do nothing since the term should handle it. */ - if (win_to_scroll == TUI_SRC_WIN - || win_to_scroll == TUI_DISASM_WIN) - tui_horizontal_source_scroll (win_to_scroll, RIGHT_SCROLL, - _num_to_scroll); - } + if (num_to_scroll == 0) + num_to_scroll = 1; + + do_scroll_horizontal (LEFT_SCROLL, num_to_scroll); } -/* Scroll a window. Arguments are passed through a va_list. */ void -tui_scroll (enum tui_scroll_direction direction, - struct tui_win_info *win_to_scroll, - int num_to_scroll) +tui_win_info::right_scroll (int num_to_scroll) { - switch (direction) - { - case FORWARD_SCROLL: - tui_scroll_forward (win_to_scroll, num_to_scroll); - break; - case BACKWARD_SCROLL: - tui_scroll_backward (win_to_scroll, num_to_scroll); - break; - case LEFT_SCROLL: - tui_scroll_left (win_to_scroll, num_to_scroll); - break; - case RIGHT_SCROLL: - tui_scroll_right (win_to_scroll, num_to_scroll); - break; - default: - break; - } + if (num_to_scroll == 0) + num_to_scroll = 1; + + do_scroll_horizontal (RIGHT_SCROLL, num_to_scroll); } @@ -880,7 +796,7 @@ tui_scroll_forward_command (const char *arg, int from_tty) parse_scrolling_args (arg, &win_to_scroll, NULL); else parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); - tui_scroll (FORWARD_SCROLL, win_to_scroll, num_to_scroll); + win_to_scroll->forward_scroll (num_to_scroll); } @@ -896,7 +812,7 @@ tui_scroll_backward_command (const char *arg, int from_tty) parse_scrolling_args (arg, &win_to_scroll, NULL); else parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); - tui_scroll (BACKWARD_SCROLL, win_to_scroll, num_to_scroll); + win_to_scroll->backward_scroll (num_to_scroll); } @@ -909,7 +825,7 @@ tui_scroll_left_command (const char *arg, int from_tty) /* Make sure the curses mode is enabled. */ tui_enable (); parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); - tui_scroll (LEFT_SCROLL, win_to_scroll, num_to_scroll); + win_to_scroll->left_scroll (num_to_scroll); } @@ -922,7 +838,7 @@ tui_scroll_right_command (const char *arg, int from_tty) /* Make sure the curses mode is enabled. */ tui_enable (); parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); - tui_scroll (RIGHT_SCROLL, win_to_scroll, num_to_scroll); + win_to_scroll->right_scroll (num_to_scroll); } |