cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
toolbox::utils::color_handler_t Class Reference

平台无关的颜色处理类/Platform-independent color handler More...

#include <print.hpp>

Static Public Member Functions

static auto get_fg_code (color_t color) -> std::string
 获取前景色ANSI代码/Get ANSI code for foreground color
 
static auto get_bg_code (color_t color) -> std::string
 获取背景色ANSI代码/Get ANSI code for background color
 
static auto reset () -> std::string
 重置所有颜色/Reset all colors
 
static auto colorize (const std::string &text, color_t fg, color_t bg) -> std::string
 应用颜色到文本/Apply color to text
 
static auto supports_color () -> bool
 检查是否支持颜色/Check if color is supported
 

Detailed Description

平台无关的颜色处理类/Platform-independent color handler

用于处理终端颜色输出/Used for handling terminal color output

Member Function Documentation

◆ colorize()

static auto toolbox::utils::color_handler_t::colorize ( const std::string &  text,
color_t  fg,
color_t  bg 
) -> std::string
inlinestatic

应用颜色到文本/Apply color to text

Parameters
text文本内容/Text content
fg前景色/Foreground color
bg背景色/Background color
Returns
std::string 带颜色的文本/Colored text
std::string colored = color_handler_t::colorize("Hello", color_t::RED,
color_t::DEFAULT);
static auto colorize(const std::string &text, color_t fg, color_t bg) -> std::string
应用颜色到文本/Apply color to text
Definition print.hpp:316

◆ get_bg_code()

static auto toolbox::utils::color_handler_t::get_bg_code ( color_t  color) -> std::string
inlinestatic

获取背景色ANSI代码/Get ANSI code for background color

Parameters
color颜色枚举/Color enum
Returns
std::string ANSI转义码/ANSI escape code

◆ get_fg_code()

static auto toolbox::utils::color_handler_t::get_fg_code ( color_t  color) -> std::string
inlinestatic

获取前景色ANSI代码/Get ANSI code for foreground color

Parameters
color颜色枚举/Color enum
Returns
std::string ANSI转义码/ANSI escape code

◆ reset()

static auto toolbox::utils::color_handler_t::reset ( ) -> std::string
inlinestatic

重置所有颜色/Reset all colors

Returns
std::string ANSI重置码/ANSI reset code

◆ supports_color()

static auto toolbox::utils::color_handler_t::supports_color ( ) -> bool
inlinestatic

检查是否支持颜色/Check if color is supported

Returns
bool 是否支持/Whether color is supported
static auto supports_color() -> bool
检查是否支持颜色/Check if color is supported
Definition print.hpp:345

The documentation for this class was generated from the following file: