From c971822bff00dc74e7038d8e0e9041d205e44a83 Mon Sep 17 00:00:00 2001 From: katalx Date: Wed, 28 Jan 2026 23:29:37 -0500 Subject: only draw visible lines --- ui.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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, -- cgit v1.2.3