mirror of
https://github.com/tmux/tmux.git
synced 2024-11-06 02:48:49 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
b8aec17af1
18
options.c
18
options.c
@ -167,20 +167,26 @@ options_set_style(struct options *oo, const char *name, const char *value,
|
|||||||
int append)
|
int append)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
struct options_entry *o;
|
||||||
|
struct grid_cell tmpgc;
|
||||||
|
|
||||||
if ((o = options_find1(oo, name)) == NULL) {
|
o = options_find1(oo, name);
|
||||||
|
if (o == NULL || !append)
|
||||||
|
memcpy(&tmpgc, &grid_default_cell, sizeof tmpgc);
|
||||||
|
else
|
||||||
|
memcpy(&tmpgc, &o->style, sizeof tmpgc);
|
||||||
|
|
||||||
|
if (style_parse(&grid_default_cell, &tmpgc, value) == -1)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
o = xmalloc(sizeof *o);
|
o = xmalloc(sizeof *o);
|
||||||
o->name = xstrdup(name);
|
o->name = xstrdup(name);
|
||||||
RB_INSERT(options_tree, &oo->tree, o);
|
RB_INSERT(options_tree, &oo->tree, o);
|
||||||
} else if (o->type == OPTIONS_STRING)
|
} else if (o->type == OPTIONS_STRING)
|
||||||
free(o->str);
|
free(o->str);
|
||||||
|
|
||||||
if (!append)
|
|
||||||
memcpy(&o->style, &grid_default_cell, sizeof o->style);
|
|
||||||
|
|
||||||
o->type = OPTIONS_STYLE;
|
o->type = OPTIONS_STYLE;
|
||||||
if (style_parse(&grid_default_cell, &o->style, value) == -1)
|
memcpy(&o->style, &tmpgc, sizeof o->style);
|
||||||
return (NULL);
|
|
||||||
return (o);
|
return (o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
style.c
16
style.c
@ -28,6 +28,7 @@ int
|
|||||||
style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
||||||
const char *in)
|
const char *in)
|
||||||
{
|
{
|
||||||
|
struct grid_cell savedgc;
|
||||||
const char delimiters[] = " ,";
|
const char delimiters[] = " ,";
|
||||||
char tmp[32];
|
char tmp[32];
|
||||||
int val;
|
int val;
|
||||||
@ -38,6 +39,7 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
|||||||
return (0);
|
return (0);
|
||||||
if (strchr(delimiters, in[strlen(in) - 1]) != NULL)
|
if (strchr(delimiters, in[strlen(in) - 1]) != NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
memcpy(&savedgc, gc, sizeof savedgc);
|
||||||
|
|
||||||
fg = gc->fg;
|
fg = gc->fg;
|
||||||
bg = gc->bg;
|
bg = gc->bg;
|
||||||
@ -46,7 +48,7 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
|||||||
do {
|
do {
|
||||||
end = strcspn(in, delimiters);
|
end = strcspn(in, delimiters);
|
||||||
if (end > (sizeof tmp) - 1)
|
if (end > (sizeof tmp) - 1)
|
||||||
return (-1);
|
goto error;
|
||||||
memcpy(tmp, in, end);
|
memcpy(tmp, in, end);
|
||||||
tmp[end] = '\0';
|
tmp[end] = '\0';
|
||||||
|
|
||||||
@ -59,7 +61,7 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
|||||||
defgc->flags & (GRID_FLAG_FG256|GRID_FLAG_BG256);
|
defgc->flags & (GRID_FLAG_FG256|GRID_FLAG_BG256);
|
||||||
} else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) {
|
} else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) {
|
||||||
if ((val = colour_fromstring(tmp + 3)) == -1)
|
if ((val = colour_fromstring(tmp + 3)) == -1)
|
||||||
return (-1);
|
goto error;
|
||||||
if (*in == 'f' || *in == 'F') {
|
if (*in == 'f' || *in == 'F') {
|
||||||
if (val != 8) {
|
if (val != 8) {
|
||||||
if (val & 0x100) {
|
if (val & 0x100) {
|
||||||
@ -87,16 +89,16 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
|||||||
flags |= defgc->flags & GRID_FLAG_BG256;
|
flags |= defgc->flags & GRID_FLAG_BG256;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
return (-1);
|
goto error;
|
||||||
} else if (strcasecmp(tmp, "none") == 0)
|
} else if (strcasecmp(tmp, "none") == 0)
|
||||||
attr = 0;
|
attr = 0;
|
||||||
else if (end > 2 && strncasecmp(tmp, "no", 2) == 0) {
|
else if (end > 2 && strncasecmp(tmp, "no", 2) == 0) {
|
||||||
if ((val = attributes_fromstring(tmp + 2)) == -1)
|
if ((val = attributes_fromstring(tmp + 2)) == -1)
|
||||||
return (-1);
|
goto error;
|
||||||
attr &= ~val;
|
attr &= ~val;
|
||||||
} else {
|
} else {
|
||||||
if ((val = attributes_fromstring(tmp)) == -1)
|
if ((val = attributes_fromstring(tmp)) == -1)
|
||||||
return (-1);
|
goto error;
|
||||||
attr |= val;
|
attr |= val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +110,10 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
|||||||
gc->flags = flags;
|
gc->flags = flags;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
error:
|
||||||
|
memcpy(gc, &savedgc, sizeof *gc);
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert style to a string. */
|
/* Convert style to a string. */
|
||||||
|
Loading…
Reference in New Issue
Block a user