Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ByronBecker/motoko-color
A library for rendering color schemes and graphics to the terminal, based on the ANSI ASCII standard in Motoko
https://github.com/ByronBecker/motoko-color
Last synced: 3 months ago
JSON representation
A library for rendering color schemes and graphics to the terminal, based on the ANSI ASCII standard in Motoko
- Host: GitHub
- URL: https://github.com/ByronBecker/motoko-color
- Owner: ByronBecker
- License: apache-2.0
- Created: 2022-02-02T20:42:03.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-08T07:06:31.000Z (over 2 years ago)
- Last Synced: 2024-08-04T00:14:16.087Z (6 months ago)
- Language: Motoko
- Size: 50.8 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-motoko - motoko-color - A Motoko library for rendering color schemes and graphics to the terminal, based on the ANSI ASCII standard. (Development tools / Testing)
- awesome-motoko - motoko-color - A Motoko library for rendering color schemes and graphics to the terminal, based on the ANSI ASCII standard. (Development tools / Testing)
README
# motoko-color
A library for styling your terminal in Motoko!
![Example image](./readme_example_image.png)
## Getting started
Easy to use, expressive API:
```motoko
import Writer "mo:color/Writer";
import TextStyle "mo:color/TextStyle";let { backgroundColor; textColor } = TextStyle;
let writer = Writer.Writer();
writer
.text("hello world")
.textColor(textColor.black)
.backgroundColor(backgroundColor.white)
.bold(true)
.print();
```Chain multiple colors on the same line:
```motoko
...
import Debug "mo:base/Debug";Debug.print(
writer
.text("It's easy being green")
.textColor(textColor.green)
.read()
# ", however... " #
writer
.text("I really love purple backgrounds!")
.backgroundColor(backgroundColor.purple)
.read()
);
```
Use RGB colors for the text or background:
```motoko
writer
.text("woah dude, RGB!")
.textColorRGB(20,40,60)
.backgroundColorRGB(180,200,220)
.print();
```Immutable text styling settings, so use it all over the place, and don't worry about overwriting a bound setting.
```motoko
let greenCheckMark = writer
.text("✓")
.textColor(textColor.green)
.backgroundColor(backgroundColor.white);
let redCheckMark = greenCheckMark
.textColor(textColor.red);greenCheckMark.print();
redCheckMark.print();
```## Documentation
Further documentation for the latest release can be found at [https://byronbecker.github.io/motoko-color](https://byronbecker.github.io/motoko-color).
If you'd like to generate documentation locally run $(vessel bin)/mo-doc && firefox docs/index.html
## Example
See the [example folder](https://github.com/ByronBecker/motoko-color/tree/main/example) for usage,
making sure that both [vessel](https://github.com/dfinity/vessel) and [wasmtime](https://wasmtime.dev/) are installed before running `make run-example` from the root directory.
## Credits
Credits to [Christopher Hegemann](https://github.com/kritzcreek) for [motoko-library-template](https://github.com/kritzcreek/motoko-library-template) that helped jumpstart this library
## License
motoko-color is distributed under the terms of the Apache License (Version 2.0).
See LICENSE for details.