wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

loadcolor.c (621B)


      1 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
      2  * See LICENSE file for license details.
      3  */
      4 #include <string.h>
      5 #include "../x11.h"
      6 
      7 int
      8 loadcolor(CTuple *c, const char *str, const char *end) {
      9 	char buf[128];
     10 	char *toks[4];
     11 
     12 	utflcpy(buf, str, end ? min(end - str + 1, sizeof buf) : sizeof buf);
     13 	if(3 > stokenize(toks, nelem(toks), buf, " \t\r\n"))
     14 		return 0;
     15 
     16 	if(!(parsecolor(toks[0], &c->fg)
     17 	   && parsecolor(toks[1], &c->bg)
     18 	   && parsecolor(toks[2], &c->border)))
     19 		return 0;
     20 
     21 	snprint(c->colstr, sizeof c->colstr, "%L %L %L", c->fg, c->bg, c->border);
     22 	return toks[2] + strlen(toks[2]) - buf;
     23 }