[vte] parser: Complete SCI infrastructure



commit 8b9cc7d79afe7d8d399840d1d269b04c71df28df
Author: Christian Persch <chpe src gnome org>
Date:   Sat Nov 10 11:08:12 2018 +0100

    parser: Complete SCI infrastructure
    
    Add (empty) list of known CSI functions, and test for them.

 src/Makefile.am    |  3 +++
 src/parser-sci.hh  | 20 ++++++++++++++++++++
 src/parser-test.cc | 24 ++++++++++++++++++++++++
 src/parser.cc      |  8 +++++++-
 4 files changed, 54 insertions(+), 1 deletion(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 8f88b447..aba51322 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,6 +73,7 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_SOURCES = \
        parser-glue.hh \
        parser-osc.hh \
        parser-reply.hh \
+       parser-sci.hh \
        parser-sgr.hh \
        parser-string.hh \
        pty.cc \
@@ -267,6 +268,7 @@ parser_cat_SOURCES = \
        parser-glue.hh \
        parser-osc.hh \
        parser-reply.hh \
+       parser-sci.hh \
        parser-sgr.hh \
        parser-string.hh \
        parser-cat.cc \
@@ -310,6 +312,7 @@ test_parser_SOURCES = \
        parser-glue.hh \
        parser-osc.hh \
        parser-reply.hh \
+       parser-sci.hh \
        parser-sgr.hh \
        parser-string.hh \
        $(NULL)
diff --git a/src/parser-sci.hh b/src/parser-sci.hh
new file mode 100644
index 00000000..9f12b92e
--- /dev/null
+++ b/src/parser-sci.hh
@@ -0,0 +1,20 @@
+/*
+ * Copyright © 2018 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(_VTE_SEQ) || !defined(_VTE_NOQ)
+#error "Must define _VTE_SEQ and _VTE_NOQ before including this file"
+#endif
diff --git a/src/parser-test.cc b/src/parser-test.cc
index c7522546..b0a70bba 100644
--- a/src/parser-test.cc
+++ b/src/parser-test.cc
@@ -765,6 +765,29 @@ test_seq_sci(void)
                 test_seq_sci(f, false);
 }
 
+G_GNUC_UNUSED
+static void
+test_seq_sci_known(uint32_t f,
+                   unsigned int cmd)
+{
+        vte_seq_builder b{VTE_SEQ_SCI, f};
+
+        auto rv = feed_parser(b);
+        g_assert_cmpint(rv, ==, VTE_SEQ_SCI);
+        g_assert_cmpint(seq.command(), ==, cmd);
+}
+
+static void
+test_seq_sci_known(void)
+{
+        parser.reset();
+
+#define _VTE_SEQ(cmd,type,f,p,ni,i) \
+        test_seq_sci_known(f, VTE_CMD_##cmd);
+#include "parser-sci.hh"
+#undef _VTE_SEQ
+}
+
 static void
 test_seq_csi_known(uint32_t f,
                    uint32_t p,
@@ -1482,6 +1505,7 @@ main(int argc,
         g_test_add_func("/vte/parser/sequences/csi/clear", test_seq_csi_clear);
         g_test_add_func("/vte/parser/sequences/csi/max", test_seq_csi_max);
         g_test_add_func("/vte/parser/sequences/sci", test_seq_sci);
+        g_test_add_func("/vte/parser/sequences/sci/known", test_seq_sci_known);
         g_test_add_func("/vte/parser/sequences/dcs", test_seq_dcs);
         g_test_add_func("/vte/parser/sequences/dcs/known", test_seq_dcs_known);
         g_test_add_func("/vte/parser/sequences/osc", test_seq_osc);
diff --git a/src/parser.cc b/src/parser.cc
index 4c3bf2f7..f3f25581 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -439,7 +439,13 @@ static unsigned int vte_parse_host_dcs(const struct vte_seq *seq)
 
 static unsigned int vte_parse_host_sci(const struct vte_seq *seq)
 {
-        return VTE_CMD_NONE;
+        switch (_VTE_SEQ_CODE(seq->terminator, 0)) {
+#define _VTE_SEQ(cmd,type,f,p,ni,i) \
+                case _VTE_SEQ_CODE(f, 0): return VTE_CMD_##cmd;
+#include "parser-sci.hh"
+#undef _VTE_SEQ
+        default: return VTE_CMD_NONE;
+        }
 }
 
 /*


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