Haxe utility for working with ANSI escape sequences.
Provides functions that return a String with the appropriate ANSI escape sequence. This is usually written to standard output for the hosting console to process.
Note: If the console doesn't support the escape sequences (e.g. default Command Prompt on Windows), you're going to see garbage.
Tested with the neko target and ansicon.
Sys.stdout().writeString(ANSI.set(ANSI.attr.Green) + "green text");
or shortened by importing ANSI and with it the Attribute enum:
import ANSI;
...
Sys.stdout().writeString(ANSI.set(Green) + "green text");
Sys.stdout().writeString(
ANSI.set(Green, Bold) + "vivid green text" +
ANSI.set(DefaultForeground) + " normal text"
);
Sys.stdout().writeString("hello world" + ANSI.moveLeft(5) + ANSI.deleteChars(5) + "ansi");
Sys.stdout().writeString(ANSI.title("Window title goes here"));
See Test.hx.