[vte/wip/egmont/bidi: 8/76] track bidi params (buggy), first explicit rtl attempt (unusable)
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/egmont/bidi: 8/76] track bidi params (buggy), first explicit rtl attempt (unusable)
- Date: Sun, 7 Oct 2018 13:03:41 +0000 (UTC)
commit 1edde63502d90082945929c06656f69c0629de5e
Author: Egmont Koblinger <egmont gmail com>
Date: Fri Aug 17 22:30:27 2018 +0200
track bidi params (buggy), first explicit rtl attempt (unusable)
src/vte.cc | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++----
src/vteinternal.hh | 5 ++++-
src/vterowdata.hh | 5 ++++-
src/vteseq.cc | 5 ++++-
4 files changed, 68 insertions(+), 7 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 30014d69..5f3b12e4 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -2772,7 +2772,7 @@ Terminal::insert_char(gunichar c,
bool invalidate_now)
{
VteCellAttr attr;
- VteRowData *row;
+ VteRowData *row, *row2;
long col;
int columns, i;
bool line_wrapped = false; /* cursor moved before char inserted */
@@ -2842,6 +2842,11 @@ Terminal::insert_char(gunichar c,
row = ensure_row();
row->attr.soft_wrapped = 1;
cursor_down(false);
+
+ row2 = ensure_row();
+ row2->attr.bidi_implicit = row->attr.bidi_implicit;
+ row2->attr.bidi_rtl = row->attr.bidi_rtl;
+ row2->attr.bidi_auto = row->attr.bidi_auto;
} else {
/* Don't wrap, stay at the rightmost column. */
col = m_screen->cursor.col =
@@ -2983,6 +2988,47 @@ not_inserted:
m_line_wrapped = line_wrapped;
}
+/* Apply the BiDi parameters on the current paragraph if the cursor
+ * is at the first position of this paragraph. */
+void
+Terminal::maybe_apply_bidi_attributes()
+{
+ _vte_debug_print(VTE_DEBUG_BIDI,
+ "Maybe applying BiDi parameters on current paragraph.\n");
+
+ if (m_screen->cursor.col != 0) {
+ _vte_debug_print(VTE_DEBUG_BIDI,
+ "No, cursor not in first column.\n");
+ return;
+ }
+
+ auto row = m_screen->cursor.row;
+
+ if (row > 0) {
+ const VteRowData *rowdata = _vte_ring_index (m_screen->row_data, row - 1);
+ if (rowdata != nullptr && rowdata->attr.soft_wrapped) {
+ _vte_debug_print(VTE_DEBUG_BIDI,
+ "No, not after a hard wrap.\n");
+ return;
+ }
+ }
+
+ _vte_debug_print(VTE_DEBUG_BIDI,
+ "Yes, applying.\n");
+
+ while (TRUE) {
+ VteRowData *rowdata = _vte_ring_index_writable (m_screen->row_data, row);
+ if (rowdata == nullptr)
+ return;
+ rowdata->attr.bidi_implicit = m_modes_ecma.BDSM();
+ rowdata->attr.bidi_rtl = m_bidi_rtl;
+ rowdata->attr.bidi_auto = m_bidi_auto;
+ if (!rowdata->attr.soft_wrapped)
+ return;
+ row++;
+ }
+}
+
static void
reaper_child_exited_cb(VteReaper *reaper,
int ipid,
@@ -8715,6 +8761,11 @@ Terminal::draw_cells_with_attributes(struct _vte_draw_text_request *items,
}
+/* XXX tmp hack */
+#define _vte_row_data_get_bidi(row_data_p, col) \
+ (_vte_row_data_get ((row_data_p), ((row_data_p)->attr.bidi_rtl ? (m_column_count - 1 - (col)) : (col))))
+
+
/* Paint the contents of a given row at the given location. Take advantage
* of multiple-draw APIs by finding runs of characters with identical
* attributes and bundling them together. */
@@ -8756,14 +8807,14 @@ Terminal::draw_rows(VteScreen *screen_,
* Locate runs of identical bg colors within a row, and paint each run as a single
rectangle. */
do {
/* Get the first cell's contents. */
- cell = row_data ? _vte_row_data_get (row_data, i) : nullptr;
+ cell = row_data ? _vte_row_data_get_bidi (row_data, i) : nullptr;
/* Find the colors for this cell. */
selected = cell_is_selected(i, row);
determine_colors(cell, selected, &fore, &back, &deco);
while (++j < column_count) {
/* Retrieve the next cell. */
- cell = row_data ? _vte_row_data_get (row_data, j) : nullptr;
+ cell = row_data ? _vte_row_data_get_bidi (row_data, j) : nullptr;
/* Resolve attributes to colors where possible and
* compare visual attributes to the first character
* in this chunk. */
@@ -8803,7 +8854,7 @@ Terminal::draw_rows(VteScreen *screen_,
item_count = 0;
for (col = 0; col < column_count; col++) {
/* Get the character cell's contents. */
- cell = _vte_row_data_get (row_data, col);
+ cell = _vte_row_data_get_bidi (row_data, col);
if (cell == NULL) {
/* There'll be no more real cells in this row. */
break;
@@ -9874,6 +9925,7 @@ 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 f5aff3c8..a652a014 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -629,7 +629,8 @@ public:
long m_hyperlink_auto_id;
/* BiDi */
- gboolean m_bidi_rtl : 1;
+ guint m_bidi_rtl : 1;
+ guint m_bidi_auto : 1;
public:
@@ -679,6 +680,8 @@ public:
void invalidate_match_span();
void invalidate_all();
+ void maybe_apply_bidi_attributes();
+
void reset_update_rects();
bool invalidate_dirty_rects_and_process_updates();
void time_process_incoming();
diff --git a/src/vterowdata.hh b/src/vterowdata.hh
index 4191cccb..e35f7ab7 100644
--- a/src/vterowdata.hh
+++ b/src/vterowdata.hh
@@ -36,7 +36,10 @@ G_BEGIN_DECLS
*/
typedef struct _VteRowAttr {
- guint8 soft_wrapped: 1;
+ guint8 soft_wrapped : 1;
+ guint8 bidi_implicit : 1;
+ guint8 bidi_rtl : 1;
+ guint8 bidi_auto : 1;
} VteRowAttr;
static_assert(sizeof (VteRowAttr) == 1, "VteRowAttr has wrong size");
diff --git a/src/vteseq.cc b/src/vteseq.cc
index a95e819d..9040c968 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -461,7 +461,7 @@ Terminal::set_mode_ecma(vte::parser::Sequence const& seq,
_vte_debug_print(VTE_DEBUG_BIDI,
"BiDi %s mode\n",
set ? "implicit" : "explicit");
- /* Will need to take immediate action too */
+ maybe_apply_bidi_attributes(); // FIXME only apply the one that changed here?
}
}
}
@@ -1017,6 +1017,7 @@ Terminal::line_feed()
{
ensure_cursor_is_onscreen();
cursor_down(true);
+ maybe_apply_bidi_attributes();
}
void
@@ -7333,6 +7334,8 @@ Terminal::SPD(vte::parser::Sequence const& seq)
_vte_debug_print(VTE_DEBUG_BIDI, "BiDi: default direction restored\n");
break;
}
+
+ maybe_apply_bidi_attributes(); // FIXME only apply the one that changed here?
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]