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-2024 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,
30 Underline = 4,
31 Blink = 5,
32 BlinkRapid = 6,
33 Reversed = 7,
34 Conceal = 8,
35 Crossed = 9,
36
37 // different fonts
38 Font0 = 10,
39 ResetFont = 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
56 ResetBold = 22,
57 ResetDim = 22,
58 ResetItalic = 23,
59 ResetUnderline = 24,
60 ResetBlink = 25,
61 ResetBlinkRapid = 25,
62 ResetReversed = 27,
63 ResetConceal = 28,
64 ResetCrossed = 29,
65
66 // sets the foreground and background color to the implementation defined colors
69
70 Frame = 51,
71 Encircle = 52,
72 Overline = 53, // draw a line over the text, barely supported
73 ResetFrame = 54,
74 ResetEncircle = 54,
75 ResetOverline = 55,
76
77 // sets the underline color to the implementation defined colors
79
80 BarRight = 60,
81 DoubleBarRight = 61,
82 BarLeft = 62,
83 DoubleBarLeft = 63,
84 StressMarking = 64,
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
@ Bold
Thick text font.
@ Italic
slightly bend text font
@ Crossed
strikes through the text, mostly supported
@ BarLeft
draw a vertical bar on the left side of the character
@ DefaultBackgroundColor
@ DefaultForegroundColor
@ BlinkRapid
MS-DOS ANSI.SYS, 150+ per minute; not widely supported.
@ Reset
resets all attributes (styles and colors)
@ DoubleBarRight
draw a double vertical bar to the right
@ Font10
Fraktur / Gothic font.
@ Underline
draws a line below the text
@ Dim
lighter, slimmer text font
@ Conceal
Note: not widely supported.
@ Font0
Primary or default font.
@ BarRight
draw a vertical bar on the right side of the character
@ DoubleBarLeft
draw a double vertical bar to the left
@ StressMarking
reset all bars left and right double and simple
@ Blink
Sets blinking to less than 150 times per minute.
@ DefaultUnderlineColor
non standard, implemented in Kitty, VTE, mintty, and iTerm2
@ DoublyUnderlinedOrNotBold
Stream & operator<<(Stream &stream, const Term::Style &style_type)
Definition style.hpp:96