Add a nicer default second and third status line, from Michael Grant in

GitHub 4490.
This commit is contained in:
nicm
2025-08-14 07:15:40 +00:00
parent 0646814235
commit 1370791734
5 changed files with 133 additions and 15 deletions

View File

@ -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)

View File

@ -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 }",

View File

@ -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,

View File

@ -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 &&

32
tmux.1
View File

@ -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