diff options
| author | katalx | 2026-01-28 23:29:37 -0500 |
|---|---|---|
| committer | katalx | 2026-01-28 23:29:37 -0500 |
| commit | c971822bff00dc74e7038d8e0e9041d205e44a83 (patch) | |
| tree | 836427cf1ff9e46e31a785d9a0d48068a7d60cf2 /ui.c | |
| parent | 4144529a31d9c7543a3e1855ef53acaa8f1d0dce (diff) | |
only draw visible lines
Diffstat (limited to 'ui.c')
| -rw-r--r-- | ui.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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, |
