diff options
author | Dan Gudmundsson <[email protected]> | 2017-08-23 08:18:28 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-08-23 08:18:28 +0200 |
commit | 557a20b04e9e9c379295ca666e94658abcfbc1e3 (patch) | |
tree | 2f94d5ce7647408a3b984b22ac2b22a205962abb /erts/emulator | |
parent | eb4ef92b083f9874b5b4db1f1060585fbb653779 (diff) | |
parent | 6a179d28022b46c287a3e075561f97aa85208e31 (diff) | |
download | otp-557a20b04e9e9c379295ca666e94658abcfbc1e3.tar.gz otp-557a20b04e9e9c379295ca666e94658abcfbc1e3.tar.bz2 otp-557a20b04e9e9c379295ca666e94658abcfbc1e3.zip |
Merge pull request #1536 from ggcampinho/fix-ansi-buffer
Fix ANSI support in the console
OTP-14549
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/drivers/unix/ttsl_drv.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/erts/emulator/drivers/unix/ttsl_drv.c b/erts/emulator/drivers/unix/ttsl_drv.c index bce097d944..f3c1aa1c4a 100644 --- a/erts/emulator/drivers/unix/ttsl_drv.c +++ b/erts/emulator/drivers/unix/ttsl_drv.c @@ -1094,15 +1094,13 @@ static int insert_buf(byte *s, int n) lbuf[lpos++] = (CONTROL_TAG | ((Uint32) ch)); ch = 0; } while (lpos % 8); - } else if (ch == '\e' || ch == '\n' || ch == '\r') { + } else if (ch == '\e') { + lbuf[lpos++] = (CONTROL_TAG | ((Uint32) ch)); + } else if (ch == '\n' || ch == '\r') { write_buf(lbuf + buffpos, lpos - buffpos); - if (ch == '\e') { - outc('\e'); - } else { outc('\r'); if (ch == '\n') outc('\n'); - } if (llen > lpos) { memcpy(lbuf, lbuf + lpos, llen - lpos); } @@ -1150,14 +1148,17 @@ static int write_buf(Uint32 *s, int n) } --n; ++s; - } - else if (*s == (CONTROL_TAG | ((Uint32) '\t'))) { + } else if (*s == (CONTROL_TAG | ((Uint32) '\t'))) { outc(lastput = ' '); --n; s++; while (n > 0 && *s == CONTROL_TAG) { outc(lastput = ' '); --n; s++; } + } else if (*s == (CONTROL_TAG | ((Uint32) '\e'))) { + outc('\e'); + --n; + ++s; } else if (*s & CONTROL_TAG) { outc('^'); outc(lastput = ((byte) ((*s == 0177) ? '?' : *s | 0x40))); |