[vte/wip/egmont/bidi: 38/76] debug: highlight RTL chars



commit d8b3ef3163e07a906ce2660a2edc1f036a4c854e
Author: Egmont Koblinger <egmont gmail com>
Date:   Mon Aug 27 01:54:17 2018 +0200

    debug: highlight RTL chars

 src/vte.cc | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 78d6ee98..7d940b1b 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -8791,6 +8791,7 @@ Terminal::draw_rows(VteScreen *screen_,
         guint fore, nfore, back, nback, deco, ndeco;
         gboolean hyperlink = FALSE, nhyperlink, hilite = FALSE, nhilite;
         gboolean selected;
+        gboolean nrtl = FALSE, rtl;  /* for debugging */
         uint32_t attr = 0, nattr;
        guint item_count;
        const VteCell *cell;
@@ -8830,6 +8831,7 @@ Terminal::draw_rows(VteScreen *screen_,
                         /* Find the colors for this cell. */
                         selected = cell_is_selected(i, row);
                         determine_colors(cell, selected, &fore, &back, &deco);
+                        rtl = bidimap[i].vis_rtl;
 
                         while (++j < column_count) {
                                 /* Retrieve the next cell. */
@@ -8839,7 +8841,8 @@ Terminal::draw_rows(VteScreen *screen_,
                                  * in this chunk. */
                                 selected = cell_is_selected(j, row);
                                 determine_colors(cell, selected, &nfore, &nback, &ndeco);
-                                if (nback != back) {
+                                nrtl = bidimap[j].vis_rtl;
+                                if (nback != back || (_vte_debug_on (VTE_DEBUG_BIDI) && nrtl != rtl)) {
                                         break;
                                 }
                         }
@@ -8853,6 +8856,21 @@ Terminal::draw_rows(VteScreen *screen_,
                                                           row_height,
                                                           &bg, VTE_DRAW_OPAQUE);
                         }
+                        if (G_UNLIKELY (_vte_debug_on (VTE_DEBUG_BIDI) && rtl)) {
+                                /* Debug: Highlight RTL letters with a slightly different background. */
+                                vte::color::rgb bg;
+                                rgb_from_index<8, 8, 8>(back, bg);
+                                bg.red   = 0xC000 + (bg.red   - 0xC000) / 2;
+                                bg.green = 0xC000 + (bg.green - 0xC000) / 2;
+                                bg.blue  = 0xC000 + (bg.blue  - 0xC000) / 2;
+                                _vte_draw_fill_rectangle (
+                                                m_draw,
+                                                x + i * column_width,
+                                                y + row_height / 8,
+                                                (j - i) * column_width,
+                                                row_height * 3 / 4,
+                                                &bg, VTE_DRAW_OPAQUE);
+                        }
                         /* We'll need to continue at the first cell which didn't
                          * match the first one in this set. */
                         i = j;


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