mirror of
https://github.com/tmux/tmux.git
synced 2026-06-20 17:25:57 +00:00
Add flags to move-pane to move floating panes around (-U, -D, -L, -R
similar to resize-pane; -X, -Y similar to new-pane).
This commit is contained in:
@@ -31,6 +31,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
static enum cmd_retval cmd_join_pane_move(struct cmdq_item *, struct args *,
|
||||||
|
struct winlink *, struct window_pane *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_join_pane_entry = {
|
const struct cmd_entry cmd_join_pane_entry = {
|
||||||
.name = "join-pane",
|
.name = "join-pane",
|
||||||
@@ -50,8 +52,10 @@ const struct cmd_entry cmd_move_pane_entry = {
|
|||||||
.name = "move-pane",
|
.name = "move-pane",
|
||||||
.alias = "movep",
|
.alias = "movep",
|
||||||
|
|
||||||
.args = { "bdfhvp:l:s:t:", 0, 0, NULL },
|
.args = { "D::L::R::U::X:Y:bdfhvp:l:s:t:", 0, 0, NULL },
|
||||||
.usage = "[-bdfhv] [-l size] " CMD_SRCDST_PANE_USAGE,
|
.usage = "[-bdfhv] [-D lines] [-L columns] [-R columns] "
|
||||||
|
"[-U lines] [-X x-position] [-Y y-position] [-l size] "
|
||||||
|
CMD_SRCDST_PANE_USAGE,
|
||||||
|
|
||||||
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@@ -60,6 +64,78 @@ const struct cmd_entry cmd_move_pane_entry = {
|
|||||||
.exec = cmd_join_pane_exec
|
.exec = cmd_join_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_join_pane_move(struct cmdq_item *item, struct args *args, struct winlink *wl,
|
||||||
|
struct window_pane *wp)
|
||||||
|
{
|
||||||
|
struct window *w = wl->window;
|
||||||
|
struct layout_cell *lc = wp->layout_cell;
|
||||||
|
const char *errstr, *argval;
|
||||||
|
const char flags[] = { 'U', 'D', 'L', 'R' };
|
||||||
|
char *cause = NULL, flag;
|
||||||
|
int xoff, yoff, adjust;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
if (!window_pane_is_floating(wp)) {
|
||||||
|
cmdq_error(item, "pane is not floating");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
xoff = lc->xoff;
|
||||||
|
yoff = lc->yoff;
|
||||||
|
|
||||||
|
if (args_has(args, 'X')) {
|
||||||
|
xoff = args_percentage_and_expand(args, 'X', -(int)lc->sx,
|
||||||
|
w->sx, w->sx, item, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "position %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args_has(args, 'Y')) {
|
||||||
|
yoff = args_percentage_and_expand(args, 'Y', -(int)lc->sy,
|
||||||
|
w->sy, w->sy, item, &cause);
|
||||||
|
if (cause != NULL) {
|
||||||
|
cmdq_error(item, "position %s", cause);
|
||||||
|
free(cause);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < nitems(flags); i++) {
|
||||||
|
flag = flags[i];
|
||||||
|
if (!args_has(args, flag))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
argval = args_get(args, flag);
|
||||||
|
if (argval == NULL)
|
||||||
|
argval = "1";
|
||||||
|
adjust = strtonum(argval, INT_MIN, INT_MAX, &errstr);
|
||||||
|
if (errstr != NULL) {
|
||||||
|
cmdq_error(item, "offset %s", errstr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag == 'U')
|
||||||
|
yoff -= adjust;
|
||||||
|
else if (flag == 'D')
|
||||||
|
yoff += adjust;
|
||||||
|
else if (flag == 'L')
|
||||||
|
xoff -= adjust;
|
||||||
|
else
|
||||||
|
xoff += adjust;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
@@ -82,6 +158,16 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
dst_idx = dst_wl->idx;
|
dst_idx = dst_wl->idx;
|
||||||
server_unzoom_window(dst_w);
|
server_unzoom_window(dst_w);
|
||||||
|
|
||||||
|
if (cmd_get_entry(self) == &cmd_move_pane_entry) {
|
||||||
|
if (args_has(args, 'X') ||
|
||||||
|
args_has(args, 'Y') ||
|
||||||
|
args_has(args, 'U') ||
|
||||||
|
args_has(args, 'D') ||
|
||||||
|
args_has(args, 'L') ||
|
||||||
|
args_has(args, 'R'))
|
||||||
|
return (cmd_join_pane_move(item, args, dst_wl, dst_wp));
|
||||||
|
}
|
||||||
|
|
||||||
src_wl = source->wl;
|
src_wl = source->wl;
|
||||||
src_wp = source->wp;
|
src_wp = source->wp;
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_resize_pane_entry = {
|
|||||||
.alias = "resizep",
|
.alias = "resizep",
|
||||||
|
|
||||||
.args = { "D::L::MR::Tt:U::x:y:Z", 0, 1, NULL },
|
.args = { "D::L::MR::Tt:U::x:y:Z", 0, 1, NULL },
|
||||||
.usage = "[-MTZ] [-U lines] [-D lines] [-L columns] [-R columns] "
|
.usage = "[-MTZ] [-D lines] [-L columns] [-R columns] [-U lines] "
|
||||||
"[-x width] [-y height] " CMD_TARGET_PANE_USAGE,
|
"[-x width] [-y height] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|||||||
33
tmux.1
33
tmux.1
@@ -3304,13 +3304,34 @@ reverses the sort order.
|
|||||||
.Tg movep
|
.Tg movep
|
||||||
.It Xo Ic move\-pane
|
.It Xo Ic move\-pane
|
||||||
.Op Fl bdfhv
|
.Op Fl bdfhv
|
||||||
|
.Op Fl D Op Ar lines
|
||||||
|
.Op Fl L Op Ar columns
|
||||||
|
.Op Fl R Op Ar columns
|
||||||
|
.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 l Ar size
|
||||||
.Op Fl s Ar src\-pane
|
.Op Fl s Ar src\-pane
|
||||||
.Op Fl t Ar dst\-pane
|
.Op Fl t Ar dst\-pane
|
||||||
.Xc
|
.Xc
|
||||||
.D1 Pq alias: Ic movep
|
.D1 Pq alias: Ic movep
|
||||||
Does the same as
|
Does the same as
|
||||||
.Ic join\-pane .
|
.Ic join\-pane ,
|
||||||
|
except if given
|
||||||
|
.Fl U ,
|
||||||
|
.Fl D ,
|
||||||
|
.Fl L
|
||||||
|
or
|
||||||
|
.Fl R
|
||||||
|
in which case move the target floating pane up, down, left or right by
|
||||||
|
.Ar lines
|
||||||
|
or
|
||||||
|
.Ar columns
|
||||||
|
(one if omitted);
|
||||||
|
.Fl X
|
||||||
|
and
|
||||||
|
.Fl Y
|
||||||
|
move to the an absolute position.
|
||||||
.Tg movew
|
.Tg movew
|
||||||
.It Xo Ic move\-window
|
.It Xo Ic move\-window
|
||||||
.Op Fl abrdk
|
.Op Fl abrdk
|
||||||
@@ -3612,13 +3633,13 @@ if specified, to
|
|||||||
.Tg resizep
|
.Tg resizep
|
||||||
.It Xo Ic resize\-pane
|
.It Xo Ic resize\-pane
|
||||||
.Op Fl MTZ
|
.Op Fl MTZ
|
||||||
.Op Fl t Ar target\-pane
|
|
||||||
.Op Fl U Ar lines
|
|
||||||
.Op Fl D Ar lines
|
.Op Fl D Ar lines
|
||||||
.Op Fl L Ar columns
|
.Op Fl L Ar columns
|
||||||
.Op Fl R Ar columns
|
.Op Fl R Ar columns
|
||||||
|
.Op Fl U Ar lines
|
||||||
.Op Fl x Ar width
|
.Op Fl x Ar width
|
||||||
.Op Fl y Ar height
|
.Op Fl y Ar height
|
||||||
|
.Op Fl t Ar target\-pane
|
||||||
.Xc
|
.Xc
|
||||||
.D1 Pq alias: Ic resizep
|
.D1 Pq alias: Ic resizep
|
||||||
Resize a pane, up, down, left or right by a specified adjustment with
|
Resize a pane, up, down, left or right by a specified adjustment with
|
||||||
@@ -3626,10 +3647,8 @@ Resize a pane, up, down, left or right by a specified adjustment with
|
|||||||
.Fl D ,
|
.Fl D ,
|
||||||
.Fl L
|
.Fl L
|
||||||
or
|
or
|
||||||
.Fl R ,
|
.Fl R ;
|
||||||
or
|
or to an absolute size with
|
||||||
to an absolute size
|
|
||||||
with
|
|
||||||
.Fl x
|
.Fl x
|
||||||
or
|
or
|
||||||
.Fl y .
|
.Fl y .
|
||||||
|
|||||||
Reference in New Issue
Block a user