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



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

    inv part2

 src/vte.cc    | 36 +++++++++++++++++++++++++++---------
 src/vteseq.cc | 47 +++++++++++++++++++++++++++--------------------
 2 files changed, 54 insertions(+), 29 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index ec4b8396..1ab81541 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -528,24 +528,38 @@ 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)
 {
         VteRowData *row_data = find_row_data_writable(row);
         g_assert(row_data != nullptr);
 
+        if (!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). */
+/* Sets the line ending to soft wrapped.
+ * Takes care of invalidating if this operation joins two paragraphs into one. */
 void
 Terminal::set_soft_wrapped(vte::grid::row_t row)
 {
         VteRowData *row_data = find_row_data_writable(row);
         g_assert(row_data != nullptr);
 
+        if (row_data->attr.soft_wrapped)
+                return;
+
         row_data->attr.soft_wrapped = true;
+
+        // FIXME also make sure that all these lines have the same bidi params!!!
+
+        invalidate_rows(row, row + 1, true);
 }
 
 /* Determine the width of the portion of the preedit string which lies
@@ -2737,7 +2751,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? */);
                 }
         }
 
@@ -2761,7 +2775,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;
                         }
@@ -2800,11 +2814,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 {
@@ -2815,8 +2831,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]