Fansi is a tiny library I wrote to make it easier to deal with colored text for display in the terminal.
It let's you easily apply or remove Ansi color codes to strings, or portions of them, and substring or split the colored strings according to their on-screen width. At the same time, it avoids problems with Ansi colors leaking "rightward" because you forgot to Console.RESET, and does all this efficiently with low memory use and high performance.
This makes it very convenient if you are not just constructing Ansi colored strings for immediate printing, but also passing them around your program, splicing/manipulating them, or applying additional colors after-the-fact. These are things that are traditionally very error-prone to do with java.lang.Strings with Ansi codes embedded, but with Fansi they are quick and easy.
Fansi was originally the text handling library for the
Ammonite REPL, now extracted into its own tiny library and published separately for people to use stand-alone.
Try it out; hope someone finds this useful!