aboutsummaryrefslogtreecommitdiff
path: root/vt.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-06-19 08:27:31 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-06-19 08:27:31 +0000
commitefc8cc49143c8945e3243380c86571af55e198cd (patch)
tree8ad065df8388dff0bdb4e3e90acfa45dedbdd841 /vt.c
parentwip: initial input handling (diff)
wip: initial scrolling support (no scrollback though)
Diffstat (limited to 'vt.c')
-rw-r--r--vt.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/vt.c b/vt.c
index 751eece3..1790201a 100644
--- a/vt.c
+++ b/vt.c
@@ -158,7 +158,11 @@ action(struct terminal *term, enum action action, uint8_t c)
LOG_DBG("execute: 0x%02x", c);
switch (c) {
case '\n':
- grid_cursor_down(&term->grid, 1);
+ LOG_DBG("NEWLINE: %d %d", term->grid.cursor.row, term->grid.rows);
+ if (term->grid.cursor.row == term->grid.rows - 1) {
+ grid_scroll(&term->grid, 1);
+ } else
+ grid_cursor_down(&term->grid, 1);
break;
case '\r':
@@ -188,8 +192,14 @@ action(struct terminal *term, enum action action, uint8_t c)
break;
case ACTION_PRINT: {
- if (term->grid.print_needs_wrap)
+ if (term->grid.print_needs_wrap) {
+ if (term->grid.cursor.row == term->grid.rows - 1) {
+ assert(false);
+ grid_scroll(&term->grid, 1);
+ }
+
grid_cursor_to(&term->grid, term->grid.cursor.row + 1, 0);
+ }
struct cell *cell = &term->grid.cells[term->grid.linear_cursor];