Add move-pane -z to move a pane to a particular the z-index.

This commit is contained in:
nicm
2026-06-13 18:06:01 +00:00
parent 56779f9542
commit 654758e622
2 changed files with 54 additions and 10 deletions

View File

@@ -50,10 +50,10 @@ const struct cmd_entry cmd_move_pane_entry = {
.name = "move-pane",
.alias = "movep",
.args = { "D::L::P:R::U::X:Y:bdfhvp:l:s:t:", 0, 0, NULL },
.usage = "[-bdfhv] [-D lines] [-L columns] [-P position] "
"[-R columns] [-U lines] [-X x-position] "
"[-Y y-position] [-l size] " CMD_SRCDST_PANE_USAGE,
.args = { "bdfhvl:L::P:R::s:t:U::X:Y:z:", 0, 0, NULL },
.usage = "[-bdfhv] [-D lines] [-l size] [-L columns] [-P position] "
"[-R columns] " CMD_SRCDST_PANE_USAGE " [-U lines] "
"[-X x-position] [-Y y-position] [-z z-index]",
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
.target = { 't', CMD_FIND_PANE, 0 },
@@ -178,8 +178,8 @@ cmd_join_pane_place(struct cmdq_item *item, struct winlink *wl,
lc->xoff = xoff;
lc->yoff = yoff;
layout_fix_panes(w, NULL);
notify_window("window-layout-changed", w);
}
notify_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
@@ -251,6 +251,42 @@ cmd_join_pane_move(struct cmdq_item *item, struct args *args,
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_join_pane_zindex(struct cmdq_item *item, struct winlink *wl,
struct window_pane *wp, const char *s)
{
struct window *w = wl->window;
struct window_pane *owp;
const char *errstr;
u_int n, z;
z = strtonum(s, 0, UINT_MAX, &errstr);
if (errstr != NULL) {
cmdq_error(item, "z-index %s", errstr);
return (CMD_RETURN_ERROR);
}
TAILQ_REMOVE(&w->z_index, wp, zentry);
n = 0;
TAILQ_FOREACH(owp, &w->z_index, zentry) {
if (!window_pane_is_floating(owp))
break;
if (n >= z)
break;
n++;
}
if (owp != NULL)
TAILQ_INSERT_BEFORE(owp, wp, zentry);
else
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
notify_window("window-layout-changed", w);
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}
static enum cmd_retval
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
{
@@ -281,6 +317,8 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
}
if ((s = args_get(args, 'P')) != NULL)
return (cmd_join_pane_place(item, dst_wl, dst_wp, s));
if ((s = args_get(args, 'z')) != NULL)
return (cmd_join_pane_zindex(item, dst_wl, dst_wp, s));
if (args_has(args, 'X') ||
args_has(args, 'Y') ||
args_has(args, 'U') ||

16
tmux.1
View File

@@ -3305,15 +3305,16 @@ reverses the sort order.
.It Xo Ic move\-pane
.Op Fl bdfhv
.Op Fl D Op Ar lines
.Op Fl l Ar size
.Op Fl L Op Ar columns
.Op Fl P Ar position
.Op Fl R Op Ar columns
.Op Fl s Ar src\-pane
.Op Fl t Ar dst\-pane
.Op Fl U Op Ar lines
.Op Fl X Ar x\-position
.Op Fl Y Ar y\-position
.Op Fl l Ar size
.Op Fl s Ar src\-pane
.Op Fl t Ar dst\-pane
.Op Fl z Ar z\-index
.Xc
.D1 Pq alias: Ic movep
Does the same as
@@ -3324,9 +3325,10 @@ except if given
.Fl P ,
.Fl R ,
.Fl U ,
.Fl X
or
.Fl X ,
.Fl Y
or
.Fl z
in which case move the target floating pane.
.Fl D ,
.Fl L ,
@@ -3369,6 +3371,10 @@ which may be one of:
and
.Fl Y
move it to an absolute position.
.Fl z
moves the pane to the given
.Ar z-index ,
where zero is the front.
.Tg movew
.It Xo Ic move\-window
.Op Fl abrdk