diff --git a/CHANGES b/CHANGES index e0928bb0..72dd626f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ 14 January 2009 +* up-pane and down-pane commands, bound to arrow up and down by default. * Multiple vertical window splitting. Minimum pane size is four lines, an (unhelpful) error will be shown if attempting to split a window with less that eight lines. If the window is resized, as many panes are shown as can @@ -8,9 +9,6 @@ Note the -p and -l options to split-window are now gone, these may reappear once I think them through again. - - To come: up-pane, down-pane; switch-pane will support -p and become - select-pane. * Server locking on inactivity (lock-after-time) is now disabled by default. 13 January 2009 @@ -917,7 +915,7 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.203 2009-01-14 19:29:32 nicm Exp $ +$Id: CHANGES,v 1.204 2009-01-14 19:41:15 nicm Exp $ LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB diff --git a/GNUmakefile b/GNUmakefile index 04582483..9ad93901 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,4 @@ -# $Id: GNUmakefile,v 1.52 2009-01-13 06:50:10 nicm Exp $ +# $Id: GNUmakefile,v 1.53 2009-01-14 19:41:15 nicm Exp $ .PHONY: clean @@ -35,6 +35,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c \ cmd-save-buffer.c cmd-switch-pane.c cmd-split-window.c \ cmd-resize-pane-up.c cmd-resize-pane-down.c cmd-kill-pane.c \ + cmd-up-pane.c cmd-down-pane.c \ window-clock.c window-scroll.c window-more.c window-copy.c \ options.c options-cmd.c paste.c colour.c utf8.c clock.c \ tty.c tty-term.c tty-keys.c tty-write.c diff --git a/Makefile b/Makefile index ab60471d..7f74d422 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.91 2009-01-13 06:50:10 nicm Exp $ +# $Id: Makefile,v 1.92 2009-01-14 19:41:15 nicm Exp $ .SUFFIXES: .c .o .y .h .PHONY: clean update-index.html upload-index.html @@ -39,6 +39,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c \ cmd-save-buffer.c cmd-switch-pane.c cmd-split-window.c \ cmd-resize-pane-up.c cmd-resize-pane-down.c cmd-kill-pane.c \ + cmd-up-pane.c cmd-down-pane.c \ window-clock.c window-scroll.c window-more.c window-copy.c \ options.c options-cmd.c paste.c colour.c utf8.c clock.c \ tty.c tty-term.c tty-keys.c tty-write.c diff --git a/cmd-down-pane.c b/cmd-down-pane.c new file mode 100644 index 00000000..109ead28 --- /dev/null +++ b/cmd-down-pane.c @@ -0,0 +1,61 @@ +/* $Id: cmd-down-pane.c,v 1.1 2009-01-14 19:41:15 nicm Exp $ */ + +/* + * Copyright (c) 2009 Nicholas Marriott + * + * 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 + +#include "tmux.h" + +/* + * Move down a pane. + */ + +void cmd_down_pane_exec(struct cmd *, struct cmd_ctx *); + +const struct cmd_entry cmd_down_pane_entry = { + "down-pane", "downp", + CMD_TARGET_WINDOW_USAGE, + 0, + cmd_target_init, + cmd_target_parse, + cmd_down_pane_exec, + cmd_target_send, + cmd_target_recv, + cmd_target_free, + cmd_target_print +}; + +void +cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) +{ + struct cmd_target_data *data = self->data; + struct winlink *wl; + struct window *w; + + if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) + return; + w = wl->window; + + do { + w->active = TAILQ_NEXT(w->active, entry); + if (w->active == NULL) + w->active = TAILQ_FIRST(&w->panes); + } while (w->active->flags & PANE_HIDDEN); + + if (ctx->cmdclient != NULL) + server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); +} diff --git a/cmd-up-pane.c b/cmd-up-pane.c new file mode 100644 index 00000000..8e0962f8 --- /dev/null +++ b/cmd-up-pane.c @@ -0,0 +1,61 @@ +/* $Id: cmd-up-pane.c,v 1.1 2009-01-14 19:41:15 nicm Exp $ */ + +/* + * Copyright (c) 2009 Nicholas Marriott + * + * 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 + +#include "tmux.h" + +/* + * Move up a pane. + */ + +void cmd_up_pane_exec(struct cmd *, struct cmd_ctx *); + +const struct cmd_entry cmd_up_pane_entry = { + "up-pane", "upp", + CMD_TARGET_WINDOW_USAGE, + 0, + cmd_target_init, + cmd_target_parse, + cmd_up_pane_exec, + cmd_target_send, + cmd_target_recv, + cmd_target_free, + cmd_target_print +}; + +void +cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx) +{ + struct cmd_target_data *data = self->data; + struct winlink *wl; + struct window *w; + + if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) + return; + w = wl->window; + + do { + w->active = TAILQ_PREV(w->active, window_panes, entry); + if (w->active == NULL) + w->active = TAILQ_LAST(&w->panes, window_panes); + } while (w->active->flags & PANE_HIDDEN); + + if (ctx->cmdclient != NULL) + server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); +} diff --git a/cmd.c b/cmd.c index b80ffebe..7082bcd8 100644 --- a/cmd.c +++ b/cmd.c @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.76 2009-01-13 06:50:10 nicm Exp $ */ +/* $Id: cmd.c,v 1.77 2009-01-14 19:41:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,6 +33,7 @@ const struct cmd_entry *cmd_table[] = { &cmd_copy_mode_entry, &cmd_delete_buffer_entry, &cmd_detach_client_entry, + &cmd_down_pane_entry, &cmd_has_session_entry, &cmd_kill_pane_entry, &cmd_kill_server_entry, @@ -81,6 +82,7 @@ const struct cmd_entry *cmd_table[] = { &cmd_switch_pane_entry, &cmd_unbind_key_entry, &cmd_unlink_window_entry, + &cmd_up_pane_entry, NULL }; diff --git a/key-bindings.c b/key-bindings.c index 633b7d53..e2497334 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,4 +1,4 @@ -/* $Id: key-bindings.c,v 1.46 2009-01-14 19:29:32 nicm Exp $ */ +/* $Id: key-bindings.c,v 1.47 2009-01-14 19:41:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -108,7 +108,9 @@ key_bindings_init(void) { 's', &cmd_list_sessions_entry }, { 't', &cmd_clock_mode_entry }, { 'w', &cmd_list_windows_entry }, - { 'x', &cmd_kill_pane_entry, }, + { 'x', &cmd_kill_pane_entry, }, + { KEYC_UP, &cmd_up_pane_entry }, + { KEYC_DOWN, &cmd_down_pane_entry }, { KEYC_ADDCTL(KEYC_UP), &cmd_resize_pane_up_entry }, { KEYC_ADDCTL(KEYC_DOWN), &cmd_resize_pane_down_entry }, { META, &cmd_send_prefix_entry }, diff --git a/tmux.h b/tmux.h index dd72d55b..f2611234 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.230 2009-01-14 19:29:32 nicm Exp $ */ +/* $Id: tmux.h,v 1.231 2009-01-14 19:41:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1089,6 +1089,7 @@ extern const struct cmd_entry cmd_command_prompt_entry; extern const struct cmd_entry cmd_copy_mode_entry; extern const struct cmd_entry cmd_delete_buffer_entry; extern const struct cmd_entry cmd_detach_client_entry; +extern const struct cmd_entry cmd_down_pane_entry; extern const struct cmd_entry cmd_has_session_entry; extern const struct cmd_entry cmd_kill_pane_entry; extern const struct cmd_entry cmd_kill_server_entry; @@ -1137,6 +1138,7 @@ extern const struct cmd_entry cmd_switch_client_entry; extern const struct cmd_entry cmd_switch_pane_entry; extern const struct cmd_entry cmd_unbind_key_entry; extern const struct cmd_entry cmd_unlink_window_entry; +extern const struct cmd_entry cmd_up_pane_entry; /* cmd-string.c */ int cmd_string_parse(const char *, struct cmd **, char **);