From 89559d5466502176995720a33316714012a638d1 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 16 Apr 2020 18:51:14 +0200 Subject: grid: move 'cursor' state from terminal to grid This way, the 'normal' and 'alt' grids have their own cursor state, and we don't need to switch between them. --- render.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index df67d85b..f0decd93 100644 --- a/render.c +++ b/render.c @@ -1373,7 +1373,7 @@ grid_render(struct terminal *term) */ bool cursor_is_visible = false; int view_end = (term->grid->view + term->rows - 1) & (term->grid->num_rows - 1); - int cursor_row = (term->grid->offset + term->cursor.point.row) & (term->grid->num_rows - 1); + int cursor_row = (term->grid->offset + term->grid->cursor.point.row) & (term->grid->num_rows - 1); if (view_end >= term->grid->view) { /* Not wrapped */ if (cursor_row >= term->grid->view && cursor_row <= view_end) @@ -1401,21 +1401,21 @@ grid_render(struct terminal *term) int view_aligned_row = (cursor_row - term->grid->view + term->grid->num_rows) & (term->grid->num_rows - 1); - term->render.last_cursor.actual = term->cursor.point; + term->render.last_cursor.actual = term->grid->cursor.point; term->render.last_cursor.in_view = (struct coord) { - term->cursor.point.col, view_aligned_row}; + term->grid->cursor.point.col, view_aligned_row}; struct row *row = grid_row_in_view(term->grid, view_aligned_row); - struct cell *cell = &row->cells[term->cursor.point.col]; + struct cell *cell = &row->cells[term->grid->cursor.point.col]; cell->attrs.clean = 0; term->render.last_cursor.cell = cell; int cols_updated = render_cell( - term, buf->pix, cell, term->cursor.point.col, view_aligned_row, true); + term, buf->pix, cell, term->grid->cursor.point.col, view_aligned_row, true); wl_surface_damage_buffer( term->window->surface, - term->margins.left + term->cursor.point.col * term->cell_width, + term->margins.left + term->grid->cursor.point.col * term->cell_width, term->margins.top + view_aligned_row * term->cell_height, cols_updated * term->cell_width, term->cell_height); } @@ -1804,7 +1804,7 @@ maybe_resize(struct terminal *term, int width, int height, bool force) term_cursor_to( term, cursor_row, - min(term->cursor.point.col, term->cols - 1)); + min(term->grid->cursor.point.col, term->cols - 1)); /* If in alt screen, update the saved 'normal' cursor too */ if (term->grid == &term->alt) { @@ -1813,10 +1813,10 @@ maybe_resize(struct terminal *term, int width, int height, bool force) while (cursor_row < 0) cursor_row += term->grid->num_rows; - term->alt_saved_cursor.lcf = false; - term->alt_saved_cursor.point.row = cursor_row; - term->alt_saved_cursor.point.col = min( - term->alt_saved_cursor.point.col, term->cols - 1); + term->normal.cursor.lcf = false; + term->normal.cursor.point.row = cursor_row; + term->normal.cursor.point.col = min( + term->normal.cursor.point.col, term->cols - 1); } term->render.last_cursor.cell = NULL; -- cgit v1.3