Search code examples
node.jsttyansi-escape

Parse ANSI TTY output and handle cursormoves/rewriting


I am capturing output from a TTY but it is full of ANSI escape codes, many of which move the cursor and rewrite part of the screen. I would like to be able to feed this string into a parser and have it resolve all the rewrites...

I have tried a couple of libraries such as anser but it looks to me like it just strips the ansi instead of resolving cursor moves when I call ansiToText. Any advice?


Solution

  • Aha! I finally found it: npm install terminal.js

    My problem here was that I was looking for a 'parser' or a 'resolver' when I wanted an 'emulator'

    ¯\_(ツ)_/¯