From: elig0n <eliran.gonen@gmail.com>
Date: Sat, 20 Apr 2019 20:25:15 +0000 (+0300)
Subject: Differentiate half-page Ctrl+U/D and pageful PageDN/UP movement keys
X-Git-Tag: v2.5~87^2
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=a3eb617dc6c666dd36bd1e4c9aad771365e8d2d3;p=nnn.git

Differentiate half-page Ctrl+U/D and pageful PageDN/UP movement keys
---

diff --git a/src/nnn.c b/src/nnn.c
index 05d1a266..54d1c664 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3062,9 +3062,17 @@ nochange:
 			break;
 		case SEL_PGDN:
 			if (cur < ndents - 1)
-				cur += MIN((xlines - 4) / 2, ndents - 1 - cur);
+				cur += MIN((xlines - 4), ndents - 1 - cur);
 			break;
 		case SEL_PGUP:
+			if (cur > 0)
+				cur -= MIN((xlines - 4), cur);
+			break;
+		case SEL_CTRL_D:
+			if (cur < ndents - 1)
+				cur += MIN((xlines - 4) / 2, ndents - 1 - cur);
+			break;
+		case SEL_CTRL_U:
 			if (cur > 0)
 				cur -= MIN((xlines - 4) / 2, cur);
 			break;
diff --git a/src/nnn.h b/src/nnn.h
index dd21ef5b..bc0561dd 100644
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -43,6 +43,8 @@ enum action {
 	SEL_PREV,
 	SEL_PGDN,
 	SEL_PGUP,
+	SEL_CTRL_D,
+	SEL_CTRL_U,
 	SEL_HOME,
 	SEL_END,
 	SEL_CDHOME,
@@ -124,10 +126,12 @@ static struct key bindings[] = {
 	{ KEY_UP,         SEL_PREV },
 	/* Page down */
 	{ KEY_NPAGE,      SEL_PGDN },
-	{ CONTROL('D'),   SEL_PGDN },
 	/* Page up */
 	{ KEY_PPAGE,      SEL_PGUP },
-	{ CONTROL('U'),   SEL_PGUP },
+	/* Ctrl+D */
+	{ CONTROL('D'),   SEL_CTRL_D },
+	/* Ctrl+U */
+	{ CONTROL('U'),   SEL_CTRL_U },
 	/* First entry */
 	{ KEY_HOME,       SEL_HOME },
 	{ 'g',            SEL_HOME },