[vte/wip/egmont/bidi: 9/107] cursor



commit 85a1b765784ec0a80d0002ec4ceeffdebdb757e7
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 27bb763e..098dbe4e 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -431,6 +431,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,
@@ -9128,7 +9144,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);
@@ -9137,7 +9154,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 9571ceee..c8da7da0 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -623,6 +623,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]