diff options
-rw-r--r-- | usr.bin/tmux/cmd-break-pane.c | 30 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-join-pane.c | 19 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-move-window.c | 16 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 22 |
4 files changed, 48 insertions, 39 deletions
diff --git a/usr.bin/tmux/cmd-break-pane.c b/usr.bin/tmux/cmd-break-pane.c index 3aea48411af..e0b1ad89b59 100644 --- a/usr.bin/tmux/cmd-break-pane.c +++ b/usr.bin/tmux/cmd-break-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-break-pane.c,v 1.55 2020/04/13 20:51:57 nicm Exp $ */ +/* $OpenBSD: cmd-break-pane.c,v 1.56 2020/04/22 21:15:33 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -34,8 +34,8 @@ const struct cmd_entry cmd_break_pane_entry = { .name = "break-pane", .alias = "breakp", - .args = { "dPF:n:s:t:", 0, 0 }, - .usage = "[-dP] [-F format] [-n window-name] [-s src-pane] " + .args = { "adPF:n:s:t:", 0, 0 }, + .usage = "[-adP] [-F format] [-n window-name] [-s src-pane] " "[-t dst-window]", .source = { 's', CMD_FIND_PANE, 0 }, @@ -63,16 +63,30 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item) const char *template; char *cp; - if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) { - cmdq_error(item, "index %d already in use", idx); - return (CMD_RETURN_ERROR); + if (args_has(args, 'a')) { + if (target->wl != NULL) + idx = winlink_shuffle_up(dst_s, target->wl); + else + idx = winlink_shuffle_up(dst_s, dst_s->curw); + if (idx == -1) + return (CMD_RETURN_ERROR); } + server_unzoom_window(w); if (window_count_panes(w) == 1) { - cmdq_error(item, "can't break with only one pane"); + if (server_link_window(src_s, wl, dst_s, idx, 0, + !args_has(args, 'd'), &cause) != 0) { + cmdq_error(item, "%s", cause); + free(cause); + return (CMD_RETURN_ERROR); + } + server_unlink_window(src_s, wl); + return (CMD_RETURN_NORMAL); + } + if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) { + cmdq_error(item, "index in use: %d", idx); return (CMD_RETURN_ERROR); } - server_unzoom_window(w); TAILQ_REMOVE(&w->panes, wp, entry); window_lost_pane(w, wp); diff --git a/usr.bin/tmux/cmd-join-pane.c b/usr.bin/tmux/cmd-join-pane.c index 3fe47ba1870..c7310e8cd04 100644 --- a/usr.bin/tmux/cmd-join-pane.c +++ b/usr.bin/tmux/cmd-join-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-join-pane.c,v 1.43 2020/04/13 14:46:04 nicm Exp $ */ +/* $OpenBSD: cmd-join-pane.c,v 1.44 2020/04/22 21:15:33 nicm Exp $ */ /* * Copyright (c) 2011 George Nachman <tmux@georgester.com> @@ -50,8 +50,8 @@ const struct cmd_entry cmd_move_pane_entry = { .name = "move-pane", .alias = "movep", - .args = { "bdhvp:l:s:t:", 0, 0 }, - .usage = "[-bdhv] [-l size] " CMD_SRCDST_PANE_USAGE, + .args = { "bdfhvp:l:s:t:", 0, 0 }, + .usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE, .source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED }, .target = { 't', CMD_FIND_PANE, 0 }, @@ -72,16 +72,11 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) struct window *src_w, *dst_w; struct window_pane *src_wp, *dst_wp; char *cause = NULL; - int size, percentage, dst_idx, not_same_window; + int size, percentage, dst_idx; int flags; enum layout_type type; struct layout_cell *lc; - if (cmd_get_entry(self) == &cmd_join_pane_entry) - not_same_window = 1; - else - not_same_window = 0; - dst_s = target->s; dst_wl = target->wl; dst_wp = target->wp; @@ -94,11 +89,7 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) src_w = src_wl->window; server_unzoom_window(src_w); - if (not_same_window && src_w == dst_w) { - cmdq_error(item, "can't join a pane to its own window"); - return (CMD_RETURN_ERROR); - } - if (!not_same_window && src_wp == dst_wp) { + if (src_wp == dst_wp) { cmdq_error(item, "source and target panes must be different"); return (CMD_RETURN_ERROR); } diff --git a/usr.bin/tmux/cmd-move-window.c b/usr.bin/tmux/cmd-move-window.c index 9f22f40f43b..c5df28f4fda 100644 --- a/usr.bin/tmux/cmd-move-window.c +++ b/usr.bin/tmux/cmd-move-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-move-window.c,v 1.31 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: cmd-move-window.c,v 1.32 2020/04/22 21:15:33 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -63,9 +63,9 @@ cmd_move_window_exec(struct cmd *self, struct cmdq_item *item) struct cmd_find_state *source = cmdq_get_source(item); struct cmd_find_state target; const char *tflag = args_get(args, 't'); - struct session *src; + struct session *src = source->s; struct session *dst; - struct winlink *wl; + struct winlink *wl = source->wl; char *cause; int idx, kflag, dflag, sflag; @@ -83,9 +83,7 @@ cmd_move_window_exec(struct cmd *self, struct cmdq_item *item) if (cmd_find_target(&target, item, tflag, CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX) != 0) return (CMD_RETURN_ERROR); - src = source->s; dst = target.s; - wl = source->wl; idx = target.idx; kflag = args_has(args, 'k'); @@ -93,12 +91,16 @@ cmd_move_window_exec(struct cmd *self, struct cmdq_item *item) sflag = args_has(args, 's'); if (args_has(args, 'a')) { - if ((idx = winlink_shuffle_up(dst, dst->curw)) == -1) + if (target.wl != NULL) + idx = winlink_shuffle_up(dst, target.wl); + else + idx = winlink_shuffle_up(dst, dst->curw); + if (idx == -1) return (CMD_RETURN_ERROR); } if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { - cmdq_error(item, "can't link window: %s", cause); + cmdq_error(item, "%s", cause); free(cause); return (CMD_RETURN_ERROR); } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 0bab4269c42..2b0f34ee4fb 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.748 2020/04/22 20:47:00 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.749 2020/04/22 21:15:33 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -1714,7 +1714,7 @@ from which the layout was originally defined. Commands related to windows and panes are as follows: .Bl -tag -width Ds .It Xo Ic break-pane -.Op Fl dP +.Op Fl adP .Op Fl F Ar format .Op Fl n Ar window-name .Op Fl s Ar src-pane @@ -1725,6 +1725,10 @@ Break .Ar src-pane off from its containing window to make it the only pane in .Ar dst-window . +With +.Fl a , +the window is moved to the next index up (following windows +are moved if necessary). If .Fl d is given, the new window does not become the current window. @@ -1873,12 +1877,15 @@ The following keys may be used in tree mode: .It Li "<" Ta "Scroll list of previews left" .It Li ">" Ta "Scroll list of previews right" .It Li "C-s" Ta "Search by name" +.It Li "m" Ta "Set the marked pane" +.It Li "M" Ta "Clear the marked pane" .It Li "n" Ta "Repeat last search" .It Li "t" Ta "Toggle if item is tagged" .It Li "T" Ta "Tag no items" .It Li "C-t" Ta "Tag all items" .It Li "\&:" Ta "Run a command for each tagged item" .It Li "f" Ta "Enter a format to filter items" +.It Li "H" Ta "Jump to the starting pane" .It Li "O" Ta "Change sort field" .It Li "r" Ta "Reverse sort order" .It Li "v" Ta "Toggle preview" @@ -2125,19 +2132,14 @@ See the .Sx FORMATS section. .It Xo Ic move-pane -.Op Fl bdhv +.Op Fl bdfhv .Op Fl l Ar size .Op Fl s Ar src-pane .Op Fl t Ar dst-pane .Xc .D1 (alias: Ic movep ) -Like -.Ic join-pane , -but -.Ar src-pane -and -.Ar dst-pane -may belong to the same window. +Does the same as +.Ic join-pane . .It Xo Ic move-window .Op Fl ardk .Op Fl s Ar src-window |