mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-04 07:15:29 -04:00
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.
This commit is contained in:
parent
c96a0b3b3c
commit
89559d5466
6 changed files with 136 additions and 129 deletions
22
render.c
22
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue