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 18991b2d419feb1a513e59e173805b1afd2ec6ff
Author: Boris Faure <[email protected]>
AuthorDate: Fri Oct 30 15:18:04 2026 +0000

    termptyesc: set palette colours with OSC 4
    
    A colour spec, OSC 4 ; c ; spec, parses with _xterm_parse_color() on
    the exact spec length (the reason the parser takes lengths now) and
    sets the palette entry through termio. A bad spec stops the parsing and
    drops the rest, so the entries before it stay applied.
    
    The reply to a later query shows the set colour: the query reads the
    textgrid back, and the checksum covers the write buffer, so the
    osc-4-set.sh script checks sets through their replies.
---
 src/bin/termptyesc.c | 13 +++++++------
 tests/osc-4-set.sh   | 41 +++++++++++++++++++++++++++++++++++++++++
 tests/tests.results  |  1 +
 3 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 0145ab85..42fce23a 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -5227,10 +5227,7 @@ found:
    return cc + 1 - c;
 }
 
-/* OSC 4: query (and, to come, set) palette colours. Each entry is
- * "idx;spec", the spec running to the next ';' or to the end of the
- * payload. An out-of-range index or a bad spec stops the parsing and
- * drops the rest, as xterm does (misc.c, ChangeAnsiColorRequest) */
+/* OSC 4: entries are "idx;spec"; a bad one stops the parsing, as in xterm */
 static void
 _handle_osc_palette_set(Termpty *ty, Eina_Unicode *p, Eina_Bool bel)
 {
@@ -5264,8 +5261,12 @@ _handle_osc_palette_set(Termpty *ty, Eina_Unicode *p, Eina_Bool bel)
           }
         else
           {
-             WRN("set palette, not supported");
-             break;
+             unsigned char cr, cg, cb;
+
+             /* stop on a bad spec; earlier pairs stay applied, as in xterm */
+             if (_xterm_parse_color(ty, &spec, &cr, &cg, &cb, spec_len) < 0)
+               break;
+             termio_palette_color_set(ty->obj, idx, cr, cg, cb);
           }
 
         if (!*p)
diff --git a/tests/osc-4-set.sh b/tests/osc-4-set.sh
new file mode 100644
index 00000000..93e1d3c6
--- /dev/null
+++ b/tests/osc-4-set.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# OSC 4 sets, every spec form, then read back with queries
+
+printf '\033]4;1;#ff0000\007'
+printf '\033]4;2;#00ff00\033\\'
+printf '\033]4;3;rgb:12/34/56\007'
+printf '\033]4;4;rgb:f/0/8\007'
+printf '\033]4;5;rgb:1234/5678/9abc\007'
+printf '\033]4;6;rgbi:1/0.5/0\007'
+printf '\033]4;7;#123456789\007'
+printf '\033]4;8;#fff\007'
+printf '\033]4;1;?;2;?;3;?;4;?;5;?;6;?;7;?;8;?\007'
+# set and query in one sequence
+printf '\033]4;200;#010203;200;?\007'
+# bad spec stops: 10 is set, 11 is not, 12 is not
+printf '\033]4;10;#0a0a0a;11;nope;12;#0c0c0c\007'
+printf '\033]4;10;?;11;?;12;?\007'
+# out of range index stops the rest
+printf '\033]4;13;#0d0d0d;300;#ffffff;14;#0e0e0e\007'
+printf '\033]4;13;?;14;?\007'
+# a set colour is used by the truecolour approximation
+printf '\033]4;232;#3b224c\007'
+printf '\033[48;2;59;34;76mX\033[m'
+
+## replies:
+# \e]4;1;rgb:ffff/0000/0000\a
+# \e]4;2;rgb:0000/ffff/0000\a
+# \e]4;3;rgb:1212/3434/5656\a
+# \e]4;4;rgb:ffff/0000/8888\a
+# \e]4;5;rgb:1212/5656/9a9a\a
+# \e]4;6;rgb:ffff/8080/0000\a
+# \e]4;7;rgb:1212/4545/7878\a
+# \e]4;8;rgb:f0f0/f0f0/f0f0\a
+# \e]4;200;rgb:0101/0202/0303\a
+# \e]4;10;rgb:0a0a/0a0a/0a0a\a  (11 and 12 answer the defaults: the bad
+# \e]4;11;rgb:ffff/ffff/8080\a  spec stopped the parsing before they
+# \e]4;12;rgb:8080/8080/ffff\a  could be set)
+# \e]4;13;rgb:0d0d/0d0d/0d0d\a \e]4;14;rgb:8080/ffff/ffff\a
+# (the out-of-range 300 stopped the sets, so 14 is still its default;
+# the queries start a new sequence, and 14 is answered)
diff --git a/tests/tests.results b/tests/tests.results
index ce96df63..bae7b5f2 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -139,6 +139,7 @@ selection_with_tabs.sh 213c7c2d9a8acc731e0b326a88bb71ef
 selection_empty_lines.sh 2ae3aa22572ef150457b63ed9a78efdc
 osc-invalid.sh e5933e7dd49d52b80240e352f4ff8965
 osc-4-query.sh 931d15bee6dffe2631cd127d6528a733
+osc-4-set.sh fc0c231e5ae1fda14d355e22f56099c4
 osc-no-payload.sh 8aa7b12e298dfbeb5a48dcc48ea2f9a8
 osc-colors-ris.sh b9cde87fbfcf5e02a0d906a8dee7dff3
 osc-110-112.sh 15d223b8ed1276fdc5fe2a708bc3b3db

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to