From 13707917341f7cce96c7c3ed22bd34cfb8da4e0d Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 14 Aug 2025 07:15:40 +0000 Subject: [PATCH] Add a nicer default second and third status line, from Michael Grant in GitHub 4490. --- format.c | 16 ++++----- key-bindings.c | 3 +- options-table.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++-- server-client.c | 3 +- tmux.1 | 32 +++++++++++++++++ 5 files changed, 133 insertions(+), 15 deletions(-) diff --git a/format.c b/format.c index 2c37938f..96e02d2c 100644 --- a/format.c +++ b/format.c @@ -4417,14 +4417,14 @@ format_loop_sessions(struct format_expand_state *es, const char *fmt) l = xreallocarray(l, lsz, sizeof *l); } l[n++] = s; - } + } - qsort(l, n, sizeof *l, format_cmp_session); + qsort(l, n, sizeof *l, format_cmp_session); value = xcalloc(1, 1); valuelen = 1; - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) { s = l[i]; format_log(es, "session loop: $%u", s->id); if (active != NULL && s->id == ft->c->session->id) @@ -4542,7 +4542,7 @@ format_loop_windows(struct format_expand_state *es, const char *fmt) l = xreallocarray(l, lsz, sizeof *l); } l[n++] = wl; - } + } if (sc->field != FORMAT_LOOP_BY_INDEX) qsort(l, n, sizeof *l, format_cmp_window); @@ -4641,9 +4641,9 @@ format_loop_panes(struct format_expand_state *es, const char *fmt) l = xreallocarray(l, lsz, sizeof *l); } l[n++] = wp; - } + } - qsort(l, n, sizeof *l, format_cmp_pane); + qsort(l, n, sizeof *l, format_cmp_pane); value = xcalloc(1, 1); valuelen = 1; @@ -4737,7 +4737,7 @@ format_loop_clients(struct format_expand_state *es, const char *fmt) l = xreallocarray(l, lsz, sizeof *l); } l[n++] = c; - } + } if (sc->field != FORMAT_LOOP_BY_INDEX) qsort(l, n, sizeof *l, format_cmp_client); @@ -4752,7 +4752,7 @@ format_loop_clients(struct format_expand_state *es, const char *fmt) } } - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) { c = l[i]; format_log(es, "client loop: %s", c->name); if (i == n - 1) diff --git a/key-bindings.c b/key-bindings.c index d334fe70..fb766a02 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -437,7 +437,6 @@ key_bindings_init(void) "bind -N 'Display window menu' < { display-menu -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU " }", "bind -N 'Display pane menu' > { display-menu -xP -yP -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", - /* Mouse button 1 down on pane. */ "bind -n MouseDown1Pane { select-pane -t=; send -M }", @@ -460,7 +459,7 @@ key_bindings_init(void) "bind -n MouseDrag1Border { resize-pane -M }", /* Mouse button 1 down on status line. */ - "bind -n MouseDown1Status { select-window -t= }", + "bind -n MouseDown1Status { switch-client -t= }", /* Mouse wheel down on status line. */ "bind -n WheelDownStatus { next-window }", diff --git a/options-table.c b/options-table.c index ebcf8f83..45e3ae52 100644 --- a/options-table.c +++ b/options-table.c @@ -174,10 +174,60 @@ static const char *options_table_allow_passthrough_list[] = { "#[pop-default]" \ "#[norange default]" #define OPTIONS_TABLE_STATUS_FORMAT2 \ - "#[align=centre]#{P:#{?pane_active,#[reverse],}" \ - "#{pane_index}[#{pane_width}x#{pane_height}]#[default] }" + "#[align=left]#{R: ,#{n:#{session_name}}}P: " \ + "#[norange default]" \ + "#[list=on align=#{status-justify}]" \ + "#[list=left-marker]<#[list=right-marker]>#[list=on]" \ + "#{P:" \ + "#[range=pane|#{pane_id} " \ + "#{E:pane-status-style}" \ + "]" \ + "#[push-default]" \ + "#P[#{pane_width}x#{pane_height}]" \ + "#[pop-default]" \ + "#[norange list=on default] " \ + "," \ + "#[range=pane|#{pane_id} list=focus " \ + "#{?#{!=:#{E:pane-status-current-style},default}," \ + "#{E:pane-status-current-style}," \ + "#{E:pane-status-style}" \ + "}" \ + "]" \ + "#[push-default]" \ + "#P[#{pane_width}x#{pane_height}]*" \ + "#[pop-default]" \ + "#[norange list=on default] " \ + "}" +#define OPTIONS_TABLE_STATUS_FORMAT3 \ + "#[align=left]#{R: ,#{n:#{session_name}}}S: " \ + "#[norange default]" \ + "#[list=on align=#{status-justify}]" \ + "#[list=left-marker]<#[list=right-marker]>#[list=on]" \ + "#{S:" \ + "#[range=session|#{session_id} " \ + "#{E:session-status-style}" \ + "]" \ + "#[push-default]" \ + "#S#{session_alert}" \ + "#[pop-default]" \ + "#[norange list=on default] " \ + "," \ + "#[range=session|#{session_id} list=focus " \ + "#{?#{!=:#{E:session-status-current-style},default}," \ + "#{E:session-status-current-style}," \ + "#{E:session-status-style}" \ + "}" \ + "]" \ + "#[push-default]" \ + "#S*#{session_alert}" \ + "#[pop-default]" \ + "#[norange list=on default] " \ + "}" static const char *options_table_status_format_default[] = { - OPTIONS_TABLE_STATUS_FORMAT1, OPTIONS_TABLE_STATUS_FORMAT2, NULL + OPTIONS_TABLE_STATUS_FORMAT1, + OPTIONS_TABLE_STATUS_FORMAT2, + OPTIONS_TABLE_STATUS_FORMAT3, + NULL }; /* Helpers for hook options. */ @@ -872,6 +922,25 @@ const struct options_table_entry options_table[] = { .text = "Style of the status line." }, + { .name = "pane-status-current-style", + .type = OPTIONS_TABLE_STRING, + .scope = OPTIONS_TABLE_WINDOW, + .default_str = "default", + .flags = OPTIONS_TABLE_IS_STYLE, + .separator = ",", + .text = "Style of the current pane in the status line." + }, + + { .name = "pane-status-style", + .type = OPTIONS_TABLE_STRING, + .scope = OPTIONS_TABLE_WINDOW, + .default_str = "default", + .flags = OPTIONS_TABLE_IS_STYLE, + .separator = ",", + .text = "Style of panes in the status line, except the current " + "pane." + }, + { .name = "prompt-cursor-colour", .type = OPTIONS_TABLE_COLOUR, .scope = OPTIONS_TABLE_SESSION, @@ -887,6 +956,25 @@ const struct options_table_entry options_table[] = { .text = "Style of the cursor when in the command prompt." }, + { .name = "session-status-current-style", + .type = OPTIONS_TABLE_STRING, + .scope = OPTIONS_TABLE_WINDOW, + .default_str = "default", + .flags = OPTIONS_TABLE_IS_STYLE, + .separator = ",", + .text = "Style of the current session in the status line." + }, + + { .name = "session-status-style", + .type = OPTIONS_TABLE_STRING, + .scope = OPTIONS_TABLE_WINDOW, + .default_str = "default", + .flags = OPTIONS_TABLE_IS_STYLE, + .separator = ",", + .text = "Style of sessions in the status line, except the current " + "session." + }, + { .name = "update-environment", .type = OPTIONS_TABLE_STRING, .scope = OPTIONS_TABLE_SESSION, diff --git a/server-client.c b/server-client.c index 1922f498..04d4eb5e 100644 --- a/server-client.c +++ b/server-client.c @@ -884,8 +884,7 @@ have_event: m->wp = wp->id; m->w = wp->window->id; } - } else - m->wp = -1; + } /* Stop dragging if needed. */ if (type != DRAG && diff --git a/tmux.1 b/tmux.1 index 2f10f614..f7ea02d8 100644 --- a/tmux.1 +++ b/tmux.1 @@ -5188,6 +5188,38 @@ Other attributes are ignored. .Xc Sets which side of the pane to display pane scrollbars on. .Pp +.It Ic pane-status-current-style Ar style +Set status line style for the currently active pane. +For how to specify +.Ar style , +see the +.Sx STYLES +section. +.Pp +.It Ic pane-status-style Ar style +Set status line style for a single pane. +For how to specify +.Ar style , +see the +.Sx STYLES +section. +.Pp +.It Ic session-status-current-style Ar style +Set status line style for the currently active session. +For how to specify +.Ar style , +see the +.Sx STYLES +section. +.Pp +.It Ic session-status-style Ar style +Set status line style for a single session. +For how to specify +.Ar style , +see the +.Sx STYLES +section. +.Pp .It Ic window-status-activity-style Ar style Set status line style for windows with an activity alert. For how to specify