[vte/wip/egmont/bidi: 107/107] inv part2



commit 38a8a254c9d5f456aeca1261512e07f76ce5fb42
Author: Egmont Koblinger <egmont gmail com>
Date:   Thu May 30 22:40:29 2019 +0200

    inv part2

 src/vte.cc         | 24 ++++++++++++++++++++++--
 src/vteinternal.hh |  3 +++
 src/vteseq.cc      | 54 ++++++++++++++++++++++++++++++++----------------------
 3 files changed, 57 insertions(+), 24 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index eb7c226a..74bb050e 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -528,6 +528,23 @@ Terminal::find_end_column(vte::grid::column_t col,
        return MIN(col + columns, m_column_count);
 }
 
+/* Sets the soft_wrapped bit, and takes care of invalidating if this operation
+ * joined two paragraphs into one, or split one into two. */
+void
+Terminal::set_soft_wrapped(vte::grid::row_t row,
+                           bool value)
+{
+        VteRowData *row_data = find_row_data_writable(row);
+        g_assert(row_data != nullptr);
+
+        if (value == row_data->attr.soft_wrapped)
+                return;
+
+        row_data->attr.soft_wrapped = value;
+
+        invalidate_rows(row, row + 1, 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
@@ -2778,19 +2795,22 @@ Terminal::cursor_down(bool explicit_sequence)
                                start++;
                                end++;
                                 ring_insert(m_screen->cursor.row, false);
+                               set_soft_wrapped(m_screen->cursor.row - 1, false);
                                /* Force the areas below the region to be
                                 * redrawn -- they've moved. */
-                                invalidate_rows(start, end, true /* FIXME */);
+                                invalidate_rows(start, end, false);
                                /* Force scroll. */
                                adjust_adjustments();
                        } else {
                                /* If we're at the bottom of the scrolling
                                 * region, add a line at the top to scroll the
                                 * bottom off. */
+                               set_soft_wrapped(start - 1, false);
+                               set_soft_wrapped(end, false);
                                ring_remove(start);
                                ring_insert(end, true);
                                /* Update the display. */
-                                invalidate_rows(start, end, true /* FIXME */);
+                                invalidate_rows(start, end, false);
                        }
                } else {
                        /* Scroll up with history. */
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index f5eb7faa..36897345 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -649,6 +649,9 @@ public:
         VteRowData *ensure_cursor();
         void update_insert_delta();
 
+        void set_soft_wrapped(vte::grid::row_t row,
+                              bool value);
+
         void cleanup_fragments(long start,
                                long end);
 
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 094b4020..977472ac 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -314,10 +314,10 @@ 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_fill_defaults, m_column_count);
-               rowdata->attr.soft_wrapped = 0;
+               set_soft_wrapped(m_screen->cursor.row, false);
                 rowdata->attr.bidi_flags = get_bidi_flags();
-               /* Repaint this row. */
-                invalidate_row(m_screen->cursor.row, false /* FIXME */);
+               /* Repaint this row's paragraph. */
+                invalidate_row(m_screen->cursor.row, true);
        }
 
        /* We've modified the display.  Make a note of it. */
@@ -330,9 +330,7 @@ Terminal::clear_above_current()
 {
         /* Make the preceding line hard wrapped, even if it's just scrolled out, as per the BiDi spec. */
         if (m_screen->insert_delta > _vte_ring_delta(m_screen->row_data)) {
-                auto rowdata = _vte_ring_index_writable(m_screen->row_data, m_screen->insert_delta - 1);
-                rowdata->attr.soft_wrapped = 0;
-                invalidate_row(m_screen->insert_delta - 1, false /* FIXME */);  // FIXME
+                set_soft_wrapped(m_screen->insert_delta - 1, false);
         }
        /* If the cursor is actually on the screen, clear data in the row
         * which corresponds to the cursor. */
@@ -345,10 +343,10 @@ Terminal::clear_above_current()
                        _vte_row_data_shrink (rowdata, 0);
                        /* Add new cells until we fill the row. */
                         _vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count);
-                       rowdata->attr.soft_wrapped = 0;
+                       set_soft_wrapped(i, false);
                         rowdata->attr.bidi_flags = get_bidi_flags();
-                       /* Repaint the row. */
-                        invalidate_row(i, false /* FIXME */);
+                       /* Repaint the row's paragraph. */
+                        invalidate_row(i, true);
                }
        }
        /* We've modified the display.  Make a note of it. */
@@ -383,8 +381,11 @@ Terminal::scroll_text(vte::grid::row_t scroll_amount)
                }
        }
 
+        set_soft_wrapped(start - 1, false);
+        set_soft_wrapped(end, false);
+
        /* Update the display. */
-        invalidate_rows(start, end, true /* FIXME */);
+        invalidate_rows(start, end, false);
 
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
@@ -760,11 +761,11 @@ Terminal::clear_below_current()
                 if (not_default_bg) {
                         _vte_row_data_fill(rowdata, &m_fill_defaults, m_column_count);
                }
-               rowdata->attr.soft_wrapped = 0;
+               set_soft_wrapped(i, false);
                if (i > m_screen->cursor.row)
                         rowdata->attr.bidi_flags = get_bidi_flags();
-               /* Repaint this row. */
-                invalidate_row(i, true /* FIXME */);
+               /* Repaint this row's paragraph. */
+                invalidate_row(i, true);
        }
 
        /* We've modified the display.  Make a note of it. */
@@ -801,9 +802,9 @@ Terminal::clear_to_eol()
                /* Add enough cells to fill out the row. */
                 _vte_row_data_fill(rowdata, &m_fill_defaults, m_column_count);
        }
-       rowdata->attr.soft_wrapped = 0;
-       /* Repaint this row. */
-        invalidate_row(m_screen->cursor.row, true /* FIXME */);
+       set_soft_wrapped(m_screen->cursor.row, false);
+       /* Repaint this row's paragraph. */
+        invalidate_row(m_screen->cursor.row, true);
 }
 
 /*
@@ -933,9 +934,9 @@ Terminal::delete_character()
                                 _vte_row_data_fill(rowdata, &m_fill_defaults, m_column_count);
                                 len = m_column_count;
                        }
-                        rowdata->attr.soft_wrapped = 0;
-                       /* Repaint this row. */
-                        invalidate_row(m_screen->cursor.row, true /* FIXME */);
+                        set_soft_wrapped(m_screen->cursor.row, false);
+                       /* Repaint this row's paragraph. */
+                        invalidate_row(m_screen->cursor.row, true);
                }
        }
 
@@ -1323,8 +1324,11 @@ Terminal::insert_lines(vte::grid::row_t param)
                 ring_insert(row, true);
        }
         m_screen->cursor.col = 0;
+
+        set_soft_wrapped(row - 1, false);
+        set_soft_wrapped(end, false);
        /* Update the display. */
-        invalidate_rows(row, end, true /* FIXME */);
+        invalidate_rows(row, end, false);
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
        /* We've modified the display.  Make a note of it. */
@@ -1358,8 +1362,11 @@ Terminal::delete_lines(vte::grid::row_t param)
                 ring_insert(end, true);
        }
         m_screen->cursor.col = 0;
+
+        set_soft_wrapped(row - 1, false);
+        set_soft_wrapped(end, false);
        /* Update the display. */
-        invalidate_rows(row, end, true /* FIXME */);
+        invalidate_rows(row, end, false);
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
        /* We've modified the display.  Make a note of it. */
@@ -6752,8 +6759,11 @@ Terminal::RI(vte::parser::Sequence const& seq)
                 * line at the top to scroll the bottom off. */
                ring_remove(end);
                ring_insert(start, true);
+
+               set_soft_wrapped(start - 1, false);
+               set_soft_wrapped(end, false);
                /* Update the display. */
-                invalidate_rows(start, end, true /* FIXME */);
+                invalidate_rows(start, end, false);
        } else {
                /* Otherwise, just move the cursor up. */
                 m_screen->cursor.row--;


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