[vte/wip/egmont/bidi: 19/75] carry bidi_flags together



commit 96d7d22c00951d45327e39d2793c129ac8d2dea3
Author: Egmont Koblinger <egmont gmail com>
Date:   Sun Aug 19 21:48:38 2018 +0200

    carry bidi_flags together

 src/ring.cc        |  7 ++++---
 src/ring.hh        |  8 ++++----
 src/vte.cc         | 26 +++++++++++++++-----------
 src/vteinternal.hh |  7 +++++++
 src/vterowdata.hh  |  4 +---
 src/vteseq.cc      |  2 +-
 6 files changed, 32 insertions(+), 22 deletions(-)
---
diff --git a/src/ring.cc b/src/ring.cc
index fc78ce53..40c18890 100644
--- a/src/ring.cc
+++ b/src/ring.cc
@@ -840,7 +840,7 @@ Ring::shrink(row_t max_len)
  * Return: the newly added row.
  */
 VteRowData*
-Ring::insert(row_t position)
+Ring::insert(row_t position, guint8 bidi_flags)
 {
        row_t i;
        VteRowData* row, tmp;
@@ -862,6 +862,7 @@ Ring::insert(row_t position)
        *get_writable_index(position) = tmp;
 
        row = get_writable_index(position);
+       row->attr.bidi_flags = bidi_flags;
        _vte_row_data_clear (row);
        m_end++;
 
@@ -912,9 +913,9 @@ Ring::remove(row_t position)
  * Return: the newly added row.
  */
 VteRowData*
-Ring::append()
+Ring::append(guint8 bidi_flags)
 {
-       return insert(next());
+       return insert(next(), bidi_flags);
 }
 
 
diff --git a/src/ring.hh b/src/ring.hh
index 1b17ca7a..a5af734a 100644
--- a/src/ring.hh
+++ b/src/ring.hh
@@ -85,8 +85,8 @@ public:
         row_t reset();
         void resize(row_t max_rows = kDefaultMaxRows);
         void shrink(row_t max_len = kDefaultMaxRows);
-        VteRowData* insert(row_t position);
-        VteRowData* append();
+        VteRowData* insert(row_t position, guint8 bidi_flags);
+        VteRowData* append(guint8 bidi_flags);
         void remove(row_t position);
         void drop_scrollback(row_t position);
         void set_visible_rows(row_t rows);
@@ -248,8 +248,8 @@ static inline auto _vte_ring_get_hyperlink_at_position (VteRing *ring, gulong po
 static inline long _vte_ring_reset (VteRing *ring) { return ring->reset(); }
 static inline void _vte_ring_resize (VteRing *ring, gulong max_rows) { ring->resize(max_rows); }
 static inline void _vte_ring_shrink (VteRing *ring, gulong max_len) { ring->shrink(max_len); }
-static inline VteRowData *_vte_ring_insert (VteRing *ring, gulong position) { return ring->insert(position); 
}
-static inline VteRowData *_vte_ring_append (VteRing *ring) { return ring->append(); }
+static inline VteRowData *_vte_ring_insert (VteRing *ring, gulong position, guint8 bidi_flags) { return 
ring->insert(position, bidi_flags); }
+static inline VteRowData *_vte_ring_append (VteRing *ring, guint8 bidi_flags) { return 
ring->append(bidi_flags); }
 static inline void _vte_ring_remove (VteRing *ring, gulong position) { ring->remove(position); }
 static inline void _vte_ring_drop_scrollback (VteRing *ring, gulong position) { 
ring->drop_scrollback(position); }
 static inline void _vte_ring_set_visible_rows (VteRing *ring, gulong rows) { ring->set_visible_rows(rows); }
diff --git a/src/vte.cc b/src/vte.cc
index 82b4081e..f5ab2c44 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -140,11 +140,11 @@ Terminal::ring_insert(vte::grid::row_t position,
         bool const not_default_bg = (m_fill_defaults.attr.back() != VTE_DEFAULT_BG);
 
        while (G_UNLIKELY (_vte_ring_next (ring) < position)) {
-               row = _vte_ring_append (ring);
+               row = _vte_ring_append (ring, get_bidi_flags());
                 if (not_default_bg)
                         _vte_row_data_fill (row, &m_fill_defaults, m_column_count);
        }
-       row = _vte_ring_insert (ring, position);
+       row = _vte_ring_insert (ring, position, get_bidi_flags());
         if (fill && not_default_bg)
                 _vte_row_data_fill (row, &m_fill_defaults, m_column_count);
        return row;
@@ -443,7 +443,7 @@ Terminal::find_charcell_bidi(vte::grid::column_t col,
        if (_vte_ring_contains(m_screen->row_data, row)) {
                rowdata = _vte_ring_index(m_screen->row_data, row);
                ret = _vte_row_data_get (rowdata, col);
-               *rtl = rowdata->attr.bidi_rtl;
+               *rtl = rowdata->attr.bidi_flags & VTE_BIDI_RTL;
        }
        return ret;
 }
@@ -2881,9 +2881,7 @@ Terminal::insert_char(gunichar c,
                         cursor_down(false);
 
                         row2 = ensure_row();
-                        row2->attr.bidi_implicit = row->attr.bidi_implicit;
-                        row2->attr.bidi_rtl      = row->attr.bidi_rtl;
-                        row2->attr.bidi_auto     = row->attr.bidi_auto;
+                        row2->attr.bidi_flags = row->attr.bidi_flags;
                } else {
                        /* Don't wrap, stay at the rightmost column. */
                         col = m_screen->cursor.col =
@@ -3030,6 +3028,14 @@ not_inserted:
         m_line_wrapped = line_wrapped;
 }
 
+guint8
+Terminal::get_bidi_flags()
+{
+        return (m_modes_ecma.BDSM() ? VTE_BIDI_IMPLICIT : 0) |
+               (m_bidi_rtl ? VTE_BIDI_RTL : 0) |
+               (m_bidi_auto ? VTE_BIDI_AUTO : 0);
+}
+
 /* Apply the BiDi parameters on the current paragraph if the cursor
  * is at the first position of this paragraph. */
 void
@@ -3062,9 +3068,7 @@ Terminal::maybe_apply_bidi_attributes()
                 VteRowData *rowdata = _vte_ring_index_writable (m_screen->row_data, row);
                 if (rowdata == nullptr)
                         return;
-                rowdata->attr.bidi_implicit = m_modes_ecma.BDSM();
-                rowdata->attr.bidi_rtl = m_bidi_rtl;
-                rowdata->attr.bidi_auto = m_bidi_auto;
+                rowdata->attr.bidi_flags = get_bidi_flags();
                 if (!rowdata->attr.soft_wrapped)
                         return;
                 row++;
@@ -8992,7 +8996,7 @@ Terminal::draw_cells_with_attributes(struct _vte_draw_text_request *items,
 
 /* XXX tmp hack */
 #define _vte_row_data_get_bidi(row_data_p, col) \
-    (_vte_row_data_get ((row_data_p), ((row_data_p)->attr.bidi_rtl ? (m_column_count - 1 - (col)) : (col))))
+    (_vte_row_data_get ((row_data_p), (((row_data_p)->attr.bidi_flags & VTE_BIDI_RTL) ? (m_column_count - 1 
- (col)) : (col))))
 
 
 /* Paint the contents of a given row at the given location.  Take advantage
@@ -9419,7 +9423,7 @@ Terminal::paint_cursor()
 
         /* Find the first cell of the character "under" the cursor.
          * This is for CJK.  For TAB, paint the cursor where it really is. */
-        gboolean rtl;
+        gboolean rtl = FALSE;
        auto cell = find_charcell_bidi(col, drow, &rtl);
         while (cell != NULL && cell->attr.fragment() && cell->c != '\t' && col > 0) {
                col--;
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index e9ff23d7..541a0c2a 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -122,6 +122,12 @@ enum {
         VTE_SGR_COLOR_SPEC_LEGACY = 5
 };
 
+enum {
+        VTE_BIDI_IMPLICIT = 1 << 0,
+        VTE_BIDI_RTL      = 1 << 1,
+        VTE_BIDI_AUTO     = 1 << 2,
+};
+
 struct vte_regex_and_flags {
         VteRegex *regex;
         guint32 match_flags;
@@ -689,6 +695,7 @@ public:
         void invalidate_selection();
         void invalidate_all();
 
+        guint8 get_bidi_flags();
         void maybe_apply_bidi_attributes();
 
         void reset_update_rects();
diff --git a/src/vterowdata.hh b/src/vterowdata.hh
index e35f7ab7..b84e55b8 100644
--- a/src/vterowdata.hh
+++ b/src/vterowdata.hh
@@ -37,9 +37,7 @@ G_BEGIN_DECLS
 
 typedef struct _VteRowAttr {
         guint8 soft_wrapped  : 1;
-        guint8 bidi_implicit : 1;
-        guint8 bidi_rtl      : 1;
-        guint8 bidi_auto     : 1;
+        guint8 bidi_flags    : 3;
 } VteRowAttr;
 static_assert(sizeof (VteRowAttr) == 1, "VteRowAttr has wrong size");
 
diff --git a/src/vteseq.cc b/src/vteseq.cc
index b88700b8..cb7c84a3 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -4671,7 +4671,7 @@ Terminal::DECSTBM(vte::parser::Sequence const& seq)
        } else {
                /* Maybe extend the ring -- bug 710483 */
                 while (_vte_ring_next(m_screen->row_data) < m_screen->insert_delta + m_row_count)
-                        _vte_ring_insert(m_screen->row_data, _vte_ring_next(m_screen->row_data));
+                        _vte_ring_insert(m_screen->row_data, _vte_ring_next(m_screen->row_data), 
get_bidi_flags());
        }
 
         home_cursor();


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