shithub: picker

Download patch

ref: e6ae8d2002a6e790bb619335dabc530ad5cc425f
parent: ffd4488bbff08ce28e74f8e453dfa9c76c955124
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sat Mar 14 17:22:50 EDT 2020

write new colors to stdout

--- a/picker.c
+++ b/picker.c
@@ -256,7 +256,7 @@
 		{ nil, nil, CHANEND },
 	};
 	Color *c;
-	char *s;
+	char *s, buf[16];
 	vlong v;
 	int i, j;
 
@@ -356,6 +356,12 @@
 						c->v[i] = MIN(mode->max[i], (double)(m.xy.x - r.min.x) * mode->max[i]/(double)(Dx(r)-1));
 						mode->torgb(c->v, c->rgba);
 						c->u = D2C(c->rgba[0])<<24 | D2C(c->rgba[1])<<16 | D2C(c->rgba[2])<<8 | D2C(c->v[3]);
+						if (nchan < 4)
+							j = sprint(buf, "%d %06lux\n", curcolor, c->u>>8);
+						else
+							j = sprint(buf, "%d %08lux\n", curcolor, c->u);
+						if (write(1, buf, j) != j)
+							goto end;
 						redraw();
 						goto next;
 					}