Terminal string styling for C++.
Header-only. Expressive. ANSI-based.
https://vixcpp.com/registry/pkg/vix/chalk
vix/chalk provides a simple and expressive API to style terminal output.
It supports:
- foreground colors
- background colors
- text styles
- RGB colors
- HEX colors
It is designed to be:
- minimal
- predictable
- easy to use
- zero overhead
Styling terminal output is often:
- verbose
- repetitive
- hard to read
- error-prone
Using raw ANSI codes leads to:
- poor readability
- duplicated logic
- hard maintenance
vix/chalk provides:
- a clean API
- composable styles
- readable code
vix add @vix/chalk
vix installgit clone https://github.com/vixcpp/chalk.gitAdd include/ to your project.
#include <vix/chalk/chalk.hpp>
#include <iostream>
int main()
{
using namespace vix::chalk;
std::cout << red("error") << '\n';
std::cout << green("success") << '\n';
}std::cout << red().bold()("fatal error") << '\n';
std::cout << blue().underline()("important") << '\n';std::cout << bgRed().white().bold()(" ERROR ") << '\n';
std::cout << bgGreen().black()(" OK ") << '\n';std::cout << rgb(255, 153, 0)("orange") << '\n';
std::cout << bgRgb(30, 30, 30).white()("panel") << '\n';std::cout << hex("#ff9900")("brand") << '\n';
std::cout << bgHex("#1e1e1e").white()("title") << '\n';std::string clean = strip_ansi(red().bold()("error"));setEnabled(false);
setEnabled(true);- styles are immutable
- chaining builds a new style
- application happens at call time
- no global state mutation
| Operation | Complexity |
|---|---|
| style creation | O(1) |
| chaining | O(1) |
| apply style | O(n) |
- minimal API
- explicit behavior
- composable styles
- no hidden magic
- header-only simplicity
vix build
vix testMIT License Copyright (c) Gaspard Kirira