[vte/wip/egmont/bidi: 7/29] ring: Keep an additional row writable



commit 690c04ad77233edeeb742e1e8928a0fb83e33499
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri May 31 12:49:15 2019 +0200

    ring: Keep an additional row writable
    
    This is so that we can set the line ending above the normal terminal area
    to hard newline. Useful e.g. when clearing the screen, and required by the
    BiDi spec.

 src/ring.cc | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/ring.cc b/src/ring.cc
index c356c235..d7a3bde1 100644
--- a/src/ring.cc
+++ b/src/ring.cc
@@ -726,7 +726,8 @@ Ring::discard_one_row()
 void
 Ring::maybe_freeze_one_row()
 {
-        if (G_LIKELY(m_mask >= m_visible_rows &&
+        /* See the comment about m_visible_rows + 1 at ensure_writable_room(). */
+        if (G_LIKELY(m_mask >= m_visible_rows + 1 &&
                      m_writable + m_mask + 1 == m_end))
                freeze_one_row();
        else
@@ -747,7 +748,11 @@ Ring::ensure_writable_room()
        row_t new_mask, old_mask, i, end;
        VteRowData* old_array, *new_array;;
 
-        if (G_LIKELY(m_mask >= m_visible_rows &&
+        /* Keep at least m_visible_rows + 1 rows in the ring.
+         * The BiDi spec requires that the just scrolled out row
+         * is still alterable (can be switched to hard line ending).
+         * It's nice anyway to make that hard wrapped upon a clear. */
+        if (G_LIKELY(m_mask >= m_visible_rows + 1 &&
                      m_writable + m_mask + 1 > m_end))
                return;
 
@@ -756,7 +761,7 @@ Ring::ensure_writable_room()
 
        do {
                m_mask = (m_mask << 1) + 1;
-        } while (m_mask < m_visible_rows || m_writable + m_mask + 1 <= m_end);
+        } while (m_mask < m_visible_rows + 1 || m_writable + m_mask + 1 <= m_end);
 
        _vte_debug_print(VTE_DEBUG_RING, "Enlarging writable array from %lu to %lu\n", old_mask, m_mask);
 


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