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
303static void303static void
304redraw(void)304redraw(void)
305{305{
306 Rectangle r;
307 Point p, top, bot;306 Point p, top, bot;
308 int x, y, len, rx, ry;307 int x, y, len, rx, ry;
309 int bg, fg, attr;308 int bg, fg, attr, selected;
310 Rune c;309 Rune c;
311 310
312 draw(screen, screen->r, color[Dback], nil, ZP);311 draw(screen, screen->r, color[Dback], nil, ZP);
@@ -317,17 +316,6 @@ redraw(void) · 4 unmodified lines
317 bot.x = top.x;316 bot.x = top.x;
318 bot.y = screen->r.max.y - Txtoff - charh*2;317 bot.y = screen->r.max.y - Txtoff - charh*2;
319 318
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
331 for (y = 0; y < field.height && p.y < bot.y-charh; y++) {319 for (y = 0; y < field.height && p.y < bot.y-charh; y++) {
332 for (x = 0; x < field.width; x++) {320 for (x = 0; x < field.width; x++) {
333 c = field.buffer[field.width*y + x];321 c = field.buffer[field.width*y + x];
@@ -336,19 +324,18 @@ redraw(void) · 2 unmodified lines
336 if (c == '.')324 if (c == '.')
337 c = dot[dotstyle];325 c = dot[dotstyle];
338 326
327 selected = x >= curx && y >= cury && x < curx+selw && y < cury+selh;
328 bg = selected ? Dbinv : Dback;
329 fg = selected ? Dfinv : Dfhigh;
330
339 if (c == dot[dotstyle] && attr == 0) {331 if (c == dot[dotstyle] && attr == 0) {
340 if ((x % gridw) == 0 && (y % gridh) == 0) {332 if ((x % gridw) == 0 && (y % gridh) == 0) {
341 rx = !!x + (x + 1) / field.width;333 rx = !!x + (x + 1) / field.width;
342 ry = !!y + (y + 1) / field.height;334 ry = !!y + (y + 1) / field.height;
343 c = ruler[rulerstyle][ry*3+rx];335 c = ruler[rulerstyle][ry*3+rx];
344 }336 }
345 runestringn(screen, p, color[Dflow], ZP, font, &c, 1);337 fg = Dflow;
346 } else if (x >= curx && y >= cury && x < curx+selw && y < cury+selh) {338 } else if (!selected) {
347 runestringn(screen, p, color[Dfinv], ZP, font, &c, 1);
348 } else {
349 bg = Dback;
350 fg = Dfhigh;
351
352 if (c == '#') {339 if (c == '#') {
353 fg = Dfmed;340 fg = Dfmed;
354 } else {341 } else {
@@ -372,8 +359,8 @@ redraw(void) · 17 unmodified lines
372 bg = Dback;359 bg = Dback;
373 fg = Dbmed;360 fg = Dbmed;
374 }361 }
375 runestringnbg(screen, p, color[fg], ZP, font, &c, 1, color[bg], ZP);
376 }362 }
363 runestringnbg(screen, p, color[fg], ZP, font, &c, 1, color[bg], ZP);
377 p.x += charw;364 p.x += charw;
378 }365 }
379 p.y += font->height;366 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