Some options tidying/code shrinkage. Also add -u option to unset non-global options (allowing them to inherit), and some extra info.

This commit is contained in:
Nicholas Marriott
2009-01-07 19:53:17 +00:00
parent 51ca51e329
commit 18312fa6fd
7 changed files with 248 additions and 202 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-window-option.c,v 1.15 2008-12-10 20:25:41 nicm Exp $ */
/* $Id: cmd-set-window-option.c,v 1.16 2009-01-07 19:53:17 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -36,8 +36,8 @@ void cmd_set_window_option_print(struct cmd *, char *, size_t);
const struct cmd_entry cmd_set_window_option_entry = {
"set-window-option", "setw",
"[-g] [-t target-window] option value",
CMD_GFLAG,
CMD_OPTION_WINDOW_USAGE,
CMD_GFLAG|CMD_UFLAG,
NULL,
cmd_option_parse,
cmd_set_window_option_exec,
@ -105,27 +105,47 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
return;
}
switch (entry->type) {
case SET_OPTION_STRING:
set_option_string(ctx, oo, entry, data->value);
break;
case SET_OPTION_NUMBER:
set_option_number(ctx, oo, entry, data->value);
break;
case SET_OPTION_KEY:
set_option_key(ctx, oo, entry, data->value);
break;
case SET_OPTION_COLOUR:
set_option_colour(ctx, oo, entry, data->value);
break;
case SET_OPTION_FLAG:
set_option_flag(ctx, oo, entry, data->value);
break;
case SET_OPTION_CHOICE:
set_option_choice(ctx, oo, entry, data->value);
break;
}
if (data->flags & CMD_UFLAG) {
if (data->flags & CMD_GFLAG) {
ctx->error(ctx,
"can't unset global option: %s", entry->name);
return;
}
if (data->value != NULL) {
ctx->error(ctx,
"value passed to unset option: %s", entry->name);
return;
}
if (options_remove(oo, entry->name) != 0) {
ctx->error(ctx,
"can't unset option, not set: %s", entry->name);
return;
}
ctx->info(ctx, "unset option: %s", entry->name);
} else {
switch (entry->type) {
case SET_OPTION_STRING:
set_option_string(ctx, oo, entry, data->value);
break;
case SET_OPTION_NUMBER:
set_option_number(ctx, oo, entry, data->value);
break;
case SET_OPTION_KEY:
set_option_key(ctx, oo, entry, data->value);
break;
case SET_OPTION_COLOUR:
set_option_colour(ctx, oo, entry, data->value);
break;
case SET_OPTION_FLAG:
set_option_flag(ctx, oo, entry, data->value);
break;
case SET_OPTION_CHOICE:
set_option_choice(ctx, oo, entry, data->value);
break;
}
}
recalculate_sizes();
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);