[vte/wip/egmont/bidi: 8/29] emulation: Make certain operataions convert line endings to hard newline



commit 728ac743c2bfa52b56609c0bbbd365d213ace3d6
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri May 31 13:45:23 2019 +0200

    emulation: Make certain operataions convert line endings to hard newline
    
    Clearing above the cursor now also turns the line just above the normal
    viewport to hard wrapped. (Clearing the entire screen already does this
    by appending new lines.)
    
    Scrolling a region turns all locations where lines are removed or added
    to hard wrapped.
    
    This is done based on the BiDi spec.

 src/vte.cc    |  7 +++++++
 src/vteseq.cc | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 703b9963..b02b673d 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -2712,6 +2712,9 @@ Terminal::cursor_down(bool explicit_sequence)
         if (m_screen->cursor.row == end) {
                 if (m_scrolling_restricted) {
                        if (start == m_screen->insert_delta) {
+                                /* Set the boundary to hard wrapped where
+                                 * we're about to tear apart the contents. */
+                                set_hard_wrapped(m_screen->cursor.row);
                                /* Scroll this line into the scrollback
                                 * buffer by inserting a line at the next
                                 * line and scrolling the area up. */
@@ -2728,6 +2731,10 @@ Terminal::cursor_down(bool explicit_sequence)
                                /* Force scroll. */
                                adjust_adjustments();
                        } else {
+                                /* Set the boundaries to hard wrapped where
+                                 * we're about to tear apart the contents. */
+                                set_hard_wrapped(start - 1);
+                                set_hard_wrapped(end);
                                 /* Scroll by removing a line and inserting a new one. */
                                ring_remove(start);
                                ring_insert(end, true);
diff --git a/src/vteseq.cc b/src/vteseq.cc
index d7855226..d12ee329 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -327,8 +327,11 @@ Terminal::clear_current_line()
 void
 Terminal::clear_above_current()
 {
-       /* If the cursor is actually on the screen, clear data in the row
-        * which corresponds to the cursor. */
+        /* Make the line just above the writable area hard wrapped. */
+        if (m_screen->insert_delta > _vte_ring_delta(m_screen->row_data)) {
+                set_hard_wrapped(m_screen->insert_delta - 1);
+        }
+        /* Clear data in all the writable rows above (excluding) the cursor's. */
         for (auto i = m_screen->insert_delta; i < m_screen->cursor.row; i++) {
                 if (_vte_ring_next(m_screen->row_data) > i) {
                        /* Get the data for the row we're erasing. */
@@ -364,11 +367,21 @@ Terminal::scroll_text(vte::grid::row_t scroll_amount)
                 ring_append(false);
 
        if (scroll_amount > 0) {
+               /* Scroll down. */
                for (auto i = 0; i < scroll_amount; i++) {
                         ring_remove(end);
                         ring_insert(start, true);
                }
+                /* Set the boundaries to hard wrapped where we tore apart the contents.
+                 * Need to do it after scrolling down, for the end row to be the desired one. */
+                set_hard_wrapped(start - 1);
+                set_hard_wrapped(end);
        } else {
+                /* Set the boundaries to hard wrapped where we're about to tear apart the contents.
+                 * Need to do it before scrolling up, for the end row to be the desired one. */
+                set_hard_wrapped(start - 1);
+                set_hard_wrapped(end);
+                /* Scroll up. */
                for (auto i = 0; i < -scroll_amount; i++) {
                         ring_remove(start);
                         ring_insert(end, true);
@@ -1290,6 +1303,12 @@ Terminal::insert_lines(vte::grid::row_t param)
                 ring_remove(end);
                 ring_insert(row, true);
        }
+
+        /* Set the boundaries to hard wrapped where we tore apart the contents.
+         * Need to do it after scrolling down, for the end row to be the desired one. */
+        set_hard_wrapped(row - 1);
+        set_hard_wrapped(end);
+
         m_screen->cursor.col = 0;
        /* Update the display. */
         invalidate_rows(row, end);
@@ -1312,6 +1331,11 @@ Terminal::delete_lines(vte::grid::row_t param)
                 end = m_screen->insert_delta + m_row_count - 1;
        }
 
+        /* Set the boundaries to hard wrapped where we're about to tear apart the contents.
+         * Need to do it before scrolling up, for the end row to be the desired one. */
+        set_hard_wrapped(row - 1);
+        set_hard_wrapped(end);
+
         /* Only allow to delete as many lines as there are between this row
          * and the end of the scrolling region. See bug #676090.
          */
@@ -6709,6 +6733,12 @@ Terminal::RI(vte::parser::Sequence const& seq)
                 * line at the top to scroll the bottom off. */
                ring_remove(end);
                ring_insert(start, true);
+
+                /* Set the boundaries to hard wrapped where we tore apart the contents.
+                 * Need to do it after scrolling down, for the end row to be the desired one. */
+                set_hard_wrapped(start - 1);
+                set_hard_wrapped(end);
+
                /* Update the display. */
                 invalidate_rows(start, end);
        } else {


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