Add pane_x, y, z format variables and show in list-panes.

This commit is contained in:
nicm
2026-06-01 14:01:09 +00:00
parent 67dbf01eeb
commit b68ab3a4b4
3 changed files with 61 additions and 4 deletions

View File

@@ -110,22 +110,28 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
switch (type) {
case 0:
template = "#{pane_index}: "
"[#{pane_width}x#{pane_height}] [history "
"[#{pane_width}x#{pane_height}"
"#{?pane_floating_flag, "
"#{pane_x}#,#{pane_y}#,#{pane_z}}] [history "
"#{history_size}/#{history_limit}, "
"#{history_bytes} bytes] #{pane_id}"
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
break;
case 1:
template = "#{window_index}.#{pane_index}: "
"[#{pane_width}x#{pane_height}] [history "
"[#{pane_width}x#{pane_height}"
"#{?pane_floating_flag, "
"#{pane_x}#,#{pane_y}#,#{pane_z}}] [history "
"#{history_size}/#{history_limit}, "
"#{history_bytes} bytes] #{pane_id}"
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
break;
case 2:
template = "#{session_name}:#{window_index}."
"#{pane_index}: [#{pane_width}x#{pane_height}] "
"[history #{history_size}/#{history_limit}, "
"#{pane_index}: [#{pane_width}x#{pane_height}"
"#{?pane_floating_flag, "
"#{pane_x}#,#{pane_y}#,#{pane_z}}] [history "
"#{history_size}/#{history_limit}, "
"#{history_bytes} bytes] #{pane_id}"
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
break;

View File

@@ -2397,6 +2397,45 @@ format_cb_pane_width(struct format_tree *ft)
return (NULL);
}
/* Callback for pane_x. */
static void *
format_cb_pane_x(struct format_tree *ft)
{
if (ft->wp != NULL)
return (format_printf("%d", ft->wp->xoff));
return (NULL);
}
/* Callback for pane_y. */
static void *
format_cb_pane_y(struct format_tree *ft)
{
if (ft->wp != NULL)
return (format_printf("%d", ft->wp->yoff));
return (NULL);
}
/* Callback for pane_z. */
static void *
format_cb_pane_z(struct format_tree *ft)
{
struct window_pane *wp;
u_int n = 0;
if (ft->wp != NULL) {
if (~ft->wp->flags & PANE_FLOATING)
return (xstrdup("0"));
TAILQ_FOREACH(wp, &ft->wp->window->z_index, zentry) {
if (wp->flags & PANE_FLOATING)
n++;
if (wp == ft->wp)
return (format_printf("%u", n));
}
return (xstrdup("0"));
}
return (NULL);
}
/* Callback for pane_zoomed_flag. */
static void *
format_cb_pane_zoomed_flag(struct format_tree *ft)
@@ -3482,6 +3521,15 @@ static const struct format_table_entry format_table[] = {
{ "pane_width", FORMAT_TABLE_STRING,
format_cb_pane_width
},
{ "pane_x", FORMAT_TABLE_STRING,
format_cb_pane_x
},
{ "pane_y", FORMAT_TABLE_STRING,
format_cb_pane_y
},
{ "pane_z", FORMAT_TABLE_STRING,
format_cb_pane_z
},
{ "pane_zoomed_flag", FORMAT_TABLE_STRING,
format_cb_pane_zoomed_flag
},

3
tmux.1
View File

@@ -6569,6 +6569,9 @@ The following variables are available, where appropriate:
.It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane"
.It Li "pane_unseen_changes" Ta "" Ta "1 if there were changes in pane while in mode"
.It Li "pane_width" Ta "" Ta "Width of pane"
.It Li "pane_x" Ta "" Ta "X position of pane"
.It Li "pane_y" Ta "" Ta "Y position of pane"
.It Li "pane_z" Ta "" Ta "Z position of pane"
.It Li "pane_zoomed_flag" Ta "" Ta "1 if pane is zoomed"
.It Li "pid" Ta "" Ta "Server PID"
.It Li "prev_window_active" Ta "" Ta "1 if previous window in W: loop is active"