diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-01-04 02:03:42 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-01-04 02:03:42 +0000 |
commit | 1ee4d36bef9cc689744ee7f9251d7ee50e9ad6ed (patch) | |
tree | 1bbde7412bc4d5731ed53a79e83f5cea9d1df1e0 /usr.bin/tmux | |
parent | 83b9981d68bee81cd3a84e592dd3d7e5d747d1e2 (diff) |
Now that parsing is common, merge some of the small, related commands
together to use the same code.
Also add some arguments (such as -n and -p) to some commands to match
existing commands.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/Makefile | 14 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-last-pane.c | 57 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-last-window.c | 57 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-lock-client.c | 52 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-lock-server.c | 42 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-lock-session.c | 52 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-next-layout.c | 53 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-next-window.c | 71 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-previous-layout.c | 53 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-previous-window.c | 71 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-select-layout.c | 44 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-select-pane.c | 29 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-select-window.c | 89 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 15 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-set-window-option.c | 46 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-show-options.c | 15 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-show-window-options.c | 49 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 34 |
18 files changed, 247 insertions, 596 deletions
diff --git a/usr.bin/tmux/Makefile b/usr.bin/tmux/Makefile index 44e1af864f6..e9cbd7081cd 100644 --- a/usr.bin/tmux/Makefile +++ b/usr.bin/tmux/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.49 2011/01/04 00:42:46 nicm Exp $ +# $OpenBSD: Makefile,v 1.50 2011/01/04 02:03:41 nicm Exp $ PROG= tmux SRCS= arguments.c attributes.c cfg.c client.c clock.c \ @@ -9,20 +9,20 @@ SRCS= arguments.c attributes.c cfg.c client.c clock.c \ cmd-choose-buffer.c cmd-delete-buffer.c cmd-detach-client.c \ cmd-find-window.c cmd-has-session.c cmd-kill-pane.c \ cmd-kill-server.c cmd-kill-session.c cmd-kill-window.c \ - cmd-last-pane.c cmd-last-window.c cmd-link-window.c cmd-list-buffers.c \ + cmd-link-window.c cmd-list-buffers.c \ cmd-list-clients.c cmd-list-commands.c cmd-list-keys.c \ cmd-list-sessions.c cmd-list-windows.c cmd-list-panes.c \ cmd-list.c cmd-load-buffer.c cmd-join-pane.c \ - cmd-lock-server.c cmd-lock-client.c cmd-lock-session.c \ + cmd-lock-server.c \ cmd-move-window.c cmd-new-session.c cmd-new-window.c \ - cmd-next-layout.c cmd-next-window.c cmd-paste-buffer.c \ - cmd-previous-layout.c cmd-previous-window.c cmd-refresh-client.c \ + cmd-paste-buffer.c \ + cmd-refresh-client.c \ cmd-rename-session.c cmd-rename-window.c cmd-resize-pane.c \ cmd-respawn-window.c cmd-rotate-window.c cmd-save-buffer.c \ cmd-select-layout.c cmd-select-pane.c cmd-select-window.c \ cmd-send-keys.c cmd-send-prefix.c cmd-server-info.c cmd-set-buffer.c \ - cmd-set-option.c cmd-set-window-option.c cmd-show-buffer.c \ - cmd-show-messages.c cmd-show-options.c cmd-show-window-options.c \ + cmd-set-option.c cmd-show-buffer.c \ + cmd-show-messages.c cmd-show-options.c \ cmd-source-file.c cmd-split-window.c cmd-start-server.c cmd-string.c \ cmd-run-shell.c cmd-suspend-client.c cmd-swap-pane.c cmd-swap-window.c \ cmd-switch-client.c cmd-unbind-key.c cmd-unlink-window.c \ diff --git a/usr.bin/tmux/cmd-last-pane.c b/usr.bin/tmux/cmd-last-pane.c deleted file mode 100644 index 0557ab85a56..00000000000 --- a/usr.bin/tmux/cmd-last-pane.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: cmd-last-pane.c,v 1.2 2011/01/04 00:42:46 nicm Exp $ */ - -/* - * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Move to last pane. - */ - -int cmd_last_pane_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_last_pane_entry = { - "last-pane", "lastp", - "t:", 0, 0, - CMD_TARGET_WINDOW_USAGE, - 0, - NULL, - NULL, - cmd_last_pane_exec -}; - -int -cmd_last_pane_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - struct winlink *wl; - struct window *w; - - if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) - return (-1); - w = wl->window; - - if (w->last == NULL) { - ctx->error(ctx, "no last pane"); - return (-1); - } - window_set_active_pane(w, w->last); - - return (0); -} diff --git a/usr.bin/tmux/cmd-last-window.c b/usr.bin/tmux/cmd-last-window.c deleted file mode 100644 index 1fcd3044f4d..00000000000 --- a/usr.bin/tmux/cmd-last-window.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: cmd-last-window.c,v 1.5 2011/01/04 00:42:46 nicm Exp $ */ - -/* - * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Move to last window. - */ - -int cmd_last_window_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_last_window_entry = { - "last-window", "last", - "t:", 0, 0, - CMD_TARGET_SESSION_USAGE, - 0, - NULL, - NULL, - cmd_last_window_exec -}; - -int -cmd_last_window_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - struct session *s; - - if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) - return (-1); - - if (session_last(s) == 0) - server_redraw_session(s); - else { - ctx->error(ctx, "no last window"); - return (-1); - } - recalculate_sizes(); - - return (0); -} diff --git a/usr.bin/tmux/cmd-lock-client.c b/usr.bin/tmux/cmd-lock-client.c deleted file mode 100644 index 85ab5031e43..00000000000 --- a/usr.bin/tmux/cmd-lock-client.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: cmd-lock-client.c,v 1.3 2011/01/04 00:42:46 nicm Exp $ */ - -/* - * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Lock a single client. - */ - -int cmd_lock_client_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_lock_client_entry = { - "lock-client", "lockc", - "t:", 0, 0, - CMD_TARGET_CLIENT_USAGE, - 0, - NULL, - NULL, - cmd_lock_client_exec -}; - -int -cmd_lock_client_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - struct client *c; - - if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL) - return (-1); - - server_lock_client(c); - recalculate_sizes(); - - return (0); -} diff --git a/usr.bin/tmux/cmd-lock-server.c b/usr.bin/tmux/cmd-lock-server.c index 8ae639fb6cd..2e1fcf5eddd 100644 --- a/usr.bin/tmux/cmd-lock-server.c +++ b/usr.bin/tmux/cmd-lock-server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-lock-server.c,v 1.8 2011/01/04 00:42:46 nicm Exp $ */ +/* $OpenBSD: cmd-lock-server.c,v 1.9 2011/01/04 02:03:41 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -25,7 +25,7 @@ #include "tmux.h" /* - * Lock server. + * Lock commands. */ int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *); @@ -40,11 +40,45 @@ const struct cmd_entry cmd_lock_server_entry = { cmd_lock_server_exec }; +const struct cmd_entry cmd_lock_session_entry = { + "lock-session", "locks", + "t:", 0, 0, + CMD_TARGET_SESSION_USAGE, + 0, + NULL, + NULL, + cmd_lock_server_exec +}; + +const struct cmd_entry cmd_lock_client_entry = { + "lock-client", "lockc", + "t:", 0, 0, + CMD_TARGET_CLIENT_USAGE, + 0, + NULL, + NULL, + cmd_lock_server_exec +}; + /* ARGSUSED */ int -cmd_lock_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx) +cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx) { - server_lock(); + struct args *args = self->args; + struct client *c; + struct session *s; + + if (self->entry == &cmd_lock_server_entry) + server_lock(); + else if (self->entry == &cmd_lock_session_entry) { + if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) + return (-1); + server_lock_session(s); + } else { + if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL) + return (-1); + server_lock_client(c); + } recalculate_sizes(); return (0); diff --git a/usr.bin/tmux/cmd-lock-session.c b/usr.bin/tmux/cmd-lock-session.c deleted file mode 100644 index 4d57eb54355..00000000000 --- a/usr.bin/tmux/cmd-lock-session.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: cmd-lock-session.c,v 1.3 2011/01/04 00:42:46 nicm Exp $ */ - -/* - * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Lock all clients attached to a session. - */ - -int cmd_lock_session_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_lock_session_entry = { - "lock-session", "locks", - "t:", 0, 0, - CMD_TARGET_SESSION_USAGE, - 0, - NULL, - NULL, - cmd_lock_session_exec -}; - -int -cmd_lock_session_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - struct session *s; - - if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) - return (-1); - - server_lock_session(s); - recalculate_sizes(); - - return (0); -} diff --git a/usr.bin/tmux/cmd-next-layout.c b/usr.bin/tmux/cmd-next-layout.c deleted file mode 100644 index 14b91c6d043..00000000000 --- a/usr.bin/tmux/cmd-next-layout.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: cmd-next-layout.c,v 1.6 2011/01/04 00:42:47 nicm Exp $ */ - -/* - * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Switch window to next layout. - */ - -int cmd_next_layout_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_next_layout_entry = { - "next-layout", "nextl", - "t:", 0, 0, - CMD_TARGET_WINDOW_USAGE, - 0, - NULL, - NULL, - cmd_next_layout_exec -}; - -int -cmd_next_layout_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - struct winlink *wl; - u_int layout; - - if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) - return (-1); - - layout = layout_set_next(wl->window); - ctx->info(ctx, "arranging in: %s", layout_set_name(layout)); - - return (0); -} diff --git a/usr.bin/tmux/cmd-next-window.c b/usr.bin/tmux/cmd-next-window.c deleted file mode 100644 index 8255c7699b6..00000000000 --- a/usr.bin/tmux/cmd-next-window.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: cmd-next-window.c,v 1.7 2011/01/04 00:42:47 nicm Exp $ */ - -/* - * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Move to next window. - */ - -void cmd_next_window_key_binding(struct cmd *, int); -int cmd_next_window_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_next_window_entry = { - "next-window", "next", - "at:", 0, 0, - "[-a] " CMD_TARGET_SESSION_USAGE, - 0, - cmd_next_window_key_binding, - NULL, - cmd_next_window_exec -}; - -void -cmd_next_window_key_binding(struct cmd *self, int key) -{ - self->args = args_create(0); - if (key == ('n' | KEYC_ESCAPE)) - args_set(self->args, 'a', NULL); -} - -int -cmd_next_window_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - struct session *s; - int activity; - - if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) - return (-1); - - activity = 0; - if (args_has(self->args, 'a')) - activity = 1; - - if (session_next(s, activity) == 0) - server_redraw_session(s); - else { - ctx->error(ctx, "no next window"); - return (-1); - } - recalculate_sizes(); - - return (0); -} diff --git a/usr.bin/tmux/cmd-previous-layout.c b/usr.bin/tmux/cmd-previous-layout.c deleted file mode 100644 index 133a5255a41..00000000000 --- a/usr.bin/tmux/cmd-previous-layout.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: cmd-previous-layout.c,v 1.7 2011/01/04 00:42:47 nicm Exp $ */ - -/* - * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Switch window to previous layout. - */ - -int cmd_previous_layout_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_previous_layout_entry = { - "previous-layout", "prevl", - "t:", 0, 0, - CMD_TARGET_WINDOW_USAGE, - 0, - NULL, - NULL, - cmd_previous_layout_exec -}; - -int -cmd_previous_layout_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - struct winlink *wl; - u_int layout; - - if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) - return (-1); - - layout = layout_set_previous(wl->window); - ctx->info(ctx, "arranging in: %s", layout_set_name(layout)); - - return (0); -} diff --git a/usr.bin/tmux/cmd-previous-window.c b/usr.bin/tmux/cmd-previous-window.c deleted file mode 100644 index 8a482fa9d3f..00000000000 --- a/usr.bin/tmux/cmd-previous-window.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: cmd-previous-window.c,v 1.7 2011/01/04 00:42:47 nicm Exp $ */ - -/* - * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Move to previous window. - */ - -void cmd_previous_window_key_binding(struct cmd *, int); -int cmd_previous_window_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_previous_window_entry = { - "previous-window", "prev", - "at:", 0, 0, - "[-a] " CMD_TARGET_SESSION_USAGE, - 0, - cmd_previous_window_key_binding, - NULL, - cmd_previous_window_exec -}; - -void -cmd_previous_window_key_binding(struct cmd *self, int key) -{ - self->args = args_create(0); - if (key == ('p' | KEYC_ESCAPE)) - args_set(self->args, 'a', NULL); -} - -int -cmd_previous_window_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - struct session *s; - int activity; - - if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) - return (-1); - - activity = 0; - if (args_has(self->args, 'a')) - activity = 1; - - if (session_previous(s, activity) == 0) - server_redraw_session(s); - else { - ctx->error(ctx, "no previous window"); - return (-1); - } - recalculate_sizes(); - - return (0); -} diff --git a/usr.bin/tmux/cmd-select-layout.c b/usr.bin/tmux/cmd-select-layout.c index f4a59c1ad52..4741f5128d2 100644 --- a/usr.bin/tmux/cmd-select-layout.c +++ b/usr.bin/tmux/cmd-select-layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-layout.c,v 1.11 2011/01/04 00:42:47 nicm Exp $ */ +/* $OpenBSD: cmd-select-layout.c,v 1.12 2011/01/04 02:03:41 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,14 +29,34 @@ int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_select_layout_entry = { "select-layout", "selectl", - "t:", 0, 1, - CMD_TARGET_WINDOW_USAGE " [layout-name]", + "npt:", 0, 1, + "[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]", 0, cmd_select_layout_key_binding, NULL, cmd_select_layout_exec }; +const struct cmd_entry cmd_next_layout_entry = { + "next-layout", "nextl", + "t:", 0, 0, + CMD_TARGET_WINDOW_USAGE, + 0, + NULL, + NULL, + cmd_select_layout_exec +}; + +const struct cmd_entry cmd_previous_layout_entry = { + "previous-layout", "prevl", + "t:", 0, 0, + CMD_TARGET_WINDOW_USAGE, + 0, + NULL, + NULL, + cmd_select_layout_exec +}; + void cmd_select_layout_key_binding(struct cmd *self, int key) { @@ -68,11 +88,27 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx) struct args *args = self->args; struct winlink *wl; const char *layoutname; - int layout; + int next, previous, layout; if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (-1); + next = self->entry == &cmd_next_layout_entry; + if (args_has(self->args, 'n')) + next = 1; + previous = self->entry == &cmd_previous_layout_entry; + if (args_has(self->args, 'p')) + previous = 1; + + if (next || previous) { + if (next) + layout = layout_set_next(wl->window); + else + layout = layout_set_previous(wl->window); + ctx->info(ctx, "arranging in: %s", layout_set_name(layout)); + return (0); + } + if (args->argc == 0) layout = wl->window->lastlayout; else diff --git a/usr.bin/tmux/cmd-select-pane.c b/usr.bin/tmux/cmd-select-pane.c index c0d76519106..f4d025a2fc6 100644 --- a/usr.bin/tmux/cmd-select-pane.c +++ b/usr.bin/tmux/cmd-select-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-pane.c,v 1.11 2011/01/04 00:42:47 nicm Exp $ */ +/* $OpenBSD: cmd-select-pane.c,v 1.12 2011/01/04 02:03:41 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,14 +29,24 @@ int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_select_pane_entry = { "select-pane", "selectp", - "DLRt:U", 0, 0, - "[-DLRU] " CMD_TARGET_PANE_USAGE, + "lDLRt:U", 0, 0, + "[-lDLRU] " CMD_TARGET_PANE_USAGE, 0, cmd_select_pane_key_binding, NULL, cmd_select_pane_exec }; +const struct cmd_entry cmd_last_pane_entry = { + "last-pane", "lastp", + "t:", 0, 0, + CMD_TARGET_WINDOW_USAGE, + 0, + NULL, + NULL, + cmd_select_pane_exec +}; + void cmd_select_pane_key_binding(struct cmd *self, int key) { @@ -60,6 +70,19 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx) struct winlink *wl; struct window_pane *wp; + if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { + wl = cmd_find_window(ctx, args_get(args, 't'), NULL); + if (wl == NULL) + return (-1); + + if (wl->window->last == NULL) { + ctx->error(ctx, "no last pane"); + return (-1); + } + window_set_active_pane(wl->window, wl->window->last); + return (0); + } + if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL) return (-1); diff --git a/usr.bin/tmux/cmd-select-window.c b/usr.bin/tmux/cmd-select-window.c index 4059b8fd9cb..c07b749bd07 100644 --- a/usr.bin/tmux/cmd-select-window.c +++ b/usr.bin/tmux/cmd-select-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-window.c,v 1.5 2011/01/04 00:42:47 nicm Exp $ */ +/* $OpenBSD: cmd-select-window.c,v 1.6 2011/01/04 02:03:41 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,23 +31,56 @@ int cmd_select_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_select_window_entry = { "select-window", "selectw", - "t:", 0, 0, - CMD_TARGET_WINDOW_USAGE, + "lnpt:", 0, 0, + "[-lnp] " CMD_TARGET_WINDOW_USAGE, + 0, + cmd_select_window_key_binding, + NULL, + cmd_select_window_exec +}; + +const struct cmd_entry cmd_next_window_entry = { + "next-window", "next", + "at:", 0, 0, + "[-a] " CMD_TARGET_SESSION_USAGE, + 0, + cmd_select_window_key_binding, + NULL, + cmd_select_window_exec +}; + +const struct cmd_entry cmd_previous_window_entry = { + "previous-window", "prev", + "at:", 0, 0, + "[-a] " CMD_TARGET_SESSION_USAGE, 0, cmd_select_window_key_binding, NULL, cmd_select_window_exec }; +const struct cmd_entry cmd_last_window_entry = { + "last-window", "last", + "t:", 0, 0, + CMD_TARGET_SESSION_USAGE, + 0, + NULL, + NULL, + cmd_select_window_exec +}; + void cmd_select_window_key_binding(struct cmd *self, int key) { char tmp[16]; - xsnprintf(tmp, sizeof tmp, ":%d", key - '0'); - self->args = args_create(0); - args_set(self->args, 't', tmp); + if (key >= '0' && key <= '9') { + xsnprintf(tmp, sizeof tmp, ":%d", key - '0'); + args_set(self->args, 't', tmp); + } + if (key == ('n' | KEYC_ESCAPE) || key == ('p' | KEYC_ESCAPE)) + args_set(self->args, 'a', NULL); } int @@ -56,12 +89,50 @@ cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx) struct args *args = self->args; struct winlink *wl; struct session *s; + int next, previous, last, activity; - if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL) - return (-1); + next = self->entry == &cmd_next_window_entry; + if (args_has(self->args, 'n')) + next = 1; + previous = self->entry == &cmd_previous_window_entry; + if (args_has(self->args, 'p')) + previous = 1; + last = self->entry == &cmd_last_window_entry; + if (args_has(self->args, 'l')) + last = 1; + + if (next || previous || last) { + s = cmd_find_session(ctx, args_get(args, 't')); + if (s == NULL) + return (-1); + + activity = args_has(self->args, 'a'); + if (next) { + if (session_next(s, activity) != 0) { + ctx->error(ctx, "no next window"); + return (-1); + } + } else if (previous) { + if (session_previous(s, activity) != 0) { + ctx->error(ctx, "no previous window"); + return (-1); + } + } else { + if (session_last(s) != 0) { + ctx->error(ctx, "no last window"); + return (-1); + } + } - if (session_select(s, wl->idx) == 0) server_redraw_session(s); + } else { + wl = cmd_find_window(ctx, args_get(args, 't'), &s); + if (wl == NULL) + return (-1); + + if (session_select(s, wl->idx) == 0) + server_redraw_session(s); + } recalculate_sizes(); return (0); diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index 3a8c7ef35ac..daf05d4307d 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.45 2011/01/04 01:58:12 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.46 2011/01/04 02:03:41 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -68,6 +68,16 @@ const struct cmd_entry cmd_set_option_entry = { cmd_set_option_exec }; +const struct cmd_entry cmd_set_window_option_entry = { + "set-window-option", "setw", + "agt:u", 1, 2, + "[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]", + 0, + NULL, + NULL, + cmd_set_option_exec +}; + int cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) { @@ -87,7 +97,8 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) if (args_has(self->args, 's')) { oo = &global_options; table = server_options_table; - } else if (args_has(self->args, 'w')) { + } else if (args_has(self->args, 'w') || + self->entry == &cmd_set_window_option_entry) { table = window_options_table; if (args_has(self->args, 'g')) oo = &global_w_options; diff --git a/usr.bin/tmux/cmd-set-window-option.c b/usr.bin/tmux/cmd-set-window-option.c deleted file mode 100644 index 96921698ffb..00000000000 --- a/usr.bin/tmux/cmd-set-window-option.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: cmd-set-window-option.c,v 1.17 2011/01/04 00:42:47 nicm Exp $ */ - -/* - * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Set a window option. This is just an alias for set-option -w. - */ - -int cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_set_window_option_entry = { - "set-window-option", "setw", - "agt:u", 1, 2, - "[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]", - 0, - NULL, - NULL, - cmd_set_window_option_exec -}; - -int -cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - - args_set(args, 'w', NULL); - return (cmd_set_option_entry.exec(self, ctx)); -} diff --git a/usr.bin/tmux/cmd-show-options.c b/usr.bin/tmux/cmd-show-options.c index 6e73d4ea277..e24b4540717 100644 --- a/usr.bin/tmux/cmd-show-options.c +++ b/usr.bin/tmux/cmd-show-options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-show-options.c,v 1.12 2011/01/04 00:42:47 nicm Exp $ */ +/* $OpenBSD: cmd-show-options.c,v 1.13 2011/01/04 02:03:41 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -39,6 +39,16 @@ const struct cmd_entry cmd_show_options_entry = { cmd_show_options_exec }; +const struct cmd_entry cmd_show_window_options_entry = { + "show-window-options", "showw", + "gt:", 0, 0, + "[-g] " CMD_TARGET_WINDOW_USAGE, + 0, + NULL, + NULL, + cmd_show_options_exec +}; + int cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) { @@ -53,7 +63,8 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) if (args_has(self->args, 's')) { oo = &global_options; table = server_options_table; - } else if (args_has(self->args, 'w')) { + } else if (args_has(self->args, 'w') || + self->entry == &cmd_show_window_options_entry) { table = window_options_table; if (args_has(self->args, 'g')) oo = &global_w_options; diff --git a/usr.bin/tmux/cmd-show-window-options.c b/usr.bin/tmux/cmd-show-window-options.c deleted file mode 100644 index 31052d989a5..00000000000 --- a/usr.bin/tmux/cmd-show-window-options.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: cmd-show-window-options.c,v 1.9 2011/01/04 00:42:47 nicm Exp $ */ - -/* - * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include <stdlib.h> -#include <string.h> - -#include "tmux.h" - -/* - * Show window options. This is an alias for show-options -w. - */ - -int cmd_show_window_options_exec(struct cmd *, struct cmd_ctx *); - -const struct cmd_entry cmd_show_window_options_entry = { - "show-window-options", "showw", - "gt:", 0, 0, - "[-g] " CMD_TARGET_WINDOW_USAGE, - 0, - NULL, - NULL, - cmd_show_window_options_exec -}; - -int -cmd_show_window_options_exec(struct cmd *self, struct cmd_ctx *ctx) -{ - struct args *args = self->args; - - args_set(args, 'w', NULL); - return (cmd_show_options_entry.exec(self, ctx)); -} diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 418a2527e93..b35fe796e0b 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.203 2011/01/03 23:35:21 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.204 2011/01/04 02:03:41 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 3 2011 $ +.Dd $Mdocdate: January 4 2011 $ .Dt TMUX 1 .Os .Sh NAME @@ -1255,6 +1255,7 @@ lower) with .Fl U or downward (numerically higher). .It Xo Ic select-layout +.Op Fl np .Op Fl t Ar target-window .Op Ar layout-name .Xc @@ -1263,8 +1264,16 @@ Choose a specific layout for a window. If .Ar layout-name is not given, the last preset layout used (if any) is reapplied. +.Fl n +and +.Fl p +are equivalent to the +.Ic next-layout +and +.Ic previous-layout +commands. .It Xo Ic select-pane -.Op Fl DLRU +.Op Fl lDLRU .Op Fl t Ar target-pane .Xc .D1 (alias: Ic selectp ) @@ -1280,10 +1289,27 @@ or .Fl U is used, respectively the pane below, to the left, to the right, or above the target pane is used. -.It Ic select-window Op Fl t Ar target-window +.Fl l +is the same as using the +.Ic last-pane +command. +.It Xo Ic select-window +.Op Fl lnp +.Op Fl t Ar target-window +.Xc .D1 (alias: Ic selectw ) Select the window at .Ar target-window . +.Fl l , +.Fl n +and +.Fl p +are equivalent to the +.Ic last-window , +.Ic next-window +and +.Ic previous-window +commands. .It Xo Ic split-window .Op Fl dhvP .Oo Fl l |