[vte/wip/egmont/bidi: 2/64] vte-26-invalidate_rows-v1.patch



commit 93e936a04fb290a5cd1dbadec87bb606f6afd651
Author: Egmont Koblinger <egmont gmail com>
Date:   Wed Sep 19 10:26:10 2018 +0200

    vte-26-invalidate_rows-v1.patch

 src/vte.cc         | 402 ++++++++++++-----------------------------------------
 src/vteinternal.hh |  18 +--
 src/vteseq.cc      |  33 ++---
 3 files changed, 108 insertions(+), 345 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 7e5a71e5..431cf805 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -229,33 +229,31 @@ Terminal::last_displayed_row() const
         return r;
 }
 
+/* start and end are inclusive, and might be in reversed order */
 void
-Terminal::invalidate_cells(vte::grid::column_t column_start,
-                                     int n_columns,
-                                     vte::grid::row_t row_start,
-                                     int n_rows)
+Terminal::invalidate_rows(vte::grid::row_t row_start,
+                          vte::grid::row_t row_end)
 {
        if (G_UNLIKELY (!widget_realized()))
                 return;
 
-        /* FIXMEchpe: == 0 is fine, but somehow sometimes we
-         * get an actual negative n_columns value passed!?
-         */
-        if (n_columns <= 0 || n_rows <= 0)
-                return;
-
-       if (m_invalidated_all) {
+        if (m_invalidated_all)
                return;
-       }
+
+        /* Swapping them here saves tons of MIN() and MAX() macros elsewhere. */
+        if (G_UNLIKELY (row_end < row_start)) {
+                auto tmp = row_start;
+                row_start = row_end;
+                row_end = tmp;
+        }
 
        _vte_debug_print (VTE_DEBUG_UPDATES,
-                       "Invalidating cells at (%ld,%ld)x(%d,%d).\n",
-                       column_start, row_start,
-                       n_columns, n_rows);
+                          "Invalidating rows %ld..%ld.\n",
+                          row_start, row_end);
        _vte_debug_print (VTE_DEBUG_WORK, "?");
 
-       if (n_columns == m_column_count &&
-            n_rows == m_row_count) {
+        // FIXMEegmont what if we're scrolled back and these are not the last rows?
+        if (row_end - row_start + 1 == m_row_count) {
                invalidate_all();
                return;
        }
@@ -265,12 +263,13 @@ Terminal::invalidate_cells(vte::grid::column_t column_start,
         * by multiplying by the size of a character cell.
         * Always include the extra pixel border and overlap pixel.
         */
-        rect.x = column_start * m_cell_width - 1;
-        int xend = (column_start + n_columns) * m_cell_width + 1;
+        // FIXMEegmont invalidate the left and right padding too
+        rect.x = -1;
+        int xend = m_column_count * m_cell_width + 1;
         rect.width = xend - rect.x;
 
         rect.y = row_to_pixel(row_start) - 1;
-        int yend = row_to_pixel(row_start + n_rows) + 1;
+        int yend = row_to_pixel(row_end + 1) + 1;
         rect.height = yend - rect.y;
 
        _vte_debug_print (VTE_DEBUG_UPDATES,
@@ -294,36 +293,18 @@ Terminal::invalidate_cells(vte::grid::column_t column_start,
        _vte_debug_print (VTE_DEBUG_WORK, "!");
 }
 
+/* Convenience method */
 void
-Terminal::invalidate_region(vte::grid::column_t scolumn,
-                                      vte::grid::column_t ecolumn,
-                                      vte::grid::row_t srow,
-                                      vte::grid::row_t erow,
-                                      bool block)
+Terminal::invalidate_row(vte::grid::row_t row)
 {
-       if (block || srow == erow) {
-               invalidate_cells(
-                               scolumn, ecolumn - scolumn + 1,
-                               srow, erow - srow + 1);
-       } else {
-               invalidate_cells(
-                               scolumn,
-                               m_column_count - scolumn,
-                               srow, 1);
-               invalidate_cells(
-                               0, m_column_count,
-                               srow + 1, erow - srow - 1);
-               invalidate_cells(
-                               0, ecolumn + 1,
-                               erow, 1);
-       }
+        invalidate_rows(row, row);
 }
 
 void
-Terminal::invalidate(vte::grid::span const& s,
-                               bool block)
+Terminal::invalidate(vte::grid::span const& s)
 {
-        invalidate_region(s.start_column(), s.end_column(), s.start_row(), s.end_row(), block);
+        invalidate_rows(s.start_row(),
+                        s.end_column() < 0 ? s.end_row() - 1 : s.end_row());
 }
 
 void
@@ -360,32 +341,6 @@ Terminal::invalidate_all()
        }
 }
 
-/* FIXMEchpe: remove this obsolete function. It became useless long ago
- * when we stopped moving window contents around on scrolling. */
-/* Scroll a rectangular region up or down by a fixed number of lines,
- * negative = up, positive = down. */
-void
-Terminal::scroll_region (long row,
-                                   long count,
-                                   long delta)
-{
-       if ((delta == 0) || (count == 0)) {
-               /* Shenanigans! */
-               return;
-       }
-
-       if (count >= m_row_count) {
-               /* We have to repaint the entire window. */
-               invalidate_all();
-       } else {
-               /* We have to repaint the area which is to be
-                * scrolled. */
-               invalidate_cells(
-                                    0, m_column_count,
-                                    row, count);
-       }
-}
-
 /* Find the row in the given position in the backscroll buffer. */
 // FIXMEchpe replace this with a method on VteRing
 VteRowData const*
@@ -512,46 +467,6 @@ Terminal::get_preedit_length(bool left_only)
        return i;
 }
 
-void
-Terminal::invalidate_cell(vte::grid::column_t col,
-                                    vte::grid::row_t row)
-{
-       int columns;
-       guint style;
-
-       if (G_UNLIKELY (!widget_realized()))
-                return;
-
-       if (m_invalidated_all) {
-               return;
-       }
-
-       columns = 1;
-       auto row_data = find_row_data(row);
-       if (row_data != NULL) {
-               const VteCell *cell;
-               cell = _vte_row_data_get (row_data, col);
-               if (cell != NULL) {
-                       while (cell->attr.fragment() && col> 0) {
-                               cell = _vte_row_data_get (row_data, --col);
-                       }
-                       columns = cell->attr.columns();
-                       style = _vte_draw_get_style(cell->attr.bold(), cell->attr.italic());
-                        if (cell->c != 0) {
-                                int right;
-                                _vte_draw_get_char_edges(m_draw, cell->c, columns, style, NULL, &right);
-                                columns = MAX(columns, howmany(right, m_cell_width));
-                       }
-               }
-       }
-
-       _vte_debug_print(VTE_DEBUG_UPDATES,
-                       "Invalidating cell at (%ld,%ld-%ld).\n",
-                       row, col, col + columns);
-
-        invalidate_cells(col, columns, row, 1);
-}
-
 void
 Terminal::invalidate_cursor_once(bool periodic)
 {
@@ -591,11 +506,9 @@ Terminal::invalidate_cursor_once(bool periodic)
                }
 
                _vte_debug_print(VTE_DEBUG_UPDATES,
-                               "Invalidating cursor at (%ld,%ld-%ld).\n",
-                               row, column, column + columns);
-               invalidate_cells(
-                                    column, columns,
-                                    row, 1);
+                                 "Invalidating cursor in row %ld.\n",
+                                 row);
+                invalidate_row(row);
        }
 }
 
@@ -830,7 +743,7 @@ void
 Terminal::deselect_all()
 {
        if (m_has_selection) {
-               gint sx, sy, ex, ey, extra;
+                gint sy, ey;
 
                _vte_debug_print(VTE_DEBUG_SELECTION,
                                "Deselecting all text.\n");
@@ -841,15 +754,9 @@ Terminal::deselect_all()
 
                emit_selection_changed();
 
-               sx = m_selection_start.col;
                sy = m_selection_start.row;
-               ex = m_selection_end.col;
                ey = m_selection_end.row;
-                extra = m_selection_block_mode ? (VTE_TAB_WIDTH_MAX - 1) : 0;
-               invalidate_region(
-                               MIN (sx, ex), MAX (sx, ex) + extra,
-                               MIN (sy, ey),   MAX (sy, ey),
-                               false);
+                invalidate_rows(sy, ey);
        }
 }
 
@@ -2621,9 +2528,7 @@ Terminal::cleanup_fragments(long start,
                         cell_end->c = ' ';
                         cell_end->attr.set_fragment(false);
                         cell_end->attr.set_columns(1);
-                        invalidate_cells(
-                                              end, 1,
-                                              m_screen->cursor.row, 1);
+                        invalidate_row(m_screen->cursor.row);
                 }
         }
 
@@ -2647,9 +2552,7 @@ Terminal::cleanup_fragments(long start,
                                                          "Cleaning CJK left half at %ld\n",
                                                          col);
                                         g_assert(start - col == 1);
-                                        invalidate_cells(
-                                                              col, 1,
-                                                              m_screen->cursor.row, 1);
+                                        invalidate_row(m_screen->cursor.row);
                                 }
                                 keep_going = FALSE;
                         }
@@ -2688,8 +2591,7 @@ Terminal::cursor_down(bool explicit_sequence)
                                 ring_insert(m_screen->cursor.row, false);
                                /* Force the areas below the region to be
                                 * redrawn -- they've moved. */
-                               scroll_region(start,
-                                                           end - start + 1, 1);
+                                invalidate_rows(start, end);
                                /* Force scroll. */
                                adjust_adjustments();
                        } else {
@@ -2699,11 +2601,7 @@ Terminal::cursor_down(bool explicit_sequence)
                                ring_remove(start);
                                ring_insert(end, true);
                                /* Update the display. */
-                               scroll_region(start,
-                                                          end - start + 1, -1);
-                               invalidate_cells(
-                                                     0, m_column_count,
-                                                     end - 2, 2);
+                                invalidate_rows(start, end);
                        }
                } else {
                        /* Scroll up with history. */
@@ -2937,10 +2835,8 @@ Terminal::insert_char(gunichar c,
 
                /* Always invalidate since we put the mark on the *previous* cell
                 * and the higher level code doesn't know this. */
-               invalidate_cells(
-                                     col - columns,
-                                     columns,
-                                     row_num, 1);
+                // FIXME could this be cleaned up now that we invalidate rows?
+                invalidate_row(row_num);
 
                goto done;
         } else {
@@ -2985,10 +2881,7 @@ Terminal::insert_char(gunichar c,
 
        /* Signal that this part of the window needs drawing. */
        if (G_UNLIKELY (invalidate_now)) {
-               invalidate_cells(
-                               col - columns,
-                               insert ? m_column_count : columns,
-                                m_screen->cursor.row, 1);
+                invalidate_row(m_screen->cursor.row);
        }
 
         m_screen->cursor.col = col;
@@ -3519,7 +3412,7 @@ Terminal::process_incoming()
        VteVisualPosition saved_cursor;
        gboolean saved_cursor_visible;
         VteCursorStyle saved_cursor_style;
-       GdkPoint bbox_topleft, bbox_bottomright;
+        vte::grid::row_t bbox_top, bbox_bottom;
        gboolean modified, bottom;
        gboolean invalidated_text;
        gboolean in_scroll_region;
@@ -3560,8 +3453,8 @@ Terminal::process_incoming()
        modified = FALSE;
        invalidated_text = FALSE;
 
-       bbox_bottomright.x = bbox_bottomright.y = -G_MAXINT;
-       bbox_topleft.x = bbox_topleft.y = G_MAXINT;
+        bbox_bottom = -G_MAXINT;
+        bbox_top = G_MAXINT;
 
         vte::parser::Sequence seq{m_parser};
 
@@ -3628,10 +3521,8 @@ Terminal::process_incoming()
                                 switch (rv) {
                                 case VTE_SEQ_GRAPHIC: {
 
-                                        bbox_topleft.x = MIN(bbox_topleft.x,
-                                                             m_screen->cursor.col);
-                                        bbox_topleft.y = MIN(bbox_topleft.y,
-                                                             m_screen->cursor.row);
+                                        bbox_top = MIN(bbox_top,
+                                                       m_screen->cursor.row);
 
                                         // does insert_char(c, false, false)
                                         GRAPHIC(seq);
@@ -3644,39 +3535,24 @@ Terminal::process_incoming()
                                                 m_line_wrapped = false;
                                                 /* line wrapped, correct bbox */
                                                 if (invalidated_text &&
-                                                    (m_screen->cursor.col > bbox_bottomright.x + 
VTE_CELL_BBOX_SLACK   ||
-                                                     m_screen->cursor.col < bbox_topleft.x - 
VTE_CELL_BBOX_SLACK       ||
-                                                     m_screen->cursor.row > bbox_bottomright.y + 
VTE_CELL_BBOX_SLACK   ||
-                                                     m_screen->cursor.row < bbox_topleft.y - 
VTE_CELL_BBOX_SLACK)) {
+                                                    (m_screen->cursor.row > bbox_bottom + 
VTE_CELL_BBOX_SLACK ||
+                                                     m_screen->cursor.row < bbox_top - VTE_CELL_BBOX_SLACK)) 
{
                                                         /* Clip off any part of the box which isn't already 
on-screen. */
-                                                        bbox_topleft.x = MAX(bbox_topleft.x, 0);
-                                                        bbox_topleft.y = MAX(bbox_topleft.y, top_row);
-                                                        bbox_bottomright.x = MIN(bbox_bottomright.x,
-                                                                                 m_column_count);
-                                                        /* lazily apply the +1 to the cursor_row */
-                                                        bbox_bottomright.y = MIN(bbox_bottomright.y + 1,
-                                                                                 bottom_row + 1);
-
-                                                        invalidate_cells(
-                                                                         bbox_topleft.x,
-                                                                         bbox_bottomright.x - bbox_topleft.x,
-                                                                         bbox_topleft.y,
-                                                                         bbox_bottomright.y - 
bbox_topleft.y);
-                                                        bbox_bottomright.x = bbox_bottomright.y = -G_MAXINT;
-                                                        bbox_topleft.x = bbox_topleft.y = G_MAXINT;
+                                                        bbox_top = MAX(bbox_top, top_row);
+                                                        bbox_bottom = MIN(bbox_bottom, bottom_row);
+
+                                                        invalidate_rows(bbox_top, bbox_bottom);
+                                                        bbox_bottom = -G_MAXINT;
+                                                        bbox_top = G_MAXINT;
 
                                                 }
-                                                bbox_topleft.x = MIN(bbox_topleft.x, 0);
-                                                bbox_topleft.y = MIN(bbox_topleft.y,
-                                                                     m_screen->cursor.row);
+                                                bbox_top = MIN(bbox_top,
+                                                               m_screen->cursor.row);
                                         }
                                         /* Add the cells over which we have moved to the region
                                          * which we need to refresh for the user. */
-                                        bbox_bottomright.x = MAX(bbox_bottomright.x,
-                                                                 m_screen->cursor.col);
-                                        /* cursor.row + 1 (defer until inv.) */
-                                        bbox_bottomright.y = MAX(bbox_bottomright.y,
-                                                                 m_screen->cursor.row);
+                                        bbox_bottom = MAX(bbox_bottom,
+                                                          m_screen->cursor.row);
                                         invalidated_text = TRUE;
 
                                         /* We *don't* emit flush pending signals here. */
@@ -3721,28 +3597,17 @@ Terminal::process_incoming()
                                          */
                                         if (invalidated_text &&
                                             ((new_in_scroll_region && !in_scroll_region) ||
-                                             (m_screen->cursor.col > bbox_bottomright.x + 
VTE_CELL_BBOX_SLACK ||
-                                              m_screen->cursor.col < bbox_topleft.x - VTE_CELL_BBOX_SLACK    
 ||
-                                              m_screen->cursor.row > bbox_bottomright.y + 
VTE_CELL_BBOX_SLACK ||
-                                              m_screen->cursor.row < bbox_topleft.y - VTE_CELL_BBOX_SLACK))) 
{
+                                             (m_screen->cursor.row > bbox_bottom + VTE_CELL_BBOX_SLACK ||
+                                              m_screen->cursor.row < bbox_top - VTE_CELL_BBOX_SLACK))) {
                                                 /* Clip off any part of the box which isn't already 
on-screen. */
-                                                bbox_topleft.x = MAX(bbox_topleft.x, 0);
-                                                bbox_topleft.y = MAX(bbox_topleft.y, top_row);
-                                                bbox_bottomright.x = MIN(bbox_bottomright.x,
-                                                                         m_column_count);
-                                                /* lazily apply the +1 to the cursor_row */
-                                                bbox_bottomright.y = MIN(bbox_bottomright.y + 1,
-                                                                         bottom_row + 1);
-
-                                                invalidate_cells(
-                                                                 bbox_topleft.x,
-                                                                 bbox_bottomright.x - bbox_topleft.x,
-                                                                 bbox_topleft.y,
-                                                                 bbox_bottomright.y - bbox_topleft.y);
+                                                bbox_top = MAX(bbox_top, top_row);
+                                                bbox_bottom = MIN(bbox_bottom, bottom_row);
+
+                                                invalidate_rows(bbox_top, bbox_bottom);
 
                                                 invalidated_text = FALSE;
-                                                bbox_bottomright.x = bbox_bottomright.y = -G_MAXINT;
-                                                bbox_topleft.x = bbox_topleft.y = G_MAXINT;
+                                                bbox_bottom = -G_MAXINT;
+                                                bbox_top = G_MAXINT;
                                         }
 
                                         in_scroll_region = new_in_scroll_region;
@@ -3797,19 +3662,10 @@ Terminal::process_incoming()
 
        if (invalidated_text) {
                /* Clip off any part of the box which isn't already on-screen. */
-               bbox_topleft.x = MAX(bbox_topleft.x, 0);
-                bbox_topleft.y = MAX(bbox_topleft.y, top_row);
-               bbox_bottomright.x = MIN(bbox_bottomright.x,
-                               m_column_count);
-               /* lazily apply the +1 to the cursor_row */
-               bbox_bottomright.y = MIN(bbox_bottomright.y + 1,
-                                bottom_row + 1);
+                bbox_top = MAX(bbox_top, top_row);
+                bbox_bottom = MIN(bbox_bottom, bottom_row);
 
-               invalidate_cells(
-                               bbox_topleft.x,
-                               bbox_bottomright.x - bbox_topleft.x,
-                               bbox_topleft.y,
-                               bbox_bottomright.y - bbox_topleft.y);
+                invalidate_rows(bbox_top, bbox_bottom);
        }
 
         // FIXMEchpe: also need to take into account if the number of columns the cursor 
@@ -3818,14 +3674,14 @@ Terminal::process_incoming()
             (saved_cursor.row != m_screen->cursor.row)) {
                /* invalidate the old and new cursor positions */
                if (saved_cursor_visible)
-                       invalidate_cell(saved_cursor.col, saved_cursor.row);
+                        invalidate_row(saved_cursor.row);
                invalidate_cursor_once();
                check_cursor_blink();
                /* Signal that the cursor moved. */
                queue_cursor_moved();
         } else if ((saved_cursor_visible != m_modes_private.DEC_TEXT_CURSOR()) ||
                    (saved_cursor_style != m_cursor_style)) {
-               invalidate_cell(saved_cursor.col, saved_cursor.row);
+                invalidate_row(saved_cursor.row);
                check_cursor_blink();
        }
 
@@ -5432,15 +5288,19 @@ Terminal::hyperlink_invalidate_and_get_bbox(vte::base::Ring::hyperlink_idx_t idx
         for (row = first_row; row < end_row; row++) {
                 rowdata = _vte_ring_index(m_screen->row_data, row);
                 if (rowdata != NULL) {
+                        bool do_invalidate_row = false;
                         for (col = 0; col < rowdata->len; col++) {
                                 if (G_UNLIKELY (rowdata->cells[col].attr.hyperlink_idx == idx)) {
-                                        invalidate_cells(col, 1, row, 1);
+                                        do_invalidate_row = true;
                                         top = MIN(top, row);
                                         bottom = MAX(bottom, row);
                                         left = MIN(left, col);
                                         right = MAX(right, col);
                                 }
                         }
+                        if (G_UNLIKELY (do_invalidate_row)) {
+                                invalidate_row(row);
+                        }
                 }
         }
 
@@ -6255,11 +6115,7 @@ Terminal::widget_paste(GdkAtom board)
 void
 Terminal::invalidate_selection()
 {
-        invalidate_region(m_selection_start.col,
-                          m_selection_end.col,
-                          m_selection_start.row,
-                          m_selection_end.row,
-                          m_selection_block_mode);
+        invalidate_rows(m_selection_start.row, m_selection_end.row);
 }
 
 /* Confine coordinates into the visible area. Padding is already subtracted. */
@@ -6726,72 +6582,19 @@ Terminal::extend_selection(long x,
        if (had_selection) {
 
                if (m_selection_block_mode) {
-                       /* Update the selection area diff in block mode. */
-
-                       /* The top band */
-                       invalidate_region(
-                                               MIN(sc->col, so->col),
-                                               MAX(ec->col, eo->col),
-                                               MIN(sc->row, so->row),
-                                               MAX(sc->row, so->row) - 1,
-                                               true);
-                       /* The bottom band */
-                       invalidate_region(
-                                               MIN(sc->col, so->col),
-                                               MAX(ec->col, eo->col),
-                                               MIN(ec->row, eo->row) + 1,
-                                               MAX(ec->row, eo->row),
-                                               true);
-                       /* The left band */
-                       invalidate_region(
-                                               MIN(sc->col, so->col),
-                                               MAX(sc->col, so->col) - 1 + (VTE_TAB_WIDTH_MAX - 1),
-                                               MIN(sc->row, so->row),
-                                               MAX(ec->row, eo->row),
-                                               true);
-                       /* The right band */
-                       invalidate_region(
-                                               MIN(ec->col, eo->col) + 1,
-                                               MAX(ec->col, eo->col) + (VTE_TAB_WIDTH_MAX - 1),
-                                               MIN(sc->row, so->row),
-                                               MAX(ec->row, eo->row),
-                                               true);
+                        /* Update the selection area diff in block mode.
+                         * We could optimize when the columns don't change, probably not worth it. */
+                        invalidate_rows(MIN(sc->row, so->row), MAX(ec->row, eo->row));
                } else {
                        /* Update the selection area diff in non-block mode. */
 
                        /* The before band */
-                       if (sc->row < so->row)
-                               invalidate_region(
-                                                       sc->col, so->col - 1,
-                                                       sc->row, so->row,
-                                                       false);
-                       else if (sc->row > so->row)
-                               invalidate_region(
-                                                       so->col, sc->col - 1,
-                                                       so->row, sc->row,
-                                                       false);
-                       else
-                               invalidate_region(
-                                                       MIN(sc->col, so->col), MAX(sc->col, so->col) - 1,
-                                                       sc->row, sc->row,
-                                                       true);
-
+                        // FIXMEegmont simplify these conditions when sc becomes a grid:coords.
+                        if (sc->row != so->row || sc->col != so->col)
+                                invalidate_rows(sc->row, so->row);
                        /* The after band */
-                       if (ec->row < eo->row)
-                               invalidate_region(
-                                                       ec->col + 1, eo->col,
-                                                       ec->row, eo->row,
-                                                       false);
-                       else if (ec->row > eo->row)
-                               invalidate_region(
-                                                       eo->col + 1, ec->col,
-                                                       eo->row, ec->row,
-                                                       false);
-                       else
-                               invalidate_region(
-                                                       MIN(ec->col, eo->col) + 1, MAX(ec->col, eo->col),
-                                                       ec->row, ec->row,
-                                                       true);
+                        if (ec->row != eo->row || ec->col != eo->col)
+                                invalidate_rows(ec->row, eo->row);
                }
        }
 
@@ -7869,6 +7672,7 @@ Terminal::Terminal(vte::platform::Widget* w,
        gtk_widget_set_redraw_on_allocate(m_widget, FALSE);
 
         m_invalidated_all = false;
+        // FIXMEegmont make this store row indices only, maybe convert to a bitmap
         m_update_rects = g_array_sized_new(FALSE /* zero terminated */,
                                            FALSE /* clear */,
                                            sizeof(cairo_rectangle_int_t),
@@ -8933,9 +8737,6 @@ void
 Terminal::draw_rows(VteScreen *screen_,
                               vte::grid::row_t start_row,
                               vte::grid::row_t end_row,
-                              vte::grid::column_t start_column,
-                              vte::grid::column_t end_column,
-                              gint start_x,
                               gint start_y,
                               gint column_width,
                               gint row_height)
@@ -8956,13 +8757,10 @@ Terminal::draw_rows(VteScreen *screen_,
 
         items = g_newa (struct _vte_draw_text_request, m_column_count);
 
-        /* Adjust for the absolute start of row. */
-       start_x -= start_column * column_width;
-
         /* Clear the background. */
         for (row = start_row, y = start_y; row < end_row; row++, y += row_height) {
                row_data = find_row_data(row);
-                i = j = start_column;
+                i = j = 0;
                 /* Walk the line. */
                 do {
                         /* Get the first cell's contents. */
@@ -8971,7 +8769,7 @@ Terminal::draw_rows(VteScreen *screen_,
                         selected = cell_is_selected(i, row);
                         determine_colors(cell, selected, &fore, &back, &deco);
 
-                        while (++j < end_column) {
+                        while (++j < m_column_count) {
                                 /* Retrieve the next cell. */
                                 cell = row_data ? _vte_row_data_get (row_data, j) : nullptr;
                                 /* Resolve attributes to colors where possible and
@@ -8988,7 +8786,7 @@ Terminal::draw_rows(VteScreen *screen_,
                                 rgb_from_index<8, 8, 8>(back, bg);
                                 _vte_draw_fill_rectangle (
                                                 m_draw,
-                                                start_x + i * column_width,
+                                                i * column_width,
                                                 y,
                                                 (j - i) * column_width,
                                                 row_height,
@@ -8997,14 +8795,10 @@ Terminal::draw_rows(VteScreen *screen_,
                         /* We'll need to continue at the first cell which didn't
                          * match the first one in this set. */
                         i = j;
-                } while (i < end_column);
+                } while (i < m_column_count);
         }
 
 
-        /* Render one more column to the left and right, to make sure CJKs are drawn correctly. */
-        start_column = MAX(start_column - 1, 0);
-        end_column = MIN(end_column + 1, m_column_count);
-
         /* Render the text. */
         for (row = start_row, y = start_y; row < end_row; row++, y += row_height) {
                 row_data = find_row_data(row);
@@ -9015,7 +8809,7 @@ Terminal::draw_rows(VteScreen *screen_,
 
                 /* Walk the line. */
                 item_count = 0;
-                for (col = start_column; col < end_column; col++) {
+                for (col = 0; col < m_column_count; col++) {
                         /* Get the character cell's contents. */
                         cell = _vte_row_data_get (row_data, col);
                         if (cell == NULL) {
@@ -9077,7 +8871,7 @@ Terminal::draw_rows(VteScreen *screen_,
                         g_assert_cmpint (item_count, <, m_column_count);
                         items[item_count].c = cell->c;
                         items[item_count].columns = cell->attr.columns();
-                        items[item_count].x = start_x + col * column_width;
+                        items[item_count].x = col * column_width;
                         items[item_count].y = y;
                         item_count++;
                 }
@@ -9131,7 +8925,6 @@ void
 Terminal::paint_area(GdkRectangle const* area)
 {
         vte::grid::row_t row, row_stop;
-        vte::grid::column_t col, col_stop;
 
         row = pixel_to_row(MAX(0, area->y));
         /* Both the value given by MIN() and row_stop are exclusive.
@@ -9142,30 +8935,22 @@ Terminal::paint_area(GdkRectangle const* area)
        if (row_stop <= row) {
                return;
        }
-       col = MAX(0, area->x / m_cell_width);
-       col_stop = MIN((area->width + area->x) / m_cell_width,
-                      m_column_count);
-       if (col_stop <= col) {
-               return;
-       }
        _vte_debug_print (VTE_DEBUG_UPDATES,
                        "paint_area"
                        "       (%d,%d)x(%d,%d) pixels,"
                        " (%ld,%ld)x(%ld,%ld) cells"
                        " [(%ld,%ld)x(%ld,%ld) pixels]\n",
                        area->x, area->y, area->width, area->height,
-                       col, row, col_stop - col, row_stop - row,
-                       col * m_cell_width,
+                        0L, row, m_column_count, row_stop - row,
+                        0L,
                        row * m_cell_height,
-                       (col_stop - col) * m_cell_width,
+                        m_column_count * m_cell_width,
                        (row_stop - row) * m_cell_height);
 
        /* Now we're ready to draw the text.  Iterate over the rows we
         * need to draw. */
        draw_rows(m_screen,
                              row, row_stop,
-                             col, col_stop,
-                             col * m_cell_width,
                              row_to_pixel(row),
                              m_cell_width,
                              m_cell_height);
@@ -10217,10 +10002,7 @@ Terminal::select_text(vte::grid::column_t start_col,
         widget_copy(VTE_SELECTION_PRIMARY, VTE_FORMAT_TEXT);
        emit_selection_changed();
 
-       invalidate_region(MIN (start_col, end_col), MAX (start_col, end_col),
-                          MIN (start_row, end_row), MAX (start_row, end_row),
-                          false);
-
+        invalidate_rows(start_row, end_row);
 }
 
 void
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 4c2d09fb..6bb39548 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -671,14 +671,11 @@ public:
                          bool insert,
                          bool invalidate_now);
 
-        void invalidate(vte::grid::span const& s, bool block = false);
+        void invalidate_row(vte::grid::row_t row);
+        void invalidate_rows(vte::grid::row_t row_start,
+                             vte::grid::row_t row_end /* inclusive */);
+        void invalidate(vte::grid::span const& s);
         void invalidate_match_span();
-        void invalidate_cell(vte::grid::column_t column, vte::grid::row_t row);
-        void invalidate_cells(vte::grid::column_t sc, int cc,
-                              vte::grid::row_t sr, int rc);
-        void invalidate_region(vte::grid::column_t sc, vte::grid::column_t ec,
-                               vte::grid::row_t sr, vte::grid::row_t er,
-                               bool block = false);
         void invalidate_selection();
         void invalidate_all();
 
@@ -812,9 +809,6 @@ public:
         void draw_rows(VteScreen *screen,
                        vte::grid::row_t start_row,
                        long row_count,
-                       vte::grid::column_t start_column,
-                       long column_count,
-                       gint start_x,
                        gint start_y,
                        gint column_width,
                        gint row_height);
@@ -823,10 +817,6 @@ public:
         void start_autoscroll();
         void stop_autoscroll();
 
-        void scroll_region (long row,
-                            long count,
-                            long delta);
-
         void connect_pty_read();
         void disconnect_pty_read();
 
diff --git a/src/vteseq.cc b/src/vteseq.cc
index eabcbbaa..ff149a5c 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -316,8 +316,7 @@ Terminal::clear_current_line()
                 _vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count);
                rowdata->attr.soft_wrapped = 0;
                /* Repaint this row. */
-               invalidate_cells(0, m_column_count,
-                                 m_screen->cursor.row, 1);
+                invalidate_row(m_screen->cursor.row);
        }
 
        /* We've modified the display.  Make a note of it. */
@@ -341,7 +340,7 @@ Terminal::clear_above_current()
                         _vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count);
                        rowdata->attr.soft_wrapped = 0;
                        /* Repaint the row. */
-                       invalidate_cells(0, m_column_count, i, 1);
+                        invalidate_row(i);
                }
        }
        /* We've modified the display.  Make a note of it. */
@@ -377,7 +376,7 @@ Terminal::scroll_text(vte::grid::row_t scroll_amount)
        }
 
        /* Update the display. */
-        scroll_region(start, end - start + 1, scroll_amount);
+        invalidate_rows(start, end);
 
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
@@ -679,8 +678,7 @@ Terminal::clear_to_bol()
                }
        }
        /* Repaint this row. */
-        invalidate_cells(0, m_screen->cursor.col+1,
-                         m_screen->cursor.row, 1);
+        invalidate_row(m_screen->cursor.row);
 
        /* We've modified the display.  Make a note of it. */
         m_text_deleted_flag = TRUE;
@@ -735,8 +733,7 @@ Terminal::clear_below_current()
                }
                rowdata->attr.soft_wrapped = 0;
                /* Repaint this row. */
-               invalidate_cells(0, m_column_count,
-                                 i, 1);
+                invalidate_row(i);
        }
 
        /* We've modified the display.  Make a note of it. */
@@ -775,8 +772,7 @@ Terminal::clear_to_eol()
        }
        rowdata->attr.soft_wrapped = 0;
        /* Repaint this row. */
-       invalidate_cells(m_screen->cursor.col, m_column_count - m_screen->cursor.col,
-                         m_screen->cursor.row, 1);
+        invalidate_row(m_screen->cursor.row);
 }
 
 /*
@@ -908,8 +904,7 @@ Terminal::delete_character()
                        }
                         rowdata->attr.soft_wrapped = 0;
                        /* Repaint this row. */
-                        invalidate_cells(col, len - col,
-                                         m_screen->cursor.row, 1);
+                        invalidate_row(m_screen->cursor.row);
                }
        }
 
@@ -967,8 +962,7 @@ Terminal::erase_characters(long count)
                        }
                }
                /* Repaint this row. */
-                invalidate_cells(m_screen->cursor.col, count,
-                                 m_screen->cursor.row, 1);
+                invalidate_row(m_screen->cursor.row);
        }
 
        /* We've modified the display.  Make a note of it. */
@@ -1082,8 +1076,7 @@ Terminal::move_cursor_tab_forward(int count)
                 }
         }
 
-        invalidate_cells(m_screen->cursor.col, newcol - m_screen->cursor.col,
-                         m_screen->cursor.row, 1);
+        invalidate_row(m_screen->cursor.row);
         m_screen->cursor.col = newcol;
 }
 
@@ -1299,7 +1292,7 @@ Terminal::insert_lines(vte::grid::row_t param)
        }
         m_screen->cursor.col = 0;
        /* Update the display. */
-        scroll_region(row, end - row + 1, param);
+        invalidate_rows(row, end);
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
        /* We've modified the display.  Make a note of it. */
@@ -1334,7 +1327,7 @@ Terminal::delete_lines(vte::grid::row_t param)
        }
         m_screen->cursor.col = 0;
        /* Update the display. */
-        scroll_region(row, end - row + 1, -param);
+        invalidate_rows(row, end);
        /* Adjust the scrollbars if necessary. */
         adjust_adjustments();
        /* We've modified the display.  Make a note of it. */
@@ -6651,9 +6644,7 @@ Terminal::RI(vte::parser::Sequence const& seq)
                ring_remove(end);
                ring_insert(start, true);
                /* Update the display. */
-               scroll_region(start, end - start + 1, 1);
-                invalidate_cells(0, m_column_count,
-                                 start, 2);
+                invalidate_rows(start, end);
        } 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]