[vte] parser: Define SGR enum from include files



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

    parser: Define SGR enum from include files

 src/Makefile.am      |  6 +++++
 src/parser-decsgr.hh | 35 ++++++++++++++++++++++++
 src/parser-sgr.hh    | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/parser.hh        | 16 +++++++++++
 src/vteinternal.hh   | 36 -------------------------
 5 files changed, 133 insertions(+), 36 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index e719750c..8f88b447 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -68,10 +68,12 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_SOURCES = \
        parser-c01.hh \
        parser-csi.hh \
        parser-dcs.hh \
+       parser-decsgr.hh \
        parser-esc.hh \
        parser-glue.hh \
        parser-osc.hh \
        parser-reply.hh \
+       parser-sgr.hh \
        parser-string.hh \
        pty.cc \
        reaper.cc \
@@ -260,10 +262,12 @@ parser_cat_SOURCES = \
        parser-c01.hh \
        parser-csi.hh \
        parser-dcs.hh \
+       parser-decsgr.hh \
        parser-esc.hh \
        parser-glue.hh \
        parser-osc.hh \
        parser-reply.hh \
+       parser-sgr.hh \
        parser-string.hh \
        parser-cat.cc \
        utf8.cc \
@@ -301,10 +305,12 @@ test_parser_SOURCES = \
        parser-c01.hh \
        parser-csi.hh \
        parser-dcs.hh \
+       parser-decsgr.hh \
        parser-esc.hh \
        parser-glue.hh \
        parser-osc.hh \
        parser-reply.hh \
+       parser-sgr.hh \
        parser-string.hh \
        $(NULL)
 test_parser_CPPFLAGS = \
diff --git a/src/parser-decsgr.hh b/src/parser-decsgr.hh
new file mode 100644
index 00000000..e6f8f9e7
--- /dev/null
+++ b/src/parser-decsgr.hh
@@ -0,0 +1,35 @@
+/*
+ * 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_SGR) || !defined(_VTE_NGR)
+#error "Must define _VTE_SGR and _VTE_NGR before including this file"
+#endif
+
+#define SGR(set, name, value) _VTE_SGR(set##_##name, value)
+#define NGR(set, name, value) _VTE_NGR(set##_##name, value)
+
+NGR(RESET, ALL, 0)
+NGR(SET, SUPERSCRIPT, 4)
+NGR(SET, SUBSCRIPT, 5)
+NGR(SET, OVERLINE, 6)
+NGR(SET, TRANSPARENCY, 8)
+NGR(RESET, SUPERSUBSCRIPT, 24)
+NGR(RESET, OVERLINE, 26)
+NGR(RESET, TRANSPARENCY, 28)
+
+#undef SGR
+#undef NGR
diff --git a/src/parser-sgr.hh b/src/parser-sgr.hh
new file mode 100644
index 00000000..c12e5ade
--- /dev/null
+++ b/src/parser-sgr.hh
@@ -0,0 +1,76 @@
+/*
+ * 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_SGR) || !defined(_VTE_NGR)
+#error "Must define _VTE_SGR and _VTE_NGR before including this file"
+#endif
+
+#define SGR(set, name, value) _VTE_SGR(set##_##name, value)
+#define NGR(set, name, value) _VTE_NGR(set##_##name, value)
+
+SGR(SET, BOLD, 1)
+SGR(SET, DIM, 2)
+SGR(SET, ITALIC, 3)
+SGR(SET, UNDERLINE, 4)
+SGR(SET, BLINK, 5)
+SGR(SET, BLINK_RAPID, 6)
+SGR(SET, REVERSE, 7)
+SGR(SET, INVISIBLE, 8)
+SGR(SET, STRIKETHROUGH, 9)
+SGR(SET, UNDERLINE_DOUBLE, 21)
+SGR(SET, FORE_LEGACY_START, 30)
+SGR(SET, FORE_LEGACY_END, 37)
+SGR(SET, FORE_SPEC, 38)
+SGR(SET, BACK_LEGACY_START, 40)
+SGR(SET, BACK_LEGACY_END, 47)
+SGR(SET, BACK_SPEC, 48)
+SGR(SET, OVERLINE, 53)
+SGR(SET, DECO_SPEC, 58)
+SGR(SET, FORE_LEGACY_BRIGHT_START, 90)
+SGR(SET, FORE_LEGACY_BRIGHT_END, 97)
+SGR(SET, BACK_LEGACY_BRIGHT_START, 100)
+SGR(SET, BACK_LEGACY_BRIGHT_END, 107)
+SGR(RESET, ALL, 0)
+SGR(RESET, BOLD_AND_DIM, 22)
+SGR(RESET, ITALIC, 23)
+SGR(RESET, UNDERLINE, 24)
+SGR(RESET, BLINK, 25)
+SGR(RESET, REVERSE, 27)
+SGR(RESET, INVISIBLE, 28)
+SGR(RESET, STRIKETHROUGH, 29)
+SGR(RESET, FORE, 39)
+SGR(RESET, BACK, 49)
+SGR(RESET, OVERLINE, 55)
+SGR(RESET, DECO, 59)
+
+NGR(SET, FONT_FIRST, 10)
+NGR(SET, FONT_LAST, 19)
+NGR(SET, FONT_FRAKTUR, 20)
+NGR(SET, PROPORTIONAL, 26)
+NGR(SET, FRAMED, 51)
+NGR(SET, ENCIRCLED, 52)
+NGR(SET, IDEOGRAM_UNDERLINE, 60)
+NGR(SET, IDEOGRAM_DOUBLE_UNDERLINE, 61)
+NGR(SET, IDEOGRAM_OVERLINE, 62)
+NGR(SET, IDEOGRAM_DOUBLE_OVERLINE, 63)
+NGR(SET, IDEOGRAM_STRESS_MARK, 64)
+NGR(RESET, PROPORTIONAL, 50)
+NGR(RESET, FRAMED_OR_ENCIRCLED, 54)
+NGR(RESET, IDEOGRAM, 65)
+
+#undef SGR
+#undef NGR
diff --git a/src/parser.hh b/src/parser.hh
index 3a96fd29..c83feaeb 100644
--- a/src/parser.hh
+++ b/src/parser.hh
@@ -162,6 +162,22 @@ enum {
         VTE_OSC_N
 };
 
+enum {
+#define _VTE_SGR(name, value) VTE_SGR_##name = value,
+#define _VTE_NGR(...)
+#include "parser-sgr.hh"
+#undef _VTE_SGR
+#undef _VTE_NGR
+};
+
+enum {
+#define _VTE_SGR(name, value) VTE_DECSGR_##name = value,
+#define _VTE_NGR(...)
+#include "parser-decsgr.hh"
+#undef _VTE_SGR
+#undef _VTE_NGR
+};
+
 #define VTE_CHARSET_CHARSET_MASK   ((1U << 16) - 1U)
 #define VTE_CHARSET_SLOT_OFFSET    (16)
 #define VTE_CHARSET_GET_CHARSET(c) ((c) & VTE_CHARSET_CHARSET_MASK)
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 9c9b3038..58cb0479 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -81,42 +81,6 @@ enum {
         VTE_XTERM_WM_TITLE_STACK_POP = 23,
 };
 
-enum {
-        VTE_SGR_SET_BOLD                     =   1,
-        VTE_SGR_SET_DIM                      =   2,
-        VTE_SGR_SET_ITALIC                   =   3,
-        VTE_SGR_SET_UNDERLINE                =   4,
-        VTE_SGR_SET_BLINK                    =   5,
-        VTE_SGR_SET_REVERSE                  =   7,
-        VTE_SGR_SET_INVISIBLE                =   8,
-        VTE_SGR_SET_STRIKETHROUGH            =   9,
-        VTE_SGR_SET_UNDERLINE_DOUBLE         =  21,
-        VTE_SGR_SET_FORE_LEGACY_START        =  30,
-        VTE_SGR_SET_FORE_LEGACY_END          =  37,
-        VTE_SGR_SET_FORE_SPEC                =  38,
-        VTE_SGR_SET_BACK_LEGACY_START        =  40,
-        VTE_SGR_SET_BACK_LEGACY_END          =  47,
-        VTE_SGR_SET_BACK_SPEC                =  48,
-        VTE_SGR_SET_OVERLINE                 =  53,
-        VTE_SGR_SET_DECO_SPEC                =  58,
-        VTE_SGR_SET_FORE_LEGACY_BRIGHT_START =  90,
-        VTE_SGR_SET_FORE_LEGACY_BRIGHT_END   =  97,
-        VTE_SGR_SET_BACK_LEGACY_BRIGHT_START = 100,
-        VTE_SGR_SET_BACK_LEGACY_BRIGHT_END   = 107,
-        VTE_SGR_RESET_ALL                    =   0,
-        VTE_SGR_RESET_BOLD_AND_DIM           =  22,
-        VTE_SGR_RESET_ITALIC                 =  23,
-        VTE_SGR_RESET_UNDERLINE              =  24,
-        VTE_SGR_RESET_BLINK                  =  25,
-        VTE_SGR_RESET_REVERSE                =  27,
-        VTE_SGR_RESET_INVISIBLE              =  28,
-        VTE_SGR_RESET_STRIKETHROUGH          =  29,
-        VTE_SGR_RESET_FORE                   =  39,
-        VTE_SGR_RESET_BACK                   =  49,
-        VTE_SGR_RESET_OVERLINE               =  55,
-        VTE_SGR_RESET_DECO                   =  59,
-};
-
 enum {
         VTE_SGR_COLOR_SPEC_RGB    = 2,
         VTE_SGR_COLOR_SPEC_LEGACY = 5


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