[vte/wip/egmont/bidi: 20/73] implicit mode (per line)



commit 6650b496e56c4eabc351c7f7baebaf8f03c6d398
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 e719750c..95a7c11a 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 e7e8dcba..00c08cf0 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 94d81662..7237b123 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -37,6 +37,7 @@
 
 #include <vte/vte.h>
 #include "vteinternal.hh"
+#include "bidi.hh"
 #include "buffer.h"
 #include "debug.h"
 #include "vtedraw.hh"
@@ -3010,7 +3011,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);
 }
 
@@ -8793,7 +8794,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
@@ -8826,6 +8827,7 @@ Terminal::draw_rows(VteScreen *screen_,
         /* Clear the background. */
         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. */
                 do {
@@ -8872,6 +8874,7 @@ Terminal::draw_rows(VteScreen *screen_,
                         /* Skip row. */
                         continue;
                 }
+                bidi_shuffle (row_data, m_column_count);
 
                 /* Walk the line. */
                 item_count = 0;
@@ -9061,8 +9064,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);
@@ -9071,7 +9076,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());
@@ -9954,7 +9959,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 739c7e33..4b1cba66 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -638,7 +638,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 379c941d..954be61d 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]