t* sacc + cursorline and uri preview
       
   URI git clone git://git.codevoid.de/sacc-sdk
   DIR Log
   DIR Files
   DIR Refs
   DIR LICENSE
       ---
   DIR commit f4e8624533fdf8beac682088523b91f14b44e920
   DIR parent f649b76d536427fbd735f77958aad9d41e1e580e
   URI Author: Quentin Rameau <quinq@fifth.space>
       Date:   Fri,  7 Jul 2017 20:53:56 +0200
       
       Add home, end, page up, page down scrolling
       
       Thanks to Hiltjo for the suggestion and work on the patch!
       
       Diffstat:
         M ui_ti.c                             |      69 ++++++++++++++++++++++++++++++
         M ui_txt.c                            |      18 +++++++++++++++---
       
       2 files changed, 84 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/ui_ti.c b/ui_ti.c
       t@@ -10,6 +10,10 @@ static struct termios tsave;
        /* navigation keys */
        #define _key_lndown        'j' /* move one line down */
        #define _key_lnup        'k' /* move one line up */
       +#define _key_pgdown        ' ' /* move one screen down */
       +#define _key_pgup        'b' /* move one screen down */
       +#define _key_home        'g' /* move to the top of page */
       +#define _key_end        'G' /* move to the bottom of page */
        #define _key_pgnext        'l' /* view highlighted item */
        #define _key_pgprev        'h' /* view previous item */
        #define _key_fetch        'L' /* refetch current item */
       t@@ -165,10 +169,44 @@ movecurline(Item *item, int l)
                fflush(stdout);
        }
        
       +static void
       +jumptoline(Item *entry, ssize_t offset)
       +{
       +        size_t nitems;
       +        int plines = lines-2;
       +
       +        if (!entry->dir)
       +                return;
       +
       +        nitems = entry->dir->nitems;
       +
       +        if (offset <= 0) {
       +                if (!entry->curline)
       +                        return;
       +                entry->printoff = 0;
       +                entry->curline = 0;
       +        } else if (offset + plines > nitems) {
       +                if (entry->curline == nitems-1)
       +                        return;
       +                if (nitems > plines)
       +                        entry->printoff = nitems-1 - plines;
       +                else
       +                        entry->printoff = 0;
       +                entry->curline = nitems-1;
       +        } else {
       +                entry->printoff = offset;
       +                entry->curline = entry->printoff;
       +        }
       +
       +        display(entry);
       +        return;
       +}
       +
        Item *
        selectitem(Item *entry)
        {
                Dir *dir = entry->dir;
       +        int plines = lines-2;
        
                for (;;) {
                        switch (getchar()) {
       t@@ -182,6 +220,18 @@ selectitem(Item *entry)
                                        continue;
                                }
                                switch (getchar()) {
       +                        case '4':
       +                                if (getchar() != '~')
       +                                        continue;
       +                                goto end;
       +                        case '5':
       +                                if (getchar() != '~')
       +                                        continue;
       +                                goto pgup;
       +                        case '6':
       +                                if (getchar() != '~')
       +                                        continue;
       +                                goto pgdown;
                                case 'A':
                                        goto lnup;
                                case 'B':
       t@@ -190,6 +240,8 @@ selectitem(Item *entry)
                                        goto pgnext;
                                case 'D':
                                        goto pgprev;
       +                        case 'H':
       +                                goto home;
                                case 0x1b:
                                        goto quit;
                                }
       t@@ -207,14 +259,31 @@ selectitem(Item *entry)
                        lndown:
                                movecurline(entry, 1);
                                continue;
       +                case _key_pgdown:
       +                pgdown:
       +                        jumptoline(entry, entry->printoff + plines);
       +                        continue;
       +                case _key_end:
       +                end:
       +                        jumptoline(entry, entry->dir->nitems);
       +                        continue;
                        case _key_lnup:
                        lnup:
                                movecurline(entry, -1);
                                continue;
       +                case _key_pgup:
       +                pgup:
       +                        jumptoline(entry, entry->printoff - plines);
       +                        continue;
       +                case _key_home:
       +                home:
       +                        jumptoline(entry, 0);
       +                        continue;
                        case _key_quit:
                        quit:
                                return NULL;
                        case _key_fetch:
       +                fetch:
                                if (entry->raw)
                                        continue;
                                return entry;
   DIR diff --git a/ui_txt.c b/ui_txt.c
       t@@ -40,6 +40,8 @@ help(void)
                     "0: browse previous item.\n"
                     "n: show next page.\n"
                     "p: show previous page.\n"
       +             "t: go to the top of the page\n"
       +             "b: go to the bottom of the page\n"
                     "!: refetch failed item.\n"
                     "^D, q: quit.\n"
                     "h: this help.");
       t@@ -98,6 +100,7 @@ selectitem(Item *entry)
                nitems = entry->dir ? entry->dir->nitems : 0;
        
                do {
       +                item = -1;
                        printstatus(entry);
                        fflush(stdout);
        
       t@@ -123,14 +126,23 @@ selectitem(Item *entry)
                                        entry->printoff = 0;
                                return entry;
                        }
       -
       +                if (!strcmp(buf, "b\n")) {
       +                        lines = termlines();
       +                        if (nitems > lines)
       +                                entry->printoff = nitems - lines;
       +                        else
       +                                entry->printoff = 0;
       +                        return entry;
       +                }
       +                if (!strcmp(buf, "t\n")) {
       +                        entry->printoff = 0;
       +                        return entry;
       +                }
                        if (!strcmp(buf, "!\n")) {
                                if (entry->raw)
                                        continue;
                                return entry;
                        }
       -
       -                item = -1;
                        if (!strcmp(buf, "h\n")) {
                                help();
                                continue;