aboutsummaryrefslogtreecommitdiffstats
path: root/src/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-05-04 06:17:38 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-05-04 06:17:38 +0530
commit625c8d11f48e4f76f559559021c057479dc0652d (patch)
tree916c22e75dd0c05a2c8427e829deb911586e1727 /src/nnn.c
parentf2fd92357384a79e31177fbd3d8c272c865b5302 (diff)
downloadnnn-625c8d11f48e4f76f559559021c057479dc0652d.tar.gz
Refactor move_cursor()
Diffstat (limited to 'src/nnn.c')
-rw-r--r--src/nnn.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 6c46db0..1a2ad77 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4669,15 +4669,17 @@ static void populate(char *path, char *lastname)
static void move_cursor(int target, int ignore_scrolloff)
{
- int delta, scrolloff, onscreen = xlines - 4;
+ int onscreen = xlines - 4; /* Leave top 2 and bottom 2 lines */
- last_curscroll = curscroll;
target = MAX(0, MIN(ndents - 1, target));
- delta = target - cur;
+ last_curscroll = curscroll;
last = cur;
cur = target;
+
if (!ignore_scrolloff) {
- scrolloff = MIN(SCROLLOFF, onscreen >> 1);
+ int delta = target - last;
+ int scrolloff = MIN(SCROLLOFF, onscreen >> 1);
+
/*
* When ignore_scrolloff is 1, the cursor can jump into the scrolloff
* margin area, but when ignore_scrolloff is 0, act like a boa