Handle OSC 9;4 progress bar sequence and store in format variables, from

Eric Dorland in GitHub issue 4954.
This commit is contained in:
nicm
2026-04-03 09:14:27 +00:00
parent 7497db6e37
commit bdd78ce38e
4 changed files with 112 additions and 1 deletions

View File

@@ -2248,6 +2248,38 @@ format_cb_pane_pipe_pid(struct format_tree *ft)
return (value);
}
/* Callback for pane_pb_progress. */
static void *
format_cb_pane_pb_progress(struct format_tree *ft)
{
char *value = NULL;
if (ft->wp != NULL)
xasprintf(&value, "%d", ft->wp->base.progress_bar.progress);
return (value);
}
/* Callback for pane_pb_state. */
static void *
format_cb_pane_pb_state(struct format_tree *ft)
{
if (ft->wp != NULL) {
switch (ft->wp->base.progress_bar.state) {
case PROGRESS_BAR_HIDDEN:
return xstrdup("hidden");
case PROGRESS_BAR_NORMAL:
return xstrdup("normal");
case PROGRESS_BAR_ERROR:
return xstrdup("error");
case PROGRESS_BAR_INDETERMINATE:
return xstrdup("indeterminate");
case PROGRESS_BAR_PAUSED:
return xstrdup("paused");
}
}
return (NULL);
}
/* Callback for pane_right. */
static void *
format_cb_pane_right(struct format_tree *ft)
@@ -3331,6 +3363,12 @@ static const struct format_table_entry format_table[] = {
{ "pane_path", FORMAT_TABLE_STRING,
format_cb_pane_path
},
{ "pane_pb_progress", FORMAT_TABLE_STRING,
format_cb_pane_pb_progress
},
{ "pane_pb_state", FORMAT_TABLE_STRING,
format_cb_pane_pb_state
},
{ "pane_pid", FORMAT_TABLE_STRING,
format_cb_pane_pid
},