[vte/wip/egmont/bidi: 26/97] implicit mode (per line)



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

    implicit mode (per line)

 src/meson.build      |  3 +++
 src/modes-private.hh |  7 +++++++
 src/vte.cc           | 16 ++++++++++------
 src/vteinternal.hh   |  1 -
 src/vteseq.cc        | 12 +++++++++++-
 5 files changed, 31 insertions(+), 8 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 4dc6a86b..64d8e967 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -56,6 +56,8 @@ utf8_sources = files(
 
 libvte_common_sources = debug_sources + modes_sources + parser_sources + utf8_sources + files(
   'attr.hh',
+  'bidi.cc',
+  'bidi.hh',
   'buffer.h',
   'caps.hh',
   'cell.hh',
@@ -143,6 +145,7 @@ libvte_common_public_deps = [
 ]
 
 libvte_common_deps = libvte_common_public_deps + [
+  fribidi_dep,
   gnutls_dep,
   pcre2_dep,
   libm_dep,
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 bf61a669..d150274d 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);
 }
 
@@ -8841,7 +8842,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
@@ -8880,6 +8881,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. */
@@ -8926,6 +8928,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. */
@@ -9146,8 +9149,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);
@@ -9156,7 +9161,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());
@@ -10047,7 +10052,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 cd20e919..e0200d3a 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]