ref: d92cd2eea68a9a15f2067adbd7afe0eaec8ea9f1
parent: f0f5833c9acc6cc7037c72e5c738247178f74314
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Mar 15 20:49:06 EDT 2020
fix color updates on theme load
--- a/picker.c
+++ b/picker.c
@@ -313,7 +313,7 @@
}
static int
-printcolor(Color *c)
+printcolor(int f, Color *c)
{
char s[64];
int n;
@@ -320,7 +320,7 @@
n = snprint(s, sizeof(s), "%s\t%©\n", c->id, c);
- return write(1, s, n) == n ? 0 : -1;
+ return write(f, s, n) == n ? 0 : -1;
}
static int
@@ -406,6 +406,15 @@
}
static void
+dump(int f)
+{
+ Color *c;
+
+ for (c = colors; c != nil; c = c->next)
+ printcolor(f, c);
+}
+
+static void
loadtheme(char *filename)
{
Biobuf *b;
@@ -429,6 +438,7 @@
while ((m = plumbrecv(f)) != nil) {
loadtheme(m->data);
redraw();
+ dump(1);
plumbfree(m);
}
}
@@ -554,7 +564,7 @@
if (c->u != u) {
c->u = u;
if (!once)
- printcolor(c);
+ printcolor(1, c);
}
redraw();
goto next;
@@ -580,12 +590,10 @@
int f;
if ((f = open("/dev/snarf", OWRITE)) >= 0) {
- if (i == nelem(spaces)) {
+ if (i == nelem(spaces))
write(f, hex, strlen(hex));
- } else {
- for (c = colors; c != nil; c = c->next)
- fprint(f, "%s\t%©\n", c->id, c);
- }
+ else
+ dump(f);
close(f);
}
} else if (m.buttons == 2) {
@@ -608,10 +616,8 @@
}
end:
- if (once) {
- for (c = colors; c != nil; c = c->next)
- print("%s\t%©\n", c->id, c);
- }
+ if (once)
+ dump(1);
threadexitsall(nil);
}