Steppable 0.0.1
A CAS project written from scratch in C++
Loading...
Searching...
No Matches
colors.hpp
1/**************************************************************************************************
2 * Copyright (c) 2023-2025 NWSOFT *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy *
5 * of this software and associated documentation files (the "Software"), to deal *
6 * in the Software without restriction, including without limitation the rights *
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
8 * copies of the Software, and to permit persons to whom the Software is *
9 * furnished to do so, subject to the following conditions: *
10 * *
11 * The above copyright notice and this permission notice shall be included in all *
12 * copies or substantial portions of the Software. *
13 * *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
20 * SOFTWARE. *
21 **************************************************************************************************/
22
37
38#pragma once
39
40#include <ostream>
41
49// RGB Text Colors (8-bit)
50#define RGB_TEXT(r, g, b) "\x1b[38;2;" #r ";" #g ";" #b "m"
51
59// RGB Background Colors (8-bit)
60#define RGB_BG(r, g, b) "\x1b[48;2;" #r ";" #g ";" #b "m"
61
63{
72 bool isTerminal(const std::ostream& stream);
73
82 std::ostream& reset(std::ostream& stream);
83
88 namespace colors
89 {
96 std::ostream& black(std::ostream& stream);
97
104 std::ostream& red(std::ostream& stream);
105
112 std::ostream& green(std::ostream& stream);
113
120 std::ostream& yellow(std::ostream& stream);
121
128 std::ostream& blue(std::ostream& stream);
129
136 std::ostream& magenta(std::ostream& stream);
137
144 std::ostream& cyan(std::ostream& stream);
145
152 std::ostream& white(std::ostream& stream);
153
160 std::ostream& brightBlack(std::ostream& stream);
161
168 std::ostream& brightRed(std::ostream& stream);
169
176 std::ostream& brightGreen(std::ostream& stream);
177
184 std::ostream& brightYellow(std::ostream& stream);
185
192 std::ostream& brightBlue(std::ostream& stream);
193
200 std::ostream& brightMagenta(std::ostream& stream);
201
208 std::ostream& brightCyan(std::ostream& stream);
209
216 std::ostream& brightWhite(std::ostream& stream);
217 } // namespace colors
218
223 namespace colorsBg
224 {
231 std::ostream& brightBlack(std::ostream& stream);
232
239 std::ostream& brightRed(std::ostream& stream);
240
247 std::ostream& brightGreen(std::ostream& stream);
248
255 std::ostream& brightYellow(std::ostream& stream);
256
263 std::ostream& brightBlue(std::ostream& stream);
264
271 std::ostream& brightCyan(std::ostream& stream);
272
279 std::ostream& brightWhite(std::ostream& stream);
280 } // namespace colorsBg
281
286 namespace formats
287 {
294 std::ostream& bold(std::ostream& stream);
295
302 std::ostream& dim(std::ostream& stream);
303
310 std::ostream& underline(std::ostream& stream);
311
318 std::ostream& blink(std::ostream& stream);
319
326 std::ostream& reverse(std::ostream& stream);
327
334 std::ostream& hidden(std::ostream& stream);
335 } // namespace formats
336} // namespace steppable::__internals::utils
A namespace containing functions to set the background color in an output stream.
Definition colors.cpp:176
std::ostream & brightYellow(std::ostream &stream)
Set the background color to bright yellow.
Definition colors.cpp:198
std::ostream & brightGreen(std::ostream &stream)
Set the background color to bright green.
Definition colors.cpp:191
std::ostream & brightWhite(std::ostream &stream)
Set the background color to bright white.
Definition colors.cpp:219
std::ostream & brightBlack(std::ostream &stream)
Set the background color to bright black.
Definition colors.cpp:177
std::ostream & brightBlue(std::ostream &stream)
Set the background color to bright blue.
Definition colors.cpp:205
std::ostream & brightCyan(std::ostream &stream)
Set the background color to bright cyan.
Definition colors.cpp:212
std::ostream & brightRed(std::ostream &stream)
Set the background color to bright red.
Definition colors.cpp:184
A namespace containing functions to set the text color in an output stream.
Definition colors.cpp:61
std::ostream & brightWhite(std::ostream &stream)
Set the text color to bright white.
Definition colors.cpp:167
std::ostream & brightGreen(std::ostream &stream)
Set the text color to bright green.
Definition colors.cpp:132
std::ostream & white(std::ostream &stream)
Set the text color to white.
Definition colors.cpp:111
std::ostream & brightMagenta(std::ostream &stream)
Set the text color to bright magenta.
Definition colors.cpp:153
std::ostream & red(std::ostream &stream)
Set the text color to red.
Definition colors.cpp:69
std::ostream & brightCyan(std::ostream &stream)
Set the text color to bright cyan.
Definition colors.cpp:160
std::ostream & brightYellow(std::ostream &stream)
Set the text color to bright yellow.
Definition colors.cpp:139
std::ostream & brightBlack(std::ostream &stream)
Set the text color to bright black.
Definition colors.cpp:118
std::ostream & blue(std::ostream &stream)
Set the text color to blue.
Definition colors.cpp:90
std::ostream & cyan(std::ostream &stream)
Set the text color to cyan.
Definition colors.cpp:104
std::ostream & magenta(std::ostream &stream)
Set the text color to magenta.
Definition colors.cpp:97
std::ostream & green(std::ostream &stream)
Set the text color to green.
Definition colors.cpp:76
std::ostream & yellow(std::ostream &stream)
Set the text color to yellow.
Definition colors.cpp:83
std::ostream & brightRed(std::ostream &stream)
Set the text color to bright red.
Definition colors.cpp:125
std::ostream & brightBlue(std::ostream &stream)
Set the text color to bright blue.
Definition colors.cpp:146
std::ostream & black(std::ostream &stream)
Set the text color to black.
Definition colors.cpp:62
A namespace containing functions to set the text format in an output stream.
Definition colors.cpp:228
std::ostream & bold(std::ostream &stream)
Set the text format to bold.
Definition colors.cpp:229
std::ostream & hidden(std::ostream &stream)
Set the text format to hidden.
Definition colors.cpp:264
std::ostream & reverse(std::ostream &stream)
Set the text format to reverse.
Definition colors.cpp:257
std::ostream & underline(std::ostream &stream)
Set the text format to underline.
Definition colors.cpp:243
std::ostream & blink(std::ostream &stream)
Set the text format to blink.
Definition colors.cpp:250
std::ostream & dim(std::ostream &stream)
Set the text format to dim.
Definition colors.cpp:236
The namespace containing utility functions for the Steppable library.
Definition argParse.cpp:40
std::ostream & reset(std::ostream &stream)
Reset the text color and format to the default values.
Definition colors.cpp:53
bool isTerminal(const std::ostream &stream)
Check if the output stream is a terminal.
Definition colors.cpp:42
Untitled