diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-04 18:45:58 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-04 18:45:58 +0000 |
commit | 1d1b680823a76eab26489e7ae3f442098b411b4f (patch) | |
tree | 3aec6dbf1cb58aad8eaa7d28a663d80c6213ac9e /usr.bin | |
parent | 9a4a35bd309b8608c0ee0beff9563a81d187f7b0 (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 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 9 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-set-window-option.c | 9 | ||||
-rw-r--r-- | usr.bin/tmux/options-cmd.c | 19 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 12 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 12 |
5 files changed, 40 insertions, 21 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index 8f1d1c792b6..e1762dfc539 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.10 2009/08/03 14:10:54 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.11 2009/08/04 18:45:57 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,8 +31,8 @@ int cmd_set_option_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_set_option_entry = { "set-option", "set", - CMD_OPTION_SESSION_USAGE, - 0, CMD_CHFLAG('g')|CMD_CHFLAG('u'), + "[-agu] " CMD_OPTION_SESSION_USAGE, + 0, CMD_CHFLAG('a')|CMD_CHFLAG('g')|CMD_CHFLAG('u'), NULL, cmd_option_parse, cmd_set_option_exec, @@ -144,7 +144,8 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) } else { switch (entry->type) { case SET_OPTION_STRING: - set_option_string(ctx, oo, entry, data->value); + set_option_string(ctx, oo, entry, + data->value, data->chflags & CMD_CHFLAG('a')); break; case SET_OPTION_NUMBER: set_option_number(ctx, oo, entry, data->value); diff --git a/usr.bin/tmux/cmd-set-window-option.c b/usr.bin/tmux/cmd-set-window-option.c index 2695e31279a..7a8ad31e7ec 100644 --- a/usr.bin/tmux/cmd-set-window-option.c +++ b/usr.bin/tmux/cmd-set-window-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-window-option.c,v 1.9 2009/07/30 07:04:50 nicm Exp $ */ +/* $OpenBSD: cmd-set-window-option.c,v 1.10 2009/08/04 18:45:57 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,8 +31,8 @@ int cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_set_window_option_entry = { "set-window-option", "setw", - CMD_OPTION_WINDOW_USAGE, - 0, CMD_CHFLAG('g')|CMD_CHFLAG('u'), + "[-agu] " CMD_OPTION_WINDOW_USAGE, + 0, CMD_CHFLAG('a')|CMD_CHFLAG('g')|CMD_CHFLAG('u'), NULL, cmd_option_parse, cmd_set_window_option_exec, @@ -134,7 +134,8 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx) } else { switch (entry->type) { case SET_OPTION_STRING: - set_option_string(ctx, oo, entry, data->value); + set_option_string(ctx, oo, entry, + data->value, data->chflags & CMD_CHFLAG('a')); break; case SET_OPTION_NUMBER: set_option_number(ctx, oo, entry, data->value); diff --git a/usr.bin/tmux/options-cmd.c b/usr.bin/tmux/options-cmd.c index 4bc727316ab..747f8219756 100644 --- a/usr.bin/tmux/options-cmd.c +++ b/usr.bin/tmux/options-cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options-cmd.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: options-cmd.c,v 1.2 2009/08/04 18:45:57 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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 diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 50464bd8d55..2388973c92a 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.57 2009/08/04 18:41:28 jmc Exp $ +.\" $OpenBSD: tmux.1,v 1.58 2009/08/04 18:45:57 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -1021,12 +1021,17 @@ command. Commands which set options are as follows: .Bl -tag -width Ds .It Xo Ic set-option -.Op Fl gu +.Op Fl agu .Op Fl t Ar target-session .Ar option Ar value .Xc .D1 (alias: Ic set ) Set a session option. +With +.Fl a , +and if the option expects a string, +.Ar value +is appended to the existing setting. If .Fl g is specified, the global session option is set. @@ -1310,13 +1315,14 @@ for which the window option is enabled. .El .It Xo Ic set-window-option -.Op Fl gu +.Op Fl agu .Op Fl t Ar target-window .Ar option Ar value .Xc .D1 (alias: Ic setw ) Set a window option. The +.Fl a , .Fl g and .Fl u diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 90e117de049..1f4846fc372 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.67 2009/08/03 14:10:54 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.68 2009/08/04 18:45:57 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1172,7 +1172,7 @@ int tty_keys_next(struct tty *, int *, u_char *); /* options-cmd.c */ void set_option_string(struct cmd_ctx *, - struct options *, const struct set_option_entry *, char *); + struct options *, const struct set_option_entry *, char *, int); void set_option_number(struct cmd_ctx *, struct options *, const struct set_option_entry *, char *); void set_option_key(struct cmd_ctx *, @@ -1326,10 +1326,10 @@ void cmd_buffer_init(struct cmd *, int); int cmd_buffer_parse(struct cmd *, int, char **, char **); void cmd_buffer_free(struct cmd *); size_t cmd_buffer_print(struct cmd *, char *, size_t); -#define CMD_OPTION_PANE_USAGE "[-gu] [-t target-pane] option [value]" -#define CMD_OPTION_WINDOW_USAGE "[-gu] [-t target-window] option [value]" -#define CMD_OPTION_SESSION_USAGE "[-gu] [-t target-session] option [value]" -#define CMD_OPTION_CLIENT_USAGE "[-gu] [-t target-client] option [value]" +#define CMD_OPTION_PANE_USAGE "[-t target-pane] option [value]" +#define CMD_OPTION_WINDOW_USAGE "[-t target-window] option [value]" +#define CMD_OPTION_SESSION_USAGE "[-t target-session] option [value]" +#define CMD_OPTION_CLIENT_USAGE "[-t target-client] option [value]" void cmd_option_init(struct cmd *, int); int cmd_option_parse(struct cmd *, int, char **, char **); void cmd_option_free(struct cmd *); |