cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
style.hpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2025 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
13
14#include <cstdint>
15#include <string>
16
17namespace Term
18{
19
20/*
21 * Styles for text in the terminal
22 */
23enum class Style : std::uint8_t
24{
25
26 Reset = 0,
27 Bold = 1,
28 Dim = 2,
29 Italic = 3,
31 Blink = 5,
34 Conceal = 8,
35 Crossed = 9,
36
37 // different fonts
38 Font0 = 10,
40 Font1 = 11,
41 Font2 = 12,
42 Font3 = 13,
43 Font4 = 14,
44 Font5 = 15,
45 Font6 = 16,
46 Font7 = 17,
47 Font8 = 18,
48 Font9 = 19,
49 Font10 = 20,
50
51 // Double-underline per ECMA-48,[5] 8.3.117 but instead disables bold intensity on several terminals,
52 // including in the Linux kernel's console before version 4.17
54
55 // resets corresponding styles
65
66 // sets the foreground and background color to the implementation defined colors
69
70 Frame = 51,
72 Overline = 53, // draw a line over the text, barely supported
76
77 // sets the underline color to the implementation defined colors
79
80 BarRight = 60,
82 BarLeft = 62,
85
86 ResetBar = 65, // resets 60 - 64 inclusive
87
88 Superscript = 73, // only implemented in mintty
89 Subscript = 74, // only implemented in mintty
90 ResetSuperscript = 75, // only implemented in mintty
92};
93
94std::string style(const Term::Style& style);
95
96template<class Stream> Stream& operator<<(Stream& stream, const Term::Style& style_type) { return stream << style(style_type); }
97// unabigify operator overload
98inline Term::TOstream& operator<<(Term::TOstream& term, const Term::Style& style_type) { return term << style(style_type); }
99
100} // namespace Term
Definition args.cpp:13
std::string style(const Term::Style &style)
Definition style.cpp:12
Style
Definition style.hpp:24
@ Reversed
swap foreground and background colors
Definition style.hpp:33
@ Bold
Thick text font.
Definition style.hpp:27
@ ResetConceal
Definition style.hpp:63
@ ResetReversed
Definition style.hpp:62
@ Italic
slightly bend text font
Definition style.hpp:29
@ Crossed
strikes through the text, mostly supported
Definition style.hpp:35
@ ResetSuperscript
Definition style.hpp:90
@ BarLeft
draw a vertical bar on the left side of the character
Definition style.hpp:82
@ DefaultBackgroundColor
Definition style.hpp:68
@ DefaultForegroundColor
Definition style.hpp:67
@ BlinkRapid
MS-DOS ANSI.SYS, 150+ per minute; not widely supported.
Definition style.hpp:32
@ Reset
resets all attributes (styles and colors)
Definition style.hpp:26
@ ResetUnderline
Definition style.hpp:59
@ Superscript
Definition style.hpp:88
@ DoubleBarRight
draw a double vertical bar to the right
Definition style.hpp:81
@ Font10
Fraktur / Gothic font.
Definition style.hpp:49
@ ResetEncircle
Definition style.hpp:74
@ Underline
draws a line below the text
Definition style.hpp:30
@ Dim
lighter, slimmer text font
Definition style.hpp:28
@ Conceal
Note: not widely supported.
Definition style.hpp:34
@ Font0
Primary or default font.
Definition style.hpp:38
@ BarRight
draw a vertical bar on the right side of the character
Definition style.hpp:80
@ DoubleBarLeft
draw a double vertical bar to the left
Definition style.hpp:83
@ StressMarking
reset all bars left and right double and simple
Definition style.hpp:84
@ ResetOverline
Definition style.hpp:75
@ ResetSubscript
Definition style.hpp:91
@ Blink
Sets blinking to less than 150 times per minute.
Definition style.hpp:31
@ ResetBlinkRapid
Definition style.hpp:61
@ ResetCrossed
Definition style.hpp:64
@ DefaultUnderlineColor
non standard, implemented in Kitty, VTE, mintty, and iTerm2
Definition style.hpp:78
@ DoublyUnderlinedOrNotBold
Definition style.hpp:53
@ ResetItalic
Definition style.hpp:58
Stream & operator<<(Stream &stream, const Term::Style &style_type)
Definition style.hpp:96