aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-06-17 12:56:39 -0600
committerTom Tromey <tom@tromey.com>2019-06-25 07:48:41 -0600
commitc3bd716ffc20cada32e8a18a209638b578d47f5e (patch)
treea3b5f316344b173b61903b7b9d19998716e22914 /gdb
parent21c32dca764039afd3517954f6dd0a23d0c9e16c (diff)
downloadgdb-c3bd716ffc20cada32e8a18a209638b578d47f5e.zip
gdb-c3bd716ffc20cada32e8a18a209638b578d47f5e.tar.gz
gdb-c3bd716ffc20cada32e8a18a209638b578d47f5e.tar.bz2
Remove tui_scroll_direction enum
The tui_scroll_direction enum is not really needed, because it's simple to adapt the various scrolling methods to use the sign of their argument as the direction in which to scroll. gdb/ChangeLog 2019-06-25 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_source_window_base::do_scroll_horizontal): Remove direction parameter. * tui/tui-windata.c (tui_data_window::do_scroll_vertical): Remove direction parameter. * tui/tui-win.c (tui_win_info::forward_scroll) (tui_win_info::backward_scroll, tui_win_info::left_scroll) (tui_win_info::right_scroll): Update. * tui/tui-source.c (tui_source_window::do_scroll_vertical): Remove direction parameter. * tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Remove direction parameter. * tui/tui-data.h (enum tui_scroll_direction): Remove. (struct tui_win_info) <do_scroll_vertical, do_scroll_horizontal>: Remove direction parameter. (struct tui_source_window_base, struct tui_source_window) (struct tui_disasm_window, struct tui_data_window) (struct tui_cmd_window): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog21
-rw-r--r--gdb/tui/tui-data.h37
-rw-r--r--gdb/tui/tui-disasm.c13
-rw-r--r--gdb/tui/tui-source.c29
-rw-r--r--gdb/tui/tui-win.c8
-rw-r--r--gdb/tui/tui-windata.c8
-rw-r--r--gdb/tui/tui-winsource.c16
7 files changed, 56 insertions, 76 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 43f8a5d..2e6b47e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,26 @@
2019-06-25 Tom Tromey <tom@tromey.com>
+ * tui/tui-winsource.c
+ (tui_source_window_base::do_scroll_horizontal): Remove direction
+ parameter.
+ * tui/tui-windata.c (tui_data_window::do_scroll_vertical): Remove
+ direction parameter.
+ * tui/tui-win.c (tui_win_info::forward_scroll)
+ (tui_win_info::backward_scroll, tui_win_info::left_scroll)
+ (tui_win_info::right_scroll): Update.
+ * tui/tui-source.c (tui_source_window::do_scroll_vertical): Remove
+ direction parameter.
+ * tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Remove
+ direction parameter.
+ * tui/tui-data.h (enum tui_scroll_direction): Remove.
+ (struct tui_win_info) <do_scroll_vertical, do_scroll_horizontal>:
+ Remove direction parameter.
+ (struct tui_source_window_base, struct tui_source_window)
+ (struct tui_disasm_window, struct tui_data_window)
+ (struct tui_cmd_window): Update.
+
+2019-06-25 Tom Tromey <tom@tromey.com>
+
* tui/tui-winsource.h (tui_set_exec_info_content)
(tui_show_exec_info_content, tui_erase_exec_info_content)
(tui_clear_exec_info_content, tui_update_exec_info): Change
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index d977c57..59d1900 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -122,16 +122,6 @@ struct tui_gen_win_info
#define MAX_TARGET_WIDTH 10
#define MAX_PID_WIDTH 19
-/* Scroll direction enum. */
-enum tui_scroll_direction
-{
- FORWARD_SCROLL,
- BACKWARD_SCROLL,
- LEFT_SCROLL,
- RIGHT_SCROLL
-};
-
-
/* The kinds of layouts available. */
enum tui_layout_type
{
@@ -264,13 +254,11 @@ protected:
/* 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;
+ virtual void do_scroll_vertical (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;
+ virtual void do_scroll_horizontal (int num_to_scroll) = 0;
public:
@@ -337,8 +325,7 @@ protected:
~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;
+ void do_scroll_horizontal (int num_to_scroll) override;
public:
@@ -396,8 +383,7 @@ struct tui_source_window : public tui_source_window_base
protected:
- void do_scroll_vertical (enum tui_scroll_direction,
- int num_to_scroll) override;
+ void do_scroll_vertical (int num_to_scroll) override;
};
/* A TUI disassembly window. */
@@ -418,8 +404,7 @@ struct tui_disasm_window : public tui_source_window_base
protected:
- void do_scroll_vertical (enum tui_scroll_direction,
- int num_to_scroll) override;
+ void do_scroll_vertical (int num_to_scroll) override;
};
struct tui_data_window : public tui_win_info
@@ -457,10 +442,8 @@ struct tui_data_window : public tui_win_info
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
+ void do_scroll_vertical (int num_to_scroll) override;
+ void do_scroll_horizontal (int num_to_scroll) override
{
}
};
@@ -495,13 +478,11 @@ struct tui_cmd_window : public tui_win_info
protected:
- void do_scroll_vertical (enum tui_scroll_direction,
- int num_to_scroll) override
+ void do_scroll_vertical (int num_to_scroll) override
{
}
- void do_scroll_horizontal (enum tui_scroll_direction,
- int num_to_scroll) override
+ void do_scroll_horizontal (int num_to_scroll) override
{
}
};
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 0bc7c64..b3d39ea 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -371,22 +371,21 @@ tui_get_low_disassembly_address (struct gdbarch *gdbarch,
/* Scroll the disassembly forward or backward vertically. */
void
-tui_disasm_window::do_scroll_vertical
- (enum tui_scroll_direction scroll_direction, int num_to_scroll)
+tui_disasm_window::do_scroll_vertical (int num_to_scroll)
{
if (content != NULL)
{
CORE_ADDR pc;
struct tui_line_or_address val;
- int dir;
pc = content[0]->which_element.source.line_or_addr.u.addr;
- num_to_scroll++;
- dir = (scroll_direction == FORWARD_SCROLL)
- ? num_to_scroll : -num_to_scroll;
+ if (num_to_scroll >= 0)
+ num_to_scroll++;
+ else
+ --num_to_scroll;
val.loa = LOA_ADDRESS;
- val.u.addr = tui_find_disassembly_address (gdbarch, pc, dir);
+ val.u.addr = tui_find_disassembly_address (gdbarch, pc, num_to_scroll);
tui_update_source_window_as_is (this, gdbarch,
NULL, val, FALSE);
}
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 39abe81..54e53cf 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -308,8 +308,7 @@ tui_source_is_displayed (const char *fullname)
/* Scroll the source forward or backward vertically. */
void
-tui_source_window::do_scroll_vertical
- (enum tui_scroll_direction scroll_direction, int num_to_scroll)
+tui_source_window::do_scroll_vertical (int num_to_scroll)
{
if (content != NULL)
{
@@ -323,23 +322,15 @@ tui_source_window::do_scroll_vertical
s = cursal.symtab;
l.loa = LOA_LINE;
- if (scroll_direction == FORWARD_SCROLL)
- {
- l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
- + num_to_scroll;
- if (l.u.line_no > s->nlines)
- /* line = s->nlines - win_info->content_size + 1; */
- /* elz: fix for dts 23398. */
- l.u.line_no
- = content[0]->which_element.source.line_or_addr.u.line_no;
- }
- else
- {
- l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
- - num_to_scroll;
- if (l.u.line_no <= 0)
- l.u.line_no = 1;
- }
+ l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
+ + num_to_scroll;
+ if (l.u.line_no > s->nlines)
+ /* line = s->nlines - win_info->content_size + 1; */
+ /* elz: fix for dts 23398. */
+ l.u.line_no
+ = content[0]->which_element.source.line_or_addr.u.line_no;
+ if (l.u.line_no <= 0)
+ l.u.line_no = 1;
print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 33dcb3b..22938b4 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -475,7 +475,7 @@ tui_win_info::forward_scroll (int num_to_scroll)
if (num_to_scroll == 0)
num_to_scroll = height - 3;
- do_scroll_vertical (FORWARD_SCROLL, num_to_scroll);
+ do_scroll_vertical (num_to_scroll);
}
void
@@ -484,7 +484,7 @@ tui_win_info::backward_scroll (int num_to_scroll)
if (num_to_scroll == 0)
num_to_scroll = height - 3;
- do_scroll_vertical (BACKWARD_SCROLL, num_to_scroll);
+ do_scroll_vertical (-num_to_scroll);
}
@@ -494,7 +494,7 @@ tui_win_info::left_scroll (int num_to_scroll)
if (num_to_scroll == 0)
num_to_scroll = 1;
- do_scroll_horizontal (LEFT_SCROLL, num_to_scroll);
+ do_scroll_horizontal (num_to_scroll);
}
@@ -504,7 +504,7 @@ tui_win_info::right_scroll (int num_to_scroll)
if (num_to_scroll == 0)
num_to_scroll = 1;
- do_scroll_horizontal (RIGHT_SCROLL, num_to_scroll);
+ do_scroll_horizontal (-num_to_scroll);
}
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 739272a..c559345 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -243,8 +243,7 @@ tui_check_data_values (struct frame_info *frame)
/* Scroll the data window vertically forward or backward. */
void
-tui_data_window::do_scroll_vertical
- (enum tui_scroll_direction scroll_direction, int num_to_scroll)
+tui_data_window::do_scroll_vertical (int num_to_scroll)
{
int first_element_no;
int first_line = (-1);
@@ -259,10 +258,7 @@ tui_data_window::do_scroll_vertical
if (first_line >= 0)
{
- if (scroll_direction == FORWARD_SCROLL)
- first_line += num_to_scroll;
- else
- first_line -= num_to_scroll;
+ first_line += num_to_scroll;
tui_erase_data_content (NULL);
tui_delete_data_content_windows ();
tui_display_data_from_line (first_line);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index e55ce40..e56fbcb 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -332,21 +332,13 @@ tui_source_window_base::refill ()
/* Scroll the source forward or backward horizontally. */
void
-tui_source_window_base::do_scroll_horizontal
- (enum tui_scroll_direction direction, int num_to_scroll)
+tui_source_window_base::do_scroll_horizontal (int num_to_scroll)
{
if (content != NULL)
{
- int offset;
-
- if (direction == LEFT_SCROLL)
- offset = horizontal_offset + num_to_scroll;
- else
- {
- offset = horizontal_offset - num_to_scroll;
- if (offset < 0)
- offset = 0;
- }
+ int offset = horizontal_offset + num_to_scroll;
+ if (offset < 0)
+ offset = 0;
horizontal_offset = offset;
refill ();
}