diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-07-14 06:43:33 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-07-14 06:43:33 +0000 |
commit | 097b96ea44d5a09ac1f3553f1789ef6e932a9eba (patch) | |
tree | 73b9da430bb07a47de4a95690427bc14768eb61a | |
parent | 5ccd0025a0867c9f5d9f173537c8336c7492bc8e (diff) | |
download | rtmux-097b96ea44d5a09ac1f3553f1789ef6e932a9eba.tar.gz rtmux-097b96ea44d5a09ac1f3553f1789ef6e932a9eba.tar.bz2 rtmux-097b96ea44d5a09ac1f3553f1789ef6e932a9eba.zip |
Having fixed flags for single-character getopt options is a bit hard to
maintain and is only going to get worse as more are used. So instead, add a new
uint64_t member to cmd_entry which is a bitmask of upper and lowercase options
accepted by the command.
This means new single character options can be used without the need to add it
explicitly to the list.
73 files changed, 264 insertions, 302 deletions
diff --git a/cmd-attach-session.c b/cmd-attach-session.c index 898bf645..2516b528 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-attach-session.c,v 1.26 2009-06-25 16:34:50 nicm Exp $ */ +/* $Id: cmd-attach-session.c,v 1.27 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_attach_session_entry = { "attach-session", "attach", "[-d] " CMD_TARGET_SESSION_USAGE, - CMD_DFLAG|CMD_CANTNEST|CMD_STARTSERVER, + CMD_CANTNEST|CMD_STARTSERVER, CMD_CHFLAG('d'), cmd_target_init, cmd_target_parse, cmd_attach_session_exec, @@ -67,7 +67,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); } - if (data->flags & CMD_DFLAG) + if (data->chflags & CMD_CHFLAG('d')) server_write_session(s, MSG_DETACH, NULL, 0); ctx->cmdclient->session = s; diff --git a/cmd-bind-key.c b/cmd-bind-key.c index 33a04164..393bc46e 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-bind-key.c,v 1.21 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd-bind-key.c,v 1.22 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -40,7 +40,7 @@ struct cmd_bind_key_data { const struct cmd_entry cmd_bind_key_entry = { "bind-key", "bind", "[-r] key command [arguments]", - 0, + 0, 0, NULL, cmd_bind_key_parse, cmd_bind_key_exec, diff --git a/cmd-break-pane.c b/cmd-break-pane.c index 88271971..0c4b89e4 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-break-pane.c,v 1.3 2009-05-18 21:01:38 nicm Exp $ */ +/* $Id: cmd-break-pane.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_break_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_break_pane_entry = { "break-pane", "breakp", CMD_PANE_WINDOW_USAGE " [-d]", - CMD_DFLAG, + 0, CMD_CHFLAG('d'), cmd_pane_init, cmd_pane_parse, cmd_break_pane_exec, @@ -82,7 +82,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->name = default_window_name(w); wl = session_attach(s, w, -1, &cause); /* can't fail */ - if (!(data->flags & CMD_DFLAG)) + if (!(data->chflags & CMD_CHFLAG('d'))) session_select(s, wl->idx); layout_refresh(w, 0); diff --git a/cmd-choose-session.c b/cmd-choose-session.c index 84569a68..d92fabb8 100644 --- a/cmd-choose-session.c +++ b/cmd-choose-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-choose-session.c,v 1.7 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd-choose-session.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ void cmd_choose_session_callback(void *, int); const struct cmd_entry cmd_choose_session_entry = { "choose-session", NULL, CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_choose_session_exec, diff --git a/cmd-choose-window.c b/cmd-choose-window.c index ede89516..fa1e6f24 100644 --- a/cmd-choose-window.c +++ b/cmd-choose-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-choose-window.c,v 1.9 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd-choose-window.c,v 1.10 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ void cmd_choose_window_callback(void *, int); const struct cmd_entry cmd_choose_window_entry = { "choose-window", NULL, CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_choose_window_exec, diff --git a/cmd-clear-history.c b/cmd-clear-history.c index d012c043..a000d486 100644 --- a/cmd-clear-history.c +++ b/cmd-clear-history.c @@ -1,4 +1,4 @@ -/* $Id: cmd-clear-history.c,v 1.3 2009-06-25 16:21:32 nicm Exp $ */ +/* $Id: cmd-clear-history.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_clear_history_entry = { "clear-history", "clearhist", CMD_PANE_WINDOW_USAGE, - 0, + 0, 0, cmd_pane_init, cmd_pane_parse, cmd_clear_history_exec, diff --git a/cmd-clock-mode.c b/cmd-clock-mode.c index de10833d..b1649d53 100644 --- a/cmd-clock-mode.c +++ b/cmd-clock-mode.c @@ -1,4 +1,4 @@ -/* $Id: cmd-clock-mode.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-clock-mode.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_clock_mode_entry = { "clock-mode", NULL, CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_clock_mode_exec, diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index 52f8db1b..05d7b1f3 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -1,4 +1,4 @@ -/* $Id: cmd-command-prompt.c,v 1.16 2009-02-16 18:58:14 nicm Exp $ */ +/* $Id: cmd-command-prompt.c,v 1.17 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,7 +35,7 @@ int cmd_command_prompt_callback(void *, const char *); const struct cmd_entry cmd_command_prompt_entry = { "command-prompt", NULL, CMD_TARGET_CLIENT_USAGE " [template]", - CMD_ARG01, + CMD_ARG01, 0, cmd_command_prompt_init, cmd_target_parse, cmd_command_prompt_exec, diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c index 60a0a1c9..dd3e88e7 100644 --- a/cmd-confirm-before.c +++ b/cmd-confirm-before.c @@ -1,4 +1,4 @@ -/* $Id: cmd-confirm-before.c,v 1.4 2009-04-28 18:29:44 tcunha Exp $ */ +/* $Id: cmd-confirm-before.c,v 1.5 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -38,7 +38,7 @@ struct cmd_confirm_before_data { const struct cmd_entry cmd_confirm_before_entry = { "confirm-before", "confirm", CMD_TARGET_CLIENT_USAGE " command", - CMD_ARG1, + CMD_ARG1, 0, cmd_confirm_before_init, cmd_target_parse, cmd_confirm_before_exec, diff --git a/cmd-copy-buffer.c b/cmd-copy-buffer.c index c72cbb5b..53538104 100644 --- a/cmd-copy-buffer.c +++ b/cmd-copy-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-copy-buffer.c,v 1.1 2009-02-03 17:21:19 tcunha Exp $ */ +/* $Id: cmd-copy-buffer.c,v 1.2 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -42,7 +42,7 @@ struct cmd_copy_buffer_data { const struct cmd_entry cmd_copy_buffer_entry = { "copy-buffer", "copyb", "[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]", - 0, + 0, 0, cmd_copy_buffer_init, cmd_copy_buffer_parse, cmd_copy_buffer_exec, diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index e46abe70..19486539 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -1,4 +1,4 @@ -/* $Id: cmd-copy-mode.c,v 1.20 2009-07-14 06:42:22 nicm Exp $ */ +/* $Id: cmd-copy-mode.c,v 1.21 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_copy_mode_entry = { "copy-mode", NULL, "[-u] " CMD_TARGET_WINDOW_USAGE, - CMD_UFLAG, + 0, CMD_CHFLAG('u'), cmd_target_init, cmd_target_parse, cmd_copy_mode_exec, @@ -51,7 +51,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx) wp = wl->window->active; window_pane_set_mode(wp, &window_copy_mode); - if (wp->mode == &window_copy_mode && data->flags & CMD_UFLAG) + if (wp->mode == &window_copy_mode && data->chflags & CMD_CHFLAG('u')) window_copy_pageup(wp); return (0); diff --git a/cmd-delete-buffer.c b/cmd-delete-buffer.c index f94e4c13..0b190eee 100644 --- a/cmd-delete-buffer.c +++ b/cmd-delete-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-delete-buffer.c,v 1.5 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd-delete-buffer.c,v 1.6 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_delete_buffer_entry = { "delete-buffer", "deleteb", CMD_BUFFER_SESSION_USAGE, - 0, + 0, 0, cmd_buffer_init, cmd_buffer_parse, cmd_delete_buffer_exec, diff --git a/cmd-detach-client.c b/cmd-detach-client.c index 3c0879e1..67f85a1e 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-detach-client.c,v 1.7 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-detach-client.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_detach_client_entry = { "detach-client", "detach", CMD_TARGET_CLIENT_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_detach_client_exec, diff --git a/cmd-down-pane.c b/cmd-down-pane.c index af67bbac..8a48c38a 100644 --- a/cmd-down-pane.c +++ b/cmd-down-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-down-pane.c,v 1.7 2009-04-01 21:10:08 nicm Exp $ */ +/* $Id: cmd-down-pane.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_down_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_down_pane_entry = { "down-pane", "downp", CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_down_pane_exec, diff --git a/cmd-find-window.c b/cmd-find-window.c index 1e024efd..2534d067 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-find-window.c,v 1.10 2009-06-25 16:21:32 nicm Exp $ */ +/* $Id: cmd-find-window.c,v 1.11 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,7 +34,7 @@ void cmd_find_window_callback(void *, int); const struct cmd_entry cmd_find_window_entry = { "find-window", "findw", CMD_TARGET_WINDOW_USAGE " match-string", - CMD_ARG1, + CMD_ARG1, 0, cmd_target_init, cmd_target_parse, cmd_find_window_exec, diff --git a/cmd-generic.c b/cmd-generic.c index b82f9c8e..ea0f0039 100644 --- a/cmd-generic.c +++ b/cmd-generic.c @@ -1,4 +1,4 @@ -/* $Id: cmd-generic.c,v 1.29 2009-07-12 17:11:39 nicm Exp $ */ +/* $Id: cmd-generic.c,v 1.30 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -23,12 +23,9 @@ #include "tmux.h" -#define CMD_FLAGS "adDgkruU" -#define CMD_FLAGMASK (CMD_AFLAG|CMD_DFLAG|CMD_BIGDFLAG|CMD_GFLAG|CMD_KFLAG| \ - CMD_RFLAG|CMD_UFLAG|CMD_BIGUFLAG) - -int cmd_do_flags(int, int, int *); -size_t cmd_print_flags(char *, size_t, size_t, int); +int cmd_getopt(int, char **, const char *, uint64_t); +int cmd_flags(int, uint64_t, uint64_t *); +size_t cmd_print_flags(char *, size_t, size_t, uint64_t); int cmd_fill_argument(int, char **, int, char **); size_t @@ -39,86 +36,70 @@ cmd_prarg(char *buf, size_t len, const char *prefix, char *arg) return (xsnprintf(buf, len, "%s%s", prefix, arg)); } +/* Prepend flags from chflags onto flagstr and call getopt. */ int -cmd_do_flags(int opt, int iflags, int *oflags) +cmd_getopt(int argc, char **argv, const char *flagstr, uint64_t chflags) { - switch (opt) { - case 'a': - if (iflags & CMD_AFLAG) { - (*oflags) |= CMD_AFLAG; - return (0); - } - return (-1); - case 'd': - if (iflags & CMD_DFLAG) { - (*oflags) |= CMD_DFLAG; - return (0); - } - return (-1); - case 'D': - if (iflags & CMD_BIGDFLAG) { - (*oflags) |= CMD_BIGDFLAG; - return (0); - } - return (-1); - case 'g': - if (iflags & CMD_GFLAG) { - (*oflags) |= CMD_GFLAG; - return (0); - } - return (-1); - case 'k': - if (iflags & CMD_KFLAG) { - (*oflags) |= CMD_KFLAG; - return (0); - } - return (-1); - case 'r': - if (iflags & CMD_RFLAG) { - (*oflags) |= CMD_RFLAG; - return (0); - } - return (-1); - case 'u': - if (iflags & CMD_UFLAG) { - (*oflags) |= CMD_UFLAG; + u_char ch; + char buf[128]; + size_t len, off; + + *buf = '\0'; + + len = sizeof buf; + off = 0; + + for (ch = 0; ch < 26; ch++) { + if (chflags & CMD_CHFLAG('a' + ch)) + off += xsnprintf(buf + off, len - off, "%c", 'a' + ch); + if (chflags & CMD_CHFLAG('A' + ch)) + off += xsnprintf(buf + off, len - off, "%c", 'A' + ch); + } + + strlcat(buf, flagstr, sizeof buf); + + return (getopt(argc, argv, buf)); +} + +/* + * If this option is expected (in ichflags), set it in ochflags, otherwise + * return -1. + */ +int +cmd_flags(int opt, uint64_t ichflags, uint64_t *ochflags) +{ + u_char ch; + + for (ch = 0; ch < 26; ch++) { + if (opt == 'a' + ch && ichflags & CMD_CHFLAG(opt)) { + (*ochflags) |= CMD_CHFLAG(opt); return (0); } - return (-1); - case 'U': - if (iflags & CMD_BIGUFLAG) { - (*oflags) |= CMD_BIGUFLAG; + if (opt == 'A' + ch && ichflags & CMD_CHFLAG(opt)) { + (*ochflags) |= CMD_CHFLAG(opt); return (0); } - return (-1); } - return (1); + return (-1); } +/* Print the flags supported in chflags. */ size_t -cmd_print_flags(char *buf, size_t len, size_t off, int flags) +cmd_print_flags(char *buf, size_t len, size_t off, uint64_t chflags) { + u_char ch; size_t boff = off; - if ((flags & CMD_FLAGMASK) == 0) + if (chflags == 0) return (0); off += xsnprintf(buf + off, len - off, " -"); - if (off < len && flags & CMD_AFLAG) - off += xsnprintf(buf + off, len - off, "a"); - if (off < len && flags & CMD_BIGDFLAG) - off += xsnprintf(buf + off, len - off, "D"); - if (off < len && flags & CMD_DFLAG) - off += xsnprintf(buf + off, len - off, "d"); - if (off < len && flags & CMD_GFLAG) - off += xsnprintf(buf + off, len - off, "g"); - if (off < len && flags & CMD_KFLAG) - off += xsnprintf(buf + off, len - off, "k"); - if (off < len && flags & CMD_RFLAG) - off += xsnprintf(buf + off, len - off, "r"); - if (off < len && flags & CMD_UFLAG) - off += xsnprintf(buf + off, len - off, "u"); - if (off < len && flags & CMD_BIGUFLAG) - off += xsnprintf(buf + off, len - off, "U"); + + for (ch = 0; ch < 26; ch++) { + if (chflags & CMD_CHFLAG('a' + ch)) + off += xsnprintf(buf + off, len - off, "%c", 'a' + ch); + if (chflags & CMD_CHFLAG('A' + ch)) + off += xsnprintf(buf + off, len - off, "%c", 'A' + ch); + } return (off - boff); } @@ -153,7 +134,7 @@ cmd_target_init(struct cmd *self, unused int key) struct cmd_target_data *data; self->data = data = xmalloc(sizeof *data); - data->flags = 0; + data->chflags = 0; data->target = NULL; data->arg = NULL; } @@ -162,19 +143,16 @@ int cmd_target_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_target_data *data; + const struct cmd_entry *entry = self->entry; int opt; /* Don't use the entry version since it may be dependent on key. */ cmd_target_init(self, 0); data = self->data; - while ((opt = getopt(argc, argv, CMD_FLAGS "t:")) != -1) { - switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) { - case -1: - goto usage; - case 0: + while ((opt = cmd_getopt(argc, argv, "t:", entry->chflags)) != -1) { + if (cmd_flags(opt, entry->chflags, &data->chflags) == 0) continue; - } switch (opt) { case 't': if (data->target == NULL) @@ -240,7 +218,7 @@ cmd_target_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return (off); - off += cmd_print_flags(buf, len, off, data->flags); + off += cmd_print_flags(buf, len, off, data->chflags); if (off < len && data->target != NULL) off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->arg != NULL) @@ -254,7 +232,7 @@ cmd_srcdst_init(struct cmd *self, unused int key) struct cmd_srcdst_data *data; self->data = data = xmalloc(sizeof *data); - data->flags = 0; + data->chflags = 0; data->src = NULL; data->dst = NULL; data->arg = NULL; @@ -264,18 +242,15 @@ int cmd_srcdst_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_srcdst_data *data; + const struct cmd_entry *entry = self->entry; int opt; cmd_srcdst_init(self, 0); data = self->data; - while ((opt = getopt(argc, argv, CMD_FLAGS "s:t:")) != -1) { - switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) { - case -1: - goto usage; - case 0: + while ((opt = cmd_getopt(argc, argv, "s:t:", entry->chflags)) != -1) { + if (cmd_flags(opt, entry->chflags, &data->chflags) == 0) continue; - } switch (opt) { case 's': if (data->src == NULL) @@ -349,7 +324,7 @@ cmd_srcdst_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return (off); - off += cmd_print_flags(buf, len, off, data->flags); + off += cmd_print_flags(buf, len, off, data->chflags); if (off < len && data->src != NULL) off += xsnprintf(buf + off, len - off, " -s %s", data->src); if (off < len && data->dst != NULL) @@ -365,7 +340,7 @@ cmd_buffer_init(struct cmd *self, unused int key) struct cmd_buffer_data *data; self->data = data = xmalloc(sizeof *data); - data->flags = 0; + data->chflags = 0; data->target = NULL; data->buffer = -1; data->arg = NULL; @@ -375,19 +350,16 @@ int cmd_buffer_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_buffer_data *data; + const struct cmd_entry *entry = self->entry; int opt, n; const char *errstr; cmd_buffer_init(self, 0); data = self->data; - while ((opt = getopt(argc, argv, CMD_FLAGS "b:t:")) != -1) { - switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) { - case -1: - goto usage; - case 0: + while ((opt = cmd_getopt(argc, argv, "b:t:", entry->chflags)) != -1) { + if (cmd_flags(opt, entry->chflags, &data->chflags) == 0) continue; - } switch (opt) { case 'b': if (data->buffer == -1) { @@ -464,7 +436,7 @@ cmd_buffer_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return (off); - off += cmd_print_flags(buf, len, off, data->flags); + off += cmd_print_flags(buf, len, off, data->chflags); if (off < len && data->buffer != -1) off += xsnprintf(buf + off, len - off, " -b %d", data->buffer); if (off < len && data->target != NULL) @@ -480,7 +452,7 @@ cmd_option_init(struct cmd *self, unused int key) struct cmd_option_data *data; self->data = data = xmalloc(sizeof *data); - data->flags = 0; + data->chflags = 0; data->target = NULL; data->option = NULL; data->value = NULL; @@ -490,19 +462,16 @@ int cmd_option_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_option_data *data; + const struct cmd_entry *entry = self->entry; int opt; /* Don't use the entry version since it may be dependent on key. */ cmd_option_init(self, 0); data = self->data; - while ((opt = getopt(argc, argv, CMD_FLAGS "t:")) != -1) { - switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) { - case -1: - goto usage; - case 0: + while ((opt = cmd_getopt(argc, argv, "t:", entry->chflags)) != -1) { + if (cmd_flags(opt, entry->chflags, &data->chflags) == 0) continue; - } switch (opt) { case 't': if (data->target == NULL) @@ -577,7 +546,7 @@ cmd_option_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return (off); - off += cmd_print_flags(buf, len, off, data->flags); + off += cmd_print_flags(buf, len, off, data->chflags); if (off < len && data->target != NULL) off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->option != NULL) @@ -593,7 +562,7 @@ cmd_pane_init(struct cmd *self, unused int key) struct cmd_pane_data *data; self->data = data = xmalloc(sizeof *data); - data->flags = 0; + data->chflags = 0; data->target = NULL; data->arg = NULL; data->pane = -1; @@ -603,6 +572,7 @@ int cmd_pane_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_pane_data *data; + const struct cmd_entry *entry = self->entry; int opt, n; const char *errstr; @@ -610,13 +580,9 @@ cmd_pane_parse(struct cmd *self, int argc, char **argv, char **cause) cmd_pane_init(self, 0); data = self->data; - while ((opt = getopt(argc, argv, CMD_FLAGS "p:t:")) != -1) { - switch (cmd_do_flags(opt, self->entry->flags, &data->flags)) { - case -1: - goto usage; - case 0: + while ((opt = cmd_getopt(argc, argv, "p:t:", entry->chflags)) != -1) { + if (cmd_flags(opt, entry->chflags, &data->chflags) == 0) continue; - } switch (opt) { case 'p': if (data->pane == -1) { @@ -693,7 +659,7 @@ cmd_pane_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return (off); - off += cmd_print_flags(buf, len, off, data->flags); + off += cmd_print_flags(buf, len, off, data->chflags); if (off < len && data->target != NULL) off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->arg != NULL) diff --git a/cmd-has-session.c b/cmd-has-session.c index 9cd3f128..27f124e3 100644 --- a/cmd-has-session.c +++ b/cmd-has-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-has-session.c,v 1.12 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-has-session.c,v 1.13 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_has_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_has_session_entry = { "has-session", "has", CMD_TARGET_SESSION_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_has_session_exec, diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 79972657..de7b0a83 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -1,4 +1,4 @@ -/* $Id: cmd-if-shell.c,v 1.2 2009-07-09 18:16:36 nicm Exp $ */ +/* $Id: cmd-if-shell.c,v 1.3 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -44,7 +44,7 @@ struct cmd_if_shell_data { const struct cmd_entry cmd_if_shell_entry = { "if-shell", "if", "shell-command command", - 0, + 0, 0, cmd_if_shell_init, cmd_if_shell_parse, cmd_if_shell_exec, diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c index 7795d603..79ea24a6 100644 --- a/cmd-kill-pane.c +++ b/cmd-kill-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-pane.c,v 1.7 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd-kill-pane.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_kill_pane_entry = { "kill-pane", "killp", CMD_PANE_WINDOW_USAGE, - 0, + 0, 0, cmd_pane_init, cmd_pane_parse, cmd_kill_pane_exec, diff --git a/cmd-kill-server.c b/cmd-kill-server.c index b35a1c9c..b65091f7 100644 --- a/cmd-kill-server.c +++ b/cmd-kill-server.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-server.c,v 1.6 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-kill-server.c,v 1.7 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_kill_server_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_kill_server_entry = { "kill-server", NULL, "", - 0, + 0, 0, NULL, NULL, cmd_kill_server_exec, diff --git a/cmd-kill-session.c b/cmd-kill-session.c index 5b0e643c..6e42458f 100644 --- a/cmd-kill-session.c +++ b/cmd-kill-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-session.c,v 1.12 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-kill-session.c,v 1.13 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_kill_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_kill_session_entry = { "kill-session", NULL, CMD_TARGET_SESSION_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_kill_session_exec, diff --git a/cmd-kill-window.c b/cmd-kill-window.c index e7fb4d62..b4d47005 100644 --- a/cmd-kill-window.c +++ b/cmd-kill-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-window.c,v 1.15 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-kill-window.c,v 1.16 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_kill_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_kill_window_entry = { "kill-window", "killw", CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_kill_window_exec, diff --git a/cmd-last-window.c b/cmd-last-window.c index e040eb3a..9523c039 100644 --- a/cmd-last-window.c +++ b/cmd-last-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-last-window.c,v 1.16 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-last-window.c,v 1.17 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_last_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_last_window_entry = { "last-window", "last", CMD_TARGET_SESSION_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_last_window_exec, diff --git a/cmd-link-window.c b/cmd-link-window.c index fd08c586..1f8115da 100644 --- a/cmd-link-window.c +++ b/cmd-link-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-link-window.c,v 1.29 2009-07-14 06:42:05 nicm Exp $ */ +/* $Id: cmd-link-window.c,v 1.30 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_link_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_link_window_entry = { "link-window", "linkw", "[-dk] " CMD_SRCDST_WINDOW_USAGE, - CMD_DFLAG|CMD_KFLAG, + 0, CMD_CHFLAG('d')|CMD_CHFLAG('k'), cmd_srcdst_init, cmd_srcdst_parse, cmd_link_window_exec, @@ -62,7 +62,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (wl_dst->window == wl_src->window) return (0); - if (data->flags & CMD_KFLAG) { + if (data->chflags & CMD_CHFLAG('k')) { /* * Can't use session_detach as it will destroy session * if this makes it empty. @@ -73,7 +73,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) /* Force select/redraw if current. */ if (wl_dst == dst->curw) { - data->flags &= ~CMD_DFLAG; + data->chflags &= ~CMD_CHFLAG('d'); dst->curw = NULL; } } @@ -86,7 +86,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); } - if (data->flags & CMD_DFLAG) + if (data->chflags & CMD_CHFLAG('d')) server_status_session(dst); else { session_select(dst, wl_dst->idx); diff --git a/cmd-list-buffers.c b/cmd-list-buffers.c index c4c042f2..38fa5abb 100644 --- a/cmd-list-buffers.c +++ b/cmd-list-buffers.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-buffers.c,v 1.7 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-list-buffers.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_buffers_entry = { "list-buffers", "lsb", CMD_TARGET_SESSION_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_list_buffers_exec, diff --git a/cmd-list-clients.c b/cmd-list-clients.c index 7cc3cea3..1bfa978f 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-clients.c,v 1.16 2009-06-25 16:34:50 nicm Exp $ */ +/* $Id: cmd-list-clients.c,v 1.17 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_list_clients_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_clients_entry = { "list-clients", "lsc", "", - 0, + 0, 0, NULL, NULL, cmd_list_clients_exec, diff --git a/cmd-list-commands.c b/cmd-list-commands.c index 99451123..11523b83 100644 --- a/cmd-list-commands.c +++ b/cmd-list-commands.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-commands.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-list-commands.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_list_commands_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_commands_entry = { "list-commands", "lscm", "", - 0, + 0, 0, NULL, NULL, cmd_list_commands_exec, diff --git a/cmd-list-keys.c b/cmd-list-keys.c index ce022fbc..056eb58c 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-keys.c,v 1.14 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd-list-keys.c,v 1.15 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_list_keys_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_keys_entry = { "list-keys", "lsk", "", - 0, + 0, 0, NULL, NULL, cmd_list_keys_exec, diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c index 135adbd6..a5a3887e 100644 --- a/cmd-list-sessions.c +++ b/cmd-list-sessions.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-sessions.c,v 1.19 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-list-sessions.c,v 1.20 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_sessions_entry = { "list-sessions", "ls", "", - 0, + 0, 0, NULL, NULL, cmd_list_sessions_exec, diff --git a/cmd-list-windows.c b/cmd-list-windows.c index dec5c6f3..bafb55b7 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-windows.c,v 1.35 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd-list-windows.c,v 1.36 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_windows_entry = { "list-windows", "lsw", CMD_TARGET_SESSION_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_list_windows_exec, diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c index f510736f..ef70b0a8 100644 --- a/cmd-load-buffer.c +++ b/cmd-load-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-load-buffer.c,v 1.6 2009-07-09 18:08:29 nicm Exp $ */ +/* $Id: cmd-load-buffer.c,v 1.7 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -35,7 +35,7 @@ int cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_load_buffer_entry = { "load-buffer", "loadb", CMD_BUFFER_SESSION_USAGE " path", - CMD_ARG1, + CMD_ARG1, 0, cmd_buffer_init, cmd_buffer_parse, cmd_load_buffer_exec, diff --git a/cmd-lock-server.c b/cmd-lock-server.c index d1244002..25a6c4da 100644 --- a/cmd-lock-server.c +++ b/cmd-lock-server.c @@ -1,4 +1,4 @@ -/* $Id: cmd-lock-server.c,v 1.4 2009-06-25 16:21:32 nicm Exp $ */ +/* $Id: cmd-lock-server.c,v 1.5 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,7 +33,7 @@ int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_lock_server_entry = { "lock-server", "lock", "", - 0, + 0, 0, NULL, NULL, cmd_lock_server_exec, diff --git a/cmd-move-window.c b/cmd-move-window.c index 7881c2e0..f43d7593 100644 --- a/cmd-move-window.c +++ b/cmd-move-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-move-window.c,v 1.6 2009-07-14 06:42:05 nicm Exp $ */ +/* $Id: cmd-move-window.c,v 1.7 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_move_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_move_window_entry = { "move-window", "movew", "[-dk] " CMD_SRCDST_WINDOW_USAGE, - CMD_DFLAG|CMD_KFLAG, + 0, CMD_CHFLAG('d')|CMD_CHFLAG('k'), cmd_srcdst_init, cmd_srcdst_parse, cmd_move_window_exec, @@ -64,7 +64,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (wl_dst->window == wl_src->window) return (0); - if (data->flags & CMD_KFLAG) { + if (data->chflags & CMD_CHFLAG('k')) { /* * Can't use session_detach as it will destroy session * if this makes it empty. @@ -75,7 +75,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx) /* Force select/redraw if current. */ if (wl_dst == dst->curw) { - data->flags &= ~CMD_DFLAG; + data->chflags &= ~CMD_CHFLAG('d'); dst->curw = NULL; } } @@ -100,7 +100,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx) server_redraw_client(c); } - if (data->flags & CMD_DFLAG) + if (data->chflags & CMD_CHFLAG('d')) server_status_session(dst); else { session_select(dst, wl_dst->idx); diff --git a/cmd-new-session.c b/cmd-new-session.c index c0b0d3be..435db88f 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-session.c,v 1.43 2009-07-08 18:03:03 nicm Exp $ */ +/* $Id: cmd-new-session.c,v 1.44 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -42,7 +42,7 @@ struct cmd_new_session_data { const struct cmd_entry cmd_new_session_entry = { "new-session", "new", "[-d] [-n window-name] [-s session-name] [command]", - CMD_STARTSERVER|CMD_CANTNEST, + CMD_STARTSERVER|CMD_CANTNEST, 0, cmd_new_session_init, cmd_new_session_parse, cmd_new_session_exec, diff --git a/cmd-new-window.c b/cmd-new-window.c index e4afe014..54bad558 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-window.c,v 1.34 2009-07-14 06:42:05 nicm Exp $ */ +/* $Id: cmd-new-window.c,v 1.35 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -45,7 +45,7 @@ struct cmd_new_window_data { const struct cmd_entry cmd_new_window_entry = { "new-window", "neww", "[-dk] [-n window-name] [-t target-window] [command]", - 0, + 0, 0, cmd_new_window_init, cmd_new_window_parse, cmd_new_window_exec, diff --git a/cmd-next-layout.c b/cmd-next-layout.c index 98017978..1f58b32d 100644 --- a/cmd-next-layout.c +++ b/cmd-next-layout.c @@ -1,4 +1,4 @@ -/* $Id: cmd-next-layout.c,v 1.2 2009-04-30 21:17:06 nicm Exp $ */ +/* $Id: cmd-next-layout.c,v 1.3 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_next_layout_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_next_layout_entry = { "next-layout", "nextl", CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_next_layout_exec, diff --git a/cmd-next-window.c b/cmd-next-window.c index 64ac3959..58a9ea2a 100644 --- a/cmd-next-window.c +++ b/cmd-next-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-next-window.c,v 1.17 2009-06-25 15:29:34 nicm Exp $ */ +/* $Id: cmd-next-window.c,v 1.18 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,7 +30,7 @@ int cmd_next_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_next_window_entry = { "next-window", "next", "[-a] " CMD_TARGET_SESSION_USAGE, - CMD_AFLAG, + 0, CMD_CHFLAG('a'), cmd_next_window_init, cmd_target_parse, cmd_next_window_exec, @@ -49,7 +49,7 @@ cmd_next_window_init(struct cmd *self, int key) data = self->data; if (key == KEYC_ADDESC('n')) - data->flags |= CMD_AFLAG; + data->chflags |= CMD_CHFLAG('a'); } int @@ -63,7 +63,7 @@ cmd_next_window_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); activity = 0; - if (data->flags & CMD_AFLAG) + if (data->chflags & CMD_CHFLAG('a')) activity = 1; if (session_next(s, activity) == 0) diff --git a/cmd-paste-buffer.c b/cmd-paste-buffer.c index 43e7704e..04b4d723 100644 --- a/cmd-paste-buffer.c +++ b/cmd-paste-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-paste-buffer.c,v 1.17 2009-07-12 17:11:39 nicm Exp $ */ +/* $Id: cmd-paste-buffer.c,v 1.18 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ void cmd_paste_buffer_lf2cr(struct buffer *, const char *, size_t); const struct cmd_entry cmd_paste_buffer_entry = { "paste-buffer", "pasteb", "[-dr] " CMD_BUFFER_WINDOW_USAGE, - CMD_DFLAG|CMD_RFLAG, + 0, CMD_CHFLAG('d')|CMD_CHFLAG('r'), cmd_buffer_init, cmd_buffer_parse, cmd_paste_buffer_exec, @@ -66,7 +66,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) if (pb != NULL && *pb->data != '\0') { /* -r means raw data without LF->CR conversion. */ - if (data->flags & CMD_RFLAG) { + if (data->chflags & CMD_CHFLAG('r')) { buffer_write( w->active->out, pb->data, strlen(pb->data)); } else { @@ -76,7 +76,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) } /* Delete the buffer if -d. */ - if (data->flags & CMD_DFLAG) { + if (data->chflags & CMD_CHFLAG('d')) { if (data->buffer == -1) paste_free_top(&s->buffers); else diff --git a/cmd-previous-layout.c b/cmd-previous-layout.c index d66a6cf4..b84bd5a1 100644 --- a/cmd-previous-layout.c +++ b/cmd-previous-layout.c @@ -1,4 +1,4 @@ -/* $Id: cmd-previous-layout.c,v 1.1 2009-04-30 21:17:06 nicm Exp $ */ +/* $Id: cmd-previous-layout.c,v 1.2 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_previous_layout_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_previous_layout_entry = { "previous-layout", "prevl", CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_previous_layout_exec, diff --git a/cmd-previous-window.c b/cmd-previous-window.c index 8841b9a5..58e292be 100644 --- a/cmd-previous-window.c +++ b/cmd-previous-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-previous-window.c,v 1.17 2009-06-25 15:29:34 nicm Exp $ */ +/* $Id: cmd-previous-window.c,v 1.18 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,7 +30,7 @@ int cmd_previous_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_previous_window_entry = { "previous-window", "prev", "[-a] " CMD_TARGET_SESSION_USAGE, - CMD_AFLAG, + 0, CMD_CHFLAG('a'), cmd_previous_window_init, cmd_target_parse, cmd_previous_window_exec, @@ -49,7 +49,7 @@ cmd_previous_window_init(struct cmd *self, int key) data = self->data; if (key == KEYC_ADDESC('p')) - data->flags |= CMD_AFLAG; + data->chflags |= CMD_CHFLAG('a'); } int @@ -63,7 +63,7 @@ cmd_previous_window_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); activity = 0; - if (data->flags & CMD_AFLAG) + if (data->chflags & CMD_CHFLAG('a')) activity = 1; if (session_previous(s, activity) == 0) diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index 31168045..6dfe5a17 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-refresh-client.c,v 1.8 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-refresh-client.c,v 1.9 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_refresh_client_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_refresh_client_entry = { "refresh-client", "refresh", CMD_TARGET_CLIENT_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_refresh_client_exec, diff --git a/cmd-rename-session.c b/cmd-rename-session.c index a3f41e6d..fa9c35c7 100644 --- a/cmd-rename-session.c +++ b/cmd-rename-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-session.c,v 1.16 2009-07-12 17:09:15 nicm Exp $ */ +/* $Id: cmd-rename-session.c,v 1.17 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_rename_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_rename_session_entry = { "rename-session", "rename", CMD_TARGET_SESSION_USAGE " new-name", - CMD_ARG1, + CMD_ARG1, 0, cmd_target_init, cmd_target_parse, cmd_rename_session_exec, diff --git a/cmd-rename-window.c b/cmd-rename-window.c index 36867eee..f88a1e61 100644 --- a/cmd-rename-window.c +++ b/cmd-rename-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-window.c,v 1.27 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd-rename-window.c,v 1.28 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_rename_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_rename_window_entry = { "rename-window", "renamew", CMD_TARGET_WINDOW_USAGE " new-name", - CMD_ARG1, + CMD_ARG1, 0, cmd_target_init, cmd_target_parse, cmd_rename_window_exec, diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index 2441b848..8dac1343 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-resize-pane.c,v 1.7 2009-05-21 19:46:00 nicm Exp $ */ +/* $Id: cmd-resize-pane.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_resize_pane_entry = { "resize-pane", "resizep", CMD_PANE_WINDOW_USAGE "[-DU] [adjustment]", - CMD_ARG01|CMD_BIGUFLAG|CMD_BIGDFLAG, + CMD_ARG01, CMD_CHFLAG('D')|CMD_CHFLAG('U'), cmd_resize_pane_init, cmd_pane_parse, cmd_resize_pane_exec, @@ -51,12 +51,12 @@ cmd_resize_pane_init(struct cmd *self, int key) data = self->data; if (key == KEYC_ADDCTL(KEYC_DOWN)) - data->flags |= CMD_BIGDFLAG; + data->chflags |= CMD_CHFLAG('D'); if (key == KEYC_ADDESC(KEYC_UP)) data->arg = xstrdup("5"); if (key == KEYC_ADDESC(KEYC_DOWN)) { - data->flags |= CMD_BIGDFLAG; + data->chflags |= CMD_CHFLAG('D'); data->arg = xstrdup("5"); } } @@ -92,7 +92,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx) } } - if (!(data->flags & CMD_BIGDFLAG)) + if (!(data->chflags & CMD_CHFLAG('D'))) adjust = -adjust; if (layout_resize(wp, adjust) != 0) { ctx->error(ctx, "layout %s " diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c index bf3bfa6c..11e31e66 100644 --- a/cmd-respawn-window.c +++ b/cmd-respawn-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-respawn-window.c,v 1.14 2009-03-04 17:24:07 nicm Exp $ */ +/* $Id: cmd-respawn-window.c,v 1.15 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_respawn_window_entry = { "respawn-window", "respawnw", "[-k] " CMD_TARGET_WINDOW_USAGE " [command]", - CMD_ARG01|CMD_KFLAG, + CMD_ARG01, CMD_CHFLAG('k'), cmd_target_init, cmd_target_parse, cmd_respawn_window_exec, @@ -56,7 +56,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); w = wl->window; - if (!(data->flags & CMD_KFLAG)) { + if (!(data->chflags & CMD_CHFLAG('k'))) { TAILQ_FOREACH(wp, &w->panes, entry) { if (wp->fd == -1) continue; diff --git a/cmd-rotate-window.c b/cmd-rotate-window.c index 1d2ab5d9..6718db93 100644 --- a/cmd-rotate-window.c +++ b/cmd-rotate-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rotate-window.c,v 1.4 2009-06-25 15:28:08 nicm Exp $ */ +/* $Id: cmd-rotate-window.c,v 1.5 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,7 +30,7 @@ int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_rotate_window_entry = { "rotate-window", "rotatew", "[-DU] " CMD_TARGET_WINDOW_USAGE, - CMD_BIGUFLAG|CMD_BIGDFLAG, + 0, CMD_CHFLAG('D')|CMD_CHFLAG('U'), cmd_rotate_window_init, cmd_target_parse, cmd_rotate_window_exec, @@ -49,7 +49,7 @@ cmd_rotate_window_init(struct cmd *self, int key) data = self->data; if (key == KEYC_ADDESC('o')) - data->flags |= CMD_BIGDFLAG; + data->chflags |= CMD_CHFLAG('D'); } int @@ -66,7 +66,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); w = wl->window; - if (data->flags & CMD_BIGDFLAG) { + if (data->chflags & CMD_CHFLAG('D')) { wp = TAILQ_LAST(&w->panes, window_panes); TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_INSERT_HEAD(&w->panes, wp, entry); diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c index 68b6f582..714de3e8 100644 --- a/cmd-save-buffer.c +++ b/cmd-save-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-save-buffer.c,v 1.5 2009-05-18 16:22:30 nicm Exp $ */ +/* $Id: cmd-save-buffer.c,v 1.6 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -33,7 +33,7 @@ int cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_save_buffer_entry = { "save-buffer", "saveb", "[-a] " CMD_BUFFER_SESSION_USAGE " path", - CMD_AFLAG|CMD_ARG1, + CMD_ARG1, CMD_CHFLAG('a'), cmd_buffer_init, cmd_buffer_parse, cmd_save_buffer_exec, @@ -68,7 +68,7 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) } mask = umask(S_IRWXG | S_IRWXO); - if (data->flags & CMD_AFLAG) + if (data->chflags & CMD_CHFLAG('a')) f = fopen(data->arg, "ab"); else f = fopen(data->arg, "wb"); diff --git a/cmd-scroll-mode.c b/cmd-scroll-mode.c index 16e28465..74ca9dcc 100644 --- a/cmd-scroll-mode.c +++ b/cmd-scroll-mode.c @@ -1,4 +1,4 @@ -/* $Id: cmd-scroll-mode.c,v 1.20 2009-07-14 06:42:22 nicm Exp $ */ +/* $Id: cmd-scroll-mode.c,v 1.21 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,7 +30,7 @@ int cmd_scroll_mode_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_scroll_mode_entry = { "scroll-mode", NULL, "[-u] " CMD_TARGET_WINDOW_USAGE, - CMD_UFLAG, + 0, CMD_CHFLAG('u'), cmd_scroll_mode_init, cmd_target_parse, cmd_scroll_mode_exec, @@ -50,7 +50,7 @@ cmd_scroll_mode_init(struct cmd *self, int key) switch (key) { case KEYC_PPAGE: - data->flags |= CMD_UFLAG; + data->chflags |= CMD_CHFLAG('u'); break; } } @@ -67,7 +67,7 @@ cmd_scroll_mode_exec(struct cmd *self, struct cmd_ctx *ctx) wp = wl->window->active; window_pane_set_mode(wp, &window_scroll_mode); - if (wp->mode == &window_scroll_mode && data->flags & CMD_UFLAG) + if (wp->mode == &window_scroll_mode && data->chflags & CMD_CHFLAG('u')) window_scroll_pageup(wp); return (0); diff --git a/cmd-select-layout.c b/cmd-select-layout.c index d2da21b1..20e2ad28 100644 --- a/cmd-select-layout.c +++ b/cmd-select-layout.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-layout.c,v 1.3 2009-06-25 16:34:50 nicm Exp $ */ +/* $Id: cmd-select-layout.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,7 +30,7 @@ int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_select_layout_entry = { "select-layout", "selectl", CMD_TARGET_WINDOW_USAGE " layout-name", - CMD_ARG1, + CMD_ARG1, 0, cmd_select_layout_init, cmd_target_parse, cmd_select_layout_exec, diff --git a/cmd-select-pane.c b/cmd-select-pane.c index 71175942..d77bac32 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-pane.c,v 1.4 2009-04-01 21:10:08 nicm Exp $ */ +/* $Id: cmd-select-pane.c,v 1.5 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_select_pane_entry = { "select-pane", "selectp", CMD_PANE_WINDOW_USAGE, - 0, + 0, 0, cmd_pane_init, cmd_pane_parse, cmd_select_pane_exec, diff --git a/cmd-select-prompt.c b/cmd-select-prompt.c index 8de9d158..1338d845 100644 --- a/cmd-select-prompt.c +++ b/cmd-select-prompt.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-prompt.c,v 1.7 2009-02-13 18:57:55 nicm Exp $ */ +/* $Id: cmd-select-prompt.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,7 +33,7 @@ int cmd_select_prompt_callback(void *, const char *); const struct cmd_entry cmd_select_prompt_entry = { "select-prompt", NULL, CMD_TARGET_CLIENT_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_select_prompt_exec, diff --git a/cmd-select-window.c b/cmd-select-window.c index a5780769..3a0f24fd 100644 --- a/cmd-select-window.c +++ b/cmd-select-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-window.c,v 1.21 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-select-window.c,v 1.22 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_select_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_select_window_entry = { "select-window", "selectw", CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_select_window_init, cmd_target_parse, cmd_select_window_exec, diff --git a/cmd-send-keys.c b/cmd-send-keys.c index 4443729e..33499dca 100644 --- a/cmd-send-keys.c +++ b/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-send-keys.c,v 1.18 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-send-keys.c,v 1.19 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -43,7 +43,7 @@ struct cmd_send_keys_data { const struct cmd_entry cmd_send_keys_entry = { "send-keys", "send", "[-t target-window] key ...", - 0, + 0, 0, NULL, cmd_send_keys_parse, cmd_send_keys_exec, diff --git a/cmd-send-prefix.c b/cmd-send-prefix.c index 810202a8..d50a7b90 100644 --- a/cmd-send-prefix.c +++ b/cmd-send-prefix.c @@ -1,4 +1,4 @@ -/* $Id: cmd-send-prefix.c,v 1.23 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-send-prefix.c,v 1.24 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_send_prefix_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_send_prefix_entry = { "send-prefix", NULL, CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_send_prefix_exec, diff --git a/cmd-server-info.c b/cmd-server-info.c index 5076fb02..30be6486 100644 --- a/cmd-server-info.c +++ b/cmd-server-info.c @@ -1,4 +1,4 @@ -/* $Id: cmd-server-info.c,v 1.20 2009-06-25 20:27:31 nicm Exp $ */ +/* $Id: cmd-server-info.c,v 1.21 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,7 +35,7 @@ int cmd_server_info_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_server_info_entry = { "server-info", "info", "", - 0, + 0, 0, NULL, NULL, cmd_server_info_exec, diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c index e5584b95..6862a9a1 100644 --- a/cmd-set-buffer.c +++ b/cmd-set-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-buffer.c,v 1.7 2009-01-25 18:51:28 tcunha Exp $ */ +/* $Id: cmd-set-buffer.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_set_buffer_entry = { "set-buffer", "setb", CMD_BUFFER_SESSION_USAGE " data", - CMD_ARG1, + CMD_ARG1, 0, cmd_buffer_init, cmd_buffer_parse, cmd_set_buffer_exec, diff --git a/cmd-set-option.c b/cmd-set-option.c index 8ef39ffe..094bf525 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-option.c,v 1.65 2009-07-12 17:07:58 nicm Exp $ */ +/* $Id: cmd-set-option.c,v 1.66 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_set_option_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_set_option_entry = { "set-option", "set", CMD_OPTION_SESSION_USAGE, - CMD_GFLAG|CMD_UFLAG, + 0, CMD_CHFLAG('g')|CMD_CHFLAG('u'), NULL, cmd_option_parse, cmd_set_option_exec, @@ -87,7 +87,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) const struct set_option_entry *entry; u_int i; - if (data->flags & CMD_GFLAG) + if (data->chflags & CMD_CHFLAG('g')) oo = &global_s_options; else { if ((s = cmd_find_session(ctx, data->target)) == NULL) @@ -120,8 +120,8 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); } - if (data->flags & CMD_UFLAG) { - if (data->flags & CMD_GFLAG) { + if (data->chflags & CMD_CHFLAG('u')) { + if (data->chflags & CMD_CHFLAG('g')) { ctx->error(ctx, "can't unset global option: %s", entry->name); return (-1); diff --git a/cmd-set-password.c b/cmd-set-password.c index b4ea90f3..00fa730f 100644 --- a/cmd-set-password.c +++ b/cmd-set-password.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-password.c,v 1.5 2009-06-25 16:47:00 nicm Exp $ */ +/* $Id: cmd-set-password.c,v 1.6 2009-07-14 06:43:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -43,7 +43,7 @@ struct cmd_set_password_data { const struct cmd_entry cmd_set_password_entry = { "set-password", "pass", "[-c] password", - 0, + 0, 0, cmd_set_password_init, cmd_set_password_parse, cmd_set_password_exec, diff --git a/cmd-set-window-option.c b/cmd-set-window-option.c index 02f7fc56..f42382a1 100644 --- a/cmd-set-window-option.c +++ b/cmd-set-window-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-window-option.c,v 1.30 2009-07-08 18:03:03 nicm Exp $ */ +/* $Id: cmd-set-window-option.c,v 1.31 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_set_window_option_entry = { "set-window-option", "setw", CMD_OPTION_WINDOW_USAGE, - CMD_GFLAG|CMD_UFLAG, + 0, CMD_CHFLAG('g')|CMD_CHFLAG('u'), NULL, cmd_option_parse, cmd_set_window_option_exec, @@ -81,7 +81,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx) const struct set_option_entry *entry; u_int i; - if (data->flags & CMD_GFLAG) + if (data->chflags & CMD_CHFLAG('g')) oo = &global_w_options; else { if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) @@ -114,8 +114,8 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); } - if (data->flags & CMD_UFLAG) { - if (data->flags & CMD_GFLAG) { + if (data->chflags & CMD_CHFLAG('u')) { + if (data->chflags & CMD_CHFLAG('g')) { ctx->error(ctx, "can't unset global option: %s", entry->name); return (-1); diff --git a/cmd-show-buffer.c b/cmd-show-buffer.c index d065f50f..823ec94b 100644 --- a/cmd-show-buffer.c +++ b/cmd-show-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-show-buffer.c,v 1.4 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-show-buffer.c,v 1.5 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_show_buffer_entry = { "show-buffer", "showb", CMD_BUFFER_SESSION_USAGE, - 0, + 0, 0, cmd_buffer_init, cmd_buffer_parse, cmd_show_buffer_exec, diff --git a/cmd-show-options.c b/cmd-show-options.c index 0cbb6cd1..8406cc16 100644 --- a/cmd-show-options.c +++ b/cmd-show-options.c @@ -1,4 +1,4 @@ -/* $Id: cmd-show-options.c,v 1.13 2009-07-08 18:03:03 nicm Exp $ */ +/* $Id: cmd-show-options.c,v 1.14 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_show_options_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_show_options_entry = { "show-options", "show", "[-g] " CMD_TARGET_SESSION_USAGE, - CMD_GFLAG, + 0, CMD_CHFLAG('g'), cmd_target_init, cmd_target_parse, cmd_show_options_exec, @@ -53,7 +53,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) char *vs; long long vn; - if (data->flags & CMD_GFLAG) + if (data->chflags & CMD_CHFLAG('g')) oo = &global_s_options; else { if ((s = cmd_find_session(ctx, data->target)) == NULL) diff --git a/cmd-show-window-options.c b/cmd-show-window-options.c index 33906841..5acec208 100644 --- a/cmd-show-window-options.c +++ b/cmd-show-window-options.c @@ -1,4 +1,4 @@ -/* $Id: cmd-show-window-options.c,v 1.9 2009-07-08 18:03:03 nicm Exp $ */ +/* $Id: cmd-show-window-options.c,v 1.10 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ int cmd_show_window_options_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_show_window_options_entry = { "show-window-options", "showw", "[-g] " CMD_TARGET_WINDOW_USAGE, - CMD_GFLAG, + 0, CMD_CHFLAG('g'), cmd_target_init, cmd_target_parse, cmd_show_window_options_exec, @@ -53,7 +53,7 @@ cmd_show_window_options_exec(struct cmd *self, struct cmd_ctx *ctx) char *vs; long long vn; - if (data->flags & CMD_GFLAG) + if (data->chflags & CMD_CHFLAG('g')) oo = &global_w_options; else { if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) diff --git a/cmd-source-file.c b/cmd-source-file.c index f7118179..8bcf25e0 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $Id: cmd-source-file.c,v 1.5 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-source-file.c,v 1.6 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> @@ -39,7 +39,7 @@ struct cmd_source_file_data { const struct cmd_entry cmd_source_file_entry = { "source-file", "source", "path", - 0, + 0, 0, cmd_source_file_init, cmd_source_file_parse, cmd_source_file_exec, diff --git a/cmd-split-window.c b/cmd-split-window.c index 80964783..f8e35fb6 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-split-window.c,v 1.17 2009-07-08 18:03:03 nicm Exp $ */ +/* $Id: cmd-split-window.c,v 1.18 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -46,7 +46,7 @@ struct cmd_split_window_data { const struct cmd_entry cmd_split_window_entry = { "split-window", "splitw", "[-d] [-p percentage|-l lines] [-t target-window] [command]", - 0, + 0, 0, cmd_split_window_init, cmd_split_window_parse, cmd_split_window_exec, diff --git a/cmd-start-server.c b/cmd-start-server.c index 364b3f4f..f0f7be09 100644 --- a/cmd-start-server.c +++ b/cmd-start-server.c @@ -1,4 +1,4 @@ -/* $Id: cmd-start-server.c,v 1.6 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-start-server.c,v 1.7 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_start_server_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_start_server_entry = { "start-server", "start", "", - CMD_STARTSERVER, + CMD_STARTSERVER, 0, NULL, NULL, cmd_start_server_exec, diff --git a/cmd-suspend-client.c b/cmd-suspend-client.c index 468e252b..ce433684 100644 --- a/cmd-suspend-client.c +++ b/cmd-suspend-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-suspend-client.c,v 1.2 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-suspend-client.c,v 1.3 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -37,7 +37,7 @@ struct cmd_suspend_client_data { const struct cmd_entry cmd_suspend_client_entry = { "suspend-client", "suspendc", "[-c target-client]", - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_suspend_client_exec, diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c index 1a38c576..05ab0a99 100644 --- a/cmd-swap-pane.c +++ b/cmd-swap-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-swap-pane.c,v 1.6 2009-06-25 15:28:08 nicm Exp $ */ +/* $Id: cmd-swap-pane.c,v 1.7 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -46,7 +46,7 @@ struct cmd_swap_pane_data { const struct cmd_entry cmd_swap_pane_entry = { "swap-pane", "swapp", "[-dDU] [-t target-window] [-p src-index] [-q dst-index]", - 0, + 0, 0, cmd_swap_pane_init, cmd_swap_pane_parse, cmd_swap_pane_exec, diff --git a/cmd-swap-window.c b/cmd-swap-window.c index 7dfe9e45..2e07517f 100644 --- a/cmd-swap-window.c +++ b/cmd-swap-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-swap-window.c,v 1.15 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-swap-window.c,v 1.16 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,7 +31,7 @@ int cmd_swap_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_swap_window_entry = { "swap-window", "swapw", "[-d] " CMD_SRCDST_WINDOW_USAGE, - CMD_DFLAG, + 0, CMD_CHFLAG('d'), cmd_srcdst_init, cmd_srcdst_parse, cmd_swap_window_exec, @@ -61,7 +61,7 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx) wl_dst->window = wl_src->window; wl_src->window = w; - if (!(data->flags & CMD_DFLAG)) { + if (!(data->chflags & CMD_CHFLAG('d'))) { session_select(dst, wl_dst->idx); if (src != dst) session_select(src, wl_src->idx); diff --git a/cmd-switch-client.c b/cmd-switch-client.c index ed37aef6..c26c741f 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-switch-client.c,v 1.15 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-switch-client.c,v 1.16 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -42,7 +42,7 @@ struct cmd_switch_client_data { const struct cmd_entry cmd_switch_client_entry = { "switch-client", "switchc", "[-c target-client] [-t target-session]", - 0, + 0, 0, NULL, cmd_switch_client_parse, cmd_switch_client_exec, diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c index f194abab..75865f34 100644 --- a/cmd-unbind-key.c +++ b/cmd-unbind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-unbind-key.c,v 1.16 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-unbind-key.c,v 1.17 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -37,7 +37,7 @@ struct cmd_unbind_key_data { const struct cmd_entry cmd_unbind_key_entry = { "unbind-key", "unbind", "key", - 0, + 0, 0, NULL, cmd_unbind_key_parse, cmd_unbind_key_exec, diff --git a/cmd-unlink-window.c b/cmd-unlink-window.c index abd011cf..6f146866 100644 --- a/cmd-unlink-window.c +++ b/cmd-unlink-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-unlink-window.c,v 1.13 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-unlink-window.c,v 1.14 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_unlink_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_unlink_window_entry = { "unlink-window", "unlinkw", CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_unlink_window_exec, diff --git a/cmd-up-pane.c b/cmd-up-pane.c index 0b14fe24..5273f8ed 100644 --- a/cmd-up-pane.c +++ b/cmd-up-pane.c @@ -1,4 +1,4 @@ -/* $Id: cmd-up-pane.c,v 1.7 2009-04-01 21:10:08 nicm Exp $ */ +/* $Id: cmd-up-pane.c,v 1.8 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,7 +29,7 @@ int cmd_up_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_up_pane_entry = { "up-pane", "upp", CMD_TARGET_WINDOW_USAGE, - 0, + 0, 0, cmd_target_init, cmd_target_parse, cmd_up_pane_exec, @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.360 2009-07-14 06:42:06 nicm Exp $ */ +/* $Id: tmux.h,v 1.361 2009-07-14 06:43:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -860,17 +860,13 @@ struct cmd_entry { #define CMD_CANTNEST 0x2 #define CMD_ARG1 0x4 #define CMD_ARG01 0x8 -#define CMD_AFLAG 0x10 -#define CMD_DFLAG 0x20 -#define CMD_GFLAG 0x40 -#define CMD_KFLAG 0x80 -#define CMD_UFLAG 0x100 -#define CMD_BIGDFLAG 0x200 -#define CMD_BIGUFLAG 0x400 -#define CMD_RFLAG 0x800 - int flags; +#define CMD_CHFLAG(flag) \ + ((flag) >= 'a' && (flag) <= 'z' ? 1ULL << ((flag) - 'a') : \ + (flag) >= 'A' && (flag) <= 'Z' ? 1ULL << (26 + (flag) - 'A') : 0) + uint64_t chflags; + void (*init)(struct cmd *, int); int (*parse)(struct cmd *, int, char **, char **); int (*exec)(struct cmd *, struct cmd_ctx *); @@ -882,34 +878,34 @@ struct cmd_entry { /* Generic command data. */ struct cmd_target_data { - int flags; + uint64_t chflags; char *target; char *arg; }; struct cmd_srcdst_data { - int flags; + uint64_t chflags; char *src; char *dst; char *arg; }; struct cmd_buffer_data { - int flags; + uint64_t chflags; char *target; int buffer; char *arg; }; struct cmd_option_data { - int flags; + uint64_t chflags; char *target; char *option; char *value; }; struct cmd_pane_data { - int flags; + uint64_t chflags; char *target; char *arg; int pane; |