[vte/wip/egmont/bidi: 17/83] implicit mode (per line)



commit 588127c466d0483513ca10540ffa95e896577d64
Author: Egmont Koblinger <egmont gmail com>
Date:   Tue Aug 21 13:32:14 2018 +0200

    implicit mode (per line)

 src/Makefile.am      |  2 ++
 src/modes-private.hh |  7 +++++++
 src/vte.cc           | 16 ++++++++++------
 src/vteinternal.hh   |  1 -
 src/vteseq.cc        | 12 +++++++++++-
 5 files changed, 30 insertions(+), 8 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0d827b30..0b7c8991 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,6 +46,8 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_SOURCES = \
        vte/vteregex.h \
        vte/vteterminal.h \
        attr.hh \
+       bidi.cc \
+       bidi.hh \
        buffer.h \
        caps.hh \
        cell.hh \
diff --git a/src/modes-private.hh b/src/modes-private.hh
index 2765bfdf..d4a9feba 100644
--- a/src/modes-private.hh
+++ b/src/modes-private.hh
@@ -153,6 +153,13 @@ MODE(URXVT_MOUSE_EXT, 1015)
  */
 MODE(VTE_BOX_DRAWING_MIRROR, 2500)
 
+/*
+ * Whether BiDi paragraph direction is autodetected.
+ *
+ * The number choice is temporary.
+ */
+MODE(VTE_BIDI_AUTO, 2501)
+
 /* Not supported modes: */
 
 /* DEC */
diff --git a/src/vte.cc b/src/vte.cc
index 22b9006d..5b6e794f 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -36,6 +36,7 @@
 
 #include <vte/vte.h>
 #include "vteinternal.hh"
+#include "bidi.hh"
 #include "buffer.h"
 #include "debug.h"
 #include "vtedraw.hh"
@@ -2997,7 +2998,7 @@ Terminal::get_bidi_flags()
 {
         return (m_modes_ecma.BDSM() ? VTE_BIDI_IMPLICIT : 0) |
                (m_bidi_rtl ? VTE_BIDI_RTL : 0) |
-               (m_bidi_auto ? VTE_BIDI_AUTO : 0) |
+               (m_modes_private.VTE_BIDI_AUTO() ? VTE_BIDI_AUTO : 0) |
                (m_modes_private.VTE_BOX_DRAWING_MIRROR() ? VTE_BIDI_BOX_MIRROR : 0);
 }
 
@@ -8835,7 +8836,7 @@ Terminal::draw_cells_with_attributes(struct _vte_draw_text_request *items,
 
 /* XXX tmp hack */
 #define _vte_row_data_get_visual(row_data_p, col) \
-    (_vte_row_data_get ((row_data_p), (((row_data_p)->attr.bidi_flags & VTE_BIDI_RTL) ? (m_column_count - 1 
- (col)) : (col))))
+        _vte_row_data_get(row_data_p, vis2log(col))
 
 
 /* Paint the contents of a given row at the given location.  Take advantage
@@ -8874,6 +8875,7 @@ Terminal::draw_rows(VteScreen *screen_,
          * Process each row independently. */
         for (row = start_row, y = start_y; row < end_row; row++, y += row_height) {
                row_data = find_row_data(row);
+               bidi_shuffle (row_data, m_column_count);
                 i = j = 0;
                 /* Walk the line.
                  * Locate runs of identical bg colors within a row, and paint each run as a single 
rectangle. */
@@ -8920,6 +8922,7 @@ Terminal::draw_rows(VteScreen *screen_,
                         /* Skip row. */
                         continue;
                 }
+                bidi_shuffle (row_data, m_column_count);
 
                 /* Walk the line.
                  * Locate runs of identical attributes within a row, and draw each run using a single 
draw_cells() call. */
@@ -9113,8 +9116,10 @@ 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. */
-        guint8 bidi_flags = 0;
-       auto cell = find_charcell(col, drow, &bidi_flags);
+        VteRowData const *row_data = find_row_data(drow);
+        bidi_shuffle (row_data, m_column_count);
+
+       auto cell = find_charcell(col, drow);
         while (cell != NULL && cell->attr.fragment() && cell->c != '\t' && col > 0) {
                col--;
                cell = find_charcell(col, drow);
@@ -9123,7 +9128,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 = ((bidi_flags & VTE_BIDI_RTL) ? m_column_count - 1 - col : col) * width;
+       item.x = log2vis(col) * width;
        item.y = row_to_pixel(drow);
        if (cell && cell->c != 0) {
                style = _vte_draw_get_style(cell->attr.bold(), cell->attr.italic());
@@ -10003,7 +10008,6 @@ Terminal::reset(bool clear_tabstops,
         save_cursor(&m_alternate_screen);
         /* BiDi */
         m_bidi_rtl = FALSE;
-        m_bidi_auto = FALSE;
        /* Cause everything to be redrawn (or cleared). */
        invalidate_all();
 
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index c80e305b..2a322b51 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -601,7 +601,6 @@ public:
 
         /* BiDi parameters outside of ECMA and DEC private modes */
         guint m_bidi_rtl  : 1;
-        guint m_bidi_auto : 1;
 
 public:
 
diff --git a/src/vteseq.cc b/src/vteseq.cc
index be38f89b..90365006 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -594,7 +594,17 @@ Terminal::set_mode_private(int mode,
                 break;
 
         case vte::terminal::modes::Private::eVTE_BOX_DRAWING_MIRROR:
-                maybe_apply_bidi_attributes();
+                _vte_debug_print(VTE_DEBUG_BIDI,
+                                 "BiDi box drawing mirroring %s\n",
+                                 set ? "enabled" : "disabled");
+                maybe_apply_bidi_attributes();  // FIXME only apply the one that changed here?
+                break;
+
+        case vte::terminal::modes::Private::eVTE_BIDI_AUTO:
+                        _vte_debug_print(VTE_DEBUG_BIDI,
+                                         "BiDi dir autodetection %s\n",
+                                         set ? "enabled" : "disabled");
+                maybe_apply_bidi_attributes();  // FIXME only apply the one that changed here?
                 break;
 
         default:


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