scroll

scrollbackbuffer program for st
git clone git://git.suckless.org//gitrepos
Log | Files | Refs

commit ece8a533fc846bdea670a74a9a1432efafcfe6f9
parent bec1249f5f66253017cfccd69009c32889696afd
Author: Jan Klemkow <j.klemkow@wemelug.de>
Date:   Wed, 25 Mar 2020 21:55:33 +0100

fix altscreen swap detection

Diffstat:
Mscroll.c | 26+++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/scroll.c b/scroll.c @@ -196,13 +196,13 @@ isaltscreen(char c) if (c == '\033') state = BREK; break; - case BREK: break; + case BREK: if (c == '[') state = ESC; else state = CHAR; break; - case ESC: break; + case ESC: buf[i++] = c; if (i == sizeof buf) { /* TODO: find a better way to handle this situation */ @@ -373,17 +373,17 @@ main(int argc, char *argv[]) ssize_t n = read(mfd, &c, 1); if (n == -1 && errno != EINTR) die("read:"); - if (isaltscreen(c)) - continue; - if (c == '\r') { - addline(buf, pos); - memset(buf, 0, size); - pos = 0; - } - buf[pos++] = c; - if (pos == size) { - size *= 2; - buf = earealloc(buf, size); + if (!isaltscreen(c)) { + if (c == '\r') { + addline(buf, pos); + memset(buf, 0, size); + pos = 0; + } + buf[pos++] = c; + if (pos == size) { + size *= 2; + buf = earealloc(buf, size); + } } if (write(STDOUT_FILENO, &c, 1) == -1) die("write:");