History

plan9: simplify redraw a bit

Sigrid Haflínudóttir committed 6 years ago

Commit ffc99341 parent 5d24d811 file · +8 −21Browse files

Unified · Split

plan9.c+8−21
@@ -303,10 +303,9 @@ orcathread(void *drawchan) · 302 unmodified lines
303303 static void
304304 redraw(void)
305305 {
306− Rectangle r;
307306 Point p, top, bot;
308307 int x, y, len, rx, ry;
309− int bg, fg, attr;
308+ int bg, fg, attr, selected;
310309 Rune c;
311310
312311 draw(screen, screen->r, color[Dback], nil, ZP);
@@ -317,17 +316,6 @@ redraw(void) · 4 unmodified lines
317316 bot.x = top.x;
318317 bot.y = screen->r.max.y - Txtoff - charh*2;
319318
320− /* cursor bg */
321− p.x += curx * charw;
322− p.y += cury * charh;
323− r.min = p;
324− r.max = p;
325− r.max.x += selw * charw;
326− r.max.y += selh * charh;
327− draw(screen, r, color[Dbinv], nil, ZP);
328−
329− p = top;
330−
331319 for (y = 0; y < field.height && p.y < bot.y-charh; y++) {
332320 for (x = 0; x < field.width; x++) {
333321 c = field.buffer[field.width*y + x];
@@ -336,19 +324,18 @@ redraw(void) · 2 unmodified lines
336324 if (c == '.')
337325 c = dot[dotstyle];
338326
327+ selected = x >= curx && y >= cury && x < curx+selw && y < cury+selh;
328+ bg = selected ? Dbinv : Dback;
329+ fg = selected ? Dfinv : Dfhigh;
330+
339331 if (c == dot[dotstyle] && attr == 0) {
340332 if ((x % gridw) == 0 && (y % gridh) == 0) {
341333 rx = !!x + (x + 1) / field.width;
342334 ry = !!y + (y + 1) / field.height;
343335 c = ruler[rulerstyle][ry*3+rx];
344336 }
345− runestringn(screen, p, color[Dflow], ZP, font, &c, 1);
346− } else if (x >= curx && y >= cury && x < curx+selw && y < cury+selh) {
347− runestringn(screen, p, color[Dfinv], ZP, font, &c, 1);
348− } else {
349− bg = Dback;
350− fg = Dfhigh;
351−
337+ fg = Dflow;
338+ } else if (!selected) {
352339 if (c == '#') {
353340 fg = Dfmed;
354341 } else {
@@ -372,8 +359,8 @@ redraw(void) · 17 unmodified lines
372359 bg = Dback;
373360 fg = Dbmed;
374361 }
375− runestringnbg(screen, p, color[fg], ZP, font, &c, 1, color[bg], ZP);
376362 }
363+ runestringnbg(screen, p, color[fg], ZP, font, &c, 1, color[bg], ZP);
377364 p.x += charw;
378365 }
379366 p.y += font->height;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t