version 1.162, 2019/10/14 09:19:40 |
version 1.163, 2019/11/01 09:09:53 |
|
|
return (0); |
return (0); |
} |
} |
|
|
|
/* Parse colour from OSC. */ |
|
static int |
|
input_osc_parse_colour(const char *p, u_int *r, u_int *g, u_int *b) |
|
{ |
|
u_int rsize, gsize, bsize; |
|
const char *cp, *s = p; |
|
|
|
if (sscanf(p, "rgb:%x/%x/%x", r, g, b) != 3) |
|
return (0); |
|
p += 4; |
|
|
|
cp = strchr(p, '/'); |
|
rsize = cp - p; |
|
if (rsize == 1) |
|
(*r) = (*r) | ((*r) << 4); |
|
else if (rsize == 3) |
|
(*r) >>= 4; |
|
else if (rsize == 4) |
|
(*r) >>= 8; |
|
else if (rsize != 2) |
|
return (0); |
|
|
|
p = cp + 1; |
|
cp = strchr(p, '/'); |
|
gsize = cp - p; |
|
if (gsize == 1) |
|
(*g) = (*g) | ((*g) << 4); |
|
else if (gsize == 3) |
|
(*g) >>= 4; |
|
else if (gsize == 4) |
|
(*g) >>= 8; |
|
else if (gsize != 2) |
|
return (0); |
|
|
|
bsize = strlen(cp + 1); |
|
if (bsize == 1) |
|
(*b) = (*b) | ((*b) << 4); |
|
else if (bsize == 3) |
|
(*b) >>= 4; |
|
else if (bsize == 4) |
|
(*b) >>= 8; |
|
else if (bsize != 2) |
|
return (0); |
|
|
|
log_debug("%s: %s = %02x%02x%02x", __func__, s, *r, *g, *b); |
|
return (1); |
|
} |
|
|
/* Handle the OSC 4 sequence for setting (multiple) palette entries. */ |
/* Handle the OSC 4 sequence for setting (multiple) palette entries. */ |
static void |
static void |
input_osc_4(struct input_ctx *ictx, const char *p) |
input_osc_4(struct input_ctx *ictx, const char *p) |
|
|
goto bad; |
goto bad; |
|
|
s = strsep(&next, ";"); |
s = strsep(&next, ";"); |
if (sscanf(s, "rgb:%2x/%2x/%2x", &r, &g, &b) != 3) { |
if (!input_osc_parse_colour(s, &r, &g, &b)) { |
s = next; |
s = next; |
continue; |
continue; |
} |
} |
|
|
u_int r, g, b; |
u_int r, g, b; |
char tmp[16]; |
char tmp[16]; |
|
|
if (sscanf(p, "rgb:%2x/%2x/%2x", &r, &g, &b) != 3) |
if (strcmp(p, "?") == 0) |
goto bad; |
return; |
|
|
|
if (!input_osc_parse_colour(p, &r, &g, &b)) |
|
goto bad; |
xsnprintf(tmp, sizeof tmp, "fg=#%02x%02x%02x", r, g, b); |
xsnprintf(tmp, sizeof tmp, "fg=#%02x%02x%02x", r, g, b); |
options_set_style(wp->options, "window-style", 1, tmp); |
options_set_style(wp->options, "window-style", 1, tmp); |
options_set_style(wp->options, "window-active-style", 1, tmp); |
options_set_style(wp->options, "window-active-style", 1, tmp); |
|
|
u_int r, g, b; |
u_int r, g, b; |
char tmp[16]; |
char tmp[16]; |
|
|
if (sscanf(p, "rgb:%2x/%2x/%2x", &r, &g, &b) != 3) |
if (strcmp(p, "?") == 0) |
|
return; |
|
|
|
if (!input_osc_parse_colour(p, &r, &g, &b)) |
goto bad; |
goto bad; |
xsnprintf(tmp, sizeof tmp, "bg=#%02x%02x%02x", r, g, b); |
xsnprintf(tmp, sizeof tmp, "bg=#%02x%02x%02x", r, g, b); |
options_set_style(wp->options, "window-style", 1, tmp); |
options_set_style(wp->options, "window-style", 1, tmp); |