[vte/vte-0-36] emulation: Add support for OSC 104 (reset colors)



commit f957cd94c3057965bc8d74d0811252ff9dbb9894
Author: Egmont Koblinger <egmont gmail com>
Date:   Tue Jan 21 00:41:22 2014 +0100

    emulation: Add support for OSC 104 (reset colors)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=640040

 src/caps.c         |    4 ++++
 src/osc            |    2 ++
 src/vteseq-n.gperf |    1 +
 src/vteseq.c       |   26 ++++++++++++++++++++++++++
 4 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/caps.c b/src/caps.c
index a35c52d..d9f52a3 100644
--- a/src/caps.c
+++ b/src/caps.c
@@ -537,6 +537,8 @@ struct _vte_capability_string _vte_xterm_capability_strings[] = {
        {OSC "46;%s" BEL, "change-logfile", 0},
        {OSC "50;#%d" BEL, "change-font-number", 0},
        {OSC "50;%s" BEL, "change-font-name", 0},
+       {OSC "104" BEL, "reset-color", 0},
+       {OSC "104;%m" BEL, "reset-color", 0},
        {OSC "112" BEL, "reset-cursor-colors", 0},
 
        /* Set text parameters, ST-terminated versions. */
@@ -559,6 +561,8 @@ struct _vte_capability_string _vte_xterm_capability_strings[] = {
        {OSC "46;%s" ST, "change-logfile", 0},
        {OSC "50;#%d" ST, "change-font-number", 0},
        {OSC "50;%s" ST, "change-font-name", 0},
+       {OSC "104" ST, "reset-color", 0},
+       {OSC "104;%m" ST, "reset-color", 0},
        {OSC "112" ST, "reset-cursor-colors", 0},
 
        /* These may be bogus, I can't find docs for them anywhere (#104154). */
diff --git a/src/osc b/src/osc
index 50cd7f4..1dbff5f 100755
--- a/src/osc
+++ b/src/osc
@@ -8,9 +8,11 @@ if [ "$#" -eq 0 ] ; then
        echo "  0 'title'       change icon name and window title"
        echo "  1 'title'       change icon name"
        echo "  2 'title'       change window title"
+       echo "  4 'index;color' change color"
        echo "  6 'uri'         change current file uri"
        echo "  7 'uri'         change current directory uri"
        echo "  12 'color'      change cursor color"
+       echo "  104 'index'     reset color (or all colors)"
        echo "  112             reset cursor color"
        exit
 fi
diff --git a/src/vteseq-n.gperf b/src/vteseq-n.gperf
index 4ba53ed..c359a80 100644
--- a/src/vteseq-n.gperf
+++ b/src/vteseq-n.gperf
@@ -42,6 +42,7 @@ struct vteseq_n_struct {
 "save-cursor", VTE_SEQUENCE_HANDLER(vte_sequence_handler_sc)
 "scroll-down", VTE_SEQUENCE_HANDLER(vte_sequence_handler_scroll_down)
 "change-color", VTE_SEQUENCE_HANDLER(vte_sequence_handler_change_color)
+"reset-color", VTE_SEQUENCE_HANDLER(vte_sequence_handler_reset_color)
 "delete-lines", VTE_SEQUENCE_HANDLER(vte_sequence_handler_delete_lines)
 #"double-width", VTE_SEQUENCE_HANDLER_NULL
 "insert-lines", VTE_SEQUENCE_HANDLER(vte_sequence_handler_insert_lines)
diff --git a/src/vteseq.c b/src/vteseq.c
index 2dd9daa..bdd186b 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -1943,6 +1943,32 @@ vte_sequence_handler_change_color (VteTerminal *terminal, GValueArray *params)
        }
 }
 
+/* Reset the color */
+static void
+vte_sequence_handler_reset_color (VteTerminal *terminal, GValueArray *params)
+{
+       GValue *value;
+       long idx, i;
+
+       if (params != NULL && params->n_values > 0) {
+               for (i = 0; i < params->n_values; i++) {
+                       value = g_value_array_get_nth (params, i);
+
+                       if (!G_VALUE_HOLDS_LONG (value))
+                               continue;
+                       idx = g_value_get_long (value);
+                       if (idx < 0 || idx >= VTE_DEF_FG)
+                               continue;
+
+                       _vte_terminal_set_color_internal(terminal, idx, VTE_COLOR_SOURCE_ESCAPE, NULL);
+               }
+       } else {
+               for (idx = 0; idx < VTE_DEF_FG; idx++) {
+                       _vte_terminal_set_color_internal(terminal, idx, VTE_COLOR_SOURCE_ESCAPE, NULL);
+               }
+       }
+}
+
 /* Scroll the text up, but don't move the cursor. */
 static void
 vte_sequence_handler_scroll_up (VteTerminal *terminal, GValueArray *params)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]