Add a -a flag to set-option and set-window-option to append to an existing

string value, useful for terminal-overrides.
This commit is contained in:
Nicholas Marriott
2009-08-04 18:45:57 +00:00
parent a0647f1616
commit 12ef3ceda1
5 changed files with 35 additions and 16 deletions

View File

@ -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