[vte/wip/egmont/bidi: 36/82] implicit mode (per line)
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/egmont/bidi: 36/82] implicit mode (per line)
- Date: Wed, 12 Sep 2018 11:55:39 +0000 (UTC)
commit 6e4df35e8031f65e34f5bec2e6ff6249efd45b31
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 | 17 +++++++++++------
src/vteinternal.hh | 1 -
src/vteseq.cc | 12 +++++++++++-
5 files changed, 31 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 cfc4b320..cad7dbba 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"
@@ -3022,7 +3023,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);
}
@@ -9027,7 +9028,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
@@ -9071,6 +9072,7 @@ Terminal::draw_rows(VteScreen *screen_,
* making the drawing area a little wider. */
i = start_column;
if (row_data != NULL) {
+ bidi_shuffle (row_data, m_column_count);
cell = _vte_row_data_get_visual (row_data, i);
while (cell != NULL && cell->attr.fragment() && i > 0) {
cell = _vte_row_data_get_visual (row_data, --i);
@@ -9160,6 +9162,7 @@ Terminal::draw_rows(VteScreen *screen_,
if (row_data == NULL) {
goto fg_skip_row;
}
+ bidi_shuffle (row_data, m_column_count);
/* Back up in case this is a multicolumn character,
* making the drawing area a little wider. */
i = start_column;
@@ -9307,6 +9310,7 @@ fg_next_row:
y += row_height;
row_data = find_row_data(row);
} while (row_data == NULL);
+ bidi_shuffle (row_data, m_column_count);
/* Back up in case this is a
* multicolumn character, making the drawing
@@ -9458,8 +9462,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);
@@ -9468,7 +9474,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());
@@ -10356,7 +10362,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 4954bc26..f543acc5 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -640,7 +640,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 5f4ff765..8ab3cb45 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -595,7 +595,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]