sfm

simple file manager
git clone git://git.afify.dev/sfm
Log | Files | Refs | README | LICENSE

commit 700ef1307424cd1e364da406b012c189ec68dfca
parent a11d51a3f1f1ae78de5cae7a45a6641f580caf40
Author: afify <hassan@afify.dev>
Date:   Sat, 12 Jun 2021 07:37:19 +0300

[fix] scroll behaviour (#18)

- return if
	cursor + mov < first
	|| cursor + mov > last row
- fix scroll pane

Diffstat:
Msfm.c | 18++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/sfm.c b/sfm.c @@ -760,20 +760,14 @@ mv_ver(const Arg *arg) if (cpane->dirc < 1) return; - if (cpane->hdir - cpane->firstrow - arg->i < 1) { /* move to the top */ - if (arg->i > 1) - mvtop(arg); + if (cpane->hdir - arg->i < 1) /* first line */ return; - } - if (cpane->hdir - arg->i > cpane->dirc || /* move to the bottom */ - cpane->hdir - cpane->firstrow - arg->i > scrheight - 1) { - if (arg->i < 1) - mvbtm(arg); + + if (cpane->hdir - arg->i > cpane->dirc) /* last line */ return; - } - if (cpane->firstrow > 1 && arg->i > 0 && - cpane->hdir < (cpane->firstrow + arg->i)) { /* scroll up */ + if (cpane->firstrow > 0 && arg->i > 0 && + cpane->hdir <= (cpane->firstrow + arg->i)) { /* scroll up */ cpane->firstrow = cpane->firstrow - arg->i; rm_hi(cpane, cpane->hdir - 1); cpane->hdir = cpane->hdir - arg->i; @@ -782,7 +776,7 @@ mv_ver(const Arg *arg) return; } - if (cpane->hdir - cpane->firstrow >= scrheight - 1 && + if (cpane->hdir - cpane->firstrow >= scrheight + arg->i && arg->i < 0) { /* scroll down */ cpane->firstrow = cpane->firstrow - arg->i; rm_hi(cpane, cpane->hdir - 1);