version 1.59, 2020/04/13 07:25:33 |
version 1.60, 2020/04/13 08:26:27 |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_show_options_exec(struct cmd *self, struct cmdq_item *item) |
cmd_show_options_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = cmd_get_args(self); |
struct cmd_find_state *fs = &item->target; |
struct cmd_find_state *fs = &item->target; |
struct client *c = cmd_find_client(item, NULL, 1); |
struct client *c = cmd_find_client(item, NULL, 1); |
struct session *s = item->target.s; |
struct session *s = item->target.s; |
|
|
int window, idx, ambiguous, parent, scope; |
int window, idx, ambiguous, parent, scope; |
struct options_entry *o; |
struct options_entry *o; |
|
|
window = (self->entry == &cmd_show_window_options_entry); |
window = (cmd_get_entry(self) == &cmd_show_window_options_entry); |
|
|
if (args->argc == 0) { |
if (args->argc == 0) { |
scope = options_scope_from_flags(args, window, fs, &oo, &cause); |
scope = options_scope_from_flags(args, window, fs, &oo, &cause); |
|
|
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, int parent) |
struct options_entry *o, int idx, int parent) |
{ |
{ |
|
struct args *args = cmd_get_args(self); |
struct options_array_item *a; |
struct options_array_item *a; |
const char *name = options_name(o); |
const char *name = options_name(o); |
char *value, *tmp = NULL, *escaped; |
char *value, *tmp = NULL, *escaped; |
|
|
if (options_isarray(o)) { |
if (options_isarray(o)) { |
a = options_array_first(o); |
a = options_array_first(o); |
if (a == NULL) { |
if (a == NULL) { |
if (!args_has(self->args, 'v')) |
if (!args_has(args, 'v')) |
cmdq_print(item, "%s", name); |
cmdq_print(item, "%s", name); |
return; |
return; |
} |
} |
|
|
} |
} |
|
|
value = options_tostring(o, idx, 0); |
value = options_tostring(o, idx, 0); |
if (args_has(self->args, 'v')) |
if (args_has(args, 'v')) |
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); |
|
|
cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope, |
cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope, |
struct options *oo) |
struct options *oo) |
{ |
{ |
|
struct args *args = cmd_get_args(self); |
const struct options_table_entry *oe; |
const struct options_table_entry *oe; |
struct options_entry *o; |
struct options_entry *o; |
struct options_array_item *a; |
struct options_array_item *a; |
|
|
if (~oe->scope & scope) |
if (~oe->scope & scope) |
continue; |
continue; |
|
|
if ((self->entry != &cmd_show_hooks_entry && |
if ((cmd_get_entry(self) != &cmd_show_hooks_entry && |
!args_has(self->args, 'H') && |
!args_has(args, 'H') && |
(oe->flags & OPTIONS_TABLE_IS_HOOK)) || |
(oe->flags & OPTIONS_TABLE_IS_HOOK)) || |
(self->entry == &cmd_show_hooks_entry && |
(cmd_get_entry(self) == &cmd_show_hooks_entry && |
(~oe->flags & OPTIONS_TABLE_IS_HOOK))) |
(~oe->flags & OPTIONS_TABLE_IS_HOOK))) |
continue; |
continue; |
|
|
o = options_get_only(oo, oe->name); |
o = options_get_only(oo, oe->name); |
if (o == NULL) { |
if (o == NULL) { |
if (!args_has(self->args, 'A')) |
if (!args_has(args, 'A')) |
continue; |
continue; |
o = options_get(oo, oe->name); |
o = options_get(oo, oe->name); |
if (o == NULL) |
if (o == NULL) |
|
|
if (!options_isarray(o)) |
if (!options_isarray(o)) |
cmd_show_options_print(self, item, o, -1, parent); |
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(args, 'v')) { |
name = options_name(o); |
name = options_name(o); |
if (parent) |
if (parent) |
cmdq_print(item, "%s*", name); |
cmdq_print(item, "%s*", name); |