summaryrefslogtreecommitdiffstats
path: root/options-cmd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-08-04 18:45:57 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-08-04 18:45:57 +0000
commit12ef3ceda13f9ae4c77384f98e6f145322971e69 (patch)
tree0202ba1ce7451cd8d6ce8568f21f17fff5a58842 /options-cmd.c
parenta0647f1616da3a2b5fc7ce831ea83519832a196e (diff)
Add a -a flag to set-option and set-window-option to append to an existing
string value, useful for terminal-overrides.
Diffstat (limited to 'options-cmd.c')
-rw-r--r--options-cmd.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/options-cmd.c b/options-cmd.c
index 6b7090bd..4cdd75d0 100644
--- a/options-cmd.c
+++ b/options-cmd.c
@@ -25,15 +25,26 @@
void
set_option_string(struct cmd_ctx *ctx, struct options *oo,
- const struct set_option_entry *entry, char *value)
+ const struct set_option_entry *entry, char *value, int append)
{
+ char *oldvalue, *newvalue;
+
if (value == NULL) {
ctx->error(ctx, "empty value");
return;
}
- options_set_string(oo, entry->name, "%s", value);
- ctx->info(ctx, "set option: %s -> %s", entry->name, value);
+ if (append) {
+ oldvalue = options_get_string(oo, entry->name);
+ xasprintf(&newvalue, "%s%s", oldvalue, value);
+ } else
+ newvalue = value;
+
+ options_set_string(oo, entry->name, "%s", newvalue);
+ ctx->info(ctx, "set option: %s -> %s", entry->name, newvalue);
+
+ if (newvalue != value)
+ xfree(newvalue);
}
void