summaryrefslogtreecommitdiff
path: root/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/ui.c b/ui.c
index 6080f13..e4d2c30 100644
--- a/ui.c
+++ b/ui.c
@@ -158,7 +158,19 @@ ui_draw(Str input, int inpi, int seli, UiOpts o)
XSetFont(dsp, gc, freg->fid);
int y = 64;
- for (int i = 0; i < o.n; i++) {
+
+ int lines = (attr.height - 32) / 24;
+ int tline = lines / 2;
+ int bline = lines - tline;
+ int scroll = seli;
+ if (scroll > o.n - bline) scroll = o.n - bline;
+ if (scroll < tline) scroll = tline;
+ int top = scroll - tline;
+ int bot = scroll + bline;
+ if (top < 0) top = 0;
+ if (bot > o.n) bot = o.n;
+
+ for (int i = top; i < bot; i++) {
if (i == seli) {
int w = XTextWidth(freg, o.v[i].s, o.v[i].n);
XFillRectangle(dsp, win, gc,