ref: 2654c713aafb1999e00ace3bce4e078168bfb38b
parent: e90c1b46c8e1bddce3665b0d12bf2d101de02236
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sat Feb 15 06:00:21 EST 2020
plan9: simplify info drawing
--- a/plan9.c
+++ b/plan9.c
@@ -306,8 +306,9 @@
{
Rectangle r;
Point p, top, bot;
- int x, y, len, rx, ry, i;
+ int x, y, rx, ry, i;
int oldbg, oldfg, bg, fg, attr, selected;
+ char s[32];
Rune c;
p = addpt(screen->r.min, Pt(Txtoff, Txtoff));
@@ -325,9 +326,6 @@
r = screen->r;
r.min.x += MIN(field.width*charw, Dx(r)-Txtoff) + Txtoff;
draw(screen, r, color[Dback], nil, ZP);
- r = screen->r;
- r.min.y = MIN(top.y + field.height*charh, bot.y-charh);
- draw(screen, r, color[Dback], nil, ZP);
}
bg = -1;
@@ -391,59 +389,31 @@
p.x = top.x;
}
- p = bot;
+ r = screen->r;
+ r.min.y = MIN(top.y + field.height*charh, bot.y-charh);
+ draw(screen, r, color[Dback], nil, ZP);
- /* field size */
- p.x = screen->r.min.x + Txtoff;
- runesprint(linebuf, "%udx%ud ", field.width, field.height);
- runestringbg(screen, p, color[Dfhigh], ZP, font, linebuf, color[Dback], ZP);
- len = 5+1+5;
+ i = 0;
+ sprint(s, "%udx%ud", field.width, field.height);
+ i += runesprint(linebuf, "%-13s", s);
+ sprint(s, "%d/%d", gridw, gridh);
+ i += runesprint(linebuf+i, "%-9s", s);
+ sprint(s, "%lldf", MAX(0, tick));
+ i += runesprint(linebuf+i, "%-8s", s);
+ i += runesprint(linebuf+i, "%-8d", bpm);
+ sprint(s, "%ldms", labs(framedev));
+ i += runesprint(linebuf+i, "%-8s", s);
+ runestringn(screen, bot, color[Dfhigh], ZP, font, linebuf, i);
+ bot.y += charh;
- /* cursor position */
- p.y += charh;
- runesprint(linebuf, "%ud,%ud ", curx, cury);
- runestringbg(screen, p, color[Dfhigh], ZP, font, linebuf, color[Dback], ZP);
-
- /* selection size */
- p.x += charw * (len + Coloff);
- runesprint(linebuf, "%d:%d ", selw, selh);
- runestringbg(screen, p, color[Dfhigh], ZP, font, linebuf, color[Dback], ZP);
- len = 3+1+3;
-
- /* grid size */
- p.y -= charh;
- runesprint(linebuf, "%d/%d", gridw, gridh);
- runestringbg(screen, p, color[Dfhigh], ZP, font, linebuf, color[Dback], ZP);
-
- /* ticks */
- p.x += charw * (len + Coloff);
- runesprint(linebuf, "%lldf", MAX(0, tick));
- runestringbg(screen, p, color[Dfhigh], ZP, font, linebuf, color[Dback], ZP);
-
- /* insert/append mode */
- p.y += charh;
- runesprint(linebuf, "%s", modes[altdown ? Mslide : mode]);
- runestringbg(screen, p, color[Dfhigh], ZP, font, linebuf, color[Dback], ZP);
- len = 6;
-
- /* bpm */
- p.y -= charh;
- p.x += charw * (len + Coloff);
- runesprint(linebuf, "%d ", bpm);
- runestringbg(screen, p, color[Dfhigh], ZP, font, linebuf, color[Dback], ZP);
- len = 6;
-
- /* filename */
- p.y += charh;
- stringbg(screen, p, color[Dfhigh], ZP, font, filename[0] ? filename : "unnamed", color[Dback], ZP);
-
- /* frame deviation */
- p.y -= charh;
- p.x += charw * (len + Coloff);
- runesprint(linebuf, "%ldms ", labs(framedev));
- runestringbg(screen, p, color[Dfhigh], ZP, font, linebuf, color[Dback], ZP);
-
- USED(len);
+ i = 0;
+ sprint(s, "%ud,%ud", curx, cury);
+ i += runesprint(linebuf, "%-13s", s);
+ sprint(s, "%d:%d", selw, selh);
+ i += runesprint(linebuf+i, "%-9s", s);
+ i += runesprint(linebuf+i, "%-8s", modes[altdown ? Mslide : mode]);
+ i += runesprint(linebuf+i, "%s", filename[0] ? filename : "unnamed");
+ runestringn(screen, bot, color[Dfhigh], ZP, font, linebuf, i);
flushimage(display, 1);
}