[vte/wip/egmont/bidi: 21/105] BDSM and SPD escape sequences



commit dd2dfeddb3c4cee2dc78d1c45b1a2645ebca409f
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri Aug 17 20:00:14 2018 +0200

    BDSM and SPD escape sequences

 src/modes-ecma.hh  | 17 +++++++++++++++--
 src/modes.hh       |  3 ++-
 src/parser-cmd.hh  |  2 +-
 src/parser-csi.hh  |  2 +-
 src/vte.cc         |  2 ++
 src/vteinternal.hh |  3 +++
 src/vteseq.cc      | 19 +++++++++++++++++++
 7 files changed, 43 insertions(+), 5 deletions(-)
---
diff --git a/src/modes-ecma.hh b/src/modes-ecma.hh
index 617d2985..9c767ac1 100644
--- a/src/modes-ecma.hh
+++ b/src/modes-ecma.hh
@@ -38,6 +38,20 @@
  */
 MODE(IRM,  4)
 
+/*
+ * BDSM - Bi-Directional Support Mode
+ *
+ * Reset state is explicit mode, set state is implicit mode
+ *
+ * References: ECMA-48
+ *             ECMA TR/53
+ *             [FIXME link to our spec]
+ *
+ * Default in ECMA: reset
+ * Default in VTE: set
+ */
+MODE(BDSM, 8)
+
 /*
  * SRM - local echo send/receive mode
  * If reset, characters entered by the keyboard are shown on the
@@ -59,8 +73,7 @@ MODE_FIXED(CRM,   3, ALWAYS_RESET)
 MODE_FIXED(SRTM,  5, ALWAYS_RESET)
 MODE_FIXED(ERM,   6, ALWAYS_RESET)
 MODE_FIXED(VEM,   7, ALWAYS_RESET)
-MODE_FIXED(BDSM,  8, ALWAYS_RESET)
-MODE_FIXED(DCSM,  9, ALWAYS_RESET)
+MODE_FIXED(DCSM,  9, ALWAYS_SET)
 MODE_FIXED(HEM,  10, ALWAYS_RESET)
 MODE_FIXED(PUM,  11, ALWAYS_RESET) /* ECMA-48 § F.4.1 Deprecated */
 MODE_FIXED(FEAM, 13, ALWAYS_RESET)
diff --git a/src/modes.hh b/src/modes.hh
index 47d0b415..c50f944a 100644
--- a/src/modes.hh
+++ b/src/modes.hh
@@ -170,7 +170,8 @@ public:
 #undef MODE
 #undef MODE_FIXED
 
-        constexpr ECMA() : Self{eSRM} { }
+        constexpr ECMA() : Self{eBDSM,
+                                eSRM} { }
 
 }; // class ECMA
 
diff --git a/src/parser-cmd.hh b/src/parser-cmd.hh
index 6fcaacc2..8299a002 100644
--- a/src/parser-cmd.hh
+++ b/src/parser-cmd.hh
@@ -109,6 +109,7 @@ _VTE_CMD(SD_OR_XTERM_IHMT) /* scroll down or xterm initiate highlight mouse trac
 _VTE_CMD(SGR) /* select graphics rendition */
 _VTE_CMD(SM_DEC) /* set mode dec */
 _VTE_CMD(SM_ECMA) /* set mode ecma */
+_VTE_CMD(SPD) /* select presentation directions */
 _VTE_CMD(SS2) /* single shift 2 */
 _VTE_CMD(SS3) /* single shift 3 */
 _VTE_CMD(SUB) /* substitute */
@@ -289,7 +290,6 @@ _VTE_NOP(SL) /* scroll left */
 _VTE_NOP(SLS) /* set line spacing */
 _VTE_NOP(SOH) /* start of heading */
 _VTE_NOP(SPA) /* start of protected area */
-_VTE_NOP(SPD) /* select presentation directions */
 _VTE_NOP(SPH) /* set page home */
 _VTE_NOP(SPI) /* spacing increment */
 _VTE_NOP(SPL) /* set page limit */
diff --git a/src/parser-csi.hh b/src/parser-csi.hh
index 410d533f..5a21f4b7 100644
--- a/src/parser-csi.hh
+++ b/src/parser-csi.hh
@@ -59,7 +59,7 @@ _VTE_NOQ(SEE,                    CSI,    'Q',  NONE,  0, NONE     ) /* select ed
 _VTE_NOQ(PPR,                    CSI,    'Q',  NONE,  1, SPACE    ) /* page-position-relative */
 _VTE_NOQ(PPB,                    CSI,    'R',  NONE,  1, SPACE    ) /* page-position-backward */
 _VTE_SEQ(SU,                     CSI,    'S',  NONE,  0, NONE     ) /* scroll-up */
-_VTE_NOQ(SPD,                    CSI,    'S',  NONE,  1, SPACE    ) /* select presentation directions */
+_VTE_SEQ(SPD,                    CSI,    'S',  NONE,  1, SPACE    ) /* select presentation directions */
 _VTE_NOQ(XTERM_SGFX,             CSI,    'S',  WHAT,  0, NONE     ) /* xterm-sixel-graphics */
 _VTE_SEQ(SD_OR_XTERM_IHMT,       CSI,    'T',  NONE,  0, NONE     ) /* scroll-down or 
xterm-initiate-highlight-mouse-tracking */
 _VTE_NOQ(DTA,                    CSI,    'T',  NONE,  1, SPACE    ) /* dimension text area */
diff --git a/src/vte.cc b/src/vte.cc
index 0aa9a3fc..73ff1842 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -9970,6 +9970,8 @@ Terminal::reset(bool clear_tabstops,
         /* Reset the saved cursor. */
         save_cursor(&m_normal_screen);
         save_cursor(&m_alternate_screen);
+        /* BiDi */
+        m_bidi_rtl = FALSE;
        /* Cause everything to be redrawn (or cleared). */
        invalidate_all();
 
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 58cb0479..fbe9b304 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -592,6 +592,9 @@ public:
         const char *m_hyperlink_hover_uri; /* data is owned by the ring */
         long m_hyperlink_auto_id;
 
+        /* BiDi */
+        gboolean m_bidi_rtl : 1;
+
 public:
 
         // FIXMEchpe inline!
diff --git a/src/vteseq.cc b/src/vteseq.cc
index d596d8b9..fcb69379 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -7356,7 +7356,26 @@ Terminal::SPD(vte::parser::Sequence const& seq)
          *   args[1]: 0
          *
          * References: ECMA-48 § 8.3.130
+         *             [FIXME link to our spec]
          */
+
+        auto const param = seq.collect1(0);
+        switch (param) {
+        case -1:
+        case 0:
+                m_bidi_rtl = FALSE;
+                _vte_debug_print(VTE_DEBUG_BIDI, "BiDi: switch to LTR\n");
+                break;
+        case 3:
+                m_bidi_rtl = TRUE;
+                _vte_debug_print(VTE_DEBUG_BIDI, "BiDi: switch to RTL\n");
+                break;
+        default:
+                /* FIXME switch to the emulator's default */
+                m_bidi_rtl = FALSE;
+                _vte_debug_print(VTE_DEBUG_BIDI, "BiDi: default direction restored\n");
+                break;
+        }
 }
 
 void


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