Skip to content

Commit 647bb75

Browse files
ssbssapalves
authored andcommitted
Fix scrolling right in the TUI
This commit fixes two issues in scrolling right in the TUI: #1 - Scrolling right with the arrow keys, the first keypress doesn't do anything. The problem is that copy_source_line() checks if (column < first_col), and because of the ++column directly before, it basically starts with 1 instead of 0. #2 - Scrolling right handles TABS and escaped characters as single characters, which just looks weird. The problem is that there's a spot that misses handling TABS. gdb/ChangeLog: 2019-03-18 Hannes Domani <ssbssa@yahoo.de> * tui/tui-source.c (copy_source_line): Fix handling of 'column'. Handle tabs.
1 parent bff8c71 commit 647bb75

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

Diff for: gdb/ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019-03-18 Hannes Domani <ssbssa@yahoo.de>
2+
3+
* tui/tui-source.c (copy_source_line): Fix handling of 'column'.
4+
Handle tabs.
5+
16
2019-03-18 Tom Tromey <tromey@adacore.com>
27

38
* ada-lang.c (empty_array): Add "high" parameter.

Diff for: gdb/tui/tui-source.c

+20-10
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,27 @@ copy_source_line (const char **ptr, int line_no, int first_col,
7171

7272
++lineptr;
7373
++column;
74+
75+
auto process_tab = [&] ()
76+
{
77+
int max_tab_len = tui_tab_width;
78+
79+
--column;
80+
for (int j = column % max_tab_len;
81+
j < max_tab_len && column < first_col + line_width;
82+
column++, j++)
83+
if (column >= first_col)
84+
result.push_back (' ');
85+
};
86+
7487
/* We have to process all the text in order to pick up all the
7588
escapes. */
76-
if (column < first_col || column > first_col + line_width)
77-
continue;
89+
if (column <= first_col || column > first_col + line_width)
90+
{
91+
if (c == '\t')
92+
process_tab ();
93+
continue;
94+
}
7895

7996
if (c == '\n' || c == '\r' || c == '\0')
8097
{
@@ -91,14 +108,7 @@ copy_source_line (const char **ptr, int line_no, int first_col,
91108
result.push_back ('?');
92109
}
93110
else if (c == '\t')
94-
{
95-
int j, max_tab_len = tui_tab_width;
96-
97-
for (j = column - ((column / max_tab_len) * max_tab_len);
98-
j < max_tab_len && column < first_col + line_width;
99-
column++, j++)
100-
result.push_back (' ');
101-
}
111+
process_tab ();
102112
else
103113
result.push_back (c);
104114
}

0 commit comments

Comments
 (0)