grid: track both linear and row,col cursor

This commit is contained in:
Daniel Eklöf 2019-06-17 21:15:20 +02:00
parent 963b266cce
commit 50c43be0d9
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 95 additions and 27 deletions

14
vt.c
View file

@ -158,13 +158,11 @@ action(struct terminal *term, enum action action, uint8_t c)
LOG_DBG("execute: 0x%02x", c);
switch (c) {
case '\r':
grid_cursor_to(
&term->grid,
term->grid.cursor / term->grid.cols * term->grid.cols);
grid_cursor_left(&term->grid, term->grid.cursor.col);
break;
case '\b':
grid_cursor_move(&term->grid, -1);
grid_cursor_left(&term->grid, 1);
break;
}
@ -179,9 +177,9 @@ action(struct terminal *term, enum action action, uint8_t c)
case ACTION_PRINT: {
if (term->grid.print_needs_wrap)
grid_cursor_move(&term->grid, 1);
grid_cursor_to(&term->grid, term->grid.cursor.row + 1, 0);
struct cell *cell = &term->grid.cells[term->grid.cursor];
struct cell *cell = &term->grid.cells[term->grid.linear_cursor];
cell->dirty = true;
@ -197,8 +195,8 @@ action(struct terminal *term, enum action action, uint8_t c)
cell->attrs = term->vt.attrs;
if ((term->grid.cursor + 1) % term->grid.cols)
grid_cursor_move(&term->grid, 1);
if (term->grid.cursor.col < term->grid.cols - 1)
grid_cursor_right(&term->grid, 1);
else
term->grid.print_needs_wrap = true;