mirror of
https://github.com/tmux/tmux.git
synced 2025-01-13 03:48:51 +00:00
Sync OpenBSD patchset 219:
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:
parent
d8a2ceea43
commit
65a28912eb
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-option.c,v 1.71 2009-08-09 15:26:24 tcunha Exp $ */
|
/* $Id: cmd-set-option.c,v 1.72 2009-08-09 16:48:34 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* 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 = {
|
const struct cmd_entry cmd_set_option_entry = {
|
||||||
"set-option", "set",
|
"set-option", "set",
|
||||||
CMD_OPTION_SESSION_USAGE,
|
"[-agu] " CMD_OPTION_SESSION_USAGE,
|
||||||
0, CMD_CHFLAG('g')|CMD_CHFLAG('u'),
|
0, CMD_CHFLAG('a')|CMD_CHFLAG('g')|CMD_CHFLAG('u'),
|
||||||
NULL,
|
NULL,
|
||||||
cmd_option_parse,
|
cmd_option_parse,
|
||||||
cmd_set_option_exec,
|
cmd_set_option_exec,
|
||||||
@ -144,7 +144,8 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else {
|
} else {
|
||||||
switch (entry->type) {
|
switch (entry->type) {
|
||||||
case SET_OPTION_STRING:
|
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;
|
break;
|
||||||
case SET_OPTION_NUMBER:
|
case SET_OPTION_NUMBER:
|
||||||
set_option_number(ctx, oo, entry, data->value);
|
set_option_number(ctx, oo, entry, data->value);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-window-option.c,v 1.36 2009-07-30 20:32:05 tcunha Exp $ */
|
/* $Id: cmd-set-window-option.c,v 1.37 2009-08-09 16:48:34 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* 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 = {
|
const struct cmd_entry cmd_set_window_option_entry = {
|
||||||
"set-window-option", "setw",
|
"set-window-option", "setw",
|
||||||
CMD_OPTION_WINDOW_USAGE,
|
"[-agu] " CMD_OPTION_WINDOW_USAGE,
|
||||||
0, CMD_CHFLAG('g')|CMD_CHFLAG('u'),
|
0, CMD_CHFLAG('a')|CMD_CHFLAG('g')|CMD_CHFLAG('u'),
|
||||||
NULL,
|
NULL,
|
||||||
cmd_option_parse,
|
cmd_option_parse,
|
||||||
cmd_set_window_option_exec,
|
cmd_set_window_option_exec,
|
||||||
@ -134,7 +134,8 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else {
|
} else {
|
||||||
switch (entry->type) {
|
switch (entry->type) {
|
||||||
case SET_OPTION_STRING:
|
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;
|
break;
|
||||||
case SET_OPTION_NUMBER:
|
case SET_OPTION_NUMBER:
|
||||||
set_option_number(ctx, oo, entry, data->value);
|
set_option_number(ctx, oo, entry, data->value);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: options-cmd.c,v 1.4 2009-01-27 20:22:33 nicm Exp $ */
|
/* $Id: options-cmd.c,v 1.5 2009-08-09 16:48:34 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -25,15 +25,26 @@
|
|||||||
|
|
||||||
void
|
void
|
||||||
set_option_string(struct cmd_ctx *ctx, struct options *oo,
|
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) {
|
if (value == NULL) {
|
||||||
ctx->error(ctx, "empty value");
|
ctx->error(ctx, "empty value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
options_set_string(oo, entry->name, "%s", value);
|
if (append) {
|
||||||
ctx->info(ctx, "set option: %s -> %s", entry->name, value);
|
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
|
void
|
||||||
|
12
tmux.h
12
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.402 2009-08-09 15:26:24 tcunha Exp $ */
|
/* $Id: tmux.h,v 1.403 2009-08-09 16:48:34 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1171,7 +1171,7 @@ int tty_keys_next(struct tty *, int *, u_char *);
|
|||||||
|
|
||||||
/* options-cmd.c */
|
/* options-cmd.c */
|
||||||
void set_option_string(struct cmd_ctx *,
|
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 *,
|
void set_option_number(struct cmd_ctx *,
|
||||||
struct options *, const struct set_option_entry *, char *);
|
struct options *, const struct set_option_entry *, char *);
|
||||||
void set_option_key(struct cmd_ctx *,
|
void set_option_key(struct cmd_ctx *,
|
||||||
@ -1325,10 +1325,10 @@ void cmd_buffer_init(struct cmd *, int);
|
|||||||
int cmd_buffer_parse(struct cmd *, int, char **, char **);
|
int cmd_buffer_parse(struct cmd *, int, char **, char **);
|
||||||
void cmd_buffer_free(struct cmd *);
|
void cmd_buffer_free(struct cmd *);
|
||||||
size_t cmd_buffer_print(struct cmd *, char *, size_t);
|
size_t cmd_buffer_print(struct cmd *, char *, size_t);
|
||||||
#define CMD_OPTION_PANE_USAGE "[-gu] [-t target-pane] option [value]"
|
#define CMD_OPTION_PANE_USAGE "[-t target-pane] option [value]"
|
||||||
#define CMD_OPTION_WINDOW_USAGE "[-gu] [-t target-window] option [value]"
|
#define CMD_OPTION_WINDOW_USAGE "[-t target-window] option [value]"
|
||||||
#define CMD_OPTION_SESSION_USAGE "[-gu] [-t target-session] option [value]"
|
#define CMD_OPTION_SESSION_USAGE "[-t target-session] option [value]"
|
||||||
#define CMD_OPTION_CLIENT_USAGE "[-gu] [-t target-client] option [value]"
|
#define CMD_OPTION_CLIENT_USAGE "[-t target-client] option [value]"
|
||||||
void cmd_option_init(struct cmd *, int);
|
void cmd_option_init(struct cmd *, int);
|
||||||
int cmd_option_parse(struct cmd *, int, char **, char **);
|
int cmd_option_parse(struct cmd *, int, char **, char **);
|
||||||
void cmd_option_free(struct cmd *);
|
void cmd_option_free(struct cmd *);
|
||||||
|
Loading…
Reference in New Issue
Block a user