[vte/wip/egmont/bidi: 31/82] mirror parens and such



commit df2cf01809dbc48240b1b70911096c92b8c02f8b
Author: Egmont Koblinger <egmont gmail com>
Date:   Sun Aug 19 23:49:29 2018 +0200

    mirror parens and such

 src/vte.cc     |  6 ++++--
 src/vtedraw.cc | 17 ++++++++++++-----
 src/vtedraw.hh |  1 +
 3 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 18268b3d..23fd547f 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -9222,7 +9222,8 @@ Terminal::draw_rows(VteScreen *screen_,
                        items[0].columns = cell->attr.columns();
                        items[0].x = start_x + i * column_width;
                        items[0].y = y;
-                        items[0].mirror = ((row_data->attr.bidi_flags & (VTE_BIDI_RTL | 
VTE_BIDI_BOX_MIRROR)) == (VTE_BIDI_RTL | VTE_BIDI_BOX_MIRROR));  // FIXME
+                       items[0].mirror = !!(row_data->attr.bidi_flags & VTE_BIDI_RTL);  // FIXME
+                        items[0].box_mirror = !!(row_data->attr.bidi_flags & VTE_BIDI_BOX_MIRROR);
                        j = i + items[0].columns;
 
                        /* Now find out how many cells have the same attributes. */
@@ -9296,7 +9297,8 @@ Terminal::draw_rows(VteScreen *screen_,
                                        items[item_count].columns = cell->attr.columns();
                                        items[item_count].x = start_x + j * column_width;
                                        items[item_count].y = y;
-                                        items[item_count].mirror = ((row_data->attr.bidi_flags & 
(VTE_BIDI_RTL | VTE_BIDI_BOX_MIRROR)) == (VTE_BIDI_RTL | VTE_BIDI_BOX_MIRROR));  // FIXME
+                                        items[item_count].mirror = !!(row_data->attr.bidi_flags & 
VTE_BIDI_RTL);  // FIXME
+                                        items[item_count].box_mirror = !!(row_data->attr.bidi_flags & 
VTE_BIDI_BOX_MIRROR);
                                        j +=  items[item_count].columns;
                                        item_count++;
                                }
diff --git a/src/vtedraw.cc b/src/vtedraw.cc
index 40bc698d..6f8c70d3 100644
--- a/src/vtedraw.cc
+++ b/src/vtedraw.cc
@@ -1164,15 +1164,16 @@ _vte_draw_terminal_draw_graphic(struct _vte_draw *draw, vteunistr c, gboolean mi
                                        upper_half - light_line_width / 2 + light_line_width,
                                        upper_half - heavy_line_width / 2 + heavy_line_width,
                                        height};
-                int xi, yi;
+                int xi, xi_bidi, yi;
                 cairo_set_line_width(cr, 0);
                 for (yi = 4; yi >= 0; yi--) {
-                        for (xi = mirror ? 0 : 4; xi >= 0 && xi <= 4; mirror ? xi++ : xi--) {
+                        for (xi = 4; xi >= 0; xi--) {
                                 if (bitmap & 1) {
+                                        xi_bidi = mirror ? 4 - xi : xi;
                                         cairo_rectangle(cr,
-                                                        x + xboundaries[xi],
+                                                        x + xboundaries[xi_bidi],
                                                         y + yboundaries[yi],
-                                                        xboundaries[xi + 1] - xboundaries[xi],
+                                                        xboundaries[xi_bidi + 1] - xboundaries[xi_bidi],
                                                         yboundaries[yi + 1] - yboundaries[yi]);
                                         cairo_fill(cr);
                                 }
@@ -1474,6 +1475,12 @@ _vte_draw_text_internal (struct _vte_draw *draw,
 
        for (i = 0; i < n_requests; i++) {
                vteunistr c = requests[i].c;
+
+                if (G_UNLIKELY (requests[i].mirror)) {
+                        // FIXME what if 'c' is actually a real vteunistr?
+                        g_unichar_get_mirror_char (c, &c);
+                }
+
                struct unistr_info *uinfo = font_info_get_unistr_info (font, c);
                union unistr_font_info *ufi = &uinfo->ufi;
                 int x, y;
@@ -1483,7 +1490,7 @@ _vte_draw_text_internal (struct _vte_draw *draw,
                 y = requests[i].y + draw->char_spacing.top + font->ascent;
 
                 if (_vte_draw_unichar_is_local_graphic(c)) {
-                        _vte_draw_terminal_draw_graphic(draw, c, requests[i].mirror, color,
+                        _vte_draw_terminal_draw_graphic(draw, c, requests[i].mirror && 
requests[i].box_mirror, color,
                                                         requests[i].x, requests[i].y,
                                                         font->width, requests[i].columns, font->height);
                         continue;
diff --git a/src/vtedraw.hh b/src/vtedraw.hh
index 0e1a2d7a..92b54122 100644
--- a/src/vtedraw.hh
+++ b/src/vtedraw.hh
@@ -46,6 +46,7 @@ struct _vte_draw_text_request {
        vteunistr c;
        gshort x, y, columns;
        guint8 mirror : 1;
+       guint8 box_mirror : 1;
 };
 
 guint _vte_draw_get_style(gboolean bold, gboolean italic);


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