[vte/wip/egmont/bidi: 12/21] paint log vs vis confusion



commit 0c054ddd6734494a7cc4046f144dcd68006fa9ad
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri May 24 15:48:46 2019 +0200

    paint log vs vis confusion

 src/vte.cc | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 4d164d45..242e5e78 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -9138,7 +9138,7 @@ Terminal::draw_rows(VteScreen *screen_,
 {
         struct _vte_draw_text_request *items;
         vte::grid::row_t row;
-        vte::grid::column_t i, j, col;
+        vte::grid::column_t i, j, lcol, vcol;
         int y;
         guint fore = VTE_DEFAULT_FG, nfore, back = VTE_DEFAULT_BG, nback, deco = VTE_DEFAULT_FG, ndeco;
         gboolean hyperlink = FALSE, nhyperlink, hilite = FALSE, nhilite;
@@ -9258,17 +9258,15 @@ Terminal::draw_rows(VteScreen *screen_,
 
                 bidirow = m_ringview.get_row_map(row);
 
-                /* Walk the line.
+                /* Walk the line in logical order.
                  * Locate runs of identical attributes within a row, and draw each run using a single 
draw_cells() call. */
                 item_count = 0;
-                for (col = 0; col < column_count; ) {
+                for (lcol = 0; lcol < row_data->len && lcol < column_count; ) {
+                        vcol = bidirow->log2vis(lcol);
+
                         /* Get the character cell's contents. */
-                        cell = _vte_row_data_get_visual (row_data, bidirow, col);
-                        if (cell == NULL) {
-                                /* We're rendering BiDi text in visual order, so an unused cell can be 
followed by a used one. */
-                                col++;
-                                continue;
-                        }
+                        cell = _vte_row_data_get (row_data, lcol);
+                        g_assert(cell != nullptr);
 
                         nhyperlink = (m_allow_hyperlink && cell->attr.hyperlink_idx != 0);
                         if (cell->c == 0 ||
@@ -9280,17 +9278,17 @@ Terminal::draw_rows(VteScreen *screen_,
                             cell->attr.fragment() ||
                             cell->attr.invisible()) {
                                 /* Skip empty or fragment cell. */
-                                col++;
+                                lcol++;
                                 continue;
                         }
 
                         /* Find the colors for this cell. */
                         nattr = cell->attr.attr;
-                        selected = cell_is_selected_vis(col, row);
+                        selected = cell_is_selected_vis(vcol, row);
                         determine_colors(cell, selected, &nfore, &nback, &ndeco);
 
                         nhilite = (nhyperlink && cell->attr.hyperlink_idx == m_hyperlink_hover_idx) ||
-                                  (!nhyperlink && m_match != nullptr && m_match_span.contains(row, 
bidirow->vis2log(col)));
+                                  (!nhyperlink && m_match != nullptr && m_match_span.contains(row, lcol));
 
                         /* See if it no longer fits the run. */
                         if (item_count > 0 &&
@@ -9317,16 +9315,16 @@ Terminal::draw_rows(VteScreen *screen_,
 
                         /* Combine with subsequent spacing marks. */
                         vteunistr c = cell->c;
-                        j = col + cell->attr.columns();
-                        if (G_UNLIKELY (col == 0 && g_unichar_ismark (_vte_unistr_get_base (cell->c)))) {
+                        j = lcol + cell->attr.columns();
+                        if (G_UNLIKELY (lcol == 0 && g_unichar_ismark (_vte_unistr_get_base (cell->c)))) {
                                 /* A rare special case: the first cell contains a spacing mark.
                                  * Place on top of a NBSP, along with additional spacing marks if any,
                                  * and display beginning at offscreen column -1.
                                  * Additional spacing marks, if any, will be combined by the loop below. */
                                 c = _vte_unistr_append_unistr (0x00A0, cell->c);
-                                col = -1;
+                                lcol = -1;
                         }
-                        while (j < m_column_count) {
+                        while (j < row_data->len && j < column_count) {
                                 /* Combine with subsequent spacing marks. */
                                 cell = _vte_row_data_get (row_data, j);
                                 if (cell && !cell->attr.fragment() && g_unichar_ismark (_vte_unistr_get_base 
(cell->c))) {
@@ -9345,16 +9343,16 @@ Terminal::draw_rows(VteScreen *screen_,
                         hilite = nhilite;
 
                         g_assert_cmpint (item_count, <, column_count);
-                        items[item_count].c = bidirow->vis_get_shaped_char(col, c);
-                        items[item_count].columns = j - col;
-                        items[item_count].x = (col - (bidirow->vis_is_rtl(col) ? j - col - 1 : 0)) * 
column_width;
+                        items[item_count].c = bidirow->vis_get_shaped_char(vcol, c);
+                        items[item_count].columns = j - lcol;
+                        items[item_count].x = (vcol - (bidirow->vis_is_rtl(vcol) ? items[item_count].columns 
- 1 : 0)) * column_width;
                         items[item_count].y = y;
-                        items[item_count].mirror = bidirow->vis_is_rtl(col);
+                        items[item_count].mirror = bidirow->vis_is_rtl(vcol);
                         items[item_count].box_mirror = !!(row_data->attr.bidi_flags & VTE_BIDI_BOX_MIRROR);
                         item_count++;
 
-                        g_assert_cmpint (j, >, col);
-                        col = j;
+                        g_assert_cmpint (j, >, lcol);
+                        lcol = j;
                 }
 
                 /* Draw the last run of cells in the row. */


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