ref: b75e90e18afb5b98cc4dec00224e2a79d69ab356
parent: 7ad0e7ef7f494a83a2240ab548b6f4ad321ca345
author: phil9 <[email protected]>
date: Thu Dec 29 05:27:40 EST 2022
improve panel scrolling always fill the whole file listing panel when scrolling by adapting the list offset.
--- a/dirviewcmd.c
+++ b/dirviewcmd.c
@@ -346,6 +346,8 @@
return;
if(p->cursor == 0){
p->offset -= p->nlines;
+ if(p->offset < 0)
+ p->offset = 0;
p->cursor = p->nlines -1;
}else{
p->cursor -= 1;
@@ -366,6 +368,8 @@
if(p->cursor == p->nlines - 1){
p->offset += p->nlines;
p->cursor = 0;
+ if(dirmodelcount(p->model)-p->offset < p->nlines)
+ p->offset = dirmodelcount(p->model) - p->nlines;
}else{
p->cursor += 1;
}
@@ -389,6 +393,10 @@
p = dirviewcurrentpanel(dview);
p->offset = p->nlines * (dirmodelcount(p->model) / p->nlines);
+ if(dirmodelcount(p->model)-p->offset < p->nlines)
+ p->offset = dirmodelcount(p->model) - p->nlines;
+ if(p->offset < 0)
+ p->offset = 0;
p->cursor = dirmodelcount(p->model) - p->offset - 1;
dirpanelredrawnotify(p);
}
@@ -405,6 +413,8 @@
p->cursor = 0;
else
p->offset -= p->nlines;
+ if(p->offset < 0)
+ p->offset = 0;
dirpanelredrawnotify(p);
}
@@ -418,9 +428,11 @@
end = dirmodelcount(p->model) - p->offset - 1;
if(p->offset + p->nlines >= dirmodelcount(p->model) && p->cursor == end)
return;
- if(p->offset + p->nlines < dirmodelcount(p->model))
+ if(p->offset + p->nlines < dirmodelcount(p->model)){
p->offset += p->nlines;
- else
+ if(dirmodelcount(p->model)-p->offset < p->nlines)
+ p->offset = dirmodelcount(p->model) - p->nlines;
+ }else
p->cursor = end;
if(p->cursor > end)
p->cursor = end;