diff options
Diffstat (limited to '')
-rw-r--r-- | term.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/term.c b/term.c index dff09f4..18eeb66 100644 --- a/term.c +++ b/term.c @@ -74,6 +74,22 @@ static void move(struct Cell *dst, struct Cell *src, uint len) { memmove(dst, src, sizeof(*dst) * len); } +static void scrollUp(uint n) { + move( + cell(scroll.top, 0), cell(scroll.top + n, 0), + cols * (scroll.bot - scroll.top - (n - 1)) + ); + clear(cell(scroll.bot - (n - 1), 0), cell(scroll.bot, cols - 1)); +} + +static void scrollDown(uint n) { + move( + cell(scroll.top + n, 0), cell(scroll.top, 0), + cols * (scroll.bot - scroll.top - (n - 1)) + ); + clear(cell(scroll.top, 0), cell(scroll.top + (n - 1), cols - 1)); +} + static char updateNUL(wchar_t ch) { switch (ch) { break; case ESC: return ESC; @@ -83,11 +99,7 @@ static char updateNUL(wchar_t ch) { break; case NL: { if (y == scroll.bot) { - move( - cell(scroll.top, 0), cell(scroll.top + 1, 0), - cols * (scroll.bot - scroll.top) - ); - clear(cell(scroll.bot, 0), cell(scroll.bot, cols - 1)); + scrollUp(1); } else { y = MIN(y + 1, rows - 1); } @@ -133,13 +145,7 @@ static char updateESC(wchar_t ch) { break; case CSI: return CSI; break; case OSC: return OSC; - break; case RI: { - move( - cell(scroll.top + 1, 0), cell(scroll.top, 0), - cols * (scroll.bot - scroll.top) - ); - clear(cell(scroll.top, 0), cell(scroll.top, cols - 1)); - } + break; case RI: scrollDown(1); break; case '(': discard = true; return ESC; break; case '=': // ignore |