| Date: Fri, 1 Sep 2017 16:09:47 +0200
Add keys to scroll to next/prev browseable entry
Diffstat:
config.def.h | 2 ++
ui_ti.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
--- |
| t@@ -2,7 +2,9 @@
/* Screen UI navigation keys */
#define _key_lndown 'j' /* move one line down */
+#define _key_entrydown 'J' /* move to next link */
#define _key_lnup 'k' /* move one line up */
+#define _key_entryup 'K' /* move to next link */
#define _key_pgdown ' ' /* move one screen down */
#define _key_pgup 'b' /* move one screen up */
#define _key_home 'g' /* move to the top of page */ |
| t@@ -334,6 +334,25 @@ jumptoline(Item *entry, ssize_t line, int absolute)
return;
}
+static ssize_t
+nearentry(Item *entry, int direction)
+{
+ Dir *dir = entry->dat;
+ size_t item, lastitem;
+
+ if (!dir)
+ return -1;
+ lastitem = dir->nitems;
+ item = dir->curline + direction;
+
+ for (; item >= 0 && item < lastitem; item += direction) {
+ if (dir->items[item]->type != 'i')
+ return item;
+ }
+
+ return dir->curline;
+}
+
Item *
uiselectitem(Item *entry)
{
t@@ -394,6 +413,9 @@ uiselectitem(Item *entry)
lndown:
movecurline(entry, 1);
continue;
+ case _key_entrydown:
+ jumptoline(entry, nearentry(entry, 1), 1);
+ continue;
case _key_pgdown:
pgdown:
jumptoline(entry, dir->printoff + plines, 0);
t@@ -406,6 +428,9 @@ uiselectitem(Item *entry)
lnup:
movecurline(entry, -1);
continue;
+ case _key_entryup:
+ jumptoline(entry, nearentry(entry, -1), 1);
+ continue;
case _key_pgup:
pgup:
jumptoline(entry, dir->printoff - plines, 0); |