version 1.56, 2012/07/10 11:53:01 |
version 1.57, 2012/07/11 07:10:15 |
|
|
* Set an option. |
* Set an option. |
*/ |
*/ |
|
|
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *); |
enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_ctx *); |
|
|
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *, |
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *, |
const struct options_table_entry *, struct options *, |
const struct options_table_entry *, struct options *, |
|
|
cmd_set_option_exec |
cmd_set_option_exec |
}; |
}; |
|
|
int |
enum cmd_retval |
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
|
|
optstr = args->argv[0]; |
optstr = args->argv[0]; |
if (*optstr == '\0') { |
if (*optstr == '\0') { |
ctx->error(ctx, "invalid option"); |
ctx->error(ctx, "invalid option"); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
if (args->argc < 2) |
if (args->argc < 2) |
valstr = NULL; |
valstr = NULL; |
|
|
table = oe = NULL; |
table = oe = NULL; |
if (options_table_find(optstr, &table, &oe) != 0) { |
if (options_table_find(optstr, &table, &oe) != 0) { |
ctx->error(ctx, "ambiguous option: %s", optstr); |
ctx->error(ctx, "ambiguous option: %s", optstr); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
if (oe == NULL) { |
if (oe == NULL) { |
ctx->error(ctx, "unknown option: %s", optstr); |
ctx->error(ctx, "unknown option: %s", optstr); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|
/* Work out the tree from the table. */ |
/* Work out the tree from the table. */ |
|
|
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 if (table == session_options_table) { |
} else if (table == session_options_table) { |
|
|
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; |
} |
} |
} else { |
} else { |
ctx->error(ctx, "unknown table"); |
ctx->error(ctx, "unknown table"); |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|
/* Unset or set the option. */ |
/* Unset or set the option. */ |
if (args_has(args, 'u')) { |
if (args_has(args, 'u')) { |
if (cmd_set_option_unset(self, ctx, oe, oo, valstr) != 0) |
if (cmd_set_option_unset(self, ctx, oe, oo, valstr) != 0) |
return (-1); |
return (CMD_RETURN_ERROR); |
} else { |
} else { |
if (cmd_set_option_set(self, ctx, oe, oo, valstr) != 0) |
if (cmd_set_option_set(self, ctx, oe, oo, valstr) != 0) |
return (-1); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|
/* Start or stop timers when automatic-rename changed. */ |
/* Start or stop timers when automatic-rename changed. */ |
|
|
server_redraw_client(c); |
server_redraw_client(c); |
} |
} |
|
|
return (0); |
return (CMD_RETURN_NORMAL); |
} |
} |
|
|
/* Unset an option. */ |
/* Unset an option. */ |