fiber
Loading...
Searching...
No Matches
ansi.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string_view>
4
5// Compile-time toggle to disable ANSI codes
6#ifdef FIBER_DISABLE_ANSI_CODES
7 #define FIBER_ANSI_CODE(str) ""
8#else
9 #define FIBER_ANSI_CODE(str) str
10#endif
11
12namespace fiber::ansi {
13
14// Reset
15constexpr std::string_view reset = FIBER_ANSI_CODE("\x1b[0m");
16
17// Text styles
18constexpr std::string_view bold = FIBER_ANSI_CODE("\x1b[1m");
19constexpr std::string_view dim = FIBER_ANSI_CODE("\x1b[2m");
20constexpr std::string_view italic = FIBER_ANSI_CODE("\x1b[3m");
21constexpr std::string_view underline = FIBER_ANSI_CODE("\x1b[4m");
22constexpr std::string_view inverse = FIBER_ANSI_CODE("\x1b[7m");
23constexpr std::string_view hidden = FIBER_ANSI_CODE("\x1b[8m");
24constexpr std::string_view strikethrough = FIBER_ANSI_CODE("\x1b[9m");
25
26// Foreground colors
27constexpr std::string_view black = FIBER_ANSI_CODE("\x1b[30m");
28constexpr std::string_view red = FIBER_ANSI_CODE("\x1b[31m");
29constexpr std::string_view green = FIBER_ANSI_CODE("\x1b[32m");
30constexpr std::string_view yellow = FIBER_ANSI_CODE("\x1b[33m");
31constexpr std::string_view orange = FIBER_ANSI_CODE("\x1b[38;2;255;165;0m");
32constexpr std::string_view blue = FIBER_ANSI_CODE("\x1b[34m");
33constexpr std::string_view magenta = FIBER_ANSI_CODE("\x1b[35m");
34constexpr std::string_view cyan = FIBER_ANSI_CODE("\x1b[36m");
35constexpr std::string_view white = FIBER_ANSI_CODE("\x1b[37m");
36
37// Foreground colors light
38constexpr std::string_view light_black = FIBER_ANSI_CODE("\x1b[38;2;80;80;80m");
39constexpr std::string_view light_red = FIBER_ANSI_CODE("\x1b[38;2;255;85;85m");
40constexpr std::string_view light_green = FIBER_ANSI_CODE("\x1b[38;2;144;238;144m");
41constexpr std::string_view light_yellow = FIBER_ANSI_CODE("\x1b[38;2;255;255;145m");
42constexpr std::string_view light_orange = FIBER_ANSI_CODE("\x1b[38;2;255;190;20m");
43constexpr std::string_view light_blue = FIBER_ANSI_CODE("\x1b[38;2;173;216;230m");
44constexpr std::string_view light_magenta = FIBER_ANSI_CODE("\x1b[38;2;240;140;240m");
45constexpr std::string_view light_cyan = FIBER_ANSI_CODE("\x1b[38;2;128;255;255m");
46constexpr std::string_view light_grey = FIBER_ANSI_CODE("\x1b[38;2;200;200;200m");
47
48// Foreground colors (bright)
49constexpr std::string_view bright_black = FIBER_ANSI_CODE("\x1b[90m");
50constexpr std::string_view bright_red = FIBER_ANSI_CODE("\x1b[91m");
51constexpr std::string_view bright_green = FIBER_ANSI_CODE("\x1b[92m");
52constexpr std::string_view bright_yellow = FIBER_ANSI_CODE("\x1b[93m");
53constexpr std::string_view bright_blue = FIBER_ANSI_CODE("\x1b[94m");
54constexpr std::string_view bright_magenta= FIBER_ANSI_CODE("\x1b[95m");
55constexpr std::string_view bright_cyan = FIBER_ANSI_CODE("\x1b[96m");
56constexpr std::string_view bright_white = FIBER_ANSI_CODE("\x1b[97m");
57
58// Background colors (standard)
59constexpr std::string_view bg_black = FIBER_ANSI_CODE("\x1b[40m");
60constexpr std::string_view bg_red = FIBER_ANSI_CODE("\x1b[41m");
61constexpr std::string_view bg_green = FIBER_ANSI_CODE("\x1b[42m");
62constexpr std::string_view bg_yellow = FIBER_ANSI_CODE("\x1b[43m");
63constexpr std::string_view bg_blue = FIBER_ANSI_CODE("\x1b[44m");
64constexpr std::string_view bg_magenta = FIBER_ANSI_CODE("\x1b[45m");
65constexpr std::string_view bg_cyan = FIBER_ANSI_CODE("\x1b[46m");
66constexpr std::string_view bg_white = FIBER_ANSI_CODE("\x1b[47m");
67
68// Background colors (bright)
69constexpr std::string_view bg_bright_black = FIBER_ANSI_CODE("\x1b[100m");
70constexpr std::string_view bg_bright_red = FIBER_ANSI_CODE("\x1b[101m");
71constexpr std::string_view bg_bright_green = FIBER_ANSI_CODE("\x1b[102m");
72constexpr std::string_view bg_bright_yellow = FIBER_ANSI_CODE("\x1b[103m");
73constexpr std::string_view bg_bright_blue = FIBER_ANSI_CODE("\x1b[104m");
74constexpr std::string_view bg_bright_magenta= FIBER_ANSI_CODE("\x1b[105m");
75constexpr std::string_view bg_bright_cyan = FIBER_ANSI_CODE("\x1b[106m");
76constexpr std::string_view bg_bright_white = FIBER_ANSI_CODE("\x1b[107m");
77
78// Aliases:
79constexpr std::string_view grey = bright_black;
80
81} // namespace fiber::ansi
#define FIBER_ANSI_CODE(str)
Definition ansi.hpp:9
Definition ansi.hpp:12
constexpr std::string_view bg_cyan
Definition ansi.hpp:65
constexpr std::string_view bg_bright_magenta
Definition ansi.hpp:74
constexpr std::string_view light_red
Definition ansi.hpp:39
constexpr std::string_view bright_black
Definition ansi.hpp:49
constexpr std::string_view light_blue
Definition ansi.hpp:43
constexpr std::string_view hidden
Definition ansi.hpp:23
constexpr std::string_view black
Definition ansi.hpp:27
constexpr std::string_view bg_bright_cyan
Definition ansi.hpp:75
constexpr std::string_view magenta
Definition ansi.hpp:33
constexpr std::string_view dim
Definition ansi.hpp:19
constexpr std::string_view light_grey
Definition ansi.hpp:46
constexpr std::string_view bg_white
Definition ansi.hpp:66
constexpr std::string_view bg_bright_black
Definition ansi.hpp:69
constexpr std::string_view bg_yellow
Definition ansi.hpp:62
constexpr std::string_view white
Definition ansi.hpp:35
constexpr std::string_view bg_magenta
Definition ansi.hpp:64
constexpr std::string_view bold
Definition ansi.hpp:18
constexpr std::string_view bright_yellow
Definition ansi.hpp:52
constexpr std::string_view bright_white
Definition ansi.hpp:56
constexpr std::string_view light_yellow
Definition ansi.hpp:41
constexpr std::string_view bright_green
Definition ansi.hpp:51
constexpr std::string_view light_black
Definition ansi.hpp:38
constexpr std::string_view light_cyan
Definition ansi.hpp:45
constexpr std::string_view bg_blue
Definition ansi.hpp:63
constexpr std::string_view light_orange
Definition ansi.hpp:42
constexpr std::string_view strikethrough
Definition ansi.hpp:24
constexpr std::string_view underline
Definition ansi.hpp:21
constexpr std::string_view orange
Definition ansi.hpp:31
constexpr std::string_view reset
Definition ansi.hpp:15
constexpr std::string_view bg_bright_red
Definition ansi.hpp:70
constexpr std::string_view grey
Definition ansi.hpp:79
constexpr std::string_view italic
Definition ansi.hpp:20
constexpr std::string_view cyan
Definition ansi.hpp:34
constexpr std::string_view bg_black
Definition ansi.hpp:59
constexpr std::string_view light_magenta
Definition ansi.hpp:44
constexpr std::string_view light_green
Definition ansi.hpp:40
constexpr std::string_view bg_bright_white
Definition ansi.hpp:76
constexpr std::string_view bright_cyan
Definition ansi.hpp:55
constexpr std::string_view bright_red
Definition ansi.hpp:50
constexpr std::string_view bright_blue
Definition ansi.hpp:53
constexpr std::string_view inverse
Definition ansi.hpp:22
constexpr std::string_view blue
Definition ansi.hpp:32
constexpr std::string_view bg_red
Definition ansi.hpp:60
constexpr std::string_view red
Definition ansi.hpp:28
constexpr std::string_view bright_magenta
Definition ansi.hpp:54
constexpr std::string_view bg_bright_green
Definition ansi.hpp:71
constexpr std::string_view bg_bright_blue
Definition ansi.hpp:73
constexpr std::string_view yellow
Definition ansi.hpp:30
constexpr std::string_view green
Definition ansi.hpp:29
constexpr std::string_view bg_bright_yellow
Definition ansi.hpp:72
constexpr std::string_view bg_green
Definition ansi.hpp:61