|
clutchlog
0.13
|
Color and style formatter for ANSI terminal escape sequences. More...
#include <clutchlog.h>
Collaboration diagram for clutchlog::fmt:Color and style formatter for ANSI terminal escape sequences.
The formatter supports typographic "styles" and colors. Typographic styles are available as named tag in fmt::typo.
The formatter supports the three ANSI modes, which are automatically selected depending the argument types:
For 16-colors mode, colors are named tag in:
The following colors are available for both foregrounds (see fmt::fg) and backgrounds (see fmt::bg):
For 256-colors mode, colors are expected to be passed as integers in [-1,255] or the fg::none and bg::none tags.
fg::none tag as first argument.For 16M-colors mode, colors can be encoded as:
fg::none and bg::none tags.fg::none tag as first argument.Definition at line 366 of file clutchlog.h.
Public Member Functions | |
| fmt () | |
| Empty constructor, only useful for a no-op formatter. | |
| std::string | operator() (const std::string &msg) const |
| Format the given string with the currently encoded format. More... | |
| std::string | str () const |
| Return the formatting code as a string. | |
All combination of 16-colors mode constructors with different parameters orders. | |
| fmt (fg f, bg b=bg::none, typo s=typo::none) | |
| fmt (fg f, typo s, bg b=bg::none) | |
| fmt (bg b, fg f=fg::none, typo s=typo::none) | |
| fmt (bg b, typo s, fg f=fg::none) | |
| fmt (typo s, fg f=fg::none, bg b=bg::none) | |
| fmt (typo s, bg b, fg f=fg::none) | |
All combination of 256-colors mode constructors with different parameters orders. | |
| fmt (fg_256 f, bg_256 b, typo s=typo::none) | |
| fmt (fg_256 f, typo s=typo::none) | |
| fmt (fg, bg_256 b, typo s=typo::none) | |
All combination of 16M-colors mode constructors with different parameters orders. | |
| fmt (const short fr, const short fg, const short fb, const short gr, const short gg, const short gb, typo s=typo::none) | |
| fmt (fg, const short gr, const short gg, const short gb, typo s=typo::none) | |
| fmt (const short fr, const short fg, const short fb, bg, typo s=typo::none) | |
| fmt (const short fr, const short fg, const short fb, typo s=typo::none) | |
| fmt (const std::string &f, const std::string &b, typo s=typo::none) | |
| fmt (fg, const std::string &b, typo s=typo::none) | |
| fmt (const std::string &f, bg, typo s=typo::none) | |
| fmt (const std::string &f, typo s=typo::none) | |
Public Attributes | |
| enum clutchlog::fmt::ansi | mode |
| Current ANSI color mode. | |
| enum clutchlog::fmt::typo | style |
| Typographic style. | |
| enum clutchlog::fmt::fg | fore |
| Foreground color. | |
| enum clutchlog::fmt::bg | back |
| Background color. | |
Protected Member Functions | |
| std::ostream & | print_on (std::ostream &os) const |
| Print the currently encoded format escape code on the given output stream. | |
Protected Attributes | |
| clutchlog::fmt::fg_256 | fore_256 |
| Current foreground in 256-colors mode. | |
| clutchlog::fmt::bg_256 | back_256 |
| Current background in 256-colors mode. | |
| clutchlog::fmt::fg_16M | fore_16M |
| Current foreground in 16M-colors mode. | |
| clutchlog::fmt::bg_16M | back_16M |
| Current background in 16M-colors mode. | |
Classes | |
| struct | bg_16M |
| background in 256-colors mode. More... | |
| struct | bg_256 |
| Background in 256-colors mode. More... | |
| struct | color |
| Interface class for colors representation. More... | |
| struct | color_16M |
| Abstract base class for 16M colors objects (24-bits ANSI). More... | |
| struct | color_256 |
| Abstract base class for 256 colors objects (8-bits ANSI). More... | |
| struct | fg_16M |
| Foreground in 256-colors mode. More... | |
| struct | fg_256 |
| Foreground in 256-colors mode. More... | |
Public Types | |
| enum | ansi { ansi::colors_16 = -1, ansi::colors_256 = 5, ansi::colors_16M = 2 } |
| ANSI code configuring the available number of colors. More... | |
| enum | typo { reset = 0, bold = 1, underline = 4, inverse = 7, none = -1 } |
| Typographic style codes. | |
| enum | fg { black = 30, red = 31, green = 32, yellow = 33, blue = 34, magenta = 35, cyan = 36, white = 37, bright_black = 90, bright_red = 91, bright_green = 92, bright_yellow = 93, bright_blue = 94, bright_magenta = 95, bright_cyan = 96, bright_white = 97, none = -1 } |
| Foreground color codes. | |
| enum | bg { black = 40, red = 41, green = 42, yellow = 43, blue = 44, magenta = 45, cyan = 46, white = 47, bright_black = 100, bright_red = 101, bright_green = 102, bright_yellow = 103, bright_blue = 104, bright_magenta = 105, bright_cyan = 106, bright_white = 107, none = -1 } |
| Background color codes. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const std::tuple< fg, bg, typo > &fbs) |
| Output stream operator for a 3-tuple of 16-colors mode tags. | |
| std::ostream & | operator<< (std::ostream &os, const typo &s) |
| Output stream operator for a typo tag alone, in 16-colors mode. | |
| std::ostream & | operator<< (std::ostream &os, const fmt &fmt) |
| Output stream overload. More... | |
|
inline |
Format the given string with the currently encoded format.
Allow to use a formatter as a function:
Definition at line 795 of file clutchlog.h.
References print_on().
|
friend |
Output stream overload.
Allow to use a formatter as a tag within a stream:
Definition at line 780 of file clutchlog.h.
|
strong |
ANSI code configuring the available number of colors.
| Enumerator | |
|---|---|
| colors_16 | 16 colors mode. |
| colors_256 | 256 colors mode. |
| colors_16M | 16 millions ("true") colors mode. |
Definition at line 369 of file clutchlog.h.