RUSH
Reusable Utilities in Single Headers is a collection of header-only utilities for C++
Loading...
Searching...
No Matches
color.hpp File Reference

This library provides text color and style formating utilities. More...

#include <cstdint>
#include <ostream>
#include <string>
#include <type_traits>

Go to the source code of this file.

Typedefs

using rush::color::fg = Foreground
 
using rush::color::bg = Background
 
using rush::color::st = Style
 

Enumerations

enum class  rush::color::Foreground : std::uint8_t {
  black = 30 , red , green , yellow ,
  blue , magenta , cyan , gray ,
  white = 0
}
 Stream buffer foreground color. More...
 
enum class  rush::color::Background : std::uint8_t {
  black = 40 , red , green , yellow ,
  blue , magenta , cyan , gray
}
 Stream buffer background color. More...
 
enum class  rush::color::Style : std::uint8_t {
  bold = 1 , dim , italic , underline ,
  blink , rblink , reversed , conceal ,
  crossed
}
 Stream buffer style. More...
 

Functions

template<typename T >
checkType< T > rush::color::operator<< (std::ostream &os, const T x)
 Stream insertion operator for applying styles and colors.
 

Variables

constexpr char rush::color::reset [] = "\033[0m"
 
constexpr char rush::color::endl [] = "\033[0m\n"
 

Detailed Description

This library provides text color and style formating utilities.

Author
Raul Tapia (raultapia.com)
See also
https://github.com/raultapia/rush

Typedef Documentation

◆ bg

using rush::color::bg = Background

Alias for Background

◆ fg

using rush::color::fg = Foreground

Alias for Foreground

◆ st

using rush::color::st = Style

Alias for Style

Enumeration Type Documentation

◆ Background

enum class rush::color::Background : std::uint8_t
strong

Stream buffer background color.

This enumeration defines various background colors that can be applied to text in console output.

◆ Foreground

enum class rush::color::Foreground : std::uint8_t
strong

Stream buffer foreground color.

This enumeration defines various foreground colors that can be applied to text in console output.

◆ Style

enum class rush::color::Style : std::uint8_t
strong

Stream buffer style.

This enumeration defines various text styles that can be applied to text in console output.

Function Documentation

◆ operator<<()

template<typename T >
checkType< T > rush::color::operator<< ( std::ostream & os,
const T x )

Stream insertion operator for applying styles and colors.

This operator allows applying styles and colors to an output stream using the defined enumerations.

Template Parameters
TThe type of the style or color.
Parameters
osThe output stream.
xThe style or color to apply.
Returns
The modified output stream.

Variable Documentation

◆ endl

char rush::color::endl[] = "\033[0m\n"
constexpr

Escape sequence to reset text formatting and add a newline

◆ reset

char rush::color::reset[] = "\033[0m"
constexpr

Escape sequence to reset text formatting

Examples
/github/workspace/include/rush/string.hpp.