[vte/wip/egmont/bidi: 8/83] cursor



commit 328cf82b94dbe9f3b18092849fae31e7848b850c
Author: Egmont Koblinger <egmont gmail com>
Date:   Sat Aug 18 17:21:21 2018 +0200

    cursor

 src/vte.cc         | 21 +++++++++++++++++++--
 src/vteinternal.hh |  3 +++
 2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index c2091290..5b5bc45a 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -415,6 +415,22 @@ Terminal::find_charcell(vte::grid::column_t col,
        return ret;
 }
 
+VteCell const*
+Terminal::find_charcell_bidi(vte::grid::column_t col,
+                                  vte::grid::row_t row,
+                                  gboolean *rtl) const
+{
+       VteRowData const* rowdata;
+       VteCell const* ret = nullptr;
+
+       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;
+       }
+       return ret;
+}
+
 // FIXMEchpe replace this with a method on VteRing
 vte::grid::column_t
 Terminal::find_start_column(vte::grid::column_t col,
@@ -9101,7 +9117,8 @@ 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. */
-       auto cell = find_charcell(col, drow);
+        gboolean rtl;
+       auto cell = find_charcell_bidi(col, drow, &rtl);
         while (cell != NULL && cell->attr.fragment() && cell->c != '\t' && col > 0) {
                col--;
                cell = find_charcell(col, drow);
@@ -9110,7 +9127,7 @@ Terminal::paint_cursor()
        /* Draw the cursor. */
        item.c = (cell && cell->c) ? cell->c : ' ';
        item.columns = item.c == '\t' ? 1 : cell ? cell->attr.columns() : 1;
-       item.x = col * width;
+       item.x = (rtl ? m_column_count - 1 - col : col) * width;
        item.y = row_to_pixel(drow);
        if (cell && cell->c != 0) {
                style = _vte_draw_get_style(cell->attr.bold(), cell->attr.italic());
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index ab396b8b..d254fe13 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -607,6 +607,9 @@ public:
         inline VteRowData* find_row_data_writable(vte::grid::row_t row) const;
         inline VteCell const* find_charcell(vte::grid::column_t col,
                                             vte::grid::row_t row) const;
+        inline VteCell const* find_charcell_bidi(vte::grid::column_t col,
+                                            vte::grid::row_t row,
+                                            gboolean *rtl) const;
         inline vte::grid::column_t find_start_column(vte::grid::column_t col,
                                                      vte::grid::row_t row) const;
         inline vte::grid::column_t find_end_column(vte::grid::column_t col,


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