Add feature for progress bar and pass to outside terminal, GitHu issue

4972 from Eric Dorland.
This commit is contained in:
nicm
2026-04-22 07:25:17 +00:00
parent 7a0cc03532
commit bc15723f7f
6 changed files with 50 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ static void server_client_check_redraw(struct client *);
static void server_client_check_modes(struct client *);
static void server_client_set_title(struct client *);
static void server_client_set_path(struct client *);
static void server_client_set_progress_bar(struct client *);
static void server_client_reset_state(struct client *);
static void server_client_update_latest(struct client *);
static void server_client_dispatch(struct imsg *, void *);
@@ -2060,6 +2061,7 @@ server_client_check_redraw(struct client *c)
server_client_set_title(c);
server_client_set_path(c);
}
server_client_set_progress_bar(c);
screen_redraw_screen(c);
}
@@ -2126,6 +2128,23 @@ server_client_set_path(struct client *c)
}
}
/* Set client progress bar. */
static void
server_client_set_progress_bar(struct client *c)
{
struct session *s = c->session;
struct progress_bar *pane_pb;
if (s->curw == NULL)
return;
pane_pb = &s->curw->window->active->base.progress_bar;
if (pane_pb->state == c->progress_bar.state &&
pane_pb->progress == c->progress_bar.progress)
return;
memcpy(&c->progress_bar, pane_pb, sizeof c->progress_bar);
tty_set_progress_bar(&c->tty, &c->progress_bar);
}
/* Dispatch message from client. */
static void
server_client_dispatch(struct imsg *imsg, void *arg)

4
tmux.1
View File

@@ -4487,6 +4487,8 @@ mouse sequences.
Supports the OSC 7 working directory extension.
.It overline
Supports the overline SGR attribute.
.It progressbar
Supports the OSC 9;4 progress bar extension.
.It rectfill
Supports the DECFRA rectangle fill escape sequence.
.It RGB
@@ -7852,6 +7854,8 @@ $ printf \[aq]\e033[4 q\[aq]
If
.Em Se
is not set, \&Ss with argument 0 will be used to reset the cursor style instead.
.It Em \&Spb
Set the state and progress for the OSC9;4 progress bar.
.It Em \&Swd
Set the opening sequence for the working directory notification.
The sequence is terminated using the standard

3
tmux.h
View File

@@ -629,6 +629,7 @@ enum tty_code_code {
TTYC_SMUL,
TTYC_SMULX,
TTYC_SMXX,
TTYC_SPB,
TTYC_SXL,
TTYC_SS,
TTYC_SWD,
@@ -1982,6 +1983,7 @@ struct client {
char *title;
char *path;
const char *cwd;
struct progress_bar progress_bar;
char *term_name;
int term_features;
@@ -2621,6 +2623,7 @@ void tty_repeat_requests(struct tty *, int);
void tty_stop_tty(struct tty *);
void tty_set_title(struct tty *, const char *);
void tty_set_path(struct tty *, const char *);
void tty_set_progress_bar(struct tty *, struct progress_bar *);
void tty_default_attributes(struct tty *, const struct grid_cell *,
struct colour_palette *, u_int, struct hyperlinks *);
void tty_update_mode(struct tty *, int, struct screen *);

View File

@@ -347,6 +347,17 @@ static const struct tty_feature tty_feature_sixel = {
TERM_SIXEL
};
/* Terminal supports the OSC 9;4 progress bar. */
static const char *const tty_feature_progressbar_capabilities[] = {
"Spb=\\E]9;4;%p1%d;%p2%d\\E\\\\",
NULL
};
static const struct tty_feature tty_feature_progressbar = {
"progressbar",
tty_feature_progressbar_capabilities,
0
};
/* Available terminal features. */
static const struct tty_feature *const tty_features[] = {
&tty_feature_256,
@@ -362,6 +373,7 @@ static const struct tty_feature *const tty_features[] = {
&tty_feature_mouse,
&tty_feature_osc7,
&tty_feature_overline,
&tty_feature_progressbar,
&tty_feature_rectfill,
&tty_feature_rgb,
&tty_feature_sixel,
@@ -480,7 +492,8 @@ tty_default_features(int *feat, const char *name, u_int version)
"focus,"
"overline,"
"usstyle,"
"hyperlinks"
"hyperlinks,"
"progressbar"
},
{ .name = "rxvt-unicode",
.features = "256,"
@@ -499,7 +512,8 @@ tty_default_features(int *feat, const char *name, u_int version)
"usstyle,"
"sync,"
"osc7,"
"hyperlinks"
"hyperlinks,"
"progressbar"
},
{ .name = "foot",
.features = TTY_FEATURES_BASE_MODERN_XTERM ","

View File

@@ -277,6 +277,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_SMULX] = { TTYCODE_STRING, "Smulx" },
[TTYC_SMUL] = { TTYCODE_STRING, "smul" },
[TTYC_SMXX] = { TTYCODE_STRING, "smxx" },
[TTYC_SPB] = { TTYCODE_STRING, "Spb" },
[TTYC_SS] = { TTYCODE_STRING, "Ss" },
[TTYC_SWD] = { TTYCODE_STRING, "Swd" },
[TTYC_SYNC] = { TTYCODE_STRING, "Sync" },

7
tty.c
View File

@@ -2931,3 +2931,10 @@ tty_clipboard_query(struct tty *tty)
evtimer_add(&tty->clipboard_timer, &tv);
}
}
void
tty_set_progress_bar(struct tty *tty, struct progress_bar *pb)
{
if (tty_term_has(tty->term, TTYC_SPB))
tty_putcode_ii(tty, TTYC_SPB, pb->state, pb->progress);
}