summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-swap-pane.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-11-13 19:53:30 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-11-13 19:53:30 +0000
commit3ee92a020aed88a5644dc7b00c460cc967397175 (patch)
treea97c30cdd0880c77ae7f568a17f5805e06d35cea /usr.bin/tmux/cmd-swap-pane.c
parent878aa8206770fdeeb3c49d9796de7bb6f8b839a5 (diff)
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.
Diffstat (limited to 'usr.bin/tmux/cmd-swap-pane.c')
-rw-r--r--usr.bin/tmux/cmd-swap-pane.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-swap-pane.c b/usr.bin/tmux/cmd-swap-pane.c
index bd1cdfc7d82..bb61796dc6c 100644
--- a/usr.bin/tmux/cmd-swap-pane.c
+++ b/usr.bin/tmux/cmd-swap-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-swap-pane.c,v 1.9 2009/07/30 17:29:12 nicm Exp $ */
+/* $OpenBSD: cmd-swap-pane.c,v 1.10 2009/11/13 19:53:29 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -32,7 +32,7 @@ int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_swap_pane_entry = {
"swap-pane", "swapp",
"[-dDU] " CMD_SRCDST_PANE_USAGE,
- 0, CMD_CHFLAG('d')|CMD_CHFLAG('D')|CMD_CHFLAG('U'),
+ 0, "dDU",
cmd_swap_pane_init,
cmd_srcdst_parse,
cmd_swap_pane_exec,
@@ -49,11 +49,12 @@ cmd_swap_pane_init(struct cmd *self, int key)
data = self->data;
if (key == '{')
- data->chflags |= CMD_CHFLAG('U');
+ cmd_set_flag(&data->chflags, 'U');
else if (key == '}')
- data->chflags |= CMD_CHFLAG('D');
+ cmd_set_flag(&data->chflags, 'D');
}
+
int
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) {
src_w = dst_w;
- if (data->chflags & CMD_CHFLAG('D')) {
+ if (cmd_check_flag(data->chflags, 'D')) {
src_wp = TAILQ_NEXT(dst_wp, entry);
if (src_wp == NULL)
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);
if (src_wp == NULL)
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;
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) {
window_set_active_pane(src_w, dst_wp);
window_set_active_pane(dst_w, src_wp);