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 7bc9fe270fd0441c80a77ba1d6940a7146080451
Author: Boris Faure <[email protected]>
AuthorDate: Fri Oct 30 15:22:21 2026 +0000

    termptyesc: reset palette colours with OSC 104
    
    OSC 104 restores palette colours to the scheme's: any number of indices
    given are reset, an out-of-range index is skipped, a non-number stops
    the parsing, and no parameter at all ("104" as well as a bare "104;")
    resets the whole table.
    
    The indices are parsed with _osc_arg_get(), which consumes the ';'
    separating two indices itself.
---
 src/bin/termio.c     | 12 ++++++++++++
 src/bin/termio.h     |  2 ++
 src/bin/termptyesc.c | 28 ++++++++++++++++++++++++++++
 tests/osc-104.sh     | 25 +++++++++++++++++++++++++
 tests/tests.results  |  1 +
 5 files changed, 68 insertions(+)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index b5086713..2742e5c4 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -251,6 +251,18 @@ termio_palette_apply(Evas_Object *obj)
    termpty_palette_changed(sd->pty);
 }
 
+/* drops one entry's override, without re-applying the palette */
+void
+termio_palette_color_override_clear(Evas_Object *obj, int idx)
+{
+   Termio *sd = evas_object_smart_data_get(obj);
+
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+   if ((idx < 0) || (idx > 255))
+     return;
+   sd->palette.overridden[idx / 32] &= ~(1u << (idx % 32));
+}
+
 void
 termio_palette_reset(Evas_Object *obj)
 {
diff --git a/src/bin/termio.h b/src/bin/termio.h
index b1222aac..35f3d536 100644
--- a/src/bin/termio.h
+++ b/src/bin/termio.h
@@ -115,6 +115,8 @@ termio_palette_color_get(const Evas_Object *obj, int idx,
 void
 termio_palette_color_set(Evas_Object *obj, int idx, int r, int g, int b);
 void
+termio_palette_color_override_clear(Evas_Object *obj, int idx);
+void
 termio_palette_reset(Evas_Object *obj);
 void
 termio_palette_apply(Evas_Object *obj);
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 42fce23a..0b6d8484 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -5279,6 +5279,30 @@ err:
    ty->decoding_error = EINA_TRUE;
 }
 
+/* OSC 104: no parameter resets them all; a non-number stops, as in xterm */
+static void
+_handle_osc_palette_reset(Termpty *ty, Eina_Unicode *p)
+{
+   if (!p || !*p)
+     {
+        termio_palette_reset(ty->obj);
+        return;
+     }
+
+   while (*p)
+     {
+        int idx;
+
+        /* _osc_arg_get consumes the ';' separating two indices */
+        idx = _osc_arg_get(ty, &p);
+        if (idx < 0)
+          break;
+        if (idx <= 255)
+          termio_palette_color_override_clear(ty->obj, idx);
+     }
+   termio_palette_apply(ty->obj);
+}
+
 static int
 _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
 {
@@ -5456,6 +5480,10 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
         DBG("Manipulate selection data");
         _handle_osc_selection(ty, p);
         break;
+      case 104:
+        DBG("Reset palette colors");
+        _handle_osc_palette_reset(ty, p);
+        break;
       case 110:
         DBG("Reset VT100 text foreground color");
         termio_reset_fg_color(ty->obj);
diff --git a/tests/osc-104.sh b/tests/osc-104.sh
new file mode 100644
index 00000000..41fdbdd0
--- /dev/null
+++ b/tests/osc-104.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+printf '\033]4;1;#010101;2;#020202;3;#030303;20;#141414\007'
+# reset two of them
+printf '\033]104;1;20\007'
+printf '\033]4;1;?;2;?;20;?\007'
+# out of range is skipped, the rest still applies
+printf '\033]104;999;2\033\\'
+printf '\033]4;2;?\007'
+# non-number stops: 3 stays set
+printf '\033]104;x;3\007'
+printf '\033]4;3;?\007'
+# no parameter resets everything
+printf '\033]104\007'
+printf '\033]4;3;?\007'
+printf '\033]4;5;#050505\007'
+printf '\033]104;\007'
+printf '\033]4;5;?\007'
+
+## replies, with default_colors256 values:
+# \e]4;1;rgb:c0c0/0000/0000\a \e]4;2;rgb:0000/c0c0/0000\a \e]4;20;rgb:c0c0/0000/0000\a
+# \e]4;2;rgb:0000/c0c0/0000\a
+# \e]4;3;rgb:c0c0/c0c0/0000\a
+# \e]4;3;rgb:c0c0/c0c0/0000\a
+# \e]4;5;rgb:8080/8080/8080\a
diff --git a/tests/tests.results b/tests/tests.results
index bae7b5f2..efa362fa 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -140,6 +140,7 @@ selection_empty_lines.sh 2ae3aa22572ef150457b63ed9a78efdc
 osc-invalid.sh e5933e7dd49d52b80240e352f4ff8965
 osc-4-query.sh 931d15bee6dffe2631cd127d6528a733
 osc-4-set.sh fc0c231e5ae1fda14d355e22f56099c4
+osc-104.sh 773d4be48c4ef99cb5a34c59fe771e25
 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