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.
master
Benno Schulenberg 2016-05-11 13:29:38 +02:00
parent 36df5ceef6
commit 58404e4ba2
1 changed files with 11 additions and 5 deletions

View File

@ -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) {