1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-17 23:03:29 +02:00

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 b280781fc6
commit 45b3be8846
3 changed files with 64 additions and 7 deletions
+11 -5
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: cmd-list-panes.c,v 1.39 2026/02/27 08:25:12 nicm Exp $ */
/* $OpenBSD: cmd-list-panes.c,v 1.40 2026/06/01 14:01:09 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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;
+49 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: format.c,v 1.368 2026/06/01 08:27:37 nicm Exp $ */
/* $OpenBSD: format.c,v 1.369 2026/06/01 14:01:09 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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
},
+4 -1
View File
@@ -1,4 +1,4 @@
.\" $OpenBSD: tmux.1,v 1.1059 2026/06/01 08:27:38 nicm Exp $
.\" $OpenBSD: tmux.1,v 1.1060 2026/06/01 14:01:09 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -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"