Add new tile-pane and float-pane commands.

This commit is contained in:
Michael Grant
2026-03-30 18:01:55 -04:00
parent 8a3620e438
commit 4232bf9e2f
6 changed files with 65 additions and 2 deletions

View File

@@ -147,6 +147,7 @@ dist_tmux_SOURCES = \
cmd-source-file.c \
cmd-split-window.c \
cmd-swap-pane.c \
cmd-tile-float-pane.c \
cmd-swap-window.c \
cmd-switch-client.c \
cmd-unbind-key.c \

4
cmd.c
View File

@@ -69,6 +69,7 @@ extern const struct cmd_entry cmd_load_buffer_entry;
extern const struct cmd_entry cmd_lock_client_entry;
extern const struct cmd_entry cmd_lock_server_entry;
extern const struct cmd_entry cmd_lock_session_entry;
extern const struct cmd_entry cmd_float_pane_entry;
extern const struct cmd_entry cmd_minimise_pane_entry;
extern const struct cmd_entry cmd_move_pane_entry;
extern const struct cmd_entry cmd_move_window_entry;
@@ -118,6 +119,7 @@ extern const struct cmd_entry cmd_swap_window_entry;
extern const struct cmd_entry cmd_switch_client_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_tile_pane_entry;
extern const struct cmd_entry cmd_unminimise_pane_entry;
extern const struct cmd_entry cmd_wait_for_entry;
@@ -164,6 +166,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_lock_client_entry,
&cmd_lock_server_entry,
&cmd_lock_session_entry,
&cmd_float_pane_entry,
&cmd_minimise_pane_entry,
&cmd_move_pane_entry,
&cmd_move_window_entry,
@@ -213,6 +216,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_switch_client_entry,
&cmd_unbind_key_entry,
&cmd_unlink_window_entry,
&cmd_tile_pane_entry,
&cmd_unminimise_pane_entry,
&cmd_wait_for_entry,
NULL

View File

@@ -364,6 +364,7 @@ key_bindings_init(void)
"bind -N 'Kill current window' & { confirm-before -p\"kill-window #W? (y/n)\" kill-window }",
"bind -N 'Prompt for window index to select' \"'\" { command-prompt -T window-target -pindex { select-window -t ':%%' } }",
"bind -N 'New floating pane' * { new-pane }",
"bind -N 'Toggle pane between floating and tiled' @ { if -F '#{pane_floating_flag}' { tile-pane } { float-pane } }",
"bind -N 'Switch to previous client' ( { switch-client -p }",
"bind -N 'Switch to next client' ) { switch-client -n }",
"bind -N 'Rename current window' , { command-prompt -I'#W' { rename-window -- '%%' } }",

View File

@@ -730,8 +730,7 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx)
width = size - x;
}
r = tty_check_overlay_range(&c->tty, x, yoff, width);
r = screen_redraw_get_visible_ranges(wp, x, yoff, width, r);
r = screen_redraw_get_visible_ranges(wp, x, yoff, width, NULL);
if (ctx->statustop)
yoff += ctx->statuslines;

51
tmux.1
View File

@@ -292,6 +292,8 @@ Rename the current session.
Split the current pane into two, left and right.
.It &
Kill the current window.
.It @
Toggle the current pane between floating and tiled.
.It \[aq]
Prompt for a window index to select.
.It \&(
@@ -2971,6 +2973,41 @@ The default is
zooms the pane.
.Pp
This command works only if at least one client is attached.
.Tg floatp
.It Xo Ic float\-pane
.Op Fl h Ar height
.Op Fl w Ar width
.Op Fl x Ar x
.Op Fl y Ar y
.Op Fl t Ar target\-pane
.Xc
Lift
.Ar target\-pane
out of the tiled layout and make it a floating pane.
The
.Fl w
and
.Fl h
options set the width and height of the floating pane in columns and lines
respectively; the default is half the window width and height.
The
.Fl x
and
.Fl y
options set the position of the upper-left corner of the pane;
if omitted, new floating panes are cascaded from the top-left of the window.
If
.Fl x ,
.Fl y ,
.Fl w ,
and
.Fl h
are all omitted and the pane was previously returned to the tiled layout
with
.Ic tile\-pane ,
its last floating position and size are restored.
The pane must not already be floating or minimised, and the window must not
be zoomed.
.Tg joinp
.It Xo Ic join\-pane
.Op Fl bdfhv
@@ -3782,6 +3819,20 @@ is omitted and a marked pane is present (see
.Ic select\-pane
.Fl m ) ,
the window containing the marked pane is used rather than the current window.
.Tg tilep
.It Xo Ic tile\-pane
.Op Fl t Ar target\-pane
.Xc
Insert a floating
.Ar target\-pane
back into the tiled layout.
The pane is placed by splitting the active tiled pane (or the most recently
active tiled pane, or any visible tiled pane if none is active).
The current floating position and size are saved so they can be restored by
a subsequent
.Ic float\-pane
command with no geometry options.
The pane must be floating and the window must not be zoomed.
.Tg unlinkw
.It Xo Ic unlink\-window
.Op Fl k

7
tmux.h
View File

@@ -1231,6 +1231,13 @@ struct window_pane {
#define PANE_FLOATING 0x10000
#define PANE_MINIMISED 0x20000
#define PANE_ZOOMED 0x40000
#define PANE_SAVED_FLOAT 0x80000 /* saved_float_* fields are valid */
/* Last floating position/size, saved when the pane is tiled. */
int saved_float_xoff;
int saved_float_yoff;
u_int saved_float_sx;
u_int saved_float_sy;
u_int sb_slider_y;
u_int sb_slider_h;