[vte/wip/egmont/bidi: 1/3] SCP



commit 8159dd09e957347876b29399fd4c4eee28467c66
Author: Egmont Koblinger <egmont gmail com>
Date:   Tue Nov 20 01:00:28 2018 +0100

    SCP

 BIDI-STATUS       |  8 ++++----
 doc/bidi.txt      | 50 +++++++++++++++++++++++++-------------------------
 src/parser-cmd.hh |  2 +-
 src/parser-csi.hh |  2 +-
 src/vteseq.cc     | 22 ++++++++++++++++++++++
 5 files changed, 53 insertions(+), 31 deletions(-)
---
diff --git a/BIDI-STATUS b/BIDI-STATUS
index aea647ee..27e5d656 100644
--- a/BIDI-STATUS
+++ b/BIDI-STATUS
@@ -1,6 +1,6 @@
 Done:
 - Implicit (level 1) and Explicit (a small subset only) modes (SM / RM 8).
-- Overall LTR or RTL direction (SPD 0 / 3).
+- Overall LTR or RTL direction (SPD 0 / 3 or SCP 1 / 2).
 - Possibility to autodetect paragraph direction (DECSET / DECRST 2501).
 - Possibility to make box drawing characters mirrorable (DECSET / DECRST 2500).
 - I-Beam cursor shows the character's resolved directionality when the
@@ -19,6 +19,7 @@ Bugs:
 - The way the modes apply to paragraphs, and what happens when a paragraph
   is split or two paragraphs are joined is just a first hack, needs to be
   reviewed, adjusted, fixed properly.
+- SPD should also update all the onscreen lines.
 
 Missing from first release:
 - The entire screen is always invalidated. Have some more fine grained
@@ -47,11 +48,10 @@ Not planned at all:
 - Operating on the presentation component (DCSM reset).
 - BiDi in explicit mode by transferring the embedding levels (SDS, SRS...).
 - Escape sequences that modify the emulation behavior (SIMD...).
-- Other silly escape sequences (SCP...).
 
 Useful aliases:
-  alias ltr='echo -ne "\e[0 S"'
-  alias rtl='echo -ne "\e[3 S"'
+  alias ltr='echo -ne "\e[1 k"'
+  alias rtl='echo -ne "\e[2 k"'
   alias implicit='echo -ne "\e[8h"'
   alias explicit='echo -ne "\e[8l"'
   alias bidi='echo -ne "\e[8h"'    # same as implicit
diff --git a/doc/bidi.txt b/doc/bidi.txt
index 3bd4b3ea..200b3b48 100644
--- a/doc/bidi.txt
+++ b/doc/bidi.txt
@@ -54,41 +54,41 @@ squares everywhere.
                                 └──────────────┘
 ⸤Hello⸣ ⸤Shlm⸣
                                                                   ⸢oi7w⸥ ⸢Hello⸥
-[3 S⸤Hello⸣ ⸤שָׁלוֹם⸣[0 S
+[2 k⸤Hello⸣ ⸤שָׁלוֹם⸣[1 k
 
 Hello01 ⸤Hello02⸣ Hello03 Shlm01 ⸤Shlm02⸣ Shlm03
                                 03oi7w ⸢02oi7w⸥ 01oi7w Hello01 ⸤Hello02⸣ Hello03
-[3 SHello01 ⸤Hello02⸣ Hello03 שָׁלוֹם01 ⸤שָׁלוֹם02⸣ שָׁלוֹם03[0 S
+[2 kHello01 ⸤Hello02⸣ Hello03 שָׁלוֹם01 ⸤שָׁלוֹם02⸣ שָׁלוֹם03[1 k
 
 ⸤Shlm⸣ ⸤Hello⸣
                                                                   ⸢Hello⸥ ⸢oi7w⸥
-[3 S⸤שָׁלוֹם⸣ ⸤Hello⸣[0 S
+[2 k⸤שָׁלוֹם⸣ ⸤Hello⸣[1 k
 
 Shlm01 ⸤Shlm02⸣ Shlm03 Hello01 ⸤Hello02⸣ Hello03
                                 Hello01 ⸤Hello02⸣ Hello03 03oi7w ⸢02oi7w⸥ 01oi7w
-[3 Sשָׁלוֹם01 ⸤שָׁלוֹם02⸣ שָׁלוֹם03 Hello01 ⸤Hello02⸣ Hello03[0 S
+[2 kשָׁלוֹם01 ⸤שָׁלוֹם02⸣ שָׁלוֹם03 Hello01 ⸤Hello02⸣ Hello03[1 k
 
 Paragraph with wrong direction (should look broken)
 w Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
                                 .incididunt ut labore et dolore magna aliqua oi7
-[3 SLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor שָׁלוֹם incididunt 
ut labore et dolore magna aliqua.[0 S
+[2 kLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor שָׁלוֹם incididunt 
ut labore et dolore magna aliqua.[1 k
 
 Double wide
                                                                       a<z  n>x
-[3 Sא<ת  a<z[0 S
+[2 kא<ת  a<z[1 k
 
 Old Hungarian Rovásírás
 (font at https://github.com/OldHungarian/old-hungarian-font)
                                                          ΛᛩHTΛᛩMↄH ↄ4TH4Λↄ¤ᛝ +ΛↃ
-[3 S𐲛𐳖𐳇 𐲏𐳪𐳙𐳍𐳀𐳢𐳐𐳀𐳙 𐲢𐳛𐳮𐳁𐳤𐳑𐳢𐳁𐳤[0 S
+[2 k𐲛𐳖𐳇 𐲏𐳪𐳙𐳍𐳀𐳢𐳐𐳀𐳙 𐲢𐳛𐳮𐳁𐳤𐳑𐳢𐳁𐳤[1 k
 
 Box
-                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[3 S
-┛━┗   א╝═╚ת  a└─┘z   ╯─╰[0 S
+                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[2 k
+┛━┗   א╝═╚ת  a└─┘z   ╯─╰[1 k
 
 Box in mirrored mode
-                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[3 S[?2500h
-┗━┛   א╚═╝ת  a└─┘z   ╰─╯[?2500l[0 S
+                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[2 k[?2500h
+┗━┛   א╚═╝ת  a└─┘z   ╰─╯[?2500l[1 k
 
                         ┌──────────────────────────────┐
 ────────────────────────┤ Implicit auto (LTR fallback) ├────────────────────────
@@ -119,24 +119,24 @@ squares everywhere.
                         └──────────────────────────────┘
 ⸤Hello⸣ ⸤Shlm⸣
 ⸤Hello⸣ ⸤oi7w⸣
-[3 S[?2501h⸤Hello⸣ ⸤שָׁלוֹם⸣[?2501l[0 S
+[2 k[?2501h⸤Hello⸣ ⸤שָׁלוֹם⸣[?2501l[1 k
 
 ⸤Shlm⸣ ⸤Hello⸣
                                                                   ⸢Hello⸥ ⸢oi7w⸥
-[3 S[?2501h⸤שָׁלוֹם⸣ ⸤Hello⸣[?2501l[0 S
+[2 k[?2501h⸤שָׁלוֹם⸣ ⸤Hello⸣[?2501l[1 k
 
 Paragraph wrapping at foreign word
 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor w
 oi7 incididunt ut labore et dolore magna aliqua.
-[3 S[?2501hLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor שָׁלוֹם 
incididunt ut labore et dolore magna aliqua.[?2501l[0 S
+[2 k[?2501hLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor שָׁלוֹם 
incididunt ut labore et dolore magna aliqua.[?2501l[1 k
 
 Box
-                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[3 S[?2501h
-┛━┗   א╝═╚ת  a└─┘z   ╯─╰[?2501l[0 S
+                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[2 k[?2501h
+┛━┗   א╝═╚ת  a└─┘z   ╯─╰[?2501l[1 k
 
 Box in mirrored mode
-                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[3 S[?2501h[?2500h
-┗━┛   א╚═╝ת  a└─┘z   ╰─╯[?2500l[?2501l[0 S
+                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[2 k[?2501h[?2500h
+┗━┛   א╚═╝ת  a└─┘z   ╰─╯[?2500l[?2501l[1 k
 
                                 ┌──────────────┐
 ────────────────────────────────┤ Explicit LTR ├────────────────────────────────
@@ -162,22 +162,22 @@ squares everywhere.
                                 └──────────────┘
 ⸤olleH⸣ ⸤Shlm⸣
                                                                   ⸢oi7w⸥ ⸢Hello⸥
-[3 S⸤olleH⸣ ⸤שָׁלוֹם⸣[0 S
+[2 k⸤olleH⸣ ⸤שָׁלוֹם⸣[1 k
 
 ⸤Shlm⸣ ⸤olleH⸣
                                                                   ⸢Hello⸥ ⸢oi7w⸥
-[3 S⸤שָׁלוֹם⸣ ⸤olleH⸣[0 S
+[2 k⸤שָׁלוֹם⸣ ⸤olleH⸣[1 k
 
 Fullwidth characters with underlines
                         [Lorem  ipsum  dolor  sit  [4:3mamet)
-[3 S[4:3m(tema  tis  rolod  muspi  meroL][0 S
+[2 k[4:3m(tema  tis  rolod  muspi  meroL][1 k
 
 Box
-                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[3 S
-┛━┗   א╝═╚ת  z┘─└a   ╯─╰[0 S
+                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[2 k
+┛━┗   א╝═╚ת  z┘─└a   ╯─╰[1 k
 
 Box in mirrored mode
-                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[3 S[?2500h
-┗━┛   א╚═╝ת  z└─┘a   ╰─╯[?2500l[0 S
+                                                        ╭─╮   a┌─┐z  n╔═╗x   ┏━┓[2 k[?2500h
+┗━┛   א╚═╝ת  z└─┘a   ╰─╯[?2500l[1 k
 
 ────────────────────────────────────────────────────────────────────────────────
diff --git a/src/parser-cmd.hh b/src/parser-cmd.hh
index 8299a002..c562d7c0 100644
--- a/src/parser-cmd.hh
+++ b/src/parser-cmd.hh
@@ -104,6 +104,7 @@ _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(SCP) /* select character path */
 _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 */
@@ -277,7 +278,6 @@ _VTE_NOP(RLOGIN_MML) /* RLogin music macro language */
 _VTE_NOP(SACS) /* set additional character separation */
 _VTE_NOP(SAPV) /* select alternative presentation variants */
 _VTE_NOP(SCO) /* select character orientation */
-_VTE_NOP(SCP) /* select character path */
 _VTE_NOP(SCS) /* set character spacing */
 _VTE_NOP(SDS) /* start directed string */
 _VTE_NOP(SEE) /* select editing extent */
diff --git a/src/parser-csi.hh b/src/parser-csi.hh
index 5a21f4b7..53e1f1f8 100644
--- a/src/parser-csi.hh
+++ b/src/parser-csi.hh
@@ -114,7 +114,7 @@ _VTE_NOQ(MC_DEC,                 CSI,    'i',  WHAT,  0, NONE     ) /* media-cop
 _VTE_NOQ(HPB,                    CSI,    'j',  NONE,  0, NONE     ) /* horizontal position backward */
 _VTE_NOQ(SPL,                    CSI,    'j',  NONE,  1, SPACE    ) /* set page limit */
 _VTE_NOQ(VPB,                    CSI,    'k',  NONE,  0, NONE     ) /* line position backward */
-_VTE_NOQ(SCP,                    CSI,    'k',  NONE,  1, SPACE    ) /* select character path */
+_VTE_SEQ(SCP,                    CSI,    'k',  NONE,  1, SPACE    ) /* select character path */
 _VTE_SEQ(RM_ECMA,                CSI,    'l',  NONE,  0, NONE     ) /* reset-mode-ecma */
 _VTE_SEQ(RM_DEC,                 CSI,    'l',  WHAT,  0, NONE     ) /* reset-mode-dec */
 _VTE_SEQ(SGR,                    CSI,    'm',  NONE,  0, NONE     ) /* select-graphics-rendition */
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 90365006..51f5310f 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -6913,7 +6913,27 @@ Terminal::SCP(vte::parser::Sequence const& seq)
          *   args[1]: no default
          *
          * References: ECMA-48 § 8.3.111
+         *             [FIXME link to our spec]
          */
+
+        auto const param = seq.collect1(0);
+        switch (param) {
+        case 1:
+                m_bidi_rtl = FALSE;
+                _vte_debug_print(VTE_DEBUG_BIDI, "BiDi: switch to LTR\n");
+                break;
+        case 2:
+                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;
+        }
+
+        maybe_apply_bidi_attributes();  // FIXME only apply the one that changed here?
 }
 
 void
@@ -7403,6 +7423,8 @@ Terminal::SPD(vte::parser::Sequence const& seq)
         }
 
         maybe_apply_bidi_attributes();  // FIXME only apply the one that changed here?
+
+        // FIXME apply to all the onscreen lines!
 }
 
 void


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