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



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

    inv part2

 src/vte.cc    | 28 +++++++++++++++++++---------
 src/vteseq.cc | 47 +++++++++++++++++++++++++++--------------------
 2 files changed, 46 insertions(+), 29 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 01e45077..82481c1d 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -528,7 +528,8 @@ 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). */
+/* Sets the line ending to hard wrapped (explicit newline).
+ * Takes care of invalidating if this operation splits a paragraph into two. */
 void
 Terminal::set_hard_wrapped(vte::grid::row_t row)
 {
@@ -539,13 +540,16 @@ Terminal::set_hard_wrapped(vte::grid::row_t row)
         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)
+        if (row_data == nullptr || !row_data->attr.soft_wrapped)
                 return;
 
         row_data->attr.soft_wrapped = false;
+
+        invalidate_rows(row, row + 1, true);
 }
 
 /* Sets the line ending to soft wrapped (overflow to the next line).
+ * Takes care of invalidating if this operation joins two paragraphs into one.
  * Also makes sure that the joined new paragraph receives the first one's bidi flags. */
 void
 Terminal::set_soft_wrapped(vte::grid::row_t row)
@@ -574,6 +578,8 @@ Terminal::set_soft_wrapped(vte::grid::row_t row)
                         row_data = find_row_data_writable(++i);
                 } while (row_data != nullptr);
         }
+
+        invalidate_rows(row, row + 1, true);
 }
 
 /* Determine the width of the portion of the preedit string which lies
@@ -2765,7 +2771,7 @@ Terminal::cleanup_fragments(long start,
                         cell_end->c = ' ';
                         cell_end->attr.set_fragment(false);
                         cell_end->attr.set_columns(1);
-                        invalidate_row(m_screen->cursor.row, false);
+                        invalidate_row(m_screen->cursor.row, true /* FIXME can we do cheaper? */);
                 }
         }
 
@@ -2789,7 +2795,7 @@ Terminal::cleanup_fragments(long start,
                                                          "Cleaning CJK left half at %ld\n",
                                                          col);
                                         g_assert(start - col == 1);
-                                        invalidate_row(m_screen->cursor.row, false);
+                                        invalidate_row(m_screen->cursor.row, true /* FIXME can we do 
cheaper? */);
                                 }
                                 keep_going = FALSE;
                         }
@@ -2828,11 +2834,13 @@ Terminal::cursor_down(bool explicit_sequence)
                                start++;
                                end++;
                                 ring_insert(m_screen->cursor.row, false);
-                               /* Force the areas below the region to be
-                                * redrawn -- they've moved. */
+                                /* Repaint the affected lines, which is _below_
+                                 * the region (bug 131). No need to extend,
+                                 * set_hard_wrapped() took care of invalidating
+                                 * the context lines if necessary. */
                                 invalidate_rows(m_screen->cursor.row,
                                                 m_screen->insert_delta + m_row_count - 1,
-                                                true /* FIXME */);
+                                                false);
                                /* Force scroll. */
                                adjust_adjustments();
                        } else {
@@ -2843,8 +2851,10 @@ Terminal::cursor_down(bool explicit_sequence)
                                 /* Scroll by removing a line and inserting a new one. */
                                ring_remove(start);
                                ring_insert(end, true);
-                               /* Update the display. */
-                                invalidate_rows(start, end, true /* FIXME */);
+                                /* Repaint the affected lines. No need to extend,
+                                 * set_hard_wrapped() took care of invalidating
+                                 * the context lines if necessary. */
+                                invalidate_rows(start, end, false);
                        }
                } else {
                        /* Scroll up with history. */
diff --git a/src/vteseq.cc b/src/vteseq.cc
index ec3f4c40..afb8c235 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -316,8 +316,8 @@ Terminal::clear_current_line()
                 _vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count);
                 set_hard_wrapped(m_screen->cursor.row);
                 rowdata->attr.bidi_flags = get_bidi_flags();
-               /* Repaint this row. */
-                invalidate_row(m_screen->cursor.row, false /* FIXME */);
+                /* Repaint this row's paragraph (might need to extend upwards). */
+                invalidate_row(m_screen->cursor.row, true);
        }
 
        /* We've modified the display.  Make a note of it. */
@@ -344,10 +344,10 @@ Terminal::clear_above_current()
                         _vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count);
                         set_hard_wrapped(i);
                         rowdata->attr.bidi_flags = get_bidi_flags();
-                       /* Repaint the row. */
-                        invalidate_row(i, false /* FIXME */);
                }
        }
+        /* Repaint the cleared area. No need to extend because both endpoints are hard newlines. */
+        invalidate_rows(m_screen->insert_delta, m_screen->cursor.row - 1, false);
        /* We've modified the display.  Make a note of it. */
         m_text_deleted_flag = TRUE;
 }
@@ -390,8 +390,9 @@ Terminal::scroll_text(vte::grid::row_t scroll_amount)
                }
        }
 
-       /* Update the display. */
-        invalidate_rows(start, end, true /* FIXME */);
+       /* Repaint the affected lines. No need to extend, set_hard_wrapped() took care of
+        * invalidating the context lines if necessary. */
+        invalidate_rows(start, end, false);
 
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
@@ -713,7 +714,7 @@ Terminal::clear_to_bol()
                         _vte_row_data_append (rowdata, &m_color_defaults);
                }
        }
-       /* Repaint this row. */
+       /* Repaint this row's paragraph. */
         invalidate_row(m_screen->cursor.row, true);
 
        /* We've modified the display.  Make a note of it. */
@@ -770,9 +771,9 @@ Terminal::clear_below_current()
                 set_hard_wrapped(i);
                if (i > m_screen->cursor.row)
                         rowdata->attr.bidi_flags = get_bidi_flags();
-               /* Repaint this row. */
-                invalidate_row(i, true /* FIXME */);
        }
+       /* Repaint the cleared area (might need to extend upwards). */
+        invalidate_rows(m_screen->cursor.row, m_screen->insert_delta + m_row_count - 1, true);
 
        /* We've modified the display.  Make a note of it. */
        m_text_deleted_flag = TRUE;
@@ -809,8 +810,8 @@ Terminal::clear_to_eol()
                 _vte_row_data_fill(rowdata, &m_fill_defaults, m_column_count);
        }
         set_hard_wrapped(m_screen->cursor.row);
-       /* Repaint this row. */
-        invalidate_row(m_screen->cursor.row, true /* FIXME */);
+       /* Repaint this row's paragraph. */
+        invalidate_row(m_screen->cursor.row, true);
 }
 
 /*
@@ -941,8 +942,8 @@ Terminal::delete_character()
                                 len = m_column_count;
                        }
                         set_hard_wrapped(m_screen->cursor.row);
-                       /* Repaint this row. */
-                        invalidate_row(m_screen->cursor.row, true /* FIXME */);
+                       /* Repaint this row's paragraph. */
+                        invalidate_row(m_screen->cursor.row, true);
                }
        }
 
@@ -999,7 +1000,7 @@ Terminal::erase_characters(long count)
                                }
                        }
                }
-               /* Repaint this row. */
+               /* Repaint this row's paragraph. */
                 invalidate_row(m_screen->cursor.row, true);
        }
 
@@ -1115,6 +1116,7 @@ Terminal::move_cursor_tab_forward(int count)
                 }
         }
 
+        /* Repaint the cursor. */
         invalidate_row(m_screen->cursor.row, false);
         m_screen->cursor.col = newcol;
 }
@@ -1336,8 +1338,10 @@ Terminal::insert_lines(vte::grid::row_t param)
         set_hard_wrapped(end);
 
         m_screen->cursor.col = 0;
-       /* Update the display. */
-        invalidate_rows(row, end, true /* FIXME */);
+
+       /* Repaint the affected lines. No need to extend, set_hard_wrapped() took care of
+        * invalidating the context lines if necessary. */
+        invalidate_rows(row, end, false);
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
        /* We've modified the display.  Make a note of it. */
@@ -1376,8 +1380,10 @@ Terminal::delete_lines(vte::grid::row_t param)
                 ring_insert(end, true);
        }
         m_screen->cursor.col = 0;
-       /* Update the display. */
-        invalidate_rows(row, end, true /* FIXME */);
+
+       /* Repaint the affected lines. No need to extend, set_hard_wrapped() took care of
+        * invalidating the context lines if necessary. */
+        invalidate_rows(row, end, false);
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
        /* We've modified the display.  Make a note of it. */
@@ -6776,8 +6782,9 @@ Terminal::RI(vte::parser::Sequence const& seq)
                 set_hard_wrapped(start - 1);
                 set_hard_wrapped(end);
 
-               /* Update the display. */
-                invalidate_rows(start, end, true /* FIXME */);
+                /* Repaint the affected lines. No need to extend, set_hard_wrapped() took care of
+                 * invalidating the context lines if necessary. */
+                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]