version 1.53, 2019/05/23 18:33:53 |
version 1.54, 2019/06/20 07:10:56 |
|
|
static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *); |
static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *); |
|
|
static void cmd_show_options_print(struct cmd *, struct cmdq_item *, |
static void cmd_show_options_print(struct cmd *, struct cmdq_item *, |
struct options_entry *, int); |
struct options_entry *, int, int); |
static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *, |
static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *, |
struct options *); |
enum options_table_scope, struct options *); |
|
|
const struct cmd_entry cmd_show_options_entry = { |
const struct cmd_entry cmd_show_options_entry = { |
.name = "show-options", |
.name = "show-options", |
.alias = "show", |
.alias = "show", |
|
|
.args = { "gHqst:vw", 0, 1 }, |
.args = { "AgHqst:vw", 0, 1 }, |
.usage = "[-gHqsvw] [-t target-session|target-window] [option]", |
.usage = "[-AgHqsvw] [-t target-session|target-window] [option]", |
|
|
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL }, |
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL }, |
|
|
|
|
enum options_table_scope scope; |
enum options_table_scope scope; |
char *argument, *name = NULL, *cause; |
char *argument, *name = NULL, *cause; |
const char *target; |
const char *target; |
int window, idx, ambiguous; |
int window, idx, ambiguous, parent; |
struct options_entry *o; |
struct options_entry *o; |
|
|
window = (self->entry == &cmd_show_window_options_entry); |
window = (self->entry == &cmd_show_window_options_entry); |
|
|
free(cause); |
free(cause); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
return (cmd_show_options_all(self, item, oo)); |
return (cmd_show_options_all(self, item, scope, oo)); |
} |
} |
argument = format_single(item, args->argv[0], c, s, wl, NULL); |
argument = format_single(item, args->argv[0], c, s, wl, NULL); |
|
|
|
|
goto fail; |
goto fail; |
} |
} |
o = options_get_only(oo, name); |
o = options_get_only(oo, name); |
|
if (args_has(args, 'A') && o == NULL) { |
|
o = options_get(oo, name); |
|
parent = 1; |
|
} else |
|
parent = 0; |
if (o != NULL) |
if (o != NULL) |
cmd_show_options_print(self, item, o, idx); |
cmd_show_options_print(self, item, o, idx, parent); |
|
|
free(name); |
free(name); |
free(argument); |
free(argument); |
|
|
|
|
static void |
static void |
cmd_show_options_print(struct cmd *self, struct cmdq_item *item, |
cmd_show_options_print(struct cmd *self, struct cmdq_item *item, |
struct options_entry *o, int idx) |
struct options_entry *o, int idx, int parent) |
{ |
{ |
struct options_array_item *a; |
struct options_array_item *a; |
const char *name = options_name(o); |
const char *name = options_name(o); |
|
|
} |
} |
while (a != NULL) { |
while (a != NULL) { |
idx = options_array_item_index(a); |
idx = options_array_item_index(a); |
cmd_show_options_print(self, item, o, idx); |
cmd_show_options_print(self, item, o, idx, |
|
parent); |
a = options_array_next(a); |
a = options_array_next(a); |
} |
} |
return; |
return; |
|
|
cmdq_print(item, "%s", value); |
cmdq_print(item, "%s", value); |
else if (options_isstring(o)) { |
else if (options_isstring(o)) { |
escaped = args_escape(value); |
escaped = args_escape(value); |
cmdq_print(item, "%s %s", name, escaped); |
if (parent) |
|
cmdq_print(item, "%s* %s", name, escaped); |
|
else |
|
cmdq_print(item, "%s %s", name, escaped); |
free(escaped); |
free(escaped); |
} else |
} else { |
cmdq_print(item, "%s %s", name, value); |
if (parent) |
|
cmdq_print(item, "%s* %s", name, value); |
|
else |
|
cmdq_print(item, "%s %s", name, value); |
|
} |
free(value); |
free(value); |
|
|
free(tmp); |
free(tmp); |
|
|
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_show_options_all(struct cmd *self, struct cmdq_item *item, |
cmd_show_options_all(struct cmd *self, struct cmdq_item *item, |
struct options *oo) |
enum options_table_scope scope, struct options *oo) |
{ |
{ |
|
const struct options_table_entry *oe; |
struct options_entry *o; |
struct options_entry *o; |
struct options_array_item *a; |
struct options_array_item *a; |
u_int idx; |
u_int idx; |
const struct options_table_entry *oe; |
int parent; |
|
|
o = options_first(oo); |
for (oe = options_table; oe->name != NULL; oe++) { |
while (o != NULL) { |
if (oe->scope != scope) |
oe = options_table_entry(o); |
continue; |
|
|
if ((self->entry != &cmd_show_hooks_entry && |
if ((self->entry != &cmd_show_hooks_entry && |
!args_has(self->args, 'H') && |
!args_has(self->args, 'H') && |
oe != NULL && |
oe != NULL && |
(oe->flags & OPTIONS_TABLE_IS_HOOK)) || |
(oe->flags & OPTIONS_TABLE_IS_HOOK)) || |
(self->entry == &cmd_show_hooks_entry && |
(self->entry == &cmd_show_hooks_entry && |
(oe == NULL || |
(oe == NULL || |
(~oe->flags & OPTIONS_TABLE_IS_HOOK)))) { |
(~oe->flags & OPTIONS_TABLE_IS_HOOK)))) |
o = options_next(o); |
|
continue; |
continue; |
} |
|
|
o = options_get_only(oo, oe->name); |
|
if (o == NULL) { |
|
if (!args_has(self->args, 'A')) |
|
continue; |
|
o = options_get(oo, oe->name); |
|
if (o == NULL) |
|
continue; |
|
parent = 1; |
|
} else |
|
parent = 0; |
|
|
if (!options_isarray(o)) |
if (!options_isarray(o)) |
cmd_show_options_print(self, item, o, -1); |
cmd_show_options_print(self, item, o, -1, parent); |
else if ((a = options_array_first(o)) == NULL) { |
else if ((a = options_array_first(o)) == NULL) { |
if (!args_has(self->args, 'v')) |
if (!args_has(self->args, 'v')) { |
cmdq_print(item, "%s", options_name(o)); |
if (parent) |
|
cmdq_print(item, "%s*", options_name(o)); |
|
else |
|
cmdq_print(item, "%s", options_name(o)); |
|
} |
} else { |
} else { |
while (a != NULL) { |
while (a != NULL) { |
idx = options_array_item_index(a); |
idx = options_array_item_index(a); |
cmd_show_options_print(self, item, o, idx); |
cmd_show_options_print(self, item, o, idx, parent); |
a = options_array_next(a); |
a = options_array_next(a); |
} |
} |
} |
} |
o = options_next(o); |
|
} |
} |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
} |
} |