1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 07:13:36 +02:00

Add Z index positions to move-pane -P.

This commit is contained in:
nicm
2026-06-13 17:43:20 +00:00
parent 2a38d5e77a
commit a15c941f0b
3 changed files with 89 additions and 33 deletions
+58 -6
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: cmd-join-pane.c,v 1.60 2026/06/13 17:12:02 nicm Exp $ */
/* $OpenBSD: cmd-join-pane.c,v 1.61 2026/06/13 17:43:20 nicm Exp $ */
/*
* Copyright (c) 2011 George Nachman <tmux@georgester.com>
@@ -68,8 +68,9 @@ cmd_join_pane_place(struct cmdq_item *item, struct winlink *wl,
{
struct window *w = wl->window;
struct layout_cell *lc = wp->layout_cell;
struct window_pane *owp;
int wx = w->sx, wy = w->sy, px = lc->sx;
int py = lc->sy, xoff, yoff;
int py = lc->sy, xoff = lc->xoff, yoff = lc->yoff;
if (strcmp(position, "top-left") == 0) {
xoff = 1;
@@ -119,15 +120,66 @@ cmd_join_pane_place(struct cmdq_item *item, struct winlink *wl,
strcmp(position, "bottom-right-center") == 0) {
xoff = (3 * wx) / 4 - px / 2;
yoff = (3 * wy) / 4 - py / 2;
} else if (strcmp(position, "front") == 0) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
} else if (strcmp(position, "back") == 0) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_FOREACH(owp, &w->z_index, zentry) {
if (!window_pane_is_floating(owp))
break;
}
if (owp != NULL)
TAILQ_INSERT_BEFORE(owp, wp, zentry);
else
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
} else if (strcmp(position, "forward") == 0) {
owp = TAILQ_PREV(wp, window_panes_zindex, zentry);
if (owp != NULL) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_BEFORE(owp, wp, zentry);
}
} else if (strcmp(position, "backward") == 0) {
owp = TAILQ_NEXT(wp, zentry);
if (owp != NULL && window_pane_is_floating(owp)) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_AFTER(&w->z_index, owp, wp, zentry);
}
} else if (strcmp(position, "forward-loop") == 0) {
owp = TAILQ_PREV(wp, window_panes_zindex, zentry);
TAILQ_REMOVE(&w->z_index, wp, zentry);
if (owp != NULL)
TAILQ_INSERT_BEFORE(owp, wp, zentry);
else {
TAILQ_FOREACH(owp, &w->z_index, zentry) {
if (!window_pane_is_floating(owp))
break;
}
if (owp != NULL)
TAILQ_INSERT_BEFORE(owp, wp, zentry);
else
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
}
} else if (strcmp(position, "backward-loop") == 0) {
owp = TAILQ_NEXT(wp, zentry);
if (owp != NULL && window_pane_is_floating(owp)) {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_AFTER(&w->z_index, owp, wp, zentry);
} else {
TAILQ_REMOVE(&w->z_index, wp, zentry);
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
}
} else {
cmdq_error(item, "unknown position: %s", position);
return (CMD_RETURN_ERROR);
}
lc->xoff = xoff;
lc->yoff = yoff;
layout_fix_panes(w, NULL);
notify_window("window-layout-changed", w);
if (xoff != lc->xoff || yoff != lc->yoff) {
lc->xoff = xoff;
lc->yoff = yoff;
layout_fix_panes(w, NULL);
notify_window("window-layout-changed", w);
}
server_redraw_window(w);
return (CMD_RETURN_NORMAL);
+5 -5
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: key-bindings.c,v 1.174 2026/06/13 17:12:02 nicm Exp $ */
/* $OpenBSD: key-bindings.c,v 1.175 2026/06/13 17:43:20 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -406,10 +406,10 @@ key_bindings_init(void)
"bind -N 'Choose a window from a list' w { choose-tree -Zw }",
"bind -N 'Kill the active pane' x { confirm-before -p\"kill-pane #P? (y/n)\" kill-pane }",
"bind -N 'Zoom the active pane' z { resize-pane -Z }",
"bind -N 'Move pane to top-left corner' '{' { move-pane -P top-left }",
"bind -N 'Move pane to top-right corner' '}' { move-pane -P top-right }",
"bind -N 'Move pane to bottom-left corner' 'M-{' { move-pane -P bottom-left }",
"bind -N 'Move pane to bottom-right corner' 'M-}' { move-pane -P bottom-right }",
"bind -N 'Move pane to top-left corner' '{' { resize-pane -x50% -y50%; move-pane -P top-left }",
"bind -N 'Move pane to top-right corner' '}' { resize-pane -x50% -y50%; move-pane -P top-right }",
"bind -N 'Move pane to bottom-left corner' 'M-{' { resize-pane -x50% -y50%; move-pane -P bottom-left }",
"bind -N 'Move pane to bottom-right corner' 'M-}' { resize-pane -x50% -y50%; move-pane -P bottom-right }",
"bind -N 'Show messages' '~' { show-messages }",
"bind -N 'Enter copy mode and scroll up' PPage { copy-mode -u }",
"bind -N 'Select the pane above the active pane' -r Up { select-pane -U }",
+26 -22
View File
@@ -1,4 +1,4 @@
.\" $OpenBSD: tmux.1,v 1.1085 2026/06/13 17:12:02 nicm Exp $
.\" $OpenBSD: tmux.1,v 1.1086 2026/06/13 17:43:20 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -3337,30 +3337,34 @@ move it down, left, right or up by
.Ar lines
or
.Ar columns
(one if omitted);
(one if omitted).
.Fl P
moves it to
.Ar position ,
which may be
.Ql top-left ,
.Ql top-centre ,
.Ql top-right ,
.Ql centre-left ,
.Ql centre ,
.Ql centre-right ,
.Ql bottom-left ,
.Ql bottom-centre ,
.Ql bottom-right ,
.Ql top-left-centre ,
.Ql top-right-centre ,
.Ql bottom-left-centre
or
.Ql bottom-right-centre ;
for each
.Ql centre
position,
.Ql center
is accepted as an alias.
which may be one of:
.Bl -column "XXXXXXXXXXXXXXXXXX" "X"
.It Sy "Position" Ta Sy "Meaning"
.It Li "top-left" Ta "Top left"
.It Li "top-centre" Ta "Top and horizontal centre"
.It Li "top-right" Ta "Top right"
.It Li "centre-left" Ta "Vertical centre and left"
.It Li "centre" Ta "Centre"
.It Li "centre-right" Ta "Vertical centre and right"
.It Li "bottom-left" Ta "Bottom left"
.It Li "bottom-centre" Ta "Bottom and horizontal centre"
.It Li "bottom-right" Ta "Bottom right"
.It Li "top-left-centre" Ta "Centre of top-left quadrant"
.It Li "top-right-centre" Ta "Centre of top-right quadrant"
.It Li "bottom-left-centre" Ta "Centre of bottom-left quadrant"
.It Li "bottom-right-centre" Ta "Centre of botton-right quadrant"
.It Li "front" Ta "Front of floating panes"
.It Li "back" Ta "Back of floating panes"
.It Li "forward" Ta "Forward one floating pane"
.It Li "backward" Ta "Backward one floating pane"
.It Li "forward-loop" Ta "Forward but back if already at front"
.It Li "backward-loop" Ta "Backward but front if already at back"
.El
.Pp
.Fl X
and
.Fl Y