This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-10-quiet-head
in repository terminology.
View the commit online.
commit 942fabbd9759632b1ae40a334d23edd97b246179
Author: Boris Faure <[email protected]>
AuthorDate: Sat Oct 31 21:19:37 2026 +0000
termptyesc: parse OSC 9;4 progress reports
ConEmu's progress report, OSC 9 ; 4 ; <state> [ ; <progress> ]
(https://conemu.github.io/en/AnsiEscapeCodes.html). States 0-4 map to
Termpty_Progress_State; the value is clamped to 0-100, a set report
without one starts over at 0, error and pause keep the previous value, and
remove and indeterminate ignore it. A trailing ';' is accepted; anything
else malformed is rejected with a warning and changes nothing.
The state is not displayed yet; termio and win come next.
tests/xterm-osc-9-4.sh checks the final state of the forms tmux sends,
xterm-osc-9-4-reset.sh that RIS forgets the value;
tytest_osc9_progress walks the whole table and
tytest_osc9_progress_cb the change-only callback rule.
---
src/bin/termpty.c | 103 +++++++++++++++++++++++++++++++++++++++++++
src/bin/termptyesc.c | 41 +++++++++++++++++
src/bin/tytest.c | 2 +
src/bin/unit_tests.h | 2 +
tests/tests.results | 2 +
tests/xterm-osc-9-4-reset.sh | 9 ++++
tests/xterm-osc-9-4.sh | 18 ++++++++
7 files changed, 177 insertions(+)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index e0404f47..01d53226 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -2791,6 +2791,109 @@ tytest_xtgettcap(void)
return 0;
}
+/* How many times ty->cb.progress fired */
+static int _osc9_progress_calls = 0;
+
+static void
+_osc9_progress_count(void *data EINA_UNUSED)
+{
+ _osc9_progress_calls++;
+}
+
+/* Every row of the ConEmu state/value table, as tmux's Spb sends it */
+int
+tytest_osc9_progress(void)
+{
+ Termpty ty;
+
+ _ty_test_init(&ty, 80, 24);
+
+ _ty_feed(&ty, "\x1b]9;4;1;50\x1b\\");
+ assert(ty.progress.state == TERMPTY_PROGRESS_NORMAL);
+ assert(ty.progress.value == 50);
+ /* clamped */
+ _ty_feed(&ty, "\x1b]9;4;1;150\x07");
+ assert(ty.progress.value == 100);
+ /* a set report without a value starts over at 0 */
+ _ty_feed(&ty, "\x1b]9;4;1\x07");
+ assert(ty.progress.value == 0);
+ _ty_feed(&ty, "\x1b]9;4;1;\x07");
+ assert(ty.progress.value == 0);
+ /* a trailing ';' is accepted */
+ _ty_feed(&ty, "\x1b]9;4;1;50;\x1b\\");
+ assert(ty.progress.value == 50);
+ /* error and pause keep the value */
+ _ty_feed(&ty, "\x1b]9;4;2\x07");
+ assert(ty.progress.state == TERMPTY_PROGRESS_ERROR);
+ assert(ty.progress.value == 50);
+ _ty_feed(&ty, "\x1b]9;4;4\x07");
+ assert(ty.progress.state == TERMPTY_PROGRESS_PAUSED);
+ assert(ty.progress.value == 50);
+ /* unless they carry one of their own */
+ _ty_feed(&ty, "\x1b]9;4;2;30\x07");
+ assert(ty.progress.state == TERMPTY_PROGRESS_ERROR);
+ assert(ty.progress.value == 30);
+ /* remove and indeterminate leave the value alone, as tmux sends them */
+ _ty_feed(&ty, "\x1b]9;4;0;57\x1b\\");
+ assert(ty.progress.state == TERMPTY_PROGRESS_NONE);
+ assert(ty.progress.value == 30);
+ _ty_feed(&ty, "\x1b]9;4;3;57\x1b\\");
+ assert(ty.progress.state == TERMPTY_PROGRESS_INDETERMINATE);
+ assert(ty.progress.value == 30);
+ /* so a later error restores it */
+ _ty_feed(&ty, "\x1b]9;4;2\x07");
+ assert(ty.progress.state == TERMPTY_PROGRESS_ERROR);
+ assert(ty.progress.value == 30);
+ /* a huge value does not overflow */
+ _ty_feed(&ty, "\x1b]9;4;1;99999999999999\x07");
+ assert(ty.progress.state == TERMPTY_PROGRESS_NORMAL);
+ assert(ty.progress.value == 100);
+ /* malformed reports change nothing */
+ _ty_feed(&ty, "\x1b]9;4;1;5x\x07");
+ _ty_feed(&ty, "\x1b]9;4;7;10\x07");
+ assert(ty.progress.state == TERMPTY_PROGRESS_NORMAL);
+ assert(ty.progress.value == 100);
+ /* RIS forgets everything */
+ _ty_feed(&ty, "\033c");
+ assert(ty.progress.state == TERMPTY_PROGRESS_NONE);
+ assert(ty.progress.value == 0);
+
+ _ty_test_shutdown(&ty);
+ return 0;
+}
+
+/* The callback fires only when (state, value) actually changed */
+int
+tytest_osc9_progress_cb(void)
+{
+ Termpty ty;
+
+ _ty_test_init(&ty, 80, 24);
+ ty.cb.progress.func = _osc9_progress_count;
+ _osc9_progress_calls = 0;
+
+ /* one call per well-formed report; the change filter lives in
+ * termio, which compares against what it last showed */
+ _ty_feed(&ty, "\x1b]9;4;1;50\x1b\\");
+ _ty_feed(&ty, "\x1b]9;4;1;50\x1b\\");
+ assert(_osc9_progress_calls == 2);
+ /* a value change: one more */
+ _ty_feed(&ty, "\x1b]9;4;1;60\x1b\\");
+ assert(_osc9_progress_calls == 3);
+ /* a state change keeping the value: one more */
+ _ty_feed(&ty, "\x1b]9;4;4\x1b\\");
+ assert(_osc9_progress_calls == 4);
+ /* the same report again: one more */
+ _ty_feed(&ty, "\x1b]9;4;4\x1b\\");
+ assert(_osc9_progress_calls == 5);
+ /* malformed: none */
+ _ty_feed(&ty, "\x1b]9;4;1;5x\x1b\\");
+ assert(_osc9_progress_calls == 5);
+
+ _ty_test_shutdown(&ty);
+ return 0;
+}
+
#if defined(BINARY_TYTEST)
/* OSC 777 is dropped entirely, notifications included, when gated off. */
int
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 124d3b81..e67f0a9e 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -5417,6 +5417,44 @@ _handle_osc_palette_reset(Termpty *ty, Eina_Unicode *p)
termio_palette_apply(ty->obj);
}
+/* ";<state>[;<progress>]", as tmux's Spb sends it. The value is clamped
+ * to 0-100 by termpty_progress_set(). A trailing ';' is accepted;
+ * anything else malformed is rejected and changes nothing. */
+static void
+_handle_osc_9_4_progress(Termpty *ty, const char *s, int len)
+{
+ Termpty_Progress_State state;
+ int value = -1;
+ int i;
+
+ if ((len < 2) || (s[0] != ';') || (s[1] < '0') || (s[1] > '4'))
+ goto bad;
+ state = (Termpty_Progress_State)(s[1] - '0');
+ i = 2;
+ if ((i < len) && (s[i] == ';'))
+ {
+ i++;
+ if ((i < len) && (s[i] >= '0') && (s[i] <= '9'))
+ {
+ value = 0;
+ while ((i < len) && (s[i] >= '0') && (s[i] <= '9'))
+ {
+ if (value <= 100)
+ value = value * 10 + (s[i] - '0');
+ i++;
+ }
+ }
+ }
+ if ((i < len) && (s[i] != ';'))
+ goto bad;
+ termpty_progress_set(ty, state, value);
+ return;
+
+bad:
+ WRN("invalid OSC 9;4 progress report");
+ ty->decoding_error = EINA_TRUE;
+}
+
/* ConEmu numbers its OSC 9 extensions; a payload starting with decimal
* digits followed by ';' or by the end is one of them, never notification
* text. */
@@ -5429,6 +5467,9 @@ _handle_osc_9(Termpty *ty, const char *s, int len)
digits++;
if ((digits > 0) && ((digits == len) || (s[digits] == ';')))
{
+ if ((digits == 1) && (s[0] == '4'))
+ _handle_osc_9_4_progress(ty, s + 1, len - 1);
+ else
DBG("ignoring ConEmu OSC 9;%.*s", digits, s);
return;
}
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index d00a6ef6..7d922608 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -79,6 +79,8 @@ static struct {
{ "tcap_table_sorted", tytest_tcap_table_sorted},
{ "notify_gated", tytest_notify_gated},
{ "osc9_notify", tytest_osc9_notify},
+ { "osc9_progress", tytest_osc9_progress},
+ { "osc9_progress_cb", tytest_osc9_progress_cb},
{ "notify_meta_parse", tytest_notify_meta_parse},
{ "notify_pending_cap", tytest_notify_pending_cap},
{ "notify_query_gated", tytest_notify_query_gated},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 9a2b6f2e..e2cd4ec6 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -53,6 +53,8 @@ int tytest_xtgettcap(void);
int tytest_tcap_table_sorted(void);
int tytest_notify_gated(void);
int tytest_osc9_notify(void);
+int tytest_osc9_progress(void);
+int tytest_osc9_progress_cb(void);
int tytest_notify_meta_parse(void);
int tytest_notify_pending_cap(void);
int tytest_notify_query_gated(void);
diff --git a/tests/tests.results b/tests/tests.results
index af8aad72..e7f292f5 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -230,3 +230,5 @@ decslrm-two-columns.sh 2bc3f2840cc2e18a5e68b3d9e053a5f2
decstbm-one-row.sh 1657d126de08379e16ac0e7ec5693309
irm-runs.sh d3a480e2a58939db077a06b95712371a
xterm-osc-9.sh 09d136a6b7f579c0d23e95f406f65bf4
+xterm-osc-9-4.sh 5e1e81fce6d8d7dbe261ea21ed2491b8
+xterm-osc-9-4-reset.sh 418469754b84535141326790ebf8e941
diff --git a/tests/xterm-osc-9-4-reset.sh b/tests/xterm-osc-9-4-reset.sh
new file mode 100755
index 00000000..34c50a13
--- /dev/null
+++ b/tests/xterm-osc-9-4-reset.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# fill space with E
+printf '\033#8'
+
+# set 80%, then RIS, then an error report: the value must be forgotten
+printf '\033]9;4;1;80\033\\'
+printf '\033c'
+printf '\033]9;4;2\007'
diff --git a/tests/xterm-osc-9-4.sh b/tests/xterm-osc-9-4.sh
new file mode 100755
index 00000000..580b2fb9
--- /dev/null
+++ b/tests/xterm-osc-9-4.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# fill space with E
+printf '\033#8'
+
+# set 50%, then the forms tmux sends
+printf '\033]9;4;1;50\033\\'
+printf '\033]9;4;3;50\033\\'
+printf '\033]9;4;0;50\033\\'
+# clamp
+printf '\033]9;4;1;150\007'
+# error keeps the value
+printf '\033]9;4;2\007'
+# malformed reports change nothing
+printf '\033]9;4;1;5x\007'
+printf '\033]9;4;7;10\007'
+# paused with a value, trailing semicolon accepted
+printf '\033]9;4;4;30;\033\\'
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.