[vte/vte-0-54] emulation: Implement SCOSC/SCORC



commit 429e15367e405d9bf993be38937e73c1fe52d3c0
Author: Egmont Koblinger <egmont gmail com>
Date:   Sun Oct 7 00:26:19 2018 +0200

    emulation: Implement SCOSC/SCORC
    
    https://gitlab.gnome.org/GNOME/vte/issues/48
    (cherry picked from commit f86cae603b23d34e36ab95fde6612bfc4d5eeca8)

 src/modes-private.hh |  3 ++-
 src/modes.hh         | 11 ++++++++--
 src/parser-cmd.hh    |  6 ++++--
 src/parser-csi.hh    |  4 ++--
 src/vteseq.cc        | 61 +++++++++++++++++++++++++++++++++++++++++-----------
 5 files changed, 66 insertions(+), 19 deletions(-)
---
diff --git a/src/modes-private.hh b/src/modes-private.hh
index 87cd0f08..eb313823 100644
--- a/src/modes-private.hh
+++ b/src/modes-private.hh
@@ -375,7 +375,8 @@ MODE_FIXED(DECKBUM,    68, ALWAYS_RESET)
  *
  * References: VT525
  *
- * Probably not worth implementing.
+ * Needs to be implemented if DECSLRM is implemented, to resolve a
+ * conflict between DECSLRM and SCOSC.
  */
 MODE_FIXED(DECLRMM, 69, ALWAYS_RESET) /* aka DECVSSM */
 
diff --git a/src/modes.hh b/src/modes.hh
index b7fe53fc..89a0c78b 100644
--- a/src/modes.hh
+++ b/src/modes.hh
@@ -36,6 +36,12 @@ namespace modes {
                 return get(e##name); \
         }
 
+#define MODE_FIXED_ACCESSOR(name,value) \
+        inline constexpr bool name() const noexcept \
+        { \
+                return value; \
+        }
+
 template <typename T>
 static inline void vte_modes_set_bool(T* modes,
                                       unsigned int shift,
@@ -159,7 +165,7 @@ public:
         }
 
 #define MODE(name,param) MODE_ACCESSOR(name)
-#define MODE_FIXED(name,param,value)
+#define MODE_FIXED(name,param,value) MODE_FIXED_ACCESSOR(name, e##value == eALWAYS_SET)
 #include "modes-ecma.hh"
 #undef MODE
 #undef MODE_FIXED
@@ -213,7 +219,7 @@ public:
         }
 
 #define MODE(name,param) MODE_ACCESSOR(name)
-#define MODE_FIXED(name,param,value)
+#define MODE_FIXED(name,param,value) MODE_FIXED_ACCESSOR(name, e##value == eALWAYS_SET)
 #include "modes-private.hh"
 #undef MODE
 #undef MODE_FIXED
@@ -244,6 +250,7 @@ private:
 }; // class Private
 
 #undef MODE_ACCESSOR
+#undef MODE_FIXED_ACCESSOR
 
 } // namespace modes
 } // namespace terminal
diff --git a/src/parser-cmd.hh b/src/parser-cmd.hh
index 96471bd6..efe62375 100644
--- a/src/parser-cmd.hh
+++ b/src/parser-cmd.hh
@@ -62,7 +62,7 @@ _VTE_CMD(DECSCUSR) /* set cursor style */
 _VTE_CMD(DECSED) /* selective erase in display */
 _VTE_CMD(DECSEL) /* selective erase in line */
 _VTE_CMD(DECSLPP) /* set lines per page */
-_VTE_CMD(DECSLRM) /* set left and right margins */
+_VTE_CMD(DECSLRM_OR_SCOSC) /* set left and right margins or SCO save cursor */
 _VTE_CMD(DECSR) /* secure reset */
 _VTE_CMD(DECST8C) /* set tab at every 8 columns */
 _VTE_CMD(DECSTBM) /* set top and bottom margins */
@@ -101,6 +101,8 @@ _VTE_CMD(RI) /* reverse index */
 _VTE_CMD(RIS) /* reset to initial state */
 _VTE_CMD(RM_DEC) /* reset mode dec */
 _VTE_CMD(RM_ECMA) /* reset mode ecma */
+_VTE_CMD(SCORC) /* SCO restore cursor */
+_VTE_CMD(SCOSC) /* SCO save cursor */
 _VTE_CMD(SD) /* scroll down */
 _VTE_CMD(SD_OR_XTERM_IHMT) /* scroll down or xterm initiate highlight mouse tracking */
 _VTE_CMD(SGR) /* select graphics rendition */
@@ -199,6 +201,7 @@ _VTE_NOP(DECSIXEL) /* SIXEL graphics */
 _VTE_NOP(DECSKCV) /* set key click volume */
 _VTE_NOP(DECSLCK) /* set lock key style */
 _VTE_NOP(DECSLE) /* select locator events */
+_VTE_NOP(DECSLRM) /* set left and right margins */
 _VTE_NOP(DECSMBV) /* set margin bell volume */
 _VTE_NOP(DECSMKR) /* select modifier key reporting */
 _VTE_NOP(DECSNLS) /* set lines per screen */
@@ -271,7 +274,6 @@ _VTE_NOP(QUAD) /* quad */
 _VTE_NOP(RLOGIN_MML) /* RLogin music macro language */
 _VTE_NOP(SACS) /* set additional character separation */
 _VTE_NOP(SAPV) /* select alternative presentation variants */
-_VTE_NOP(SCORC) /* SCO restore cursor */
 _VTE_NOP(SCO) /* select character orientation */
 _VTE_NOP(SCP) /* select character path */
 _VTE_NOP(SCS) /* set character spacing */
diff --git a/src/parser-csi.hh b/src/parser-csi.hh
index f88cd2ce..69eca32d 100644
--- a/src/parser-csi.hh
+++ b/src/parser-csi.hh
@@ -150,7 +150,7 @@ _VTE_NOQ(DECSCS,                 CSI,    'r',  NONE,  1, MULT     ) /* select-co
 _VTE_NOQ(DECSMKR,                CSI,    'r',  NONE,  1, PLUS     ) /* select-modifier-key-reporting */
 _VTE_NOQ(DECSEST,                CSI,    'r',  NONE,  1, MINUS    ) /* energy saver time */
 _VTE_SEQ(DECPCTERM_OR_XTERM_RPM, CSI,    'r',  WHAT,  0, NONE     ) /* pcterm or xterm restore DEC private 
mode */
-_VTE_SEQ(DECSLRM,                CSI,    's',  NONE,  0, NONE     ) /* set-left-and-right-margins */
+_VTE_SEQ(DECSLRM_OR_SCOSC,       CSI,    's',  NONE,  0, NONE     ) /* set left and right margins or SCO 
save cursor */
 _VTE_NOQ(DECSPRTT,               CSI,    's',  NONE,  1, CASH     ) /* select-printer-type */
 _VTE_NOQ(DECSFC,                 CSI,    's',  NONE,  1, MULT     ) /* select-flow-control */
 _VTE_SEQ(XTERM_SPM,              CSI,    's',  WHAT,  0, NONE     ) /* xterm save private mode */
@@ -159,7 +159,7 @@ _VTE_NOQ(DECSWBV,                CSI,    't',  NONE,  1, SPACE    ) /* set-warni
 _VTE_NOQ(DECSRFR,                CSI,    't',  NONE,  1, DQUOTE   ) /* select-refresh-rate */
 _VTE_NOQ(DECRARA,                CSI,    't',  NONE,  1, CASH     ) /* 
reverse-attributes-in-rectangular-area */
 _VTE_NOQ(XTERM_STM,              CSI,    't',  GT,    0, NONE     ) /* xterm-set-title-mode */
-_VTE_NOQ(SCORC,                  CSI,    'u',  NONE,  0, NONE     ) /* SCO restore-cursor */
+_VTE_SEQ(SCORC,                  CSI,    'u',  NONE,  0, NONE     ) /* SCO restore cursor */
 _VTE_NOQ(DECSMBV,                CSI,    'u',  NONE,  1, SPACE    ) /* set-margin-bell-volume */
 _VTE_NOQ(DECSTRL,                CSI,    'u',  NONE,  1, DQUOTE   ) /* set-transmit-rate-limit */
 _VTE_SEQ(DECRQTSR,               CSI,    'u',  NONE,  1, CASH     ) /* request-terminal-state-report */
diff --git a/src/vteseq.cc b/src/vteseq.cc
index eabcbbaa..d8cc3a1b 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -4343,19 +4343,36 @@ Terminal::DECSLRM(vte::parser::Sequence const& seq)
          *
          * References: VT525
          *
-         * Note: There is a conflict between SCOSC and DECSLRM that both
-         * have final character 's' (7/3). SCOSC has 0 parameters, and
-         * DECSLRM has 2 parameters which both have default values, and
-         * my reading of ECMA-48 § 5.4.2h says that this allows for an
-         * empty parameter string to represent them.
+         * FIXMEchpe: Consider implementing this.
+         */
+}
+
+void
+Terminal::DECSLRM_OR_SCOSC(vte::parser::Sequence const& seq)
+{
+        /*
+         * set left and right margins or SCO restore cursor - DECSLRM or SCOSC
+         * There is a conflict between SCOSC and DECSLRM that both are
+         * CSI s (CSI 7/3). SCOSC has 0 parameters, and DECSLRM has 2
+         * parameters which both have default values, and my reading
+         * of ECMA-48 § 5.4.2h says that this allows for an empty
+         * parameter string to represent them.
          *
-         * We could either fudge it by dispatching zero params to SCOSC
-         * and anything else to DECSLRM, or, since we already implement
-         * DECSC/DECRC, we can just drop support for the extra SCOSC/SCORC.
-         * Do the latter.
+         * While the DEC manuals say that SCOSC/SCORC only operates in
+         * "SCO Console Mode" (which is entered by DECTME 13), and not in
+         * "VT mode" (i.e. native mode), we instead distinguish the cases
+         * by private mode DECLRMM: If DECLRMM is set, dispatch DECSLRM;
+         * if it's reset, dispatch SCOSC.
          *
-         * FIXMEchpe: Consider implementing this.
+         * See issue #48.
          */
+
+#ifdef PARSER_INCLUDE_NOP
+        if (m_modes_private.DECLRMM())
+                DECSLRM(seq);
+        else
+#endif
+                SCOSC(seq);
 }
 
 void
@@ -6723,12 +6740,32 @@ void
 Terminal::SCORC(vte::parser::Sequence const& seq)
 {
         /*
-         * SCORC - SCO restore-cursor
+         * SCORC - SCO restore cursor
+         * Works like DECRC, except in that it does not restore the page.
+         * While this is an obsolete sequence from an obsolete terminal,
+         * and not used in terminfo, there still are some programmes
+         * that use it and break when it's not implemented; see issue#48.
          *
          * References: VT525
+         */
+
+        restore_cursor();
+}
+
+void
+Terminal::SCOSC(vte::parser::Sequence const& seq)
+{
+        /*
+         * SCORC - SCO save cursor
+         * Works like DECSC, except in that it does not save the page.
+         * While this is an obsolete sequence from an obsolete terminal,
+         * and not used in terminfo, there still are some programmes
+         * that use it and break when it's not implemented; see issue#48.
          *
-         * Not worth implementing, given that we already support DECSC/DECRC.
+         * References: VT525
          */
+
+        save_cursor();
 }
 
 void


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