[vte] widget: Set the soft_wrapped flag via wrapper methods



commit 616d6a1874f3703ec01420eb40e7d09fdb90993e
Author: Egmont Koblinger <egmont gmail com>
Date:   Sun Jun 30 15:28:45 2019 +0200

    widget: Set the soft_wrapped flag via wrapper methods
    
    This is in preparation for RingView and BiDi where there'll be more to do.
    
    https://gitlab.gnome.org/GNOME/vte/issues/53

 src/vte.cc         | 32 +++++++++++++++++++++++++++++++-
 src/vteinternal.hh |  3 +++
 src/vteseq.cc      | 10 +++++-----
 3 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 6ed8fccd..ef2773a5 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -470,6 +470,36 @@ Terminal::find_end_column(vte::grid::column_t col,
        return MIN(col + columns, m_column_count);
 }
 
+/* Sets the line ending to hard wrapped (explicit newline). */
+void
+Terminal::set_hard_wrapped(vte::grid::row_t row)
+{
+        /* We can set the row just above insert_delta to hard wrapped. */
+        g_assert_cmpint(row, >=, m_screen->insert_delta - 1);
+        g_assert_cmpint(row, <, m_screen->insert_delta + m_row_count);
+
+        VteRowData *row_data = find_row_data_writable(row);
+
+        /* It's okay for this row not to be covered by the ring. */
+        if (row_data == nullptr)
+                return;
+
+        row_data->attr.soft_wrapped = false;
+}
+
+/* Sets the line ending to soft wrapped (overflow to the next line). */
+void
+Terminal::set_soft_wrapped(vte::grid::row_t row)
+{
+        g_assert_cmpint(row, >=, m_screen->insert_delta);
+        g_assert_cmpint(row, <, m_screen->insert_delta + m_row_count);
+
+        VteRowData *row_data = find_row_data_writable(row);
+        g_assert(row_data != nullptr);
+
+        row_data->attr.soft_wrapped = true;
+}
+
 /* Determine the width of the portion of the preedit string which lies
  * to the left of the cursor, or the entire string, in columns. */
 // FIXMEchpe this is for the view, so use int not gssize
@@ -2853,7 +2883,7 @@ Terminal::insert_char(gunichar c,
                         col = m_screen->cursor.col = 0;
                        /* Mark this line as soft-wrapped. */
                        row = ensure_row();
-                       row->attr.soft_wrapped = 1;
+                        set_soft_wrapped(m_screen->cursor.row);
                         cursor_down(false);
                } else {
                        /* Don't wrap, stay at the rightmost column. */
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 9eaed1e6..757e6674 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -632,6 +632,9 @@ public:
         VteRowData *ensure_cursor();
         void update_insert_delta();
 
+        void set_hard_wrapped(vte::grid::row_t row);
+        void set_soft_wrapped(vte::grid::row_t row);
+
         void cleanup_fragments(long start,
                                long end);
 
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 894b95fe..d3b3a36c 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -314,7 +314,7 @@ Terminal::clear_current_line()
                _vte_row_data_shrink (rowdata, 0);
                /* Add enough cells to the end of the line to fill out the row. */
                 _vte_row_data_fill (rowdata, &m_color_defaults, m_column_count);
-               rowdata->attr.soft_wrapped = 0;
+                set_hard_wrapped(m_screen->cursor.row);
                /* Repaint this row. */
                 invalidate_row(m_screen->cursor.row);
        }
@@ -338,7 +338,7 @@ Terminal::clear_above_current()
                        _vte_row_data_shrink (rowdata, 0);
                        /* Add new cells until we fill the row. */
                         _vte_row_data_fill (rowdata, &m_color_defaults, m_column_count);
-                       rowdata->attr.soft_wrapped = 0;
+                        set_hard_wrapped(i);
                        /* Repaint the row. */
                         invalidate_row(i);
                }
@@ -731,7 +731,7 @@ Terminal::clear_below_current()
                 if (not_default_bg) {
                         _vte_row_data_fill(rowdata, &m_color_defaults, m_column_count);
                }
-               rowdata->attr.soft_wrapped = 0;
+                set_hard_wrapped(i);
                /* Repaint this row. */
                 invalidate_row(i);
        }
@@ -770,7 +770,7 @@ Terminal::clear_to_eol()
                /* Add enough cells to fill out the row. */
                 _vte_row_data_fill(rowdata, &m_color_defaults, m_column_count);
        }
-       rowdata->attr.soft_wrapped = 0;
+        set_hard_wrapped(m_screen->cursor.row);
        /* Repaint this row. */
         invalidate_row(m_screen->cursor.row);
 }
@@ -908,7 +908,7 @@ Terminal::delete_character()
                                 _vte_row_data_fill(rowdata, &m_color_defaults, m_column_count);
                                 len = m_column_count;
                        }
-                        rowdata->attr.soft_wrapped = 0;
+                        set_hard_wrapped(m_screen->cursor.row);
                        /* Repaint this row. */
                         invalidate_row(m_screen->cursor.row);
                }


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