aboutsummaryrefslogtreecommitdiff
path: root/vt.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-06-17 19:15:20 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-06-17 19:15:20 +0000
commit50c43be0d9729c20b1daa7a1303ca247aed2bb9e (patch)
treee46ec16f795b5647cd09e86725dacb559ac538ea /vt.c
parentvt: handle cursor-at-right-edge (diff)
grid: track both linear and row,col cursor
Diffstat (limited to 'vt.c')
-rw-r--r--vt.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/vt.c b/vt.c
index e1fe0f03..06d4a1a0 100644
--- a/vt.c
+++ b/vt.c
@@ -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;