TTY-aware ANSI colored output utilities.
More...
|
| bool & | color_enabled () |
| | Global toggle for colored output.
|
| |
| std::string | emphasis (std::string const &s) |
| | Format text in bold (for emphasis / labels).
|
| |
| std::string | error (std::string const &s) |
| | Format text in red (for error messages).
|
| |
| std::string | info (std::string const &s) |
| | Format text in cyan (for informational highlights like progress bars).
|
| |
| void | init_color (bool no_color) |
| | Initialize color support based on TTY detection and user preference.
|
| |
| std::string | link (std::string const &url, std::string const &text) |
| | Wrap text in an OSC 8 hyperlink targeting url.
|
| |
| std::string | muted (std::string const &s) |
| | Format text in dim gray (for hints and secondary info).
|
| |
| std::string | styled (std::string const &s, fmt::terminal_color c) |
| | Apply a foreground color with a specific reset (\033[39m) instead of fmt's full reset, so that emphasis and other non-fg styles survive nesting.
|
| |
| std::string | success (std::string const &s) |
| | Format text in green (for success messages).
|
| |
| std::string | warning (std::string const &s) |
| | Format text in yellow (for warnings).
|
| |
TTY-aware ANSI colored output utilities.
Wraps fmt/color.h with conditional formatting that disables escape codes when stdout is not a TTY or the user passes –no-color. Provides semantic helpers: error(), success(), emphasis(), muted(), info(), and warning().
◆ color_enabled()
| bool & ppforest2::io::style::color_enabled |
( |
| ) |
|
|
inline |
Global toggle for colored output.
- Returns
- Reference to the static enabled flag.
◆ emphasis()
| std::string ppforest2::io::style::emphasis |
( |
std::string const & | s | ) |
|
|
inline |
Format text in bold (for emphasis / labels).
Uses a specific bold-off code (\033[22m) so that fg colors survive nesting, e.g. success("total: " + emphasis("7")).
◆ error()
| std::string ppforest2::io::style::error |
( |
std::string const & | s | ) |
|
|
inline |
Format text in red (for error messages).
◆ info()
| std::string ppforest2::io::style::info |
( |
std::string const & | s | ) |
|
|
inline |
Format text in cyan (for informational highlights like progress bars).
◆ init_color()
| void ppforest2::io::style::init_color |
( |
bool | no_color | ) |
|
|
inline |
Initialize color support based on TTY detection and user preference.
On Windows, enables ANSI Virtual Terminal Processing. Disables color when stdout is not a TTY or when the user explicitly requests no color.
- Parameters
-
| no_color | If true, unconditionally disable colored output. |
◆ link()
| std::string ppforest2::io::style::link |
( |
std::string const & | url, |
|
|
std::string const & | text ) |
|
inline |
Wrap text in an OSC 8 hyperlink targeting url.
Supported by iTerm2, WezTerm, Konsole, modern xterm, Windows Terminal and others. In terminals that don't recognize the escape sequence the URL text still shows verbatim, so the only behavioral difference is "click to open" in capable terminals. Falls back to plain text when colored output is disabled (no-TTY or –no-color).
◆ muted()
| std::string ppforest2::io::style::muted |
( |
std::string const & | s | ) |
|
|
inline |
Format text in dim gray (for hints and secondary info).
◆ styled()
| std::string ppforest2::io::style::styled |
( |
std::string const & | s, |
|
|
fmt::terminal_color | c ) |
|
inline |
Apply a foreground color with a specific reset (\033[39m) instead of fmt's full reset, so that emphasis and other non-fg styles survive nesting.
◆ success()
| std::string ppforest2::io::style::success |
( |
std::string const & | s | ) |
|
|
inline |
Format text in green (for success messages).
◆ warning()
| std::string ppforest2::io::style::warning |
( |
std::string const & | s | ) |
|
|
inline |
Format text in yellow (for warnings).