From a99833d6c5c1a25eba14985faae062349ac73952 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sat, 10 Aug 2019 20:52:15 -0400 Subject: Respect scroll region in DL and IL --- term.c | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/term.c b/term.c index c71d4dc..8c2ee9f 100644 --- a/term.c +++ b/term.c @@ -53,11 +53,11 @@ static void move(struct Cell *dst, struct Cell *src, uint len) { memmove(dst, src, sizeof(*dst) * len); } -static void scrollUp(struct Term *t, uint n) { +static void scrollUp(struct Term *t, uint top, uint n) { move( - cell(t, t->scroll.top, 0), - cell(t, t->scroll.top + n, 0), - t->cols * (1 + t->scroll.bot - t->scroll.top - n) + cell(t, top, 0), + cell(t, top + n, 0), + t->cols * (1 + t->scroll.bot - top - n) ); erase( t->style, @@ -66,16 +66,16 @@ static void scrollUp(struct Term *t, uint n) { ); } -static void scrollDown(struct Term *t, uint n) { +static void scrollDown(struct Term *t, uint top, uint n) { move( - cell(t, t->scroll.top + n, 0), - cell(t, t->scroll.top, 0), - t->cols * (1 + t->scroll.bot - t->scroll.top - n) + cell(t, top + n, 0), + cell(t, top, 0), + t->cols * (1 + t->scroll.bot - top - n) ); erase( t->style, - cell(t, t->scroll.top, 0), - cell(t, t->scroll.top + n - 1, t->cols - 1) + cell(t, top, 0), + cell(t, top + n - 1, t->cols - 1) ); } @@ -174,43 +174,40 @@ ACTION(ech) { erase(t->style, C(Y, X), C(Y, MIN(X + P(0, 1) - 1, R))); } -ACTION(dl) { - uint n = MIN(P(0, 1), t->rows - Y); - move(C(Y, 0), C(Y + n, 0), t->cols * (t->rows - Y - n)); - erase(t->style, C(t->rows - n, 0), C(B, R)); -} ACTION(dch) { uint n = MIN(P(0, 1), t->cols - X); move(C(Y, X), C(Y, X + n), t->cols - X - n); erase(t->style, C(Y, t->cols - n), C(Y, R)); } -ACTION(il) { - uint n = MIN(P(0, 1), t->rows - Y); - move(C(Y + n, 0), C(Y, 0), t->cols * (t->rows - Y - n)); - erase(t->style, C(Y, 0), C(Y + n - 1, R)); -} ACTION(ich) { uint n = MIN(P(0, 1), t->cols - X); move(C(Y, X + n), C(Y, X), t->cols - X - n); erase(t->style, C(Y, X), C(Y, X + n - 1)); } +ACTION(dl) { scrollUp(t, Y, MIN(P(0, 1), t->scroll.bot - Y)); } +ACTION(il) { scrollDown(t, Y, MIN(P(0, 1), t->scroll.bot - Y)); } + ACTION(nl) { if (Y == t->scroll.bot) { - scrollUp(t, 1); + scrollUp(t, t->scroll.top, 1); } else { Y = MIN(Y + 1, B); } } ACTION(ri) { if (Y == t->scroll.top) { - scrollDown(t, 1); + scrollDown(t, t->scroll.top, 1); } else { if (Y) Y--; } } -ACTION(su) { scrollUp(t, MIN(P(0, 1), t->scroll.bot - t->scroll.top)); } -ACTION(sd) { scrollDown(t, MIN(P(0, 1), t->scroll.bot - t->scroll.top)); } +ACTION(su) { + scrollUp(t, t->scroll.top, MIN(P(0, 1), t->scroll.bot - t->scroll.top)); +} +ACTION(sd) { + scrollDown(t, t->scroll.top, MIN(P(0, 1), t->scroll.bot - t->scroll.top)); +} ACTION(decstbm) { t->scroll.bot = MIN(P(1, t->rows) - 1, B); t->scroll.top = MIN(P(0, 1) - 1, t->scroll.bot); @@ -227,10 +224,15 @@ static void mode(struct Term *t, wchar_t ch) { for (uint i = 0; i < t->param.n; ++i) { if (t->param.q) { switch (t->param.s[i]) { - break; case 1: // ignore + break; case 1: // DECCKM break; case DECAWM: mode |= Wrap; + break; case 12: // "Start Blinking Cursor" break; case DECTCEM: mode |= Cursor; - break; default: unhandled("DECSET/DECRST %u", t->param.s[i]); + break; default: { + if (t->param.s[i] < 1000) { + unhandled("DECSET/DECRST %u", t->param.s[i]); + } + } } } else { switch (t->param.s[i]) { -- cgit 1.4.1