mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-17 05:33:52 -04:00
render: track last cursor position in absolute values
This seems to fix an issue where we sometimes saw "ghost" cursors when scrolling.
This commit is contained in:
parent
8ed7239458
commit
d5158b2432
1 changed files with 6 additions and 7 deletions
13
main.c
13
main.c
|
|
@ -386,11 +386,11 @@ grid_render_scroll_reverse(struct context *c, struct buffer *buf,
|
||||||
static void
|
static void
|
||||||
grid_render(struct context *c)
|
grid_render(struct context *c)
|
||||||
{
|
{
|
||||||
static struct cursor last_cursor = {.linear = 0, .col = 0, .row = 0};
|
static int last_cursor;
|
||||||
|
|
||||||
if (tll_length(c->term.grid->damage) == 0 &&
|
if (tll_length(c->term.grid->damage) == 0 &&
|
||||||
tll_length(c->term.grid->scroll_damage) == 0 &&
|
tll_length(c->term.grid->scroll_damage) == 0 &&
|
||||||
last_cursor.linear == c->term.cursor.linear)
|
last_cursor == c->term.cursor.linear)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -444,12 +444,11 @@ grid_render(struct context *c)
|
||||||
|
|
||||||
/* TODO: break out to function */
|
/* TODO: break out to function */
|
||||||
/* Re-render last cursor cell and current cursor cell */
|
/* Re-render last cursor cell and current cursor cell */
|
||||||
|
/* Make sure previous cursor is refreshed (to avoid "ghost" cursors) */
|
||||||
if (last_cursor.linear != c->term.cursor.linear) {
|
if (last_cursor != c->term.cursor.linear) {
|
||||||
struct damage prev_cursor = {
|
struct damage prev_cursor = {
|
||||||
.type = DAMAGE_UPDATE,
|
.type = DAMAGE_UPDATE,
|
||||||
.range = {.start = c->term.grid->offset + last_cursor.linear,
|
.range = {.start = last_cursor, .length = 1},
|
||||||
.length = 1},
|
|
||||||
};
|
};
|
||||||
grid_render_update(c, buf, &prev_cursor);
|
grid_render_update(c, buf, &prev_cursor);
|
||||||
}
|
}
|
||||||
|
|
@ -459,7 +458,7 @@ grid_render(struct context *c)
|
||||||
.range = {.start = c->term.grid->offset + c->term.cursor.linear, .length = 1},
|
.range = {.start = c->term.grid->offset + c->term.cursor.linear, .length = 1},
|
||||||
};
|
};
|
||||||
grid_render_update(c, buf, &cursor);
|
grid_render_update(c, buf, &cursor);
|
||||||
last_cursor = c->term.cursor;
|
last_cursor = c->term.grid->offset + c->term.cursor.linear;
|
||||||
|
|
||||||
c->term.grid->offset %= c->term.grid->size;
|
c->term.grid->offset %= c->term.grid->size;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue