[vte/wip/egmont/bidi: 76/83] apply bidi params on wrap



commit ade8d0e4803019a6d7459eb8ccdef142bec99de9
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri Dec 7 12:50:10 2018 +0100

    apply bidi params on wrap

 src/vte.cc         | 44 ++++++++++++++++++++++++++++----------------
 src/vteinternal.hh |  3 ++-
 src/vteseq.cc      | 12 ++++++------
 3 files changed, 36 insertions(+), 23 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index b26e69ec..6e944c46 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -2817,7 +2817,7 @@ Terminal::insert_char(gunichar c,
                                 bool invalidate_now)
 {
        VteCellAttr attr;
-       VteRowData *row, *row2;
+       VteRowData *row;
        long col;
        int columns, i;
        bool line_wrapped = false; /* cursor moved before char inserted */
@@ -2887,9 +2887,8 @@ Terminal::insert_char(gunichar c,
                        row = ensure_row();
                        row->attr.soft_wrapped = 1;
                         cursor_down(false);
-
-                        row2 = ensure_row();
-                        row2->attr.bidi_flags = row->attr.bidi_flags;
+                        ensure_row();
+                        apply_bidi_attributes(m_screen->cursor.row, row->attr.bidi_flags);
                } else {
                        /* Don't wrap, stay at the rightmost column. */
                         col = m_screen->cursor.col =
@@ -3040,10 +3039,32 @@ Terminal::get_bidi_flags()
                (m_modes_private.VTE_BOX_DRAWING_MIRROR() ? VTE_BIDI_BOX_MIRROR : 0);
 }
 
-/* Apply the BiDi parameters on the current paragraph if the cursor
+/* 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)
+{
+        VteRowData *rowdata;
+
+        while (true) {
+                rowdata = _vte_ring_index_writable (m_screen->row_data, row);
+                if (rowdata == nullptr)
+                        return;
+
+                _vte_debug_print(VTE_DEBUG_BIDI,
+                                 "Applying BiDi parameters on row %ld.\n", row);
+
+                rowdata->attr.bidi_flags = bidi_flags;
+                invalidate_row(row);
+                if (!rowdata->attr.soft_wrapped)
+                        return;
+                row++;
+        }
+}
+
+/* Apply the current BiDi parameters on the current paragraph if the cursor
  * is at the first position of this paragraph. */
 void
-Terminal::maybe_apply_bidi_attributes()
+Terminal::maybe_apply_current_bidi_attributes()
 {
         _vte_debug_print(VTE_DEBUG_BIDI,
                          "Maybe applying BiDi parameters on current paragraph.\n");
@@ -3068,16 +3089,7 @@ Terminal::maybe_apply_bidi_attributes()
         _vte_debug_print(VTE_DEBUG_BIDI,
                          "Yes, applying.\n");
 
-        while (TRUE) {
-                VteRowData *rowdata = _vte_ring_index_writable (m_screen->row_data, row);
-                if (rowdata == nullptr)
-                        return;
-                rowdata->attr.bidi_flags = get_bidi_flags();
-                invalidate_row(row);
-                if (!rowdata->attr.soft_wrapped)
-                        return;
-                row++;
-        }
+        apply_bidi_attributes (row, get_bidi_flags());
 }
 
 static void
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index cae7b1fd..33aa1746 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -653,7 +653,8 @@ public:
         void invalidate_all();
 
         guint8 get_bidi_flags();
-        void maybe_apply_bidi_attributes();
+        void apply_bidi_attributes(vte::grid::row_t row, guint8 bidi_flags);
+        void maybe_apply_current_bidi_attributes();
 
         void reset_update_rects();
         bool invalidate_dirty_rects_and_process_updates();
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 51f5310f..16867725 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_bidi_attributes();  // FIXME only apply the one that changed here?
+                        maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed 
here?
                 }
         }
 }
@@ -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_bidi_attributes();  // FIXME only apply the one that changed here?
+                maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed here?
                 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_bidi_attributes();  // FIXME only apply the one that changed here?
+                maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed here?
                 break;
 
         default:
@@ -1034,7 +1034,7 @@ Terminal::line_feed()
 {
         ensure_cursor_is_onscreen();
         cursor_down(true);
-        maybe_apply_bidi_attributes();
+        maybe_apply_current_bidi_attributes();
 }
 
 void
@@ -6933,7 +6933,7 @@ Terminal::SCP(vte::parser::Sequence const& seq)
                 break;
         }
 
-        maybe_apply_bidi_attributes();  // FIXME only apply the one that changed here?
+        maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed here?
 }
 
 void
@@ -7422,7 +7422,7 @@ Terminal::SPD(vte::parser::Sequence const& seq)
                 break;
         }
 
-        maybe_apply_bidi_attributes();  // FIXME only apply the one that changed here?
+        maybe_apply_current_bidi_attributes();  // FIXME only apply the one that changed here?
 
         // FIXME apply to all the onscreen lines!
 }


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