mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-14 05:33:59 -04:00
vt: handle cursor-at-right-edge
When printing to the right-most-cell, don't advance the cursor. Instead, set a flag that indicates that the *next* print should line-wrap.
This commit is contained in:
parent
4585df532c
commit
963b266cce
3 changed files with 11 additions and 2 deletions
1
grid.c
1
grid.c
|
|
@ -25,6 +25,7 @@ grid_cursor_move(struct grid *grid, int cols)
|
||||||
grid->cells[new_cursor].dirty = true;
|
grid->cells[new_cursor].dirty = true;
|
||||||
grid->cursor = new_cursor;
|
grid->cursor = new_cursor;
|
||||||
grid->dirty = true;
|
grid->dirty = true;
|
||||||
|
grid->print_needs_wrap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ struct grid {
|
||||||
int cell_height;
|
int cell_height;
|
||||||
|
|
||||||
int cursor;
|
int cursor;
|
||||||
|
bool print_needs_wrap;
|
||||||
struct cell *cells;
|
struct cell *cells;
|
||||||
|
|
||||||
uint32_t foreground;
|
uint32_t foreground;
|
||||||
|
|
|
||||||
11
vt.c
11
vt.c
|
|
@ -177,7 +177,10 @@ action(struct terminal *term, enum action action, uint8_t c)
|
||||||
memset(&term->vt.utf8, 0, sizeof(term->vt.utf8));
|
memset(&term->vt.utf8, 0, sizeof(term->vt.utf8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_PRINT:{
|
case ACTION_PRINT: {
|
||||||
|
if (term->grid.print_needs_wrap)
|
||||||
|
grid_cursor_move(&term->grid, 1);
|
||||||
|
|
||||||
struct cell *cell = &term->grid.cells[term->grid.cursor];
|
struct cell *cell = &term->grid.cells[term->grid.cursor];
|
||||||
|
|
||||||
cell->dirty = true;
|
cell->dirty = true;
|
||||||
|
|
@ -194,7 +197,11 @@ action(struct terminal *term, enum action action, uint8_t c)
|
||||||
|
|
||||||
cell->attrs = term->vt.attrs;
|
cell->attrs = term->vt.attrs;
|
||||||
|
|
||||||
grid_cursor_move(&term->grid, 1);
|
if ((term->grid.cursor + 1) % term->grid.cols)
|
||||||
|
grid_cursor_move(&term->grid, 1);
|
||||||
|
else
|
||||||
|
term->grid.print_needs_wrap = true;
|
||||||
|
|
||||||
term->grid.dirty = true;
|
term->grid.dirty = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue