From e1fc6b31eed435877351817c70ad71f7212081c2 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 3 Jul 2026 15:10:07 +0000 Subject: [PATCH] Add manual width and height window formats. --- format.c | 32 ++++++++++++++++++++++++++++++++ tmux.1 | 2 ++ 2 files changed, 34 insertions(+) diff --git a/format.c b/format.c index f73a6caa0..dd6961b95 100644 --- a/format.c +++ b/format.c @@ -2844,6 +2844,19 @@ format_cb_window_height(struct format_tree *ft) return (NULL); } +/* Callback for window_manual_height. */ +static void * +format_cb_window_manual_height(struct format_tree *ft) +{ + struct window *w = ft->w; + + if (w == NULL) + return (NULL); + if (options_get_number(w->options, "window-size") != WINDOW_SIZE_MANUAL) + return (xstrdup("")); + return (format_printf("%u", w->manual_sy)); +} + /* Callback for window_id. */ static void * format_cb_window_id(struct format_tree *ft) @@ -3024,6 +3037,19 @@ format_cb_window_width(struct format_tree *ft) return (NULL); } +/* Callback for window_manual_width. */ +static void * +format_cb_window_manual_width(struct format_tree *ft) +{ + struct window *w = ft->w; + + if (w == NULL) + return (NULL); + if (options_get_number(w->options, "window-size") != WINDOW_SIZE_MANUAL) + return (xstrdup("")); + return (format_printf("%u", w->manual_sx)); +} + /* Callback for window_zoomed_flag. */ static void * format_cb_window_zoomed_flag(struct format_tree *ft) @@ -3730,6 +3756,12 @@ static const struct format_table_entry format_table[] = { { "window_linked_sessions_list", FORMAT_TABLE_STRING, format_cb_window_linked_sessions_list }, + { "window_manual_height", FORMAT_TABLE_STRING, + format_cb_window_manual_height + }, + { "window_manual_width", FORMAT_TABLE_STRING, + format_cb_window_manual_width + }, { "window_marked_flag", FORMAT_TABLE_STRING, format_cb_window_marked_flag }, diff --git a/tmux.1 b/tmux.1 index f016d9db9..83c6bf042 100644 --- a/tmux.1 +++ b/tmux.1 @@ -7180,6 +7180,8 @@ The following variables are available, where appropriate: .It Li "window_linked" Ta "" Ta "1 if window is linked across sessions" .It Li "window_linked_sessions" Ta "" Ta "Number of sessions this window is linked to" .It Li "window_linked_sessions_list" Ta "" Ta "List of sessions this window is linked to" +.It Li "window_manual_height" Ta "" Ta "Manual height of window, if set" +.It Li "window_manual_width" Ta "" Ta "Manual width of window, if set" .It Li "window_marked_flag" Ta "" Ta "1 if window contains the marked pane" .It Li "window_name" Ta "#W" Ta "Name of window" .It Li "window_offset_x" Ta "" Ta "X offset into window if larger than client"