Unified · Split
| @@ -313,14 +313,14 @@ loadbg(void) · 312 unmodified lines | ||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | static int |
| 316 | −printcolor(Color *c) | |
| 316 | +printcolor(int f, Color *c) | |
| 317 | 317 | { |
| 318 | 318 | char s[64]; |
| 319 | 319 | int n; |
| 320 | 320 | |
| 321 | 321 | n = snprint(s, sizeof(s), "%s\t%©\n", c->id, c); |
| 322 | 322 | |
| 323 | − return write(1, s, n) == n ? 0 : -1; | |
| 323 | + return write(f, s, n) == n ? 0 : -1; | |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | static int |
| @@ -405,6 +405,15 @@ readcolors(Biobuf *b) · 78 unmodified lines | ||
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 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 | + | |
| 408 | 417 | static void |
| 409 | 418 | loadtheme(char *filename) |
| 410 | 419 | { |
| @@ -429,6 +438,7 @@ plumbproc(void *) · 18 unmodified lines | ||
| 429 | 438 | while ((m = plumbrecv(f)) != nil) { |
| 430 | 439 | loadtheme(m->data); |
| 431 | 440 | redraw(); |
| 441 | + dump(1); | |
| 432 | 442 | plumbfree(m); |
| 433 | 443 | } |
| 434 | 444 | } |
| @@ -554,7 +564,7 @@ changed: · 119 unmodified lines | ||
| 554 | 564 | if (c->u != u) { |
| 555 | 565 | c->u = u; |
| 556 | 566 | if (!once) |
| 557 | − printcolor(c); | |
| 567 | + printcolor(1, c); | |
| 558 | 568 | } |
| 559 | 569 | redraw(); |
| 560 | 570 | goto next; |
| @@ -580,12 +590,10 @@ changed: · 19 unmodified lines | ||
| 580 | 590 | |
| 581 | 591 | int f; |
| 582 | 592 | if ((f = open("/dev/snarf", OWRITE)) >= 0) { |
| 583 | − if (i == nelem(spaces)) { | |
| 593 | + if (i == nelem(spaces)) | |
| 584 | 594 | 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); | |
| 589 | 597 | close(f); |
| 590 | 598 | } |
| 591 | 599 | } else if (m.buttons == 2) { |
| @@ -608,10 +616,8 @@ changed: · 16 unmodified lines | ||
| 608 | 616 | } |
| 609 | 617 | |
| 610 | 618 | 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); | |
| 615 | 621 | |
| 616 | 622 | threadexitsall(nil); |
| 617 | 623 | } |