1#ifndef SOURCEMETA_CORE_TERMINAL_H_
2#define SOURCEMETA_CORE_TERMINAL_H_
4#ifndef SOURCEMETA_CORE_TERMINAL_EXPORT
5#include <sourcemeta/core/terminal_export.h>
24namespace sourcemeta::core {
145 using Underlying = std::underlying_type_t<TerminalStyle>;
146 return static_cast<TerminalStyle>(
static_cast<Underlying
>(left) |
147 static_cast<Underlying
>(right));
168 using Underlying = std::underlying_type_t<TerminalStyle>;
169 return static_cast<TerminalStyle>(
static_cast<Underlying
>(left) &
170 static_cast<Underlying
>(right));
187[[nodiscard]]
constexpr auto operator~(
TerminalStyle value)
noexcept
189 using Underlying = std::underlying_type_t<TerminalStyle>;
190 return static_cast<TerminalStyle>(~static_cast<Underlying>(value));
210 using Underlying = std::underlying_type_t<TerminalStyle>;
211 return static_cast<TerminalStyle>(
static_cast<Underlying
>(left) ^
212 static_cast<Underlying
>(right));
233[[nodiscard]]
constexpr auto
235 using Underlying = std::underlying_type_t<TerminalStyle>;
236 constexpr Underlying DEFINED_MASK{
244 const auto raw{
static_cast<Underlying
>(style)};
245 if ((raw & ~DEFINED_MASK) != 0) {
249 constexpr std::array<TerminalStyle, 5> COLORS{
254 for (
const auto color : COLORS) {
257 if (color_count > 1) {
281SOURCEMETA_CORE_TERMINAL_EXPORT
299SOURCEMETA_CORE_TERMINAL_EXPORT
314SOURCEMETA_CORE_TERMINAL_EXPORT
330SOURCEMETA_CORE_TERMINAL_EXPORT
351SOURCEMETA_CORE_TERMINAL_EXPORT
374SOURCEMETA_CORE_TERMINAL_EXPORT
392SOURCEMETA_CORE_TERMINAL_EXPORT
409SOURCEMETA_CORE_TERMINAL_EXPORT
432SOURCEMETA_CORE_TERMINAL_EXPORT
451SOURCEMETA_CORE_TERMINAL_EXPORT
472SOURCEMETA_CORE_TERMINAL_EXPORT
474 bool enabled = true) -> std::
string;
493SOURCEMETA_CORE_TERMINAL_EXPORT
514SOURCEMETA_CORE_TERMINAL_EXPORT
536SOURCEMETA_CORE_TERMINAL_EXPORT
@ None
The cookie is sent on every cross-site request.
Definition http.h:615
SOURCEMETA_CORE_TERMINAL_EXPORT auto terminal_is_interactive(TerminalStream stream) noexcept -> bool
SOURCEMETA_CORE_TERMINAL_EXPORT auto terminal_sgr_reset() noexcept -> std::string_view
constexpr auto terminal_style_is_valid(TerminalStyle style) noexcept -> bool
Definition terminal.h:234
SOURCEMETA_CORE_TERMINAL_EXPORT auto terminal_set_color_policy(TerminalColorPolicy policy) noexcept -> void
SOURCEMETA_CORE_TERMINAL_EXPORT auto terminal_color_policy(TerminalStream stream=TerminalStream::Stdout) noexcept -> TerminalColorPolicy
TerminalStyle
Definition terminal.h:110
SOURCEMETA_CORE_TERMINAL_EXPORT auto terminal_color_enabled(TerminalStream stream) noexcept -> bool
TerminalStream
Definition terminal.h:41
SOURCEMETA_CORE_TERMINAL_EXPORT auto terminal_reset_color_policy() noexcept -> void
SOURCEMETA_CORE_TERMINAL_EXPORT auto terminal_paint(std::string_view text, TerminalStyle style, bool enabled=true) -> std::string
TerminalColorPolicy
Definition terminal.h:71
SOURCEMETA_CORE_TERMINAL_EXPORT auto terminal_sgr_sequence(TerminalStyle style) noexcept -> std::string_view
@ Cyan
Cyan foreground color (ECMA-48 SGR parameter 36).
Definition terminal.h:124
@ Bold
Bold or increased intensity (ECMA-48 SGR parameter 1).
Definition terminal.h:114
@ Yellow
Yellow foreground color (ECMA-48 SGR parameter 33).
Definition terminal.h:120
@ None
Normal display / no style (plain text, ECMA-48 SGR parameter 0).
Definition terminal.h:112
@ Blue
Blue foreground color (ECMA-48 SGR parameter 34).
Definition terminal.h:122
@ Green
Green foreground color (ECMA-48 SGR parameter 32).
Definition terminal.h:118
@ Red
Red foreground color (ECMA-48 SGR parameter 31).
Definition terminal.h:116
@ Stdout
Definition terminal.h:49
@ Stdin
Definition terminal.h:45
@ Stderr
Definition terminal.h:53
@ Always
Definition terminal.h:82
@ Disabled
Styling is unconditionally suppressed.
Definition terminal.h:79
@ WhenInteractive
Definition terminal.h:77