Commit 58404e4b authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

browser: keep the highlight in the same spot or column, when possible

When doing a PageUp or PageDown in the browser, don't move the highlight
to the first line in the same column, but keep it in the same relative
position of the screen.  If we're already on the first or last page,
move the highlight to the first or last line, but keep it in the same
column.  If we're already on the first or last line, only then move it
to the first or last entry.
No related merge requests found
Showing with 11 additions and 5 deletions
+11 -5
......@@ -187,14 +187,20 @@ char *do_browser(char *path, DIR *dir)
/* Search for another filename. */
do_fileresearch();
} else if (func == do_page_up) {
if (selected >= (editwinrows + fileline % editwinrows) * width)
selected -= (editwinrows + fileline % editwinrows) * width;
else
if (selected < width)
selected = 0;
else if (selected < editwinrows * width)
selected = selected % width;
else
selected -= editwinrows * width;
} else if (func == do_page_down) {
selected += (editwinrows - fileline % editwinrows) * width;
if (selected > filelist_len - 1)
if (selected + width >= filelist_len - 1)
selected = filelist_len - 1;
else if (selected + editwinrows * width >= filelist_len)
selected = (selected + editwinrows * width - filelist_len) %
width + filelist_len - width;
else
selected += editwinrows * width;
} else if (func == do_first_file) {
selected = 0;
} else if (func == do_last_file) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment