[vte] emulation: Ignore delete/insert line outside the scroll region



commit cdeaea32b406fd462c08883e3d4595bdcc645c20
Author: Egmont Koblinger <egmont gmail com>
Date:   Thu Nov 14 12:13:15 2019 +0100

    emulation: Ignore delete/insert line outside the scroll region
    
    https://gitlab.gnome.org/GNOME/vte/issues/199

 src/vteseq.cc | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 27308dff..ea11444f 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -1320,16 +1320,22 @@ Terminal::erase_in_line(vte::parser::Sequence const& seq)
 void
 Terminal::insert_lines(vte::grid::row_t param)
 {
-        vte::grid::row_t end, i;
+        vte::grid::row_t start, end, i;
 
        /* Find the region we're messing with. */
         auto row = m_screen->cursor.row;
         if (m_scrolling_restricted) {
+                start = m_screen->insert_delta + m_scrolling_region.start;
                 end = m_screen->insert_delta + m_scrolling_region.end;
        } else {
+                start = m_screen->insert_delta;
                 end = m_screen->insert_delta + m_row_count - 1;
        }
 
+        /* Don't do anything if the cursor is outside of the scrolling region: DEC STD 070 & bug #199. */
+        if (m_screen->cursor.row < start || m_screen->cursor.row > end)
+                return;
+
        /* Only allow to insert as many lines as there are between this row
          * and the end of the scrolling region. See bug #676090.
          */
@@ -1362,16 +1368,22 @@ Terminal::insert_lines(vte::grid::row_t param)
 void
 Terminal::delete_lines(vte::grid::row_t param)
 {
-        vte::grid::row_t end, i;
+        vte::grid::row_t start, end, i;
 
        /* Find the region we're messing with. */
         auto row = m_screen->cursor.row;
         if (m_scrolling_restricted) {
+                start = m_screen->insert_delta + m_scrolling_region.start;
                 end = m_screen->insert_delta + m_scrolling_region.end;
        } else {
+                start = m_screen->insert_delta;
                 end = m_screen->insert_delta + m_row_count - 1;
        }
 
+        /* Don't do anything if the cursor is outside of the scrolling region: DEC STD 070 & bug #199. */
+        if (m_screen->cursor.row < start || m_screen->cursor.row > end)
+                return;
+
         /* 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);
@@ -5014,6 +5026,7 @@ Terminal::DL(vte::parser::Sequence const& seq)
          *   args[0]: 1
          *
          * References: ECMA-48 § 8.3.32
+         *             DEC STD 070 page 5-148
          *             Terminal-wg/bidi
          */
 #if 0
@@ -6036,6 +6049,7 @@ Terminal::IL(vte::parser::Sequence const& seq)
          * and the SLH and SEE functions.
          *
          * References: ECMA-48 § 8.3.67
+         *             DEC STD 070 page 5-146
          *             Terminal-wg/bidi
          */
 #if 0


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