diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-08-04 18:45:57 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-08-04 18:45:57 +0000 |
commit | 12ef3ceda13f9ae4c77384f98e6f145322971e69 (patch) | |
tree | 0202ba1ce7451cd8d6ce8568f21f17fff5a58842 /options-cmd.c | |
parent | a0647f1616da3a2b5fc7ce831ea83519832a196e (diff) | |
download | rtmux-12ef3ceda13f9ae4c77384f98e6f145322971e69.tar.gz rtmux-12ef3ceda13f9ae4c77384f98e6f145322971e69.tar.bz2 rtmux-12ef3ceda13f9ae4c77384f98e6f145322971e69.zip |
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.c | 17 |
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 |