History

fix color updates on theme load

Sigrid Haflínudóttir committed 6 years ago

Commit d92cd2e1 parent f0f58331 file · +18 −12Browse files

Unified · Split

picker.c+18−12
@@ -313,14 +313,14 @@ loadbg(void) · 312 unmodified lines
313313 }
314314
315315 static int
316−printcolor(Color *c)
316+printcolor(int f, Color *c)
317317 {
318318 char s[64];
319319 int n;
320320
321321 n = snprint(s, sizeof(s), "%s\t%©\n", c->id, c);
322322
323− return write(1, s, n) == n ? 0 : -1;
323+ return write(f, s, n) == n ? 0 : -1;
324324 }
325325
326326 static int
@@ -405,6 +405,15 @@ readcolors(Biobuf *b) · 78 unmodified lines
405405 }
406406 }
407407
408+static void
409+dump(int f)
410+{
411+ Color *c;
412+
413+ for (c = colors; c != nil; c = c->next)
414+ printcolor(f, c);
415+}
416+
408417 static void
409418 loadtheme(char *filename)
410419 {
@@ -429,6 +438,7 @@ plumbproc(void *) · 18 unmodified lines
429438 while ((m = plumbrecv(f)) != nil) {
430439 loadtheme(m->data);
431440 redraw();
441+ dump(1);
432442 plumbfree(m);
433443 }
434444 }
@@ -554,7 +564,7 @@ changed: · 119 unmodified lines
554564 if (c->u != u) {
555565 c->u = u;
556566 if (!once)
557− printcolor(c);
567+ printcolor(1, c);
558568 }
559569 redraw();
560570 goto next;
@@ -580,12 +590,10 @@ changed: · 19 unmodified lines
580590
581591 int f;
582592 if ((f = open("/dev/snarf", OWRITE)) >= 0) {
583− if (i == nelem(spaces)) {
593+ if (i == nelem(spaces))
584594 write(f, hex, strlen(hex));
585− } else {
586− for (c = colors; c != nil; c = c->next)
587− fprint(f, "%s\t%©\n", c->id, c);
588− }
595+ else
596+ dump(f);
589597 close(f);
590598 }
591599 } else if (m.buttons == 2) {
@@ -608,10 +616,8 @@ changed: · 16 unmodified lines
608616 }
609617
610618 end:
611− if (once) {
612− for (c = colors; c != nil; c = c->next)
613− print("%s\t%©\n", c->id, c);
614− }
619+ if (once)
620+ dump(1);
615621
616622 threadexitsall(nil);
617623 }

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