ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
ppforest2::io::style Namespace Reference

TTY-aware ANSI colored output utilities. More...

Functions

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 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).
 

Detailed Description

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().

Function Documentation

◆ 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_colorIf true, unconditionally disable colored output.

◆ 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).