Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snsvrno/ansi-hx
easy to use ansi commands to make beautiful and interesting terminal appications in haxe
https://github.com/snsvrno/ansi-hx
ansi haxe library terminal tui
Last synced: about 1 month ago
JSON representation
easy to use ansi commands to make beautiful and interesting terminal appications in haxe
- Host: GitHub
- URL: https://github.com/snsvrno/ansi-hx
- Owner: snsvrno
- License: mit
- Created: 2022-05-25T20:11:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-07T22:35:14.000Z (over 1 year ago)
- Last Synced: 2024-10-27T05:51:31.367Z (2 months ago)
- Topics: ansi, haxe, library, terminal, tui
- Language: Haxe
- Homepage:
- Size: 43.9 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ANSI.hx
A haxe library with easy access to ANSI commands / escape codes.
Implements most commands allowing for complete control of the terminal.
## Getting Started
install using this git repo
```
haxelib git http://www.github.com/snsvrno/ansi-hx.git
```and then use to make rich terminal applications
```haxe
import ansi.Paint.*;
// you can use single commands it change different aspectsSys.println(background(Cyan) + bold() + " [ ANSI.hx ] " + reset());
Sys.println(color(Magenta) + "It's " + italic() + color() + "Great!" + italic(false));// or you can use the paint wrapper
Sys.println(paint(" [ ANSI.hx ] ", null, Cyan, Bold));
Sys.println(paint("It's ", Magenta) + paint("Great!", Standout));
```![output of the above commands](images/short-example.png)
## General Usage
There are two main packages:
1. `ansi.Command` - sends commands to the terminal
2. `ansi.Paint` - creates command strings that need to be written to the terminal### Features
#### Color Fallback
By default **ANSI.hx** will be using `True Color` mode. This should allow you to print to the terminal using all 24bits of colors.
All though all modern terminals _should_ support this, there maybe some that do not. **ANSI.hx** has a fallback so that things will look somewhat like you want them.
In order to enable fallback you need to run the color mode check function
```haxe
ansi.colors.ColorMode.check();
```This will determine if the terminal supports `True Color` `256 Color` or just the standard `16` colors.
Everything else will automatically evaluate based on what the terminal supports.
```haxe
Sys.println(backgroundRGB(0, 230, 0));
```This will show the actual rgb color of (0,230,0) if `True Color`, the closest 256 color of index `46` (0,255,0) in `256 Color` or the standard color of `Green`.
![3 different outputs based on the color mode of terminal](images/color-fallback.png)
It is imporant to note that the standard color scheme may vary drastically from the desired color because of a user's terminal theme.