Adjust cursor place when moving around pages - sacc - sacc(omys), simple console gopher client (HTM) git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/ (DIR) Log (DIR) Files (DIR) Refs (DIR) Tags (DIR) LICENSE --- (DIR) commit 9cc56dc59541a6a7d71faab023000516b74bf994 (DIR) parent f4e8624533fdf8beac682088523b91f14b44e920 (HTM) Author: Quentin Rameau <quinq@fifth.space> Date: Fri, 7 Jul 2017 22:00:01 +0200 Adjust cursor place when moving around pages Diffstat: M ui_ti.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) --- (DIR) diff --git a/ui_ti.c b/ui_ti.c @@ -185,17 +185,23 @@ jumptoline(Item *entry, ssize_t offset) 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; + } else if (offset + plines < nitems) { + entry->printoff = offset; + entry->curline = offset; + } else if (entry->curline == nitems-1) { + return; + } else if (nitems < plines) { + entry->curline = nitems-1; + } else if (offset == nitems) { + entry->printoff = nitems-1 - plines; entry->curline = nitems-1; } else { + offset = nitems-1 - plines; + if (entry->printoff == offset) + entry->curline = nitems-1; + else if (entry->curline < offset) + entry->curline = offset; entry->printoff = offset; - entry->curline = entry->printoff; } display(entry);