+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.
+
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-data.h (struct tui_source_window_base): New struct.
switch (ch)
{
case KEY_NPAGE:
- tui_scroll_forward (win_info, 0);
+ win_info->forward_scroll (0);
break;
case KEY_PPAGE:
- tui_scroll_backward (win_info, 0);
+ win_info->backward_scroll (0);
break;
case KEY_DOWN:
case KEY_SF:
- tui_scroll_forward (win_info, 1);
+ win_info->forward_scroll (1);
break;
case KEY_UP:
case KEY_SR:
- tui_scroll_backward (win_info, 1);
+ win_info->backward_scroll (1);
break;
case KEY_RIGHT:
- tui_scroll_left (win_info, 1);
+ win_info->left_scroll (1);
break;
case KEY_LEFT:
- tui_scroll_right (win_info, 1);
+ win_info->right_scroll (1);
break;
case '\f':
break;
explicit tui_win_info (enum tui_win_type type);
DISABLE_COPY_AND_ASSIGN (tui_win_info);
+ /* Scroll the contents vertically. This is only called via
+ forward_scroll and backward_scroll. */
+ virtual void do_scroll_vertical (enum tui_scroll_direction,
+ int num_to_scroll) = 0;
+
+ /* Scroll the contents horizontally. This is only called via
+ left_scroll and right_scroll. */
+ virtual void do_scroll_horizontal (enum tui_scroll_direction,
+ int num_to_scroll) = 0;
+
public:
virtual ~tui_win_info ();
/* Clear the pertinent detail in the window. */
virtual void clear_detail () = 0;
+ /* Methods to scroll the contents of this window. Note that they
+ are named with "_scroll" coming at the end because the more
+ obvious "scroll_forward" is defined as a macro in term.h. */
+ void forward_scroll (int num_to_scroll);
+ void backward_scroll (int num_to_scroll);
+ void left_scroll (int num_to_scroll);
+ void right_scroll (int num_to_scroll);
+
struct tui_gen_win_info generic; /* General window information. */
union
{
~tui_source_window_base () override;
DISABLE_COPY_AND_ASSIGN (tui_source_window_base);
+ void do_scroll_horizontal (enum tui_scroll_direction,
+ int num_to_scroll) override;
+
public:
void clear_detail () override;
}
DISABLE_COPY_AND_ASSIGN (tui_source_window);
+
+protected:
+
+ void do_scroll_vertical (enum tui_scroll_direction,
+ int num_to_scroll) override;
};
/* A TUI disassembly window. */
}
DISABLE_COPY_AND_ASSIGN (tui_disasm_window);
+
+protected:
+
+ void do_scroll_vertical (enum tui_scroll_direction,
+ int num_to_scroll) override;
};
struct tui_data_window : public tui_win_info
DISABLE_COPY_AND_ASSIGN (tui_data_window);
void clear_detail () override;
+
+protected:
+
+ void do_scroll_vertical (enum tui_scroll_direction,
+ int num_to_scroll) override;
+ void do_scroll_horizontal (enum tui_scroll_direction,
+ int num_to_scroll) override
+ {
+ }
};
struct tui_cmd_window : public tui_win_info
DISABLE_COPY_AND_ASSIGN (tui_cmd_window);
void clear_detail () override;
+
+protected:
+
+ void do_scroll_vertical (enum tui_scroll_direction,
+ int num_to_scroll) override
+ {
+ }
+
+ void do_scroll_horizontal (enum tui_scroll_direction,
+ int num_to_scroll) override
+ {
+ }
};
extern int tui_win_is_source_type (enum tui_win_type win_type);
/* Scroll the disassembly forward or backward vertically. */
void
-tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction,
- int num_to_scroll)
+tui_disasm_window::do_scroll_vertical
+ (enum tui_scroll_direction scroll_direction, int num_to_scroll)
{
- if (TUI_DISASM_WIN->generic.content != NULL)
+ if (generic.content != NULL)
{
- struct gdbarch *gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
+ struct gdbarch *gdbarch = detail.source_info.gdbarch;
CORE_ADDR pc;
tui_win_content content;
struct tui_line_or_address val;
int dir;
- content = TUI_DISASM_WIN->generic.content;
+ content = generic.content;
pc = content[0]->which_element.source.line_or_addr.u.addr;
num_to_scroll++;
extern enum tui_status tui_set_disassem_content (struct gdbarch *, CORE_ADDR);
extern void tui_show_disassem (struct gdbarch *, CORE_ADDR);
extern void tui_show_disassem_and_update_source (struct gdbarch *, CORE_ADDR);
-extern void tui_vertical_disassem_scroll (enum tui_scroll_direction,
- int);
extern void tui_get_begin_asm_address (struct gdbarch **, CORE_ADDR *);
#endif /* TUI_TUI_DISASM_H */
/* Scroll the source forward or backward vertically. */
void
-tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction,
- int num_to_scroll)
+tui_source_window::do_scroll_vertical
+ (enum tui_scroll_direction scroll_direction, int num_to_scroll)
{
- if (TUI_SRC_WIN->generic.content != NULL)
+ if (generic.content != NULL)
{
struct tui_line_or_address l;
struct symtab *s;
- tui_win_content content = TUI_SRC_WIN->generic.content;
+ tui_win_content content = generic.content;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
if (cursal.symtab == NULL)
struct tui_line_or_address,
int);
extern int tui_source_is_displayed (const char *);
-extern void tui_vertical_source_scroll (enum tui_scroll_direction,
- int);
#endif /* TUI_TUI_SOURCE_H */
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);
}
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);
}
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);
}
/* 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);
}
/* 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);
}
extern void tui_scroll_backward (struct tui_win_info *, int);
extern void tui_scroll_left (struct tui_win_info *, int);
extern void tui_scroll_right (struct tui_win_info *, int);
-extern void tui_scroll (enum tui_scroll_direction,
- struct tui_win_info *, int);
extern void tui_set_win_focus_to (struct tui_win_info *);
extern void tui_resize_all (void);
extern void tui_refresh_all_win (void);
/* Scroll the data window vertically forward or backward. */
void
-tui_vertical_data_scroll (enum tui_scroll_direction scroll_direction,
- int num_to_scroll)
+tui_data_window::do_scroll_vertical
+ (enum tui_scroll_direction scroll_direction, int num_to_scroll)
{
int first_element_no;
int first_line = (-1);
first_element_no = tui_first_data_item_displayed ();
if (first_element_no
- < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+ < detail.data_display_info.regs_content_count)
first_line = tui_line_from_reg_element_no (first_element_no);
else
{ /* Calculate the first line from the element number which is in
extern void tui_delete_data_content_windows (void);
extern void tui_refresh_data_win (void);
extern void tui_display_data_from (int, int);
-extern void tui_vertical_data_scroll (enum tui_scroll_direction,
- int);
#endif /* TUI_TUI_WINDATA_H */
/* Scroll the source forward or backward horizontally. */
void
-tui_horizontal_source_scroll (struct tui_win_info *win_info,
- enum tui_scroll_direction direction,
- int num_to_scroll)
+tui_source_window_base::do_scroll_horizontal
+ (enum tui_scroll_direction direction, int num_to_scroll)
{
- if (win_info->generic.content != NULL)
+ if (generic.content != NULL)
{
int offset;
if (direction == LEFT_SCROLL)
- offset = win_info->detail.source_info.horizontal_offset
+ offset = detail.source_info.horizontal_offset
+ num_to_scroll;
else
{
- offset = win_info->detail.source_info.horizontal_offset
+ offset = detail.source_info.horizontal_offset
- num_to_scroll;
if (offset < 0)
offset = 0;
}
- win_info->detail.source_info.horizontal_offset = offset;
- tui_refill_source_window (win_info);
+ detail.source_info.horizontal_offset = offset;
+ tui_refill_source_window (this);
}
}
extern void tui_clear_source_content (struct tui_win_info *, int);
extern void tui_erase_source_content (struct tui_win_info *, int);
extern void tui_show_source_content (struct tui_win_info *);
-extern void tui_horizontal_source_scroll (struct tui_win_info *,
- enum tui_scroll_direction,
- int);
extern void tui_refill_source_window (struct tui_win_info *);
extern enum tui_status tui_set_exec_info_content (struct tui_win_info *);
extern void tui_show_exec_info_content (struct tui_win_info *);