Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
term_colors.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
18
19#include "sham/term/color.hpp"
20#include <cstdint>
21#include <string>
22namespace shambase {
23
24 namespace term_colors {
25
28
31
34
37
39 inline const std::string empty() { return ""; };
41 inline const std::string reset() { return sham::term::style::reset(); };
43 inline const std::string bold() { return sham::term::style::bold(); };
45 inline const std::string faint() { return sham::term::style::faint(); };
47 inline const std::string underline() { return sham::term::style::underline(); };
49 inline const std::string blink() { return sham::term::style::blink(); };
51 inline const std::string col8b_black() { return sham::term::colors_8b::black(); };
53 inline const std::string col8b_red() { return sham::term::colors_8b::red(); };
55 inline const std::string col8b_green() { return sham::term::colors_8b::green(); };
57 inline const std::string col8b_yellow() { return sham::term::colors_8b::yellow(); };
59 inline const std::string col8b_blue() { return sham::term::colors_8b::blue(); };
61 inline const std::string col8b_magenta() { return sham::term::colors_8b::magenta(); };
63 inline const std::string col8b_cyan() { return sham::term::colors_8b::cyan(); };
65 inline const std::string col8b_white() { return sham::term::colors_8b::white(); };
66
68 inline std::string col256_foreground(std::uint8_t index) {
70 };
71
73 inline std::string col256_background(std::uint8_t index) {
75 };
76
78 inline std::string rgb_foreground(std::uint8_t r, std::uint8_t g, std::uint8_t b) {
80 };
81
83 inline std::string rgb_background(std::uint8_t r, std::uint8_t g, std::uint8_t b) {
85 };
86
87 } // namespace term_colors
88
89} // namespace shambase
Terminal color escape sequences and enable/disable control.
ColorLevel
The possible levels of terminal color support.
Definition color.hpp:27
ColorLevel color_level()
Query the currently detected/forced terminal color support level.
Definition color.cpp:45
void enable_colors()
Enable colors.
Definition color.cpp:50
void disable_colors()
Disable all colors.
Definition color.cpp:53
bool are_colors_enabled()
Query whether terminal color output is currently enabled.
Definition color.cpp:56
std::string foreground(std::uint8_t r, std::uint8_t g, std::uint8_t b)
Escape sequence to set the given RGB foreground text color.
Definition color.cpp:108
std::string background(std::uint8_t r, std::uint8_t g, std::uint8_t b)
Escape sequence to set the given RGB background color.
Definition color.cpp:111
std::string background(std::uint8_t index)
Escape sequence to set the given palette index as background color.
Definition color.cpp:91
std::string foreground(std::uint8_t index)
Escape sequence to set the given palette index as foreground text color.
Definition color.cpp:90
const char * red()
Escape sequence to set red text color.
Definition color.cpp:68
const char * green()
Escape sequence to set green text color.
Definition color.cpp:69
const char * black()
Escape sequence to set black text color.
Definition color.cpp:67
const char * white()
Escape sequence to set white text color.
Definition color.cpp:74
const char * magenta()
Escape sequence to set magenta (pink) text color.
Definition color.cpp:72
const char * cyan()
Escape sequence to set cyan text color.
Definition color.cpp:73
const char * blue()
Escape sequence to set blue text color.
Definition color.cpp:71
const char * yellow()
Escape sequence to set yellow text color.
Definition color.cpp:70
const char * blink()
escape sequence to set blinking text formatting.
Definition color.cpp:63
const char * reset()
escape sequence to reset the terminal text formatting.
Definition color.cpp:59
const char * bold()
escape sequence to set bold text formatting.
Definition color.cpp:60
const char * underline()
escape sequence to set underlined text formatting.
Definition color.cpp:62
const char * faint()
escape sequence to set faint (dim) text formatting.
Definition color.cpp:61
namespace for basic c++ utilities
std::string col256_foreground(std::uint8_t index)
Get the 256-color palette foreground terminal escape char (empty if unsupported).
const std::string reset()
Get the reset terminal escape char.
const std::string col8b_yellow()
Get the yellow terminal escape char.
const std::string col8b_white()
Get the white terminal escape char.
const std::string col8b_magenta()
Get the magenta (pink) terminal escape char.
const std::string empty()
Get the empty terminal escape.
const std::string blink()
Get the blink terminal escape char.
const std::string col8b_green()
Get the green terminal escape char.
sham::term::ColorLevel color_level()
Get the detected/forced terminal color support level.
std::string rgb_background(std::uint8_t r, std::uint8_t g, std::uint8_t b)
Get the 24-bit RGB truecolor background terminal escape char (empty if unsupported).
const std::string col8b_blue()
Get the blue terminal escape char.
const std::string col8b_black()
Get the black terminal escape char.
const std::string underline()
Get the underline terminal escape char.
bool colors_enabled()
Are colors enabled.
std::string col256_background(std::uint8_t index)
Get the 256-color palette background terminal escape char (empty if unsupported).
void disable_colors()
Disable all colors.
void enable_colors()
Enable colors in logs.
std::string rgb_foreground(std::uint8_t r, std::uint8_t g, std::uint8_t b)
Get the 24-bit RGB truecolor foreground terminal escape char (empty if unsupported).
const std::string col8b_cyan()
Get the cyan terminal escape char.
const std::string faint()
Get the faint terminal escape char.
const std::string bold()
Get the bold terminal escape char.
const std::string col8b_red()
Get the red terminal escape char.