mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-15 05:33:58 -04:00
render: move local static variables into the terminal struct
This commit is contained in:
parent
4838763d18
commit
f93384b9c9
2 changed files with 36 additions and 31 deletions
57
render.c
57
render.c
|
|
@ -370,27 +370,25 @@ grid_render(struct terminal *term)
|
||||||
gseq.g = gseq.glyphs;
|
gseq.g = gseq.glyphs;
|
||||||
gseq.count = 0;
|
gseq.count = 0;
|
||||||
|
|
||||||
static struct coord last_cursor = {0,0};
|
|
||||||
static struct coord last_cursor_on_screen = {0, 0};
|
|
||||||
static struct cell *last_cursor_cell = NULL;
|
|
||||||
|
|
||||||
bool all_clean = tll_length(term->grid->scroll_damage) == 0;
|
bool all_clean = tll_length(term->grid->scroll_damage) == 0;
|
||||||
|
|
||||||
/* Erase old cursor (if we rendered a cursor last time) */
|
/* Erase old cursor (if we rendered a cursor last time) */
|
||||||
if (last_cursor_cell != NULL) {
|
if (term->render.last_cursor.cell != NULL) {
|
||||||
render_cell(
|
render_cell(
|
||||||
term, buf, last_cursor_cell,
|
term, buf,
|
||||||
last_cursor_on_screen.col, last_cursor_on_screen.row, false);
|
term->render.last_cursor.cell,
|
||||||
|
term->render.last_cursor.in_view.col,
|
||||||
|
term->render.last_cursor.in_view.row, false);
|
||||||
|
|
||||||
wl_surface_damage_buffer(
|
wl_surface_damage_buffer(
|
||||||
term->wl.surface,
|
term->wl.surface,
|
||||||
last_cursor_on_screen.col * term->cell_width,
|
term->render.last_cursor.in_view.col * term->cell_width,
|
||||||
last_cursor_on_screen.row * term->cell_height,
|
term->render.last_cursor.in_view.row * term->cell_height,
|
||||||
term->cell_width, term->cell_height);
|
term->cell_width, term->cell_height);
|
||||||
last_cursor_cell = NULL;
|
term->render.last_cursor.cell = NULL;
|
||||||
|
|
||||||
if (last_cursor.col != term->cursor.col ||
|
if (term->render.last_cursor.actual.col != term->cursor.col ||
|
||||||
last_cursor.row != term->cursor.row) {
|
term->render.last_cursor.actual.row != term->cursor.row) {
|
||||||
/* Detect cursor movement - we don't dirty cells touched
|
/* Detect cursor movement - we don't dirty cells touched
|
||||||
* by the cursor, since only the final cell matters. */
|
* by the cursor, since only the final cell matters. */
|
||||||
all_clean = false;
|
all_clean = false;
|
||||||
|
|
@ -400,11 +398,8 @@ grid_render(struct terminal *term)
|
||||||
if (term->flash.active)
|
if (term->flash.active)
|
||||||
term_damage_view(term);
|
term_damage_view(term);
|
||||||
|
|
||||||
static struct buffer *last_buf = NULL;
|
|
||||||
static bool last_flash = false;
|
|
||||||
|
|
||||||
/* If we resized the window, or is flashing, or just stopped flashing */
|
/* If we resized the window, or is flashing, or just stopped flashing */
|
||||||
if (last_buf != buf || term->flash.active || last_flash) {
|
if (term->render.last_buf != buf || term->flash.active || term->render.was_flashing) {
|
||||||
LOG_DBG("new buffer");
|
LOG_DBG("new buffer");
|
||||||
|
|
||||||
/* Fill area outside the cell grid with the default background color */
|
/* Fill area outside the cell grid with the default background color */
|
||||||
|
|
@ -429,8 +424,8 @@ grid_render(struct terminal *term)
|
||||||
/* Force a full grid refresh */
|
/* Force a full grid refresh */
|
||||||
term_damage_view(term);
|
term_damage_view(term);
|
||||||
|
|
||||||
last_buf = buf;
|
term->render.last_buf = buf;
|
||||||
last_flash = term->flash.active;
|
term->render.was_flashing = term->flash.active;
|
||||||
}
|
}
|
||||||
|
|
||||||
tll_foreach(term->grid->scroll_damage, it) {
|
tll_foreach(term->grid->scroll_damage, it) {
|
||||||
|
|
@ -516,25 +511,25 @@ grid_render(struct terminal *term)
|
||||||
if (cursor_is_visible && !term->hide_cursor) {
|
if (cursor_is_visible && !term->hide_cursor) {
|
||||||
/* Remember cursor coordinates so that we can erase it next
|
/* Remember cursor coordinates so that we can erase it next
|
||||||
* time. Note that we need to re-align it against the view. */
|
* time. Note that we need to re-align it against the view. */
|
||||||
last_cursor = term->cursor;
|
int view_aligned_row
|
||||||
last_cursor_on_screen = (struct coord) {
|
= (cursor_row - term->grid->view + term->grid->num_rows)
|
||||||
term->cursor.col,
|
% term->grid->num_rows;
|
||||||
(cursor_row - term->grid->view + term->grid->num_rows) % term->grid->num_rows,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct row *row = grid_row_in_view(
|
term->render.last_cursor.actual = term->cursor;
|
||||||
term->grid, last_cursor_on_screen.row);
|
term->render.last_cursor.in_view = (struct coord) {
|
||||||
|
term->cursor.col, view_aligned_row};
|
||||||
|
|
||||||
last_cursor_cell = &row->cells[term->cursor.col];
|
struct row *row = grid_row_in_view(term->grid, view_aligned_row);
|
||||||
render_cell(term, buf, last_cursor_cell,
|
|
||||||
term->cursor.col,
|
term->render.last_cursor.cell = &row->cells[term->cursor.col];
|
||||||
last_cursor_on_screen.row,
|
render_cell(
|
||||||
true);
|
term, buf, term->render.last_cursor.cell,
|
||||||
|
term->cursor.col, view_aligned_row, true);
|
||||||
|
|
||||||
wl_surface_damage_buffer(
|
wl_surface_damage_buffer(
|
||||||
term->wl.surface,
|
term->wl.surface,
|
||||||
term->cursor.col * term->cell_width,
|
term->cursor.col * term->cell_width,
|
||||||
term->cursor.row * term->cell_height,
|
view_aligned_row * term->cell_height,
|
||||||
term->cell_width, term->cell_height);
|
term->cell_width, term->cell_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
10
terminal.h
10
terminal.h
|
|
@ -323,6 +323,16 @@ struct terminal {
|
||||||
struct wayland wl;
|
struct wayland wl;
|
||||||
struct {
|
struct {
|
||||||
struct wl_callback *frame_callback;
|
struct wl_callback *frame_callback;
|
||||||
|
|
||||||
|
/* Last rendered cursor position */
|
||||||
|
struct {
|
||||||
|
struct coord actual; /* Absolute */
|
||||||
|
struct coord in_view; /* Offset by view */
|
||||||
|
const struct cell *cell; /* For easy access to content */
|
||||||
|
} last_cursor;
|
||||||
|
|
||||||
|
struct buffer *last_buf; /* Buffer we rendered to last time */
|
||||||
|
bool was_flashing; /* Flash was active last time we rendered */
|
||||||
} render;
|
} render;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue