Terminal utility to display colours in your terminal written in reasonml. Very much inspired from Chalk and Colors.js, go check them out.
Install the project:
npm install colors.re --save
And add the dependency to your bs-dependencies in bsconfig.json
:
"bs-dependencies": [
"colors.re"
]
open Colors;
let redString = changeColor(Red, "Red String");
let redBgString = changeBackground(Red, "String with red background");
let modifyString = modify(Bold, "Bold String");
let myString =
colors(
~color=White,
~modifier=Bold,
~bg=BgBlueBright,
~keywordOptions={colorType: Green, word: "my"},
"this is my string"
);
Js.log(myString); // White text with blue background, with highlighted word "my" in Green
Or using the utils.
open Colors_Utils;
let (<<) = Colors_Utils.compose;
let (>>) = Colors_Utils.pipe;
let composedStyle =
Colors_Utils.bold
<< Colors_Utils.bgBlue
<< Colors_Utils.underline
<< Colors_Utils.green;
Js.log(
composedStyle("This string will be bold, underlined with a blue background with green text")
);
type color =
| Red
| Yellow
| Green
| Blue
| White
| Cyan
| Magenta
| BgBlack
| BgRed
| BgGreen
| BgYellow
| BgBlue
| BgMagenta
| BgCyan
| BgWhite
| BgRedBright
| BgGreenBright
| BgYellowBright
| BgBlueBright
| BgMagentaBright
| BgCyanBright
| BgWhiteBright;
type modifier =
| Reset
| Bold
| Dim
| Italic
| Underline
| Inverse
| Hidden
| Strikethrough;
Support color detection.