mirror of
https://github.com/tmux/tmux.git
synced 2025-01-08 08:58:47 +00:00
Allow choice options (multiple states) to be toggled between states 0
and 1.
This commit is contained in:
parent
a5a873dccc
commit
5a2d0533a8
@ -289,10 +289,16 @@ cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq,
|
|||||||
{
|
{
|
||||||
struct options_entry *o;
|
struct options_entry *o;
|
||||||
|
|
||||||
if (oe->type != OPTIONS_TABLE_FLAG && value == NULL) {
|
switch (oe->type) {
|
||||||
|
case OPTIONS_TABLE_FLAG:
|
||||||
|
case OPTIONS_TABLE_CHOICE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (value == NULL) {
|
||||||
cmdq_error(cmdq, "empty value");
|
cmdq_error(cmdq, "empty value");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
o = NULL;
|
o = NULL;
|
||||||
switch (oe->type) {
|
switch (oe->type) {
|
||||||
@ -455,6 +461,11 @@ cmd_set_option_choice(unused struct cmd *self, struct cmd_q *cmdq,
|
|||||||
const char **choicep;
|
const char **choicep;
|
||||||
int n, choice = -1;
|
int n, choice = -1;
|
||||||
|
|
||||||
|
if (value == NULL) {
|
||||||
|
choice = options_get_number(oo, oe->name);
|
||||||
|
if (choice < 2)
|
||||||
|
choice = !choice;
|
||||||
|
} else {
|
||||||
n = 0;
|
n = 0;
|
||||||
for (choicep = oe->choices; *choicep != NULL; choicep++) {
|
for (choicep = oe->choices; *choicep != NULL; choicep++) {
|
||||||
n++;
|
n++;
|
||||||
@ -471,6 +482,7 @@ cmd_set_option_choice(unused struct cmd *self, struct cmd_q *cmdq,
|
|||||||
cmdq_error(cmdq, "unknown value: %s", value);
|
cmdq_error(cmdq, "unknown value: %s", value);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (options_set_number(oo, oe->name, choice));
|
return (options_set_number(oo, oe->name, choice));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user