[vte/wip/egmont/bidi: 95/104] etap7
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/egmont/bidi: 95/104] etap7
- Date: Wed, 29 May 2019 08:41:41 +0000 (UTC)
commit 5501cf5a221821f956ca27daa935f6e933200eb8
Author: Egmont Koblinger <egmont gmail com>
Date: Fri May 24 15:31:13 2019 +0200
etap7
src/debug.cc | 1 +
src/debug.h | 3 ++-
src/ring.cc | 2 +-
src/ringview.cc | 59 +++++++++++++++++++++++++++----------------------------
src/ringview.hh | 4 ++--
src/vterowdata.cc | 4 ++--
6 files changed, 37 insertions(+), 36 deletions(-)
---
diff --git a/src/debug.cc b/src/debug.cc
index afbd7413..e8dd8d08 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -57,6 +57,7 @@ _vte_debug_init(void)
{ "hyperlink", VTE_DEBUG_HYPERLINK },
{ "modes", VTE_DEBUG_MODES },
{ "emulation", VTE_DEBUG_EMULATION },
+ { "ringview", VTE_DEBUG_RINGVIEW },
{ "bidi", VTE_DEBUG_BIDI },
};
diff --git a/src/debug.h b/src/debug.h
index 92d9d0f9..8601dad0 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -64,7 +64,8 @@ typedef enum {
VTE_DEBUG_HYPERLINK = 1 << 24,
VTE_DEBUG_MODES = 1 << 25,
VTE_DEBUG_EMULATION = 1 << 26,
- VTE_DEBUG_BIDI = 1 << 27,
+ VTE_DEBUG_RINGVIEW = 1 << 27,
+ VTE_DEBUG_BIDI = 1 << 28,
} VteDebugFlags;
void _vte_debug_init(void);
diff --git a/src/ring.cc b/src/ring.cc
index 7cbbbee6..fc1dd047 100644
--- a/src/ring.cc
+++ b/src/ring.cc
@@ -881,8 +881,8 @@ Ring::insert(row_t position, guint8 bidi_flags)
*get_writable_index(position) = tmp;
row = get_writable_index(position);
- row->attr.bidi_flags = bidi_flags;
_vte_row_data_clear (row);
+ row->attr.bidi_flags = bidi_flags;
m_end++;
maybe_freeze_one_row();
diff --git a/src/ringview.cc b/src/ringview.cc
index a62bafb0..6065ad27 100644
--- a/src/ringview.cc
+++ b/src/ringview.cc
@@ -73,16 +73,19 @@ RingView::~RingView()
*/
void RingView::pause()
{
+ int i;
+
if (m_paused)
return;
- for (int i = 0; i < m_rows_alloc_len; i++) {
+ for (i = 0; i < m_rows_alloc_len; i++) {
_vte_row_data_fini(m_rows[i]);
+ g_free (m_rows[i]);
}
g_free (m_rows);
m_rows_alloc_len = 0;
- for (int i = 0; i < m_bidirows_alloc_len; i++) {
+ for (i = 0; i < m_bidirows_alloc_len; i++) {
delete m_bidirows[i];
}
g_free (m_bidirows);
@@ -100,7 +103,7 @@ void RingView::unpause()
m_rows_alloc_len = m_len + 16; /* a bit of random heuristics for context lines */
m_rows = (VteRowData **) g_malloc (sizeof (VteRowData *) * m_rows_alloc_len);
for (int i = 0; i < m_rows_alloc_len; i++) {
- m_rows[i] = (VteRowData *) malloc (sizeof (VteRowData));
+ m_rows[i] = (VteRowData *) g_malloc (sizeof (VteRowData));
_vte_row_data_init (m_rows[i]);
}
@@ -159,7 +162,8 @@ void RingView::set_rows(vte::grid::row_t start, vte::grid::row_t len)
}
VteRowData *RingView::get_row(vte::grid::row_t row) {
- // FIXME safety boundary checks!
+ g_assert_cmpint(row, >=, m_top);
+ g_assert_cmpint(row, <, m_top + m_rows_len);
return m_rows[row - m_top];
}
@@ -172,12 +176,16 @@ void RingView::maybe_update()
unpause();
/* Find the beginning of the topmost paragraph.
- * Bail out if it's preceded by VTE_BIDI_PARAGRAPH_LENGTH_MAX (or more)
- * soft newlines. */
-
+ * Extract at most VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX rows.
+ * Together with the row of m_start, this paragraph fragment is already
+ * longer than VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX lines, and thus the
+ * BiDi code will skip it. */
vte::grid::row_t row = m_start;
const VteRowData *row_data;
+ _vte_debug_print (VTE_DEBUG_RINGVIEW, "Updating ringview for [%ld..%ld] (%ld rows).\n",
+ m_start, m_start + m_len - 1, m_len);
+
int i = VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX;
while (i--) {
// FIXME this could be much cheaper, we don't need to read the actual rows (text_stream),
@@ -187,21 +195,17 @@ void RingView::maybe_update()
break;
row--;
}
- if (i == 0) {
- /* Paragraph has more than VTE_BIDI_PARAGRAPH_LENGTH_MAX lines; take a note of it. */
-// cut_at_top = true;
- row++;
- }
- /* Extract the data beginning at the found row. */
- m_rows_len = 0;
+ /* Extract the data beginning at the found row.
+ * Proceed by at most VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX rows beyond the end of the specified area. */
m_top = row;
- while (row < m_start + m_len) {
+ m_rows_len = 0;
+ while (row < m_start + m_len + VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX) {
if (m_rows_len == m_rows_alloc_len) {
m_rows_alloc_len *= 1.25 /* whatever */;
m_rows = (VteRowData **) g_realloc (m_rows, sizeof (VteRowData *) *
m_rows_alloc_len);
for (int j = m_rows_len; j < m_rows_alloc_len; j++) {
- m_rows[j] = (VteRowData *) malloc (sizeof (VteRowData));
+ m_rows[j] = (VteRowData *) g_malloc (sizeof (VteRowData));
_vte_row_data_init (m_rows[j]);
}
}
@@ -210,17 +214,20 @@ void RingView::maybe_update()
if (row_data != nullptr) {
_vte_row_data_copy (row_data, m_rows[m_rows_len]);
} else {
- // FIXME
_vte_row_data_clear (m_rows[m_rows_len]);
}
m_rows_len++;
row++;
- }
- /* FIXME Extract further rows, up to a newline or the safety limit. */
+ /* Once the bottom of the specified area is reached, stop at a hard newline. */
+ if (row >= m_start + m_len && (!row_data || !row_data->attr.soft_wrapped))
+ break;
+ }
+ _vte_debug_print (VTE_DEBUG_RINGVIEW, "Extracted %ld more rows at top, %ld more rows at bottom.\n",
+ m_start - m_top, (m_top + m_rows_len) - (m_start + m_len));
- /* Loop through paragraphs of the extracted text, and do whatever we need to do on paragraphs. */
+ /* Loop through paragraphs of the extracted text, and do whatever we need to do on each paragraph. */
auto top = m_top;
row = top;
while (row < m_top + m_rows_len) {
@@ -239,16 +246,6 @@ void RingView::maybe_update()
m_invalid = false;
}
-
-
-
-
-
-
-
-
-
-
BidiRow const* RingView::get_row_map(vte::grid::row_t row) const
{
g_assert_cmpint (row, >=, m_start);
@@ -259,6 +256,8 @@ BidiRow const* RingView::get_row_map(vte::grid::row_t row) const
return m_bidirows[row - m_start];
}
+/* For internal use by BidiRunner. Get where the BiDi mapping for the given row
+ * needs to be stored, of nullptr if it's a context row. */
BidiRow* RingView::get_row_map_writable(vte::grid::row_t row) const
{
if (row < m_start || row >= m_start + m_len)
diff --git a/src/ringview.hh b/src/ringview.hh
index 4064b630..1489d1a3 100644
--- a/src/ringview.hh
+++ b/src/ringview.hh
@@ -64,11 +64,11 @@ public:
private:
Ring *m_ring;
- VteRowData **m_rows; // FIXME remove one pointer indirection, or use GArray
+ VteRowData **m_rows;
int m_rows_len;
int m_rows_alloc_len;
- BidiRow **m_bidirows; // FIXME remove one pointer indirection, or use GArray
+ BidiRow **m_bidirows;
int m_bidirows_alloc_len;
BidiRunner *m_bidirunner;
diff --git a/src/vterowdata.cc b/src/vterowdata.cc
index b165f21c..c86fa69c 100644
--- a/src/vterowdata.cc
+++ b/src/vterowdata.cc
@@ -83,9 +83,9 @@ void
_vte_row_data_init (VteRowData *row)
{
// FIXME pass the bidi attrs to this method?
- guint8 bidi_flags_save = row->attr.bidi_flags;
+// guint8 bidi_flags_save = row->attr.bidi_flags;
memset (row, 0, sizeof (*row));
- row->attr.bidi_flags = bidi_flags_save;
+// row->attr.bidi_flags = bidi_flags_save;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]