aboutsummaryrefslogtreecommitdiff
path: root/options.c
diff options
context:
space:
mode:
authorThomas <thomas@xteddy.org>2014-02-05 10:47:57 +0000
committerThomas <thomas@xteddy.org>2014-02-05 10:47:57 +0000
commit6eef24c37a69c0faa12deb4374730cf02561c934 (patch)
tree181937aeab92a1a9aa3c888bb1194ba1f919ec2d /options.c
parentd02c4bda3a4b456f654fb0c1b454ba9724bff0f3 (diff)
parent57332be8da86f0e40a91d7acd857564e789027a7 (diff)
downloadrtmux-6eef24c37a69c0faa12deb4374730cf02561c934.tar.gz
rtmux-6eef24c37a69c0faa12deb4374730cf02561c934.tar.bz2
rtmux-6eef24c37a69c0faa12deb4374730cf02561c934.zip
Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code
Diffstat (limited to 'options.c')
-rw-r--r--options.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/options.c b/options.c
index d70550f1..8bec8e5c 100644
--- a/options.c
+++ b/options.c
@@ -109,6 +109,7 @@ options_set_string(struct options *oo, const char *name, const char *fmt, ...)
o = xmalloc(sizeof *o);
o->name = xstrdup(name);
RB_INSERT(options_tree, &oo->tree, o);
+ memcpy(&o->style, &grid_default_cell, sizeof o->style);
} else if (o->type == OPTIONS_STRING)
free(o->str);
@@ -140,6 +141,7 @@ options_set_number(struct options *oo, const char *name, long long value)
o = xmalloc(sizeof *o);
o->name = xstrdup(name);
RB_INSERT(options_tree, &oo->tree, o);
+ memcpy(&o->style, &grid_default_cell, sizeof o->style);
} else if (o->type == OPTIONS_STRING)
free(o->str);
@@ -159,3 +161,37 @@ options_get_number(struct options *oo, const char *name)
fatalx("option not a number");
return (o->num);
}
+
+struct options_entry *
+options_set_style(struct options *oo, const char *name, const char *value,
+ int append)
+{
+ struct options_entry *o;
+
+ if ((o = options_find1(oo, name)) == NULL) {
+ o = xmalloc(sizeof *o);
+ o->name = xstrdup(name);
+ RB_INSERT(options_tree, &oo->tree, o);
+ } else if (o->type == OPTIONS_STRING)
+ free(o->str);
+
+ if (!append)
+ memcpy(&o->style, &grid_default_cell, sizeof o->style);
+
+ o->type = OPTIONS_STYLE;
+ if (style_parse(&grid_default_cell, &o->style, value) == -1)
+ return (NULL);
+ return (o);
+}
+
+struct grid_cell *
+options_get_style(struct options *oo, const char *name)
+{
+ struct options_entry *o;
+
+ if ((o = options_find(oo, name)) == NULL)
+ fatalx("missing option");
+ if (o->type != OPTIONS_STYLE)
+ fatalx("option not a style");
+ return (&o->style);
+}