1
0
mirror of https://github.com/tmux/tmux.git synced 2025-04-13 23:08:49 +00:00

Get rid of the ugly CMD_CHFLAG macro and use a const string (eg "dDU") in the

command entry structs and a couple of functions to check/set the flags.
This commit is contained in:
Nicholas Marriott 2009-11-13 19:53:28 +00:00
parent dafa0f022c
commit 76ef8770cd
81 changed files with 186 additions and 186 deletions

View File

@ -29,7 +29,7 @@ int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_attach_session_entry = { const struct cmd_entry cmd_attach_session_entry = {
"attach-session", "attach", "attach-session", "attach",
"[-d] " CMD_TARGET_SESSION_USAGE, "[-d] " CMD_TARGET_SESSION_USAGE,
CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON, CMD_CHFLAG('d'), CMD_CANTNEST|CMD_STARTSERVER|CMD_SENDENVIRON, "d",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_attach_session_exec, cmd_attach_session_exec,
@ -58,7 +58,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
return (0); return (0);
if (ctx->cmdclient == NULL) { if (ctx->cmdclient == NULL) {
if (data->chflags & CMD_CHFLAG('d')) { if (cmd_check_flag(data->chflags, 'd')) {
/* /*
* Can't use server_write_session in case attaching to * Can't use server_write_session in case attaching to
* the same session as currently attached to. * the same session as currently attached to.
@ -89,7 +89,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
} }
if (data->chflags & CMD_CHFLAG('d')) if (cmd_check_flag(data->chflags, 'd'))
server_write_session(s, MSG_DETACH, NULL, 0); server_write_session(s, MSG_DETACH, NULL, 0);
ctx->cmdclient->session = s; ctx->cmdclient->session = s;

View File

@ -46,7 +46,7 @@ struct cmd_bind_key_data {
const struct cmd_entry cmd_bind_key_entry = { const struct cmd_entry cmd_bind_key_entry = {
"bind-key", "bind", "bind-key", "bind",
"[-cnr] [-t key-table] key command [arguments]", "[-cnr] [-t key-table] key command [arguments]",
0, 0, 0, "",
NULL, NULL,
cmd_bind_key_parse, cmd_bind_key_parse,
cmd_bind_key_exec, cmd_bind_key_exec,

View File

@ -31,7 +31,7 @@ int cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_break_pane_entry = { const struct cmd_entry cmd_break_pane_entry = {
"break-pane", "breakp", "break-pane", "breakp",
CMD_TARGET_PANE_USAGE " [-d]", CMD_TARGET_PANE_USAGE " [-d]",
0, CMD_CHFLAG('d'), 0, "d",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_break_pane_exec, cmd_break_pane_exec,
@ -74,7 +74,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
base_idx = options_get_number(&s->options, "base-index"); base_idx = options_get_number(&s->options, "base-index");
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */ wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
if (!(data->chflags & CMD_CHFLAG('d'))) if (!cmd_check_flag(data->chflags, 'd'))
session_select(s, wl->idx); session_select(s, wl->idx);
server_redraw_session(s); server_redraw_session(s);

View File

@ -34,7 +34,7 @@ void cmd_choose_client_free(void *);
const struct cmd_entry cmd_choose_client_entry = { const struct cmd_entry cmd_choose_client_entry = {
"choose-client", NULL, "choose-client", NULL,
CMD_TARGET_WINDOW_USAGE " [template]", CMD_TARGET_WINDOW_USAGE " [template]",
CMD_ARG01, 0, CMD_ARG01, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_choose_client_exec, cmd_choose_client_exec,

View File

@ -34,7 +34,7 @@ void cmd_choose_session_free(void *);
const struct cmd_entry cmd_choose_session_entry = { const struct cmd_entry cmd_choose_session_entry = {
"choose-session", NULL, "choose-session", NULL,
CMD_TARGET_WINDOW_USAGE " [template]", CMD_TARGET_WINDOW_USAGE " [template]",
CMD_ARG01, 0, CMD_ARG01, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_choose_session_exec, cmd_choose_session_exec,

View File

@ -34,7 +34,7 @@ void cmd_choose_window_free(void *);
const struct cmd_entry cmd_choose_window_entry = { const struct cmd_entry cmd_choose_window_entry = {
"choose-window", NULL, "choose-window", NULL,
CMD_TARGET_WINDOW_USAGE " [template]", CMD_TARGET_WINDOW_USAGE " [template]",
CMD_ARG01, 0, CMD_ARG01, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_choose_window_exec, cmd_choose_window_exec,

View File

@ -29,7 +29,7 @@ int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_clear_history_entry = { const struct cmd_entry cmd_clear_history_entry = {
"clear-history", "clearhist", "clear-history", "clearhist",
CMD_TARGET_PANE_USAGE, CMD_TARGET_PANE_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_clear_history_exec, cmd_clear_history_exec,

View File

@ -29,7 +29,7 @@ int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_clock_mode_entry = { const struct cmd_entry cmd_clock_mode_entry = {
"clock-mode", NULL, "clock-mode", NULL,
CMD_TARGET_PANE_USAGE, CMD_TARGET_PANE_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_clock_mode_exec, cmd_clock_mode_exec,

View File

@ -39,7 +39,7 @@ void cmd_command_prompt_cfree(void *);
const struct cmd_entry cmd_command_prompt_entry = { const struct cmd_entry cmd_command_prompt_entry = {
"command-prompt", NULL, "command-prompt", NULL,
CMD_TARGET_CLIENT_USAGE " [-p prompts] [template]", CMD_TARGET_CLIENT_USAGE " [-p prompts] [template]",
0, 0, 0, "",
cmd_command_prompt_init, cmd_command_prompt_init,
cmd_command_prompt_parse, cmd_command_prompt_parse,
cmd_command_prompt_exec, cmd_command_prompt_exec,

View File

@ -34,7 +34,7 @@ void cmd_confirm_before_free(void *);
const struct cmd_entry cmd_confirm_before_entry = { const struct cmd_entry cmd_confirm_before_entry = {
"confirm-before", "confirm", "confirm-before", "confirm",
CMD_TARGET_CLIENT_USAGE " command", CMD_TARGET_CLIENT_USAGE " command",
CMD_ARG1, 0, CMD_ARG1, "",
cmd_confirm_before_init, cmd_confirm_before_init,
cmd_target_parse, cmd_target_parse,
cmd_confirm_before_exec, cmd_confirm_before_exec,

View File

@ -43,7 +43,7 @@ struct cmd_copy_buffer_data {
const struct cmd_entry cmd_copy_buffer_entry = { const struct cmd_entry cmd_copy_buffer_entry = {
"copy-buffer", "copyb", "copy-buffer", "copyb",
"[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]", "[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]",
0, 0, 0, "",
cmd_copy_buffer_init, cmd_copy_buffer_init,
cmd_copy_buffer_parse, cmd_copy_buffer_parse,
cmd_copy_buffer_exec, cmd_copy_buffer_exec,

View File

@ -30,7 +30,7 @@ int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_copy_mode_entry = { const struct cmd_entry cmd_copy_mode_entry = {
"copy-mode", NULL, "copy-mode", NULL,
"[-u] " CMD_TARGET_PANE_USAGE, "[-u] " CMD_TARGET_PANE_USAGE,
0, CMD_CHFLAG('u'), 0, "u",
cmd_copy_mode_init, cmd_copy_mode_init,
cmd_target_parse, cmd_target_parse,
cmd_copy_mode_exec, cmd_copy_mode_exec,
@ -48,7 +48,7 @@ cmd_copy_mode_init(struct cmd *self, int key)
switch (key) { switch (key) {
case KEYC_PPAGE: case KEYC_PPAGE:
data->chflags |= CMD_CHFLAG('u'); cmd_set_flag(&data->chflags, 'u');
break; break;
} }
} }
@ -63,7 +63,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
window_pane_set_mode(wp, &window_copy_mode); window_pane_set_mode(wp, &window_copy_mode);
if (wp->mode == &window_copy_mode && data->chflags & CMD_CHFLAG('u')) if (wp->mode == &window_copy_mode && cmd_check_flag(data->chflags, 'u'))
window_copy_pageup(wp); window_copy_pageup(wp);
return (0); return (0);

View File

@ -31,7 +31,7 @@ int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_delete_buffer_entry = { const struct cmd_entry cmd_delete_buffer_entry = {
"delete-buffer", "deleteb", "delete-buffer", "deleteb",
CMD_BUFFER_SESSION_USAGE, CMD_BUFFER_SESSION_USAGE,
0, 0, 0, "",
cmd_buffer_init, cmd_buffer_init,
cmd_buffer_parse, cmd_buffer_parse,
cmd_delete_buffer_exec, cmd_delete_buffer_exec,

View File

@ -29,7 +29,7 @@ int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_detach_client_entry = { const struct cmd_entry cmd_detach_client_entry = {
"detach-client", "detach", "detach-client", "detach",
CMD_TARGET_CLIENT_USAGE, CMD_TARGET_CLIENT_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_detach_client_exec, cmd_detach_client_exec,

View File

@ -31,7 +31,7 @@ int cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_display_message_entry = { const struct cmd_entry cmd_display_message_entry = {
"display-message", "display", "display-message", "display",
CMD_TARGET_CLIENT_USAGE " [message]", CMD_TARGET_CLIENT_USAGE " [message]",
CMD_ARG01, 0, CMD_ARG01, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_display_message_exec, cmd_display_message_exec,

View File

@ -29,7 +29,7 @@ int cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_display_panes_entry = { const struct cmd_entry cmd_display_panes_entry = {
"display-panes", "displayp", "display-panes", "displayp",
CMD_TARGET_CLIENT_USAGE, CMD_TARGET_CLIENT_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_display_panes_exec, cmd_display_panes_exec,

View File

@ -29,7 +29,7 @@ int cmd_down_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_down_pane_entry = { const struct cmd_entry cmd_down_pane_entry = {
"down-pane", "downp", "down-pane", "downp",
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_down_pane_exec, cmd_down_pane_exec,

View File

@ -34,7 +34,7 @@ void cmd_find_window_callback(void *, int);
const struct cmd_entry cmd_find_window_entry = { const struct cmd_entry cmd_find_window_entry = {
"find-window", "findw", "find-window", "findw",
CMD_TARGET_WINDOW_USAGE " match-string", CMD_TARGET_WINDOW_USAGE " match-string",
CMD_ARG1, 0, CMD_ARG1, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_find_window_exec, cmd_find_window_exec,

View File

@ -23,8 +23,8 @@
#include "tmux.h" #include "tmux.h"
int cmd_getopt(int, char **, const char *, uint64_t); int cmd_getopt(int, char **, const char *, const char *);
int cmd_flags(int, uint64_t, uint64_t *); int cmd_parse_flags(int, const char *, uint64_t *);
size_t cmd_print_flags(char *, size_t, size_t, uint64_t); size_t cmd_print_flags(char *, size_t, size_t, uint64_t);
int cmd_fill_argument(int, char **, char **, int, char **); int cmd_fill_argument(int, char **, char **, int, char **);
@ -36,51 +36,53 @@ cmd_prarg(char *buf, size_t len, const char *prefix, char *arg)
return (xsnprintf(buf, len, "%s%s", prefix, arg)); return (xsnprintf(buf, len, "%s%s", prefix, arg));
} }
/* Prepend flags from chflags onto flagstr and call getopt. */ /* Append two flag strings together and call getopt. */
int int
cmd_getopt(int argc, char **argv, const char *flagstr, uint64_t chflags) cmd_getopt(int argc, char **argv, const char *flagstr, const char *chflagstr)
{ {
u_char ch; char tmp[BUFSIZ];
char buf[128];
size_t len, off;
*buf = '\0'; if (strlcpy(tmp, flagstr, sizeof tmp) >= sizeof tmp)
fatalx("strlcpy overflow");
len = sizeof buf; if (strlcat(tmp, chflagstr, sizeof tmp) >= sizeof tmp)
off = 0; fatalx("strlcat overflow");
return (getopt(argc, argv, tmp));
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));
} }
/* /* Return if flag character is set. */
* If this option is expected (in ichflags), set it in ochflags, otherwise
* return -1.
*/
int int
cmd_flags(int opt, uint64_t ichflags, uint64_t *ochflags) cmd_check_flag(uint64_t chflags, int flag)
{ {
u_char ch; if (flag >= 'A' && flag <= 'Z')
flag = 26 + flag - 'A';
else if (flag >= 'a' && flag <= 'z')
flag = flag - 'a';
else
return (0);
return ((chflags & (1ULL << flag)) != 0);
}
for (ch = 0; ch < 26; ch++) { /* Set flag character. */
if (opt == 'a' + ch && ichflags & CMD_CHFLAG(opt)) { void
(*ochflags) |= CMD_CHFLAG(opt); cmd_set_flag(uint64_t *chflags, int flag)
return (0); {
} if (flag >= 'A' && flag <= 'Z')
if (opt == 'A' + ch && ichflags & CMD_CHFLAG(opt)) { flag = 26 + flag - 'A';
(*ochflags) |= CMD_CHFLAG(opt); else if (flag >= 'a' && flag <= 'z')
return (0); flag = flag - 'a';
} else
} return;
return (-1); (*chflags) |= (1ULL << flag);
}
/* If this option is expected, set it in chflags, otherwise return -1. */
int
cmd_parse_flags(int opt, const char *chflagstr, uint64_t *chflags)
{
if (strchr(chflagstr, opt) == NULL)
return (-1);
cmd_set_flag(chflags, opt);
return (0);
} }
/* Print the flags supported in chflags. */ /* Print the flags supported in chflags. */
@ -95,9 +97,9 @@ cmd_print_flags(char *buf, size_t len, size_t off, uint64_t chflags)
off += xsnprintf(buf + off, len - off, " -"); off += xsnprintf(buf + off, len - off, " -");
for (ch = 0; ch < 26; ch++) { for (ch = 0; ch < 26; ch++) {
if (chflags & CMD_CHFLAG('a' + ch)) if (cmd_check_flag(chflags, 'a' + ch))
off += xsnprintf(buf + off, len - off, "%c", 'a' + ch); off += xsnprintf(buf + off, len - off, "%c", 'a' + ch);
if (chflags & CMD_CHFLAG('A' + ch)) if (cmd_check_flag(chflags, 'A' + ch))
off += xsnprintf(buf + off, len - off, "%c", 'A' + ch); off += xsnprintf(buf + off, len - off, "%c", 'A' + ch);
} }
return (off - boff); return (off - boff);
@ -170,7 +172,7 @@ cmd_target_parse(struct cmd *self, int argc, char **argv, char **cause)
data = self->data; data = self->data;
while ((opt = cmd_getopt(argc, argv, "t:", entry->chflags)) != -1) { while ((opt = cmd_getopt(argc, argv, "t:", entry->chflags)) != -1) {
if (cmd_flags(opt, entry->chflags, &data->chflags) == 0) if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
continue; continue;
switch (opt) { switch (opt) {
case 't': case 't':
@ -253,7 +255,7 @@ cmd_srcdst_parse(struct cmd *self, int argc, char **argv, char **cause)
data = self->data; data = self->data;
while ((opt = cmd_getopt(argc, argv, "s:t:", entry->chflags)) != -1) { while ((opt = cmd_getopt(argc, argv, "s:t:", entry->chflags)) != -1) {
if (cmd_flags(opt, entry->chflags, &data->chflags) == 0) if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
continue; continue;
switch (opt) { switch (opt) {
case 's': case 's':
@ -345,7 +347,7 @@ cmd_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
data = self->data; data = self->data;
while ((opt = cmd_getopt(argc, argv, "b:t:", entry->chflags)) != -1) { while ((opt = cmd_getopt(argc, argv, "b:t:", entry->chflags)) != -1) {
if (cmd_flags(opt, entry->chflags, &data->chflags) == 0) if (cmd_parse_flags(opt, entry->chflags, &data->chflags) == 0)
continue; continue;
switch (opt) { switch (opt) {
case 'b': case 'b':

View File

@ -29,7 +29,7 @@ int cmd_has_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_has_session_entry = { const struct cmd_entry cmd_has_session_entry = {
"has-session", "has", "has-session", "has",
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_has_session_exec, cmd_has_session_exec,

View File

@ -36,7 +36,7 @@ void cmd_if_shell_free(void *);
const struct cmd_entry cmd_if_shell_entry = { const struct cmd_entry cmd_if_shell_entry = {
"if-shell", "if", "if-shell", "if",
"shell-command command", "shell-command command",
CMD_ARG2, 0, CMD_ARG2, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_if_shell_exec, cmd_if_shell_exec,

View File

@ -31,7 +31,7 @@ int cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_kill_pane_entry = { const struct cmd_entry cmd_kill_pane_entry = {
"kill-pane", "killp", "kill-pane", "killp",
"[-a] " CMD_TARGET_PANE_USAGE, "[-a] " CMD_TARGET_PANE_USAGE,
0, CMD_CHFLAG('a'), 0, "a",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_kill_pane_exec, cmd_kill_pane_exec,
@ -56,7 +56,7 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
return (0); return (0);
} }
if (data->chflags & CMD_CHFLAG('a')) { if (cmd_check_flag(data->chflags, 'a')) {
loopwp = TAILQ_FIRST(&wl->window->panes); loopwp = TAILQ_FIRST(&wl->window->panes);
while (loopwp != NULL) { while (loopwp != NULL) {
nextwp = TAILQ_NEXT(loopwp, entry); nextwp = TAILQ_NEXT(loopwp, entry);

View File

@ -32,7 +32,7 @@ int cmd_kill_server_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_kill_server_entry = { const struct cmd_entry cmd_kill_server_entry = {
"kill-server", NULL, "kill-server", NULL,
"", "",
0, 0, 0, "",
NULL, NULL,
NULL, NULL,
cmd_kill_server_exec, cmd_kill_server_exec,

View File

@ -32,7 +32,7 @@ int cmd_kill_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_kill_session_entry = { const struct cmd_entry cmd_kill_session_entry = {
"kill-session", NULL, "kill-session", NULL,
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_kill_session_exec, cmd_kill_session_exec,

View File

@ -29,7 +29,7 @@ int cmd_kill_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_kill_window_entry = { const struct cmd_entry cmd_kill_window_entry = {
"kill-window", "killw", "kill-window", "killw",
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_kill_window_exec, cmd_kill_window_exec,

View File

@ -29,7 +29,7 @@ int cmd_last_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_last_window_entry = { const struct cmd_entry cmd_last_window_entry = {
"last-window", "last", "last-window", "last",
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_last_window_exec, cmd_last_window_exec,

View File

@ -31,7 +31,7 @@ int cmd_link_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_link_window_entry = { const struct cmd_entry cmd_link_window_entry = {
"link-window", "linkw", "link-window", "linkw",
"[-dk] " CMD_SRCDST_WINDOW_USAGE, "[-dk] " CMD_SRCDST_WINDOW_USAGE,
0, CMD_CHFLAG('d')|CMD_CHFLAG('k'), 0, "dk",
cmd_srcdst_init, cmd_srcdst_init,
cmd_srcdst_parse, cmd_srcdst_parse,
cmd_link_window_exec, cmd_link_window_exec,
@ -53,8 +53,8 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2) if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2)
return (-1); return (-1);
kflag = data->chflags & CMD_CHFLAG('k'); kflag = cmd_check_flag(data->chflags, 'k');
dflag = data->chflags & CMD_CHFLAG('d'); dflag = cmd_check_flag(data->chflags, 'd');
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
ctx->error(ctx, "can't link window: %s", cause); ctx->error(ctx, "can't link window: %s", cause);
xfree(cause); xfree(cause);

View File

@ -32,7 +32,7 @@ int cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_buffers_entry = { const struct cmd_entry cmd_list_buffers_entry = {
"list-buffers", "lsb", "list-buffers", "lsb",
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_list_buffers_exec, cmd_list_buffers_exec,

View File

@ -32,7 +32,7 @@ int cmd_list_clients_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_clients_entry = { const struct cmd_entry cmd_list_clients_entry = {
"list-clients", "lsc", "list-clients", "lsc",
"", "",
0, 0, 0, "",
NULL, NULL,
NULL, NULL,
cmd_list_clients_exec, cmd_list_clients_exec,

View File

@ -29,7 +29,7 @@ int cmd_list_commands_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_commands_entry = { const struct cmd_entry cmd_list_commands_entry = {
"list-commands", "lscm", "list-commands", "lscm",
"", "",
0, 0, 0, "",
NULL, NULL,
NULL, NULL,
cmd_list_commands_exec, cmd_list_commands_exec,

View File

@ -33,7 +33,7 @@ int cmd_list_keys_table(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_keys_entry = { const struct cmd_entry cmd_list_keys_entry = {
"list-keys", "lsk", "list-keys", "lsk",
"[-t key-table]", "[-t key-table]",
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_list_keys_exec, cmd_list_keys_exec,

View File

@ -31,7 +31,7 @@ int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_panes_entry = { const struct cmd_entry cmd_list_panes_entry = {
"list-panes", "lsp", "list-panes", "lsp",
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_list_panes_exec, cmd_list_panes_exec,

View File

@ -31,7 +31,7 @@ int cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_sessions_entry = { const struct cmd_entry cmd_list_sessions_entry = {
"list-sessions", "ls", "", "list-sessions", "ls", "",
0, 0, 0, "",
NULL, NULL,
NULL, NULL,
cmd_list_sessions_exec, cmd_list_sessions_exec,

View File

@ -31,7 +31,7 @@ int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_windows_entry = { const struct cmd_entry cmd_list_windows_entry = {
"list-windows", "lsw", "list-windows", "lsw",
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_list_windows_exec, cmd_list_windows_exec,

View File

@ -35,7 +35,7 @@ int cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_load_buffer_entry = { const struct cmd_entry cmd_load_buffer_entry = {
"load-buffer", "loadb", "load-buffer", "loadb",
CMD_BUFFER_SESSION_USAGE " path", CMD_BUFFER_SESSION_USAGE " path",
CMD_ARG1, 0, CMD_ARG1, "",
cmd_buffer_init, cmd_buffer_init,
cmd_buffer_parse, cmd_buffer_parse,
cmd_load_buffer_exec, cmd_load_buffer_exec,

View File

@ -29,7 +29,7 @@ int cmd_lock_client_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_lock_client_entry = { const struct cmd_entry cmd_lock_client_entry = {
"lock-client", "lockc", "lock-client", "lockc",
CMD_TARGET_CLIENT_USAGE, CMD_TARGET_CLIENT_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_lock_client_exec, cmd_lock_client_exec,

View File

@ -33,7 +33,7 @@ int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_lock_server_entry = { const struct cmd_entry cmd_lock_server_entry = {
"lock-server", "lock", "lock-server", "lock",
"", "",
0, 0, 0, "",
NULL, NULL,
NULL, NULL,
cmd_lock_server_exec, cmd_lock_server_exec,

View File

@ -29,7 +29,7 @@ int cmd_lock_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_lock_session_entry = { const struct cmd_entry cmd_lock_session_entry = {
"lock-session", "locks", "lock-session", "locks",
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_lock_session_exec, cmd_lock_session_exec,

View File

@ -31,7 +31,7 @@ int cmd_move_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_move_window_entry = { const struct cmd_entry cmd_move_window_entry = {
"move-window", "movew", "move-window", "movew",
"[-dk] " CMD_SRCDST_WINDOW_USAGE, "[-dk] " CMD_SRCDST_WINDOW_USAGE,
0, CMD_CHFLAG('d')|CMD_CHFLAG('k'), 0, "dk",
cmd_srcdst_init, cmd_srcdst_init,
cmd_srcdst_parse, cmd_srcdst_parse,
cmd_move_window_exec, cmd_move_window_exec,
@ -53,8 +53,8 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2) if ((idx = cmd_find_index(ctx, data->dst, &dst)) == -2)
return (-1); return (-1);
kflag = data->chflags & CMD_CHFLAG('k'); kflag = cmd_check_flag(data->chflags, 'k');
dflag = data->chflags & CMD_CHFLAG('d'); dflag = cmd_check_flag(data->chflags, 'd');
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
ctx->error(ctx, "can't move window: %s", cause); ctx->error(ctx, "can't move window: %s", cause);
xfree(cause); xfree(cause);

View File

@ -44,7 +44,7 @@ struct cmd_new_session_data {
const struct cmd_entry cmd_new_session_entry = { const struct cmd_entry cmd_new_session_entry = {
"new-session", "new", "new-session", "new",
"[-d] [-n window-name] [-s session-name] [-t target-session] [command]", "[-d] [-n window-name] [-s session-name] [-t target-session] [command]",
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON, 0, CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON, "",
cmd_new_session_init, cmd_new_session_init,
cmd_new_session_parse, cmd_new_session_parse,
cmd_new_session_exec, cmd_new_session_exec,

View File

@ -43,7 +43,7 @@ struct cmd_new_window_data {
const struct cmd_entry cmd_new_window_entry = { const struct cmd_entry cmd_new_window_entry = {
"new-window", "neww", "new-window", "neww",
"[-dk] [-n window-name] [-t target-window] [command]", "[-dk] [-n window-name] [-t target-window] [command]",
0, 0, 0, "",
cmd_new_window_init, cmd_new_window_init,
cmd_new_window_parse, cmd_new_window_parse,
cmd_new_window_exec, cmd_new_window_exec,

View File

@ -29,7 +29,7 @@ int cmd_next_layout_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_next_layout_entry = { const struct cmd_entry cmd_next_layout_entry = {
"next-layout", "nextl", "next-layout", "nextl",
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_next_layout_exec, cmd_next_layout_exec,

View File

@ -30,7 +30,7 @@ int cmd_next_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_next_window_entry = { const struct cmd_entry cmd_next_window_entry = {
"next-window", "next", "next-window", "next",
"[-a] " CMD_TARGET_SESSION_USAGE, "[-a] " CMD_TARGET_SESSION_USAGE,
0, CMD_CHFLAG('a'), 0, "a",
cmd_next_window_init, cmd_next_window_init,
cmd_target_parse, cmd_target_parse,
cmd_next_window_exec, cmd_next_window_exec,
@ -47,7 +47,7 @@ cmd_next_window_init(struct cmd *self, int key)
data = self->data; data = self->data;
if (key == ('n' | KEYC_ESCAPE)) if (key == ('n' | KEYC_ESCAPE))
data->chflags |= CMD_CHFLAG('a'); cmd_set_flag(&data->chflags, 'a');
} }
int int
@ -61,7 +61,7 @@ cmd_next_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
activity = 0; activity = 0;
if (data->chflags & CMD_CHFLAG('a')) if (cmd_check_flag(data->chflags, 'a'))
activity = 1; activity = 1;
if (session_next(s, activity) == 0) if (session_next(s, activity) == 0)

View File

@ -32,7 +32,7 @@ void cmd_paste_buffer_lf2cr(struct window_pane *, const char *, size_t);
const struct cmd_entry cmd_paste_buffer_entry = { const struct cmd_entry cmd_paste_buffer_entry = {
"paste-buffer", "pasteb", "paste-buffer", "pasteb",
"[-dr] " CMD_BUFFER_WINDOW_USAGE, "[-dr] " CMD_BUFFER_WINDOW_USAGE,
0, CMD_CHFLAG('d')|CMD_CHFLAG('r'), 0, "dr",
cmd_buffer_init, cmd_buffer_init,
cmd_buffer_parse, cmd_buffer_parse,
cmd_paste_buffer_exec, cmd_paste_buffer_exec,
@ -64,14 +64,14 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
if (pb != NULL && *pb->data != '\0') { if (pb != NULL && *pb->data != '\0') {
/* -r means raw data without LF->CR conversion. */ /* -r means raw data without LF->CR conversion. */
if (data->chflags & CMD_CHFLAG('r')) if (cmd_check_flag(data->chflags, 'r'))
bufferevent_write(wp->event, pb->data, pb->size); bufferevent_write(wp->event, pb->data, pb->size);
else else
cmd_paste_buffer_lf2cr(wp, pb->data, pb->size); cmd_paste_buffer_lf2cr(wp, pb->data, pb->size);
} }
/* Delete the buffer if -d. */ /* Delete the buffer if -d. */
if (data->chflags & CMD_CHFLAG('d')) { if (cmd_check_flag(data->chflags, 'd')) {
if (data->buffer == -1) if (data->buffer == -1)
paste_free_top(&s->buffers); paste_free_top(&s->buffers);
else else

View File

@ -38,7 +38,7 @@ void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
const struct cmd_entry cmd_pipe_pane_entry = { const struct cmd_entry cmd_pipe_pane_entry = {
"pipe-pane", "pipep", "pipe-pane", "pipep",
CMD_TARGET_PANE_USAGE "[-o] [command]", CMD_TARGET_PANE_USAGE "[-o] [command]",
CMD_ARG01, CMD_CHFLAG('o'), CMD_ARG01, "o",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_pipe_pane_exec, cmd_pipe_pane_exec,
@ -74,7 +74,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
* *
* bind ^p pipep -o 'cat >>~/output' * bind ^p pipep -o 'cat >>~/output'
*/ */
if (data->chflags & CMD_CHFLAG('o') && old_fd != -1) if (cmd_check_flag(data->chflags, 'o') && old_fd != -1)
return (0); return (0);
/* Open the new pipe. */ /* Open the new pipe. */

View File

@ -29,7 +29,7 @@ int cmd_previous_layout_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_previous_layout_entry = { const struct cmd_entry cmd_previous_layout_entry = {
"previous-layout", "prevl", "previous-layout", "prevl",
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_previous_layout_exec, cmd_previous_layout_exec,

View File

@ -30,7 +30,7 @@ int cmd_previous_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_previous_window_entry = { const struct cmd_entry cmd_previous_window_entry = {
"previous-window", "prev", "previous-window", "prev",
"[-a] " CMD_TARGET_SESSION_USAGE, "[-a] " CMD_TARGET_SESSION_USAGE,
0, CMD_CHFLAG('a'), 0, "a",
cmd_previous_window_init, cmd_previous_window_init,
cmd_target_parse, cmd_target_parse,
cmd_previous_window_exec, cmd_previous_window_exec,
@ -47,7 +47,7 @@ cmd_previous_window_init(struct cmd *self, int key)
data = self->data; data = self->data;
if (key == ('p' | KEYC_ESCAPE)) if (key == ('p' | KEYC_ESCAPE))
data->chflags |= CMD_CHFLAG('a'); cmd_set_flag(&data->chflags, 'a');
} }
int int
@ -61,7 +61,7 @@ cmd_previous_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
activity = 0; activity = 0;
if (data->chflags & CMD_CHFLAG('a')) if (cmd_check_flag(data->chflags, 'a'))
activity = 1; activity = 1;
if (session_previous(s, activity) == 0) if (session_previous(s, activity) == 0)

View File

@ -29,7 +29,7 @@ int cmd_refresh_client_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_refresh_client_entry = { const struct cmd_entry cmd_refresh_client_entry = {
"refresh-client", "refresh", "refresh-client", "refresh",
CMD_TARGET_CLIENT_USAGE, CMD_TARGET_CLIENT_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_refresh_client_exec, cmd_refresh_client_exec,

View File

@ -31,7 +31,7 @@ int cmd_rename_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_rename_session_entry = { const struct cmd_entry cmd_rename_session_entry = {
"rename-session", "rename", "rename-session", "rename",
CMD_TARGET_SESSION_USAGE " new-name", CMD_TARGET_SESSION_USAGE " new-name",
CMD_ARG1, 0, CMD_ARG1, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_rename_session_exec, cmd_rename_session_exec,

View File

@ -31,7 +31,7 @@ int cmd_rename_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_rename_window_entry = { const struct cmd_entry cmd_rename_window_entry = {
"rename-window", "renamew", "rename-window", "renamew",
CMD_TARGET_WINDOW_USAGE " new-name", CMD_TARGET_WINDOW_USAGE " new-name",
CMD_ARG1, 0, CMD_ARG1, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_rename_window_exec, cmd_rename_window_exec,

View File

@ -31,9 +31,8 @@ int cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_resize_pane_entry = { const struct cmd_entry cmd_resize_pane_entry = {
"resize-pane", "resizep", "resize-pane", "resizep",
"[-DU] " CMD_TARGET_PANE_USAGE " [adjustment]", "[-DLRU] " CMD_TARGET_PANE_USAGE " [adjustment]",
CMD_ARG01, CMD_ARG01, "DLRU",
CMD_CHFLAG('D')|CMD_CHFLAG('L')|CMD_CHFLAG('R')|CMD_CHFLAG('U'),
cmd_resize_pane_init, cmd_resize_pane_init,
cmd_target_parse, cmd_target_parse,
cmd_resize_pane_exec, cmd_resize_pane_exec,
@ -50,28 +49,28 @@ cmd_resize_pane_init(struct cmd *self, int key)
data = self->data; data = self->data;
if (key == (KEYC_UP | KEYC_CTRL)) if (key == (KEYC_UP | KEYC_CTRL))
data->chflags |= CMD_CHFLAG('U'); cmd_set_flag(&data->chflags, 'U');
if (key == (KEYC_DOWN | KEYC_CTRL)) if (key == (KEYC_DOWN | KEYC_CTRL))
data->chflags |= CMD_CHFLAG('D'); cmd_set_flag(&data->chflags, 'D');
if (key == (KEYC_LEFT | KEYC_CTRL)) if (key == (KEYC_LEFT | KEYC_CTRL))
data->chflags |= CMD_CHFLAG('L'); cmd_set_flag(&data->chflags, 'L');
if (key == (KEYC_RIGHT | KEYC_CTRL)) if (key == (KEYC_RIGHT | KEYC_CTRL))
data->chflags |= CMD_CHFLAG('R'); cmd_set_flag(&data->chflags, 'R');
if (key == (KEYC_UP | KEYC_ESCAPE)) { if (key == (KEYC_UP | KEYC_ESCAPE)) {
data->chflags |= CMD_CHFLAG('U'); cmd_set_flag(&data->chflags, 'U');
data->arg = xstrdup("5"); data->arg = xstrdup("5");
} }
if (key == (KEYC_DOWN | KEYC_ESCAPE)) { if (key == (KEYC_DOWN | KEYC_ESCAPE)) {
data->chflags |= CMD_CHFLAG('D'); cmd_set_flag(&data->chflags, 'D');
data->arg = xstrdup("5"); data->arg = xstrdup("5");
} }
if (key == (KEYC_LEFT | KEYC_ESCAPE)) { if (key == (KEYC_LEFT | KEYC_ESCAPE)) {
data->chflags |= CMD_CHFLAG('L'); cmd_set_flag(&data->chflags, 'L');
data->arg = xstrdup("5"); data->arg = xstrdup("5");
} }
if (key == (KEYC_RIGHT | KEYC_ESCAPE)) { if (key == (KEYC_RIGHT | KEYC_ESCAPE)) {
data->chflags |= CMD_CHFLAG('R'); cmd_set_flag(&data->chflags, 'R');
data->arg = xstrdup("5"); data->arg = xstrdup("5");
} }
} }
@ -98,15 +97,14 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
} }
} }
if (data->chflags & (CMD_CHFLAG('L')|CMD_CHFLAG('R'))) { if (cmd_check_flag(data->chflags, 'L'))
if (data->chflags & CMD_CHFLAG('L')) layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
adjust = -adjust; else if (cmd_check_flag(data->chflags, 'R'))
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust); layout_resize_pane(wp, LAYOUT_LEFTRIGHT, adjust);
} else { else if (cmd_check_flag(data->chflags, 'U'))
if (data->chflags & CMD_CHFLAG('U')) layout_resize_pane(wp, LAYOUT_TOPBOTTOM, -adjust);
adjust = -adjust; else if (cmd_check_flag(data->chflags, 'D'))
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust); layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
}
server_redraw_window(wl->window); server_redraw_window(wl->window);
return (0); return (0);

View File

@ -31,7 +31,7 @@ int cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_respawn_window_entry = { const struct cmd_entry cmd_respawn_window_entry = {
"respawn-window", "respawnw", "respawn-window", "respawnw",
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]", "[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
CMD_ARG01, CMD_CHFLAG('k'), CMD_ARG01, "k",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_respawn_window_exec, cmd_respawn_window_exec,
@ -54,7 +54,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
w = wl->window; w = wl->window;
if (!(data->chflags & CMD_CHFLAG('k'))) { if (!cmd_check_flag(data->chflags, 'k')) {
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp->fd == -1) if (wp->fd == -1)
continue; continue;

View File

@ -30,7 +30,7 @@ int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_rotate_window_entry = { const struct cmd_entry cmd_rotate_window_entry = {
"rotate-window", "rotatew", "rotate-window", "rotatew",
"[-DU] " CMD_TARGET_WINDOW_USAGE, "[-DU] " CMD_TARGET_WINDOW_USAGE,
0, CMD_CHFLAG('D')|CMD_CHFLAG('U'), 0, "DU",
cmd_rotate_window_init, cmd_rotate_window_init,
cmd_target_parse, cmd_target_parse,
cmd_rotate_window_exec, cmd_rotate_window_exec,
@ -47,7 +47,7 @@ cmd_rotate_window_init(struct cmd *self, int key)
data = self->data; data = self->data;
if (key == ('o' | KEYC_ESCAPE)) if (key == ('o' | KEYC_ESCAPE))
data->chflags |= CMD_CHFLAG('D'); cmd_set_flag(&data->chflags, 'D');
} }
int int
@ -64,7 +64,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
w = wl->window; w = wl->window;
if (data->chflags & CMD_CHFLAG('D')) { if (cmd_check_flag(data->chflags, 'D')) {
wp = TAILQ_LAST(&w->panes, window_panes); wp = TAILQ_LAST(&w->panes, window_panes);
TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_REMOVE(&w->panes, wp, entry);
TAILQ_INSERT_HEAD(&w->panes, wp, entry); TAILQ_INSERT_HEAD(&w->panes, wp, entry);

View File

@ -36,7 +36,7 @@ void cmd_run_shell_free(void *);
const struct cmd_entry cmd_run_shell_entry = { const struct cmd_entry cmd_run_shell_entry = {
"run-shell", "run", "run-shell", "run",
"command", "command",
CMD_ARG1, 0, CMD_ARG1, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_run_shell_exec, cmd_run_shell_exec,

View File

@ -33,7 +33,7 @@ int cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_save_buffer_entry = { const struct cmd_entry cmd_save_buffer_entry = {
"save-buffer", "saveb", "save-buffer", "saveb",
"[-a] " CMD_BUFFER_SESSION_USAGE " path", "[-a] " CMD_BUFFER_SESSION_USAGE " path",
CMD_ARG1, CMD_CHFLAG('a'), CMD_ARG1, "a",
cmd_buffer_init, cmd_buffer_init,
cmd_buffer_parse, cmd_buffer_parse,
cmd_save_buffer_exec, cmd_save_buffer_exec,
@ -66,7 +66,7 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
} }
mask = umask(S_IRWXG | S_IRWXO); mask = umask(S_IRWXG | S_IRWXO);
if (data->chflags & CMD_CHFLAG('a')) if (cmd_check_flag(data->chflags, 'a'))
f = fopen(data->arg, "ab"); f = fopen(data->arg, "ab");
else else
f = fopen(data->arg, "wb"); f = fopen(data->arg, "wb");

View File

@ -30,7 +30,7 @@ int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_select_layout_entry = { const struct cmd_entry cmd_select_layout_entry = {
"select-layout", "selectl", "select-layout", "selectl",
CMD_TARGET_WINDOW_USAGE " [layout-name]", CMD_TARGET_WINDOW_USAGE " [layout-name]",
CMD_ARG01, 0, CMD_ARG01, "",
cmd_select_layout_init, cmd_select_layout_init,
cmd_target_parse, cmd_target_parse,
cmd_select_layout_exec, cmd_select_layout_exec,

View File

@ -29,7 +29,7 @@ int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_select_pane_entry = { const struct cmd_entry cmd_select_pane_entry = {
"select-pane", "selectp", "select-pane", "selectp",
CMD_TARGET_PANE_USAGE, CMD_TARGET_PANE_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_select_pane_exec, cmd_select_pane_exec,

View File

@ -33,7 +33,7 @@ int cmd_select_prompt_callback(void *, const char *);
const struct cmd_entry cmd_select_prompt_entry = { const struct cmd_entry cmd_select_prompt_entry = {
"select-prompt", NULL, "select-prompt", NULL,
CMD_TARGET_CLIENT_USAGE, CMD_TARGET_CLIENT_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_select_prompt_exec, cmd_select_prompt_exec,

View File

@ -32,7 +32,7 @@ int cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_select_window_entry = { const struct cmd_entry cmd_select_window_entry = {
"select-window", "selectw", "select-window", "selectw",
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0, 0, "",
cmd_select_window_init, cmd_select_window_init,
cmd_target_parse, cmd_target_parse,
cmd_select_window_exec, cmd_select_window_exec,

View File

@ -40,7 +40,7 @@ struct cmd_send_keys_data {
const struct cmd_entry cmd_send_keys_entry = { const struct cmd_entry cmd_send_keys_entry = {
"send-keys", "send", "send-keys", "send",
"[-t target-pane] key ...", "[-t target-pane] key ...",
0, 0, 0, "",
NULL, NULL,
cmd_send_keys_parse, cmd_send_keys_parse,
cmd_send_keys_exec, cmd_send_keys_exec,

View File

@ -29,7 +29,7 @@ int cmd_send_prefix_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_send_prefix_entry = { const struct cmd_entry cmd_send_prefix_entry = {
"send-prefix", NULL, "send-prefix", NULL,
CMD_TARGET_PANE_USAGE, CMD_TARGET_PANE_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_send_prefix_exec, cmd_send_prefix_exec,

View File

@ -36,7 +36,7 @@ int cmd_server_info_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_server_info_entry = { const struct cmd_entry cmd_server_info_entry = {
"server-info", "info", "server-info", "info",
"", "",
0, 0, 0, "",
NULL, NULL,
NULL, NULL,
cmd_server_info_exec, cmd_server_info_exec,

View File

@ -31,7 +31,7 @@ int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_set_buffer_entry = { const struct cmd_entry cmd_set_buffer_entry = {
"set-buffer", "setb", "set-buffer", "setb",
CMD_BUFFER_SESSION_USAGE " data", CMD_BUFFER_SESSION_USAGE " data",
CMD_ARG1, 0, CMD_ARG1, "",
cmd_buffer_init, cmd_buffer_init,
cmd_buffer_parse, cmd_buffer_parse,
cmd_set_buffer_exec, cmd_set_buffer_exec,

View File

@ -32,7 +32,7 @@ int cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_set_environment_entry = { const struct cmd_entry cmd_set_environment_entry = {
"set-environment", "setenv", "set-environment", "setenv",
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]", "[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
CMD_ARG12, CMD_CHFLAG('g')|CMD_CHFLAG('r')|CMD_CHFLAG('u'), CMD_ARG12, "gru",
NULL, NULL,
cmd_target_parse, cmd_target_parse,
cmd_set_environment_exec, cmd_set_environment_exec,
@ -56,7 +56,7 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
} }
if (data->chflags & CMD_CHFLAG('g')) if (cmd_check_flag(data->chflags, 'g'))
env = &global_environ; env = &global_environ;
else { else {
if ((s = cmd_find_session(ctx, data->target)) == NULL) if ((s = cmd_find_session(ctx, data->target)) == NULL)
@ -64,13 +64,13 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
env = &s->environ; env = &s->environ;
} }
if (data->chflags & CMD_CHFLAG('u')) { if (cmd_check_flag(data->chflags, 'u')) {
if (data->arg2 != NULL) { if (data->arg2 != NULL) {
ctx->error(ctx, "can't specify a value with -u"); ctx->error(ctx, "can't specify a value with -u");
return (-1); return (-1);
} }
environ_unset(env, data->arg); environ_unset(env, data->arg);
} else if (data->chflags & CMD_CHFLAG('r')) { } else if (cmd_check_flag(data->chflags, 'r')) {
if (data->arg2 != NULL) { if (data->arg2 != NULL) {
ctx->error(ctx, "can't specify a value with -r"); ctx->error(ctx, "can't specify a value with -r");
return (-1); return (-1);

View File

@ -32,7 +32,7 @@ int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_set_option_entry = { const struct cmd_entry cmd_set_option_entry = {
"set-option", "set", "set-option", "set",
"[-agu] " CMD_TARGET_SESSION_USAGE " option [value]", "[-agu] " CMD_TARGET_SESSION_USAGE " option [value]",
CMD_ARG12, CMD_CHFLAG('a')|CMD_CHFLAG('g')|CMD_CHFLAG('u'), CMD_ARG12, "agu",
NULL, NULL,
cmd_target_parse, cmd_target_parse,
cmd_set_option_exec, cmd_set_option_exec,
@ -113,7 +113,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
u_int i; u_int i;
int try_again; int try_again;
if (data->chflags & CMD_CHFLAG('g')) if (cmd_check_flag(data->chflags, 'g'))
oo = &global_s_options; oo = &global_s_options;
else { else {
if ((s = cmd_find_session(ctx, data->target)) == NULL) if ((s = cmd_find_session(ctx, data->target)) == NULL)
@ -145,8 +145,8 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
} }
if (data->chflags & CMD_CHFLAG('u')) { if (cmd_check_flag(data->chflags, 'u')) {
if (data->chflags & CMD_CHFLAG('g')) { if (cmd_check_flag(data->chflags, 'g')) {
ctx->error(ctx, ctx->error(ctx,
"can't unset global option: %s", entry->name); "can't unset global option: %s", entry->name);
return (-1); return (-1);
@ -163,7 +163,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
switch (entry->type) { switch (entry->type) {
case SET_OPTION_STRING: case SET_OPTION_STRING:
set_option_string(ctx, oo, entry, set_option_string(ctx, oo, entry,
data->arg2, data->chflags & CMD_CHFLAG('a')); data->arg2, cmd_check_flag(data->chflags, 'a'));
break; break;
case SET_OPTION_NUMBER: case SET_OPTION_NUMBER:
set_option_number(ctx, oo, entry, data->arg2); set_option_number(ctx, oo, entry, data->arg2);

View File

@ -32,7 +32,7 @@ int cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_set_window_option_entry = { const struct cmd_entry cmd_set_window_option_entry = {
"set-window-option", "setw", "set-window-option", "setw",
"[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]", "[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]",
CMD_ARG12, CMD_CHFLAG('a')|CMD_CHFLAG('g')|CMD_CHFLAG('u'), CMD_ARG12, "agu",
NULL, NULL,
cmd_target_parse, cmd_target_parse,
cmd_set_window_option_exec, cmd_set_window_option_exec,
@ -86,7 +86,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
const struct set_option_entry *entry, *opt; const struct set_option_entry *entry, *opt;
u_int i; u_int i;
if (data->chflags & CMD_CHFLAG('g')) if (cmd_check_flag(data->chflags, 'g'))
oo = &global_w_options; oo = &global_w_options;
else { else {
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
@ -118,8 +118,8 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1); return (-1);
} }
if (data->chflags & CMD_CHFLAG('u')) { if (cmd_check_flag(data->chflags, 'u')) {
if (data->chflags & CMD_CHFLAG('g')) { if (cmd_check_flag(data->chflags, 'g')) {
ctx->error(ctx, ctx->error(ctx,
"can't unset global option: %s", entry->name); "can't unset global option: %s", entry->name);
return (-1); return (-1);
@ -136,7 +136,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
switch (entry->type) { switch (entry->type) {
case SET_OPTION_STRING: case SET_OPTION_STRING:
set_option_string(ctx, oo, entry, set_option_string(ctx, oo, entry,
data->arg2, data->chflags & CMD_CHFLAG('a')); data->arg2, cmd_check_flag(data->chflags, 'a'));
break; break;
case SET_OPTION_NUMBER: case SET_OPTION_NUMBER:
set_option_number(ctx, oo, entry, data->arg2); set_option_number(ctx, oo, entry, data->arg2);

View File

@ -31,7 +31,7 @@ int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_show_buffer_entry = { const struct cmd_entry cmd_show_buffer_entry = {
"show-buffer", "showb", "show-buffer", "showb",
CMD_BUFFER_SESSION_USAGE, CMD_BUFFER_SESSION_USAGE,
0, 0, 0, "",
cmd_buffer_init, cmd_buffer_init,
cmd_buffer_parse, cmd_buffer_parse,
cmd_show_buffer_exec, cmd_show_buffer_exec,

View File

@ -32,7 +32,7 @@ int cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_show_environment_entry = { const struct cmd_entry cmd_show_environment_entry = {
"show-environment", "showenv", "show-environment", "showenv",
"[-g] " CMD_TARGET_SESSION_USAGE, "[-g] " CMD_TARGET_SESSION_USAGE,
0, CMD_CHFLAG('g'), 0, "g",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_show_environment_exec, cmd_show_environment_exec,
@ -48,7 +48,7 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
struct environ *env; struct environ *env;
struct environ_entry *envent; struct environ_entry *envent;
if (data->chflags & CMD_CHFLAG('g')) if (cmd_check_flag(data->chflags, 'g'))
env = &global_environ; env = &global_environ;
else { else {
if ((s = cmd_find_session(ctx, data->target)) == NULL) if ((s = cmd_find_session(ctx, data->target)) == NULL)

View File

@ -32,7 +32,7 @@ int 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",
"[-g] " CMD_TARGET_SESSION_USAGE, "[-g] " CMD_TARGET_SESSION_USAGE,
0, CMD_CHFLAG('g'), 0, "g",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_show_options_exec, cmd_show_options_exec,
@ -50,7 +50,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
const struct set_option_entry *entry; const struct set_option_entry *entry;
const char *optval; const char *optval;
if (data->chflags & CMD_CHFLAG('g')) if (cmd_check_flag(data->chflags, 'g'))
oo = &global_s_options; oo = &global_s_options;
else { else {
if ((s = cmd_find_session(ctx, data->target)) == NULL) if ((s = cmd_find_session(ctx, data->target)) == NULL)

View File

@ -32,7 +32,7 @@ int cmd_show_window_options_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_show_window_options_entry = { const struct cmd_entry cmd_show_window_options_entry = {
"show-window-options", "showw", "show-window-options", "showw",
"[-g] " CMD_TARGET_WINDOW_USAGE, "[-g] " CMD_TARGET_WINDOW_USAGE,
0, CMD_CHFLAG('g'), 0, "g",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_show_window_options_exec, cmd_show_window_options_exec,
@ -50,7 +50,7 @@ cmd_show_window_options_exec(struct cmd *self, struct cmd_ctx *ctx)
const struct set_option_entry *entry; const struct set_option_entry *entry;
const char *optval; const char *optval;
if (data->chflags & CMD_CHFLAG('g')) if (cmd_check_flag(data->chflags, 'g'))
oo = &global_w_options; oo = &global_w_options;
else { else {
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)

View File

@ -37,7 +37,7 @@ struct cmd_source_file_data {
const struct cmd_entry cmd_source_file_entry = { const struct cmd_entry cmd_source_file_entry = {
"source-file", "source", "source-file", "source",
"path", "path",
0, 0, 0, "",
cmd_source_file_init, cmd_source_file_init,
cmd_source_file_parse, cmd_source_file_parse,
cmd_source_file_exec, cmd_source_file_exec,

View File

@ -46,7 +46,7 @@ struct cmd_split_window_data {
const struct cmd_entry cmd_split_window_entry = { const struct cmd_entry cmd_split_window_entry = {
"split-window", "splitw", "split-window", "splitw",
"[-dhv] [-p percentage|-l size] [-t target-window] [command]", "[-dhv] [-p percentage|-l size] [-t target-window] [command]",
0, 0, 0, "",
cmd_split_window_init, cmd_split_window_init,
cmd_split_window_parse, cmd_split_window_parse,
cmd_split_window_exec, cmd_split_window_exec,

View File

@ -29,7 +29,7 @@ int cmd_start_server_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_start_server_entry = { const struct cmd_entry cmd_start_server_entry = {
"start-server", "start", "start-server", "start",
"", "",
CMD_STARTSERVER, 0, CMD_STARTSERVER, "",
NULL, NULL,
NULL, NULL,
cmd_start_server_exec, cmd_start_server_exec,

View File

@ -37,7 +37,7 @@ struct cmd_suspend_client_data {
const struct cmd_entry cmd_suspend_client_entry = { const struct cmd_entry cmd_suspend_client_entry = {
"suspend-client", "suspendc", "suspend-client", "suspendc",
"[-c target-client]", "[-c target-client]",
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_suspend_client_exec, cmd_suspend_client_exec,

View File

@ -32,7 +32,7 @@ int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_swap_pane_entry = { const struct cmd_entry cmd_swap_pane_entry = {
"swap-pane", "swapp", "swap-pane", "swapp",
"[-dDU] " CMD_SRCDST_PANE_USAGE, "[-dDU] " CMD_SRCDST_PANE_USAGE,
0, CMD_CHFLAG('d')|CMD_CHFLAG('D')|CMD_CHFLAG('U'), 0, "dDU",
cmd_swap_pane_init, cmd_swap_pane_init,
cmd_srcdst_parse, cmd_srcdst_parse,
cmd_swap_pane_exec, cmd_swap_pane_exec,
@ -49,11 +49,12 @@ cmd_swap_pane_init(struct cmd *self, int key)
data = self->data; data = self->data;
if (key == '{') if (key == '{')
data->chflags |= CMD_CHFLAG('U'); cmd_set_flag(&data->chflags, 'U');
else if (key == '}') else if (key == '}')
data->chflags |= CMD_CHFLAG('D'); cmd_set_flag(&data->chflags, 'D');
} }
int int
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
{ {
@ -73,11 +74,11 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
if (data->src == NULL) { if (data->src == NULL) {
src_w = dst_w; src_w = dst_w;
if (data->chflags & CMD_CHFLAG('D')) { if (cmd_check_flag(data->chflags, 'D')) {
src_wp = TAILQ_NEXT(dst_wp, entry); src_wp = TAILQ_NEXT(dst_wp, entry);
if (src_wp == NULL) if (src_wp == NULL)
src_wp = TAILQ_FIRST(&dst_w->panes); src_wp = TAILQ_FIRST(&dst_w->panes);
} else if (data->chflags & CMD_CHFLAG('U')) { } else if (cmd_check_flag(data->chflags, 'U')) {
src_wp = TAILQ_PREV(dst_wp, window_panes, entry); src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
if (src_wp == NULL) if (src_wp == NULL)
src_wp = TAILQ_LAST(&dst_w->panes, window_panes); src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
@ -120,7 +121,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
dst_wp->xoff = xoff; dst_wp->yoff = yoff; dst_wp->xoff = xoff; dst_wp->yoff = yoff;
window_pane_resize(dst_wp, sx, sy); window_pane_resize(dst_wp, sx, sy);
if (!(data->chflags & CMD_CHFLAG('d'))) { if (!cmd_check_flag(data->chflags, 'd')) {
if (src_w != dst_w) { if (src_w != dst_w) {
window_set_active_pane(src_w, dst_wp); window_set_active_pane(src_w, dst_wp);
window_set_active_pane(dst_w, src_wp); window_set_active_pane(dst_w, src_wp);

View File

@ -31,7 +31,7 @@ int cmd_swap_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_swap_window_entry = { const struct cmd_entry cmd_swap_window_entry = {
"swap-window", "swapw", "swap-window", "swapw",
"[-d] " CMD_SRCDST_WINDOW_USAGE, "[-d] " CMD_SRCDST_WINDOW_USAGE,
0, CMD_CHFLAG('d'), 0, "d",
cmd_srcdst_init, cmd_srcdst_init,
cmd_srcdst_parse, cmd_srcdst_parse,
cmd_swap_window_exec, cmd_swap_window_exec,
@ -68,7 +68,7 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
wl_dst->window = wl_src->window; wl_dst->window = wl_src->window;
wl_src->window = w; wl_src->window = w;
if (!(data->chflags & CMD_CHFLAG('d'))) { if (!cmd_check_flag(data->chflags, 'd')) {
session_select(dst, wl_dst->idx); session_select(dst, wl_dst->idx);
if (src != dst) if (src != dst)
session_select(src, wl_src->idx); session_select(src, wl_src->idx);

View File

@ -40,7 +40,7 @@ struct cmd_switch_client_data {
const struct cmd_entry cmd_switch_client_entry = { const struct cmd_entry cmd_switch_client_entry = {
"switch-client", "switchc", "switch-client", "switchc",
"[-c target-client] [-t target-session]", "[-c target-client] [-t target-session]",
0, 0, 0, "",
NULL, NULL,
cmd_switch_client_parse, cmd_switch_client_parse,
cmd_switch_client_exec, cmd_switch_client_exec,

View File

@ -40,7 +40,7 @@ struct cmd_unbind_key_data {
const struct cmd_entry cmd_unbind_key_entry = { const struct cmd_entry cmd_unbind_key_entry = {
"unbind-key", "unbind", "unbind-key", "unbind",
"[-cn] [-t key-table] key", "[-cn] [-t key-table] key",
0, 0, 0, "",
NULL, NULL,
cmd_unbind_key_parse, cmd_unbind_key_parse,
cmd_unbind_key_exec, cmd_unbind_key_exec,

View File

@ -29,7 +29,7 @@ int cmd_unlink_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_unlink_window_entry = { const struct cmd_entry cmd_unlink_window_entry = {
"unlink-window", "unlinkw", "unlink-window", "unlinkw",
"[-k] " CMD_TARGET_WINDOW_USAGE, "[-k] " CMD_TARGET_WINDOW_USAGE,
0, CMD_CHFLAG('k'), 0, "k",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_unlink_window_exec, cmd_unlink_window_exec,
@ -59,7 +59,7 @@ cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
} else } else
references = 1; references = 1;
if (!(data->chflags & CMD_CHFLAG('k')) && w->references == references) { if (!cmd_check_flag(data->chflags, 'k') && w->references == references) {
ctx->error(ctx, "window is only linked to one session"); ctx->error(ctx, "window is only linked to one session");
return (-1); return (-1);
} }

View File

@ -29,7 +29,7 @@ int cmd_up_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_up_pane_entry = { const struct cmd_entry cmd_up_pane_entry = {
"up-pane", "upp", "up-pane", "upp",
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0, 0, "",
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_up_pane_exec, cmd_up_pane_exec,

7
tmux.h
View File

@ -1150,10 +1150,7 @@ struct cmd_entry {
#define CMD_ARG12 0x40 #define CMD_ARG12 0x40
int flags; int flags;
#define CMD_CHFLAG(flag) \ const char *chflags;
((flag) >= 'a' && (flag) <= 'z' ? 1ULL << ((flag) - 'a') : \
(flag) >= 'A' && (flag) <= 'Z' ? 1ULL << (26 + (flag) - 'A') : 0)
uint64_t chflags;
void (*init)(struct cmd *, int); void (*init)(struct cmd *, int);
int (*parse)(struct cmd *, int, char **, char **); int (*parse)(struct cmd *, int, char **, char **);
@ -1502,6 +1499,8 @@ int cmd_string_parse(const char *, struct cmd_list **, char **);
/* cmd-generic.c */ /* cmd-generic.c */
size_t cmd_prarg(char *, size_t, const char *, char *); size_t cmd_prarg(char *, size_t, const char *, char *);
int cmd_check_flag(uint64_t, int);
void cmd_set_flag(uint64_t *, int);
#define CMD_TARGET_PANE_USAGE "[-t target-pane]" #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
#define CMD_TARGET_WINDOW_USAGE "[-t target-window]" #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
#define CMD_TARGET_SESSION_USAGE "[-t target-session]" #define CMD_TARGET_SESSION_USAGE "[-t target-session]"