version 1.15, 2012/02/25 12:57:42 |
version 1.16, 2012/07/11 07:10:15 |
|
|
* Show options. |
* Show options. |
*/ |
*/ |
|
|
int cmd_show_options_exec(struct cmd *, struct cmd_ctx *); |
enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_ctx *); |
|
|
const struct cmd_entry cmd_show_options_entry = { |
const struct cmd_entry cmd_show_options_entry = { |
"show-options", "show", |
"show-options", "show", |
|
|
cmd_show_options_exec |
cmd_show_options_exec |
}; |
}; |
|
|
int |
enum cmd_retval |
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
|
|
else { |
else { |
wl = cmd_find_window(ctx, args_get(args, 't'), NULL); |
wl = cmd_find_window(ctx, args_get(args, 't'), NULL); |
if (wl == NULL) |
if (wl == NULL) |
return (-1); |
return (CMD_RETURN_ERROR); |
oo = &wl->window->options; |
oo = &wl->window->options; |
} |
} |
} else { |
} else { |
|
|
else { |
else { |
s = cmd_find_session(ctx, args_get(args, 't'), 0); |
s = cmd_find_session(ctx, args_get(args, 't'), 0); |
if (s == NULL) |
if (s == NULL) |
return (-1); |
return (CMD_RETURN_ERROR); |
oo = &s->options; |
oo = &s->options; |
} |
} |
} |
} |
|
|
table = oe = NULL; |
table = oe = NULL; |
if (options_table_find(args->argv[0], &table, &oe) != 0) { |
if (options_table_find(args->argv[0], &table, &oe) != 0) { |
ctx->error(ctx, "ambiguous option: %s", args->argv[0]); |
ctx->error(ctx, "ambiguous option: %s", args->argv[0]); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
if (oe == NULL) { |
if (oe == NULL) { |
ctx->error(ctx, "unknown option: %s", args->argv[0]); |
ctx->error(ctx, "unknown option: %s", args->argv[0]); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
if ((o = options_find1(oo, oe->name)) == NULL) |
if ((o = options_find1(oo, oe->name)) == NULL) |
return (0); |
return (CMD_RETURN_NORMAL); |
optval = options_table_print_entry(oe, o); |
optval = options_table_print_entry(oe, o); |
ctx->print(ctx, "%s %s", oe->name, optval); |
ctx->print(ctx, "%s %s", oe->name, optval); |
} else { |
} else { |
|
|
} |
} |
} |
} |
|
|
return (0); |
return (CMD_RETURN_NORMAL); |
} |
} |