ansi icon indicating copy to clipboard operation
ansi copied to clipboard

Haxe utility for working with ANSI escape sequences.

ansi

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.

Examples

Text Color

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");

example


Sys.stdout().writeString(
	ANSI.set(Green, Bold) + "vivid green text" +
	ANSI.set(DefaultForeground) + " normal text"
);

example


Move and Delete

Sys.stdout().writeString("hello world" + ANSI.moveLeft(5) + ANSI.deleteChars(5) + "ansi");

example


Window Title

Sys.stdout().writeString(ANSI.title("Window title goes here"));

example


Particles!

See Test.hx.

particles gif