[vte/wip/egmont/bidi: 94/105] apply the relevant bidi flag only



commit 064b9ed88aa689bf7f0e1cb58d8a0e0b3542347a
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri Dec 7 13:07:56 2018 +0100

    apply the relevant bidi flag only

 src/vte.cc         | 18 +++++++++++-------
 src/vteinternal.hh |  5 +++--
 src/vteseq.cc      | 14 +++++++-------
 3 files changed, 21 insertions(+), 16 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index e9c544a9..2e470909 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -2888,7 +2888,7 @@ Terminal::insert_char(gunichar c,
                        row->attr.soft_wrapped = 1;
                         cursor_down(false);
                         ensure_row();
-                        apply_bidi_attributes(m_screen->cursor.row, row->attr.bidi_flags);
+                        apply_bidi_attributes(m_screen->cursor.row, row->attr.bidi_flags, VTE_BIDI_ALL);
                } else {
                        /* Don't wrap, stay at the rightmost column. */
                         col = m_screen->cursor.col =
@@ -3041,10 +3041,12 @@ Terminal::get_bidi_flags()
 
 /* Apply the specified BiDi parameters on the paragraph beginning at the specified line. */
 void
-Terminal::apply_bidi_attributes(vte::grid::row_t row, guint8 bidi_flags)
+Terminal::apply_bidi_attributes(vte::grid::row_t row, guint8 bidi_flags, guint8 bidi_flags_mask)
 {
         VteRowData *rowdata;
 
+        bidi_flags &= bidi_flags_mask;
+
         while (true) {
                 rowdata = _vte_ring_index_writable (m_screen->row_data, row);
                 if (rowdata == nullptr)
@@ -3053,7 +3055,9 @@ Terminal::apply_bidi_attributes(vte::grid::row_t row, guint8 bidi_flags)
                 _vte_debug_print(VTE_DEBUG_BIDI,
                                  "Applying BiDi parameters on row %ld.\n", row);
 
-                rowdata->attr.bidi_flags = bidi_flags;
+                rowdata->attr.bidi_flags &= ~bidi_flags_mask;
+                rowdata->attr.bidi_flags |= bidi_flags;
+
                 invalidate_row(row);
                 if (!rowdata->attr.soft_wrapped)
                         return;
@@ -3061,10 +3065,10 @@ Terminal::apply_bidi_attributes(vte::grid::row_t row, guint8 bidi_flags)
         }
 }
 
-/* Apply the current BiDi parameters on the current paragraph if the cursor
- * is at the first position of this paragraph. */
+/* Apply the current BiDi parameters covered by bidi_flags_mask on the current paragraph
+ * if the cursor is at the first position of this paragraph. */
 void
-Terminal::maybe_apply_current_bidi_attributes()
+Terminal::maybe_apply_bidi_attributes(guint8 bidi_flags_mask)
 {
         _vte_debug_print(VTE_DEBUG_BIDI,
                          "Maybe applying BiDi parameters on current paragraph.\n");
@@ -3089,7 +3093,7 @@ Terminal::maybe_apply_current_bidi_attributes()
         _vte_debug_print(VTE_DEBUG_BIDI,
                          "Yes, applying.\n");
 
-        apply_bidi_attributes (row, get_bidi_flags());
+        apply_bidi_attributes (row, get_bidi_flags(), bidi_flags_mask);
 }
 
 static void
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 33aa1746..73211e11 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -92,6 +92,7 @@ enum {
         VTE_BIDI_RTL        = 1 << 1,
         VTE_BIDI_AUTO       = 1 << 2,
         VTE_BIDI_BOX_MIRROR = 1 << 3,
+        VTE_BIDI_ALL        = (1 << 4) - 1,
 };
 
 struct vte_regex_and_flags {
@@ -653,8 +654,8 @@ public:
         void invalidate_all();
 
         guint8 get_bidi_flags();
-        void apply_bidi_attributes(vte::grid::row_t row, guint8 bidi_flags);
-        void maybe_apply_current_bidi_attributes();
+        void apply_bidi_attributes(vte::grid::row_t row, guint8 bidi_flags, guint8 bidi_flags_mask);
+        void maybe_apply_bidi_attributes(guint8 bidi_flags_mask);
 
         void reset_update_rects();
         bool invalidate_dirty_rects_and_process_updates();
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 16867725..e8404699 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -463,7 +463,7 @@ Terminal::set_mode_ecma(vte::parser::Sequence const& seq,
                         _vte_debug_print(VTE_DEBUG_BIDI,
                                          "BiDi %s mode\n",
                                          set ? "implicit" : "explicit");
-                        maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed 
here?
+                        maybe_apply_bidi_attributes(VTE_BIDI_IMPLICIT);
                 }
         }
 }
@@ -597,14 +597,14 @@ Terminal::set_mode_private(int mode,
                 _vte_debug_print(VTE_DEBUG_BIDI,
                                  "BiDi box drawing mirroring %s\n",
                                  set ? "enabled" : "disabled");
-                maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed here?
+                maybe_apply_bidi_attributes(VTE_BIDI_BOX_MIRROR);
                 break;
 
         case vte::terminal::modes::Private::eVTE_BIDI_AUTO:
                         _vte_debug_print(VTE_DEBUG_BIDI,
                                          "BiDi dir autodetection %s\n",
                                          set ? "enabled" : "disabled");
-                maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed here?
+                maybe_apply_bidi_attributes(VTE_BIDI_AUTO);
                 break;
 
         default:
@@ -1034,7 +1034,7 @@ Terminal::line_feed()
 {
         ensure_cursor_is_onscreen();
         cursor_down(true);
-        maybe_apply_current_bidi_attributes();
+        maybe_apply_bidi_attributes(VTE_BIDI_ALL);
 }
 
 void
@@ -6933,7 +6933,7 @@ Terminal::SCP(vte::parser::Sequence const& seq)
                 break;
         }
 
-        maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed here?
+        maybe_apply_bidi_attributes(VTE_BIDI_RTL);
 }
 
 void
@@ -7422,9 +7422,9 @@ Terminal::SPD(vte::parser::Sequence const& seq)
                 break;
         }
 
-        maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed here?
+        maybe_apply_bidi_attributes(VTE_BIDI_RTL);
 
-        // FIXME apply to all the onscreen lines!
+        // FIXME apply to all the onscreen lines?
 }
 
 void


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