Plasma
A type-safe, native Haxe library for terminals, providing a Chalk-like, easy-to-use, composable ANSI API, and other utilities such as, cursor, screen, and buffer manipulation. \
Known Support Platforms: hl, py, njs, js, cpp, cppia, and neko.
Usage
final plasma = new plasma.Plasma({level: TRUE_COLOR}); // Max Level
trace(plasma.yellow.bold.apply('Mrraow', 'Meow', 'Mrrp', 'Nya', 'Mlem'));
final red:Plasma = new Plasma().hex(0xFF0000);
final bold:Plasma = new Plasma().bold;
trace((red + bold) + "CRITICAL MEOW DETECTED");
For additional usage examples, please refer to /tests
API
plasma.<style>[.<style>...].apply(string, [string...])
e.g. plasma.blue.bold.underline.apply("Hello,", "world!");
Chain styles and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that plasma.red.yellow.green is equivalent to plasma.green.
Multiple arguments will be separated by space.
Modifiers
| Primary Constant | Enum | Aliases |
|---|---|---|
reset | Reset | - |
bold | Bold | strong |
dim | Dim | faint |
italic | Italic | - |
underline | Underline | - |
overline | Overline | - |
inverse | Inverse | invert reverse |
hidden | Hidden | conceal |
strikethrough | Strikethrough | - |
visible | Visible | - |
Color Styles
| Base Hue | Foreground | Background | Aliases |
|---|---|---|---|
| Base Variants | |||
| Black | black | bgBlack | - |
| Red | red | bgRed | - |
| Green | green | bgGreen | - |
| Yellow | yellow | bgYellow | - |
| Blue | blue | bgBlue | - |
| Magenta | magenta | bgMagenta | pink bgPink |
| Cyan | cyan | bgCyan | aqua bgAqua |
| White | white | bgWhite | - |
| Bright Variants | |||
| Bright Black | blackBright | bgBlackBright | gray grey |
| Bright Red | redBright | bgRedBright | - |
| Bright Green | greenBright | bgGreenBright | - |
| Bright Yellow | yellowBright | bgYellowBright | - |
| Bright Blue | blueBright | bgBlueBright | - |
| Bright Magenta | magentaBright | bgMagentaBright | pinkBright |
| Bright Cyan | cyanBright | bgCyanBright | aquaBright |
| Bright White | whiteBright | bgWhiteBright | - |
Since Chrome 69, ANSI escape codes are natively supported in the developer console.
Utilities
| Category | Method | Enum | Description |
|---|---|---|---|
| Cursor | Terminal.hideCursor() | HideCursor | Suppresses the visibility of the terminal Cursor. |
| Cursor | Terminal.showCursor() | ShowCursor | Restores Cursor visibility to the user interface. |
| Cursor | Terminal.saveCursor() | SaveCursor | Captures the current spatial coordinates of the Cursor. |
| Cursor | Terminal.restoreCursor() | RestoreCursor | Reinstates the Cursor to its previously recorded position. |
| Screen | Terminal.clearScreen() | ClearScreen | Clears all content from the current, active terminal Buffer. |
| Screen | Terminal.clearLine() | ClearLine | Clears all textual data on the current Cursor line. |
| Buffer | Terminal.enterAltBuffer() | EnterAltBuffer | Initializes the secondary alternate Screen environment Buffer. |
| Buffer | Terminal.leaveAltBuffer() | LeaveAltBuffer | Terminates the alternate Buffer and returns to the primary view. |
| System | Terminal.beep() | Bell | Triggers an audible hardware-based notification signal. |