Browse Source

Add keys to scroll to next/prev browseable entry

master
Quentin Rameau 5 years ago
parent
commit
90277d09e3
  1. 2
      config.def.h
  2. 25
      ui_ti.c

2
config.def.h

@ -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 */

25
ui_ti.c

@ -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)
{
@ -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);
@ -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);

Loading…
Cancel
Save