ref: 82adfe54e258ed20d55fb6fd8505190b1e20aa0d
parent: 52ac66512399a01cb3f9cbfb1e75e4ac860b4c79
author: Jacob Moody <moody@posixcafe.org>
date: Fri Mar 10 15:39:38 EST 2023
kbmap: fix multi column display for smaller windows (thanks mkf)
--- a/sys/src/cmd/kbmap.c
+++ b/sys/src/cmd/kbmap.c
@@ -99,14 +99,16 @@
void
geometry(void)
{
- int i, rows;
+ int i, rows, cols;
Rectangle r;
rows = (Dy(screen->r)-2*MARGIN+PAD)/(font->height+PAD);
if(rows < 1)
rows = 1;
-
- r = Rect(0,0,(Dx(screen->r)-2*MARGIN), font->height);
+ cols = (nmap+rows-1)/rows;
+ if(cols < 1)
+ cols = 1;
+ r = Rect(0,0,(Dx(screen->r)-2*MARGIN+PAD)/cols-PAD, font->height);
for(i=0; i<nmap; i++)
map[i].r = rectaddpt(rectaddpt(r, Pt(MARGIN+(PAD+Dx(r))*(i/rows),
MARGIN+(PAD+Dy(r))*(i%rows))), screen->r.min);