commit ee6867a7b3c703e45c264d3b99ac0b9ef2c0fcdc
parent 76c376f48cd317fdf2f4a4b6e8b9bb4b3127f075
Author: Claudio Alessi <smoppy@gmail.com>
Date: Sun, 30 Jul 2017 18:37:35 +0200
Proper initial scroll offset.
Diffstat:
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/circo.c b/circo.c
@@ -914,6 +914,10 @@ resize(int x, int y) {
void
scroll(const Arg *arg) {
+ int bufh = rows - 2;
+
+ if(sel->nlines <= bufh)
+ return;
if(arg->i == 0) {
sel->line = 0;
sel->lnoff = 0;
@@ -921,12 +925,12 @@ scroll(const Arg *arg) {
return;
}
if(!sel->line)
- sel->line = sel->nlines;
+ sel->line = sel->nlines - bufh + 1;
sel->line += arg->i;
if(sel->line < 1)
sel->line = 1;
- else if(sel->line > sel->nlines)
- sel->line = sel->nlines;
+ else if(sel->line > sel->nlines - bufh)
+ sel->line = 0;
sel->lnoff = bufinfo(sel->data, sel->len, sel->line, LineToOffset);
sel->need_redraw = 1;
}
diff --git a/config.def.h b/config.def.h
@@ -31,8 +31,8 @@ static Key keys[] = {
{ KeyRight, cmdln_cursor, {.i = +1}},
{ CTRL('n'), focusnext, {0} },
{ CTRL('p'), focusprev, {0} },
- { KeyPgUp, scroll, {.i = -1} },
- { KeyPgDw, scroll, {.i = +1} },
+ { KeyPgUp, scroll, {.i = -20} },
+ { KeyPgDw, scroll, {.i = +20} },
{ KeyEnd, scroll, {.i = 0} },
{ KeyUp, history, {.i = -1} },
{ KeyDown, history, {.i = +1} },