[vte/wip/egmont/bidi: 4/21] etap2



commit fddcbd5a92216be901d871bc1162989e800a6b0a
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri May 24 00:16:18 2019 +0200

    etap2

 src/bidi.hh     |  3 ++-
 src/ringview.cc | 25 ++++++++++++++++++++++---
 src/ringview.hh |  3 +++
 3 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/src/bidi.hh b/src/bidi.hh
index 11f130f1..a257f7d9 100644
--- a/src/bidi.hh
+++ b/src/bidi.hh
@@ -87,12 +87,13 @@ public:
         BidiRunner& operator= (BidiRunner const& o) = delete;
         BidiRunner& operator= (BidiRunner&& o) = delete;
 
+        void paragraph(vte::grid::row_t start, vte::grid::row_t end);
+
 private:
         RingView *m_ringview;
 
         void explicit_line(vte::grid::row_t row, bool rtl);
         void explicit_paragraph(vte::grid::row_t start, vte::grid::row_t end, bool rtl);
-        void paragraph(vte::grid::row_t start, vte::grid::row_t end);
 };
 
 }; /* namespace base */
diff --git a/src/ringview.cc b/src/ringview.cc
index 76df16c6..cd1ee311 100644
--- a/src/ringview.cc
+++ b/src/ringview.cc
@@ -59,6 +59,8 @@ RingView::RingView()
         m_start = m_len = m_width = 0;
         m_rows_alloc_len = m_bidirows_alloc_len = 0;
 
+        m_bidirunner = new BidiRunner(this);
+
         m_invalid = true;
         m_paused = true;
 }
@@ -66,6 +68,7 @@ RingView::RingView()
 RingView::~RingView()
 {
         pause();
+        delete m_bidirunner;
 }
 
 /* Pausing a RingView frees up pretty much all of its memory. This is to be
@@ -179,7 +182,7 @@ void RingView::maybe_update()
         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),
-                // we only need the soft_wrapped flag which is stored in row_stream. Needs method in ring. */
+                // we only need the soft_wrapped flag which is stored in row_stream. Needs method in ring.
                 row_data = m_ring->index_safe(row - 1);
                 if (row_data == nullptr || !row_data->attr.soft_wrapped)
                         break;
@@ -215,9 +218,25 @@ void RingView::maybe_update()
                 row++;
         }
 
+        /* FIXME Extract further rows, up to a newline or the safety limit. */
+
+
+        /* Loop through paragraphs of the extracted text, and do whatever we need to do on paragraphs. */
+        auto top = m_top;
+        row = top;
+        while (row < m_top + m_rows_len) {
+                row_data = m_rows[row - m_top];
+                if (!row_data->attr.soft_wrapped || row == m_top + m_rows_len - 1) {
+                        /* Found a paragraph from @top to @row, inclusive. */
+                        m_bidirunner->paragraph(top, row + 1);
+
+                        /* Doing syntax highlighting etc. come here in the future. */
+
+                        top = row + 1;
+                }
+                row++;
+        }
 
-        // FIXME extract further rows
-        
         m_invalid = false;
 }
 
diff --git a/src/ringview.hh b/src/ringview.hh
index 918a983c..4064b630 100644
--- a/src/ringview.hh
+++ b/src/ringview.hh
@@ -31,6 +31,7 @@ namespace vte {
 namespace base {  // FIXME ???
 
 class BidiRow;
+class BidiRunner;
 
 /* RingView contains the BiDi transformations for all the rows of the viewport. */
 class RingView {
@@ -70,6 +71,8 @@ private:
         BidiRow **m_bidirows;  // FIXME remove one pointer indirection, or use GArray
         int m_bidirows_alloc_len;
 
+        BidiRunner *m_bidirunner;
+
         vte::grid::row_t m_top;  /* the row of the Ring corresponding to m_rows[0] */
 
         vte::grid::row_t m_start;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]