cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
Term::Key Class Reference

#include <cpp-terminal/key.hpp>

Public Types

enum  Value : std::int32_t {
  NoKey = -1 , Ctrl_Arobase = 0 , Ctrl_A = 1 , Ctrl_B = 2 ,
  Ctrl_C = 3 , Ctrl_D = 4 , Ctrl_E = 5 , Ctrl_F = 6 ,
  Ctrl_G = 7 , Ctrl_H = 8 , Ctrl_I = 9 , Ctrl_J = 10 ,
  Ctrl_K = 11 , Ctrl_L = 12 , Ctrl_M = 13 , Ctrl_N = 14 ,
  Ctrl_O = 15 , Ctrl_P = 16 , Ctrl_Q = 17 , Ctrl_R = 18 ,
  Ctrl_S = 19 , Ctrl_T = 20 , Ctrl_U = 21 , Ctrl_V = 22 ,
  Ctrl_W = 23 , Ctrl_X = 24 , Ctrl_Y = 25 , Ctrl_Z = 26 ,
  Ctrl_OpenBracket = 27 , Ctrl_BackSlash = 28 , Ctrl_CloseBracket = 29 , Ctrl_Caret = 30 ,
  Ctrl_Underscore = 31 , Space = 32 , ExclamationMark = 33 , Quote = 34 ,
  Hash = 35 , Dollar = 36 , Percent = 37 , Ampersand = 38 ,
  Apostrophe = 39 , OpenParenthesis = 40 , CloseParenthesis = 41 , Asterisk = 42 ,
  Plus = 43 , Comma = 44 , Hyphen = 45 , Minus = 45 ,
  Period = 46 , Slash = 47 , Zero = 48 , One = 49 ,
  Two = 50 , Three = 51 , Four = 52 , Five = 53 ,
  Six = 54 , Seven = 55 , Eight = 56 , Nine = 57 ,
  Colon = 58 , Semicolon = 59 , LessThan = 60 , OpenChevron = 60 ,
  Equal = 61 , GreaterThan = 62 , CloseChevron = 62 , QuestionMark = 63 ,
  Arobase = 64 , A = 65 , B = 66 , C = 67 ,
  D = 68 , E = 69 , F = 70 , G = 71 ,
  H = 72 , I = 73 , J = 74 , K = 75 ,
  L = 76 , M = 77 , N = 78 , O = 79 ,
  P = 80 , Q = 81 , R = 82 , S = 83 ,
  T = 84 , U = 85 , V = 86 , W = 87 ,
  X = 88 , Y = 89 , Z = 90 , OpenBracket = 91 ,
  Backslash = 92 , CloseBracket = 93 , Caret = 94 , Underscore = 95 ,
  GraveAccent = 96 , a = 97 , b = 98 , c = 99 ,
  d = 100 , e = 101 , f = 102 , g = 103 ,
  h = 104 , i = 105 , j = 106 , k = 107 ,
  l = 108 , m = 109 , n = 110 , o = 111 ,
  p = 112 , q = 113 , r = 114 , s = 115 ,
  t = 116 , u = 117 , v = 118 , w = 119 ,
  x = 120 , y = 121 , z = 122 , OpenBrace = 123 ,
  VerticalBar = 124 , Close_Brace = 125 , Tilde = 126 , CTRL_QuestionMark = 127 ,
  Null = 0 , Backspace = 8 , Tab = 9 , Enter = 13 ,
  Esc = 27 , Del = 127 , ArrowLeft = 0x10FFFF + 1 , ArrowRight = 0x10FFFF + 2 ,
  ArrowUp = 0x10FFFF + 3 , ArrowDown = 0x10FFFF + 4 , Numeric5 = 0x10FFFF + 5 , Home = 0x10FFFF + 6 ,
  Insert = 0x10FFFF + 7 , End = 0x10FFFF + 8 , PageUp = 0x10FFFF + 9 , PageDown = 0x10FFFF + 10 ,
  F1 = 0x10FFFF + 11 , F2 = 0x10FFFF + 12 , F3 = 0x10FFFF + 13 , F4 = 0x10FFFF + 14 ,
  F5 = 0x10FFFF + 15 , F6 = 0x10FFFF + 16 , F7 = 0x10FFFF + 17 , F8 = 0x10FFFF + 18 ,
  F9 = 0x10FFFF + 19 , F10 = 0x10FFFF + 20 , F11 = 0x10FFFF + 21 , F12 = 0x10FFFF + 22 ,
  F13 = 0x10FFFF + 23 , F14 = 0x10FFFF + 24 , F15 = 0x10FFFF + 25 , F16 = 0x10FFFF + 26 ,
  F17 = 0x10FFFF + 27 , F18 = 0x10FFFF + 28 , F19 = 0x10FFFF + 29 , F20 = 0x10FFFF + 30 ,
  F21 = 0x10FFFF + 31 , F22 = 0x10FFFF + 32 , F23 = 0x10FFFF + 33 , F24 = 0x10FFFF + 34 ,
  PrintScreen = 0x10FFFF + 35 , Menu = 0x10FFFF + 36
}
 
using value_type = std::int32_t
 

Public Member Functions

constexpr Key ()
 
constexpr Key (const Key &key)=default
 
Keyoperator= (const Key &key)=default
 
constexpr Key (const Value &v)
 
Keyoperator= (const Value &v)
 
constexpr Key (char val)
 
Keyoperator= (char val)
 
constexpr Key (std::int32_t val)
 
Keyoperator= (std::int32_t val)
 
constexpr Key (std::size_t val)
 
Keyoperator= (std::size_t val)
 
constexpr Key (char32_t val)
 
Keyoperator= (char32_t val)
 
constexpr operator std::int32_t () const
 
constexpr bool iscntrl () const
 
constexpr bool isblank () const
 
constexpr bool isspace () const
 
constexpr bool isupper () const
 
constexpr bool islower () const
 
constexpr bool isalpha () const
 
constexpr bool isdigit () const
 
constexpr bool isxdigit () const
 
constexpr bool isalnum () const
 
constexpr bool ispunct () const
 
constexpr bool isgraph () const
 
constexpr bool isprint () const
 
constexpr bool isunicode () const
 
constexpr Key tolower () const
 
constexpr Key toupper () const
 
constexpr bool isASCII () const
 
constexpr bool isExtendedASCII () const
 
constexpr bool hasCtrlAll () const
 
constexpr bool hasCtrl () const
 
constexpr bool hasAlt () const
 
constexpr bool empty () const
 
void append_name (std::string &strOut) const
 
std::string name () const
 
std::string str () const
 

Public Attributes

std::int32_t value
 

Friends

constexpr bool operator== (Key l, Key r)
 
constexpr bool operator== (Key l, char r)
 
constexpr bool operator== (char l, Key r)
 
constexpr bool operator== (Key l, char32_t r)
 
constexpr bool operator== (char32_t l, Key r)
 
constexpr bool operator== (Key l, std::int32_t r)
 
constexpr bool operator== (std::int32_t l, Key r)
 
constexpr bool operator== (Key l, std::size_t r)
 
constexpr bool operator== (std::size_t l, Key r)
 
constexpr bool operator!= (Key l, Key r)
 
constexpr bool operator!= (Key l, char r)
 
constexpr bool operator!= (char l, Key r)
 
constexpr bool operator!= (Key l, char32_t r)
 
constexpr bool operator!= (char32_t l, Key r)
 
constexpr bool operator!= (Key l, std::int32_t r)
 
constexpr bool operator!= (std::int32_t l, Key r)
 
constexpr bool operator!= (Key l, std::size_t r)
 
constexpr bool operator!= (std::size_t l, Key r)
 
constexpr bool operator< (Key l, Key r)
 
constexpr bool operator< (Key l, char r)
 
constexpr bool operator< (char l, Key r)
 
constexpr bool operator< (Key l, char32_t r)
 
constexpr bool operator< (char32_t l, Key r)
 
constexpr bool operator< (Key l, std::int32_t r)
 
constexpr bool operator< (std::int32_t l, Key r)
 
constexpr bool operator< (Key l, std::size_t r)
 
constexpr bool operator< (std::size_t l, Key r)
 
constexpr bool operator>= (Key l, Key r)
 
constexpr bool operator>= (Key l, char r)
 
constexpr bool operator>= (char l, Key r)
 
constexpr bool operator>= (Key l, char32_t r)
 
constexpr bool operator>= (char32_t l, Key r)
 
constexpr bool operator>= (Key l, std::int32_t r)
 
constexpr bool operator>= (std::int32_t l, Key r)
 
constexpr bool operator>= (Key l, std::size_t r)
 
constexpr bool operator>= (std::size_t l, Key r)
 
constexpr bool operator> (Key l, Key r)
 
constexpr bool operator> (Key l, char r)
 
constexpr bool operator> (char l, Key r)
 
constexpr bool operator> (Key l, char32_t r)
 
constexpr bool operator> (char32_t l, Key r)
 
constexpr bool operator> (Key l, std::int32_t r)
 
constexpr bool operator> (std::int32_t l, Key r)
 
constexpr bool operator> (Key l, std::size_t r)
 
constexpr bool operator> (std::size_t l, Key r)
 
constexpr bool operator<= (Key l, Key r)
 
constexpr bool operator<= (Key l, char r)
 
constexpr bool operator<= (char l, Key r)
 
constexpr bool operator<= (Key l, char32_t r)
 
constexpr bool operator<= (char32_t l, Key r)
 
constexpr bool operator<= (Key l, std::int32_t r)
 
constexpr bool operator<= (std::int32_t l, Key r)
 
constexpr bool operator<= (Key l, std::size_t r)
 
constexpr bool operator<= (std::size_t l, Key r)
 

Detailed Description

Definition at line 85 of file key.hpp.

Member Typedef Documentation

◆ value_type

using Term::Key::value_type = std::int32_t

Definition at line 88 of file key.hpp.

Member Enumeration Documentation

◆ Value

enum Term::Key::Value : std::int32_t
Enumerator
NoKey 
Ctrl_Arobase 
Ctrl_A 
Ctrl_B 
Ctrl_C 
Ctrl_D 
Ctrl_E 
Ctrl_F 
Ctrl_G 
Ctrl_H 
Ctrl_I 
Ctrl_J 
Ctrl_K 
Ctrl_L 
Ctrl_M 
Ctrl_N 
Ctrl_O 
Ctrl_P 
Ctrl_Q 
Ctrl_R 
Ctrl_S 
Ctrl_T 
Ctrl_U 
Ctrl_V 
Ctrl_W 
Ctrl_X 
Ctrl_Y 
Ctrl_Z 
Ctrl_OpenBracket 
Ctrl_BackSlash 
Ctrl_CloseBracket 
Ctrl_Caret 
Ctrl_Underscore 
Space 
ExclamationMark 
Quote 
Hash 
Dollar 
Percent 
Ampersand 
Apostrophe 
OpenParenthesis 
CloseParenthesis 
Asterisk 
Plus 
Comma 
Hyphen 
Minus 
Period 
Slash 
Zero 
One 
Two 
Three 
Four 
Five 
Six 
Seven 
Eight 
Nine 
Colon 
Semicolon 
LessThan 
OpenChevron 
Equal 
GreaterThan 
CloseChevron 
QuestionMark 
Arobase 
OpenBracket 
Backslash 
CloseBracket 
Caret 
Underscore 
GraveAccent 
OpenBrace 
VerticalBar 
Close_Brace 
Tilde 
CTRL_QuestionMark 
Null 
Backspace 
Tab 
Enter 
Esc 
Del 
ArrowLeft 
ArrowRight 
ArrowUp 
ArrowDown 
Numeric5 
Home 
Insert 
End 
PageUp 
PageDown 
F1 
F2 
F3 
F4 
F5 
F6 
F7 
F8 
F9 
F10 
F11 
F12 
F13 
F14 
F15 
F16 
F17 
F18 
F19 
F20 
F21 
F22 
F23 
F24 
PrintScreen 
Menu 

Definition at line 90 of file key.hpp.

91 {
92 NoKey = -1,
93 // Now use << to for detecting special key + key press
94
95 // Begin ASCII (some ASCII names has been change to their Ctrl_+key part) the value is different to be able to do
96 Ctrl_Arobase = 0,
97 Ctrl_A = 1,
98 Ctrl_B = 2,
99 Ctrl_C = 3,
100 Ctrl_D = 4,
101 Ctrl_E = 5,
102 Ctrl_F = 6,
103 Ctrl_G = 7,
104 Ctrl_H = 8, /*corresponds to Backspace*/
105 Ctrl_I = 9, /*corresponds to Tab*/
106 Ctrl_J = 10,
107 Ctrl_K = 11,
108 Ctrl_L = 12,
109 Ctrl_M = 13, /*corresponds to Enter*/
110 Ctrl_N = 14,
111 Ctrl_O = 15,
112 Ctrl_P = 16,
113 Ctrl_Q = 17,
114 Ctrl_R = 18,
115 Ctrl_S = 19,
116 Ctrl_T = 20,
117 Ctrl_U = 21,
118 Ctrl_V = 22,
119 Ctrl_W = 23,
120 Ctrl_X = 24,
121 Ctrl_Y = 25,
122 Ctrl_Z = 26,
123 Ctrl_OpenBracket = 27, /*corresponds to Escape*/
124 Ctrl_BackSlash = 28,
126 Ctrl_Caret = 30,
127 Ctrl_Underscore = 31,
128 Space = 32,
129 ExclamationMark = 33,
130 Quote = 34,
131 Hash = 35,
132 Dollar = 36,
133 Percent = 37,
134 Ampersand = 38,
135 Apostrophe = 39,
136 OpenParenthesis = 40,
137 CloseParenthesis = 41,
138 Asterisk = 42,
139 Plus = 43,
140 Comma = 44,
141 Hyphen = 45,
142 Minus = 45,
143 Period = 46,
144 Slash = 47,
145 Zero = 48,
146 One = 49,
147 Two = 50,
148 Three = 51,
149 Four = 52,
150 Five = 53,
151 Six = 54,
152 Seven = 55,
153 Eight = 56,
154 Nine = 57,
155 Colon = 58,
156 Semicolon = 59,
157 LessThan = 60,
158 OpenChevron = 60,
159 Equal = 61,
160 GreaterThan = 62,
161 CloseChevron = 62,
162 QuestionMark = 63,
163 Arobase = 64,
164 A = 65,
165 B = 66,
166 C = 67,
167 D = 68,
168 E = 69,
169 F = 70,
170 G = 71,
171 H = 72,
172 I = 73,
173 J = 74,
174 K = 75,
175 L = 76,
176 M = 77,
177 N = 78,
178 O = 79,
179 P = 80,
180 Q = 81,
181 R = 82,
182 S = 83,
183 T = 84,
184 U = 85,
185 V = 86,
186 W = 87,
187 X = 88,
188 Y = 89,
189 Z = 90,
190 OpenBracket = 91,
191 Backslash = 92,
192 CloseBracket = 93,
193 Caret = 94,
194 Underscore = 95,
195 GraveAccent = 96,
196 a = 97,
197 b = 98,
198 c = 99,
199 d = 100,
200 e = 101,
201 f = 102,
202 g = 103,
203 h = 104,
204 i = 105,
205 j = 106,
206 k = 107,
207 l = 108,
208 m = 109,
209 n = 110,
210 o = 111,
211 p = 112,
212 q = 113,
213 r = 114,
214 s = 115,
215 t = 116,
216 u = 117,
217 v = 118,
218 w = 119,
219 x = 120,
220 y = 121,
221 z = 122,
222 OpenBrace = 123,
223 VerticalBar = 124,
224 Close_Brace = 125,
225 Tilde = 126,
226 CTRL_QuestionMark = 127, /*corresponds to DEL*/
227 // Very useful CTRL_* alternative names
228 Null = 0,
229 Backspace = 8,
230 Tab = 9,
231 Enter = 13,
232 Esc = 27,
233 Del = 127,
234 //
235 // End ASCII
236 // Extended ASCII goes up to 255
237 // Last Unicode codepage 0x10FFFF
238 ArrowLeft = 0x10FFFF + 1,
239 ArrowRight = 0x10FFFF + 2,
240 ArrowUp = 0x10FFFF + 3,
241 ArrowDown = 0x10FFFF + 4,
242 Numeric5 = 0x10FFFF + 5,
243 Home = 0x10FFFF + 6,
244 Insert = 0x10FFFF + 7,
245 End = 0x10FFFF + 8,
246 PageUp = 0x10FFFF + 9,
247 PageDown = 0x10FFFF + 10,
248 F1 = 0x10FFFF + 11,
249 F2 = 0x10FFFF + 12,
250 F3 = 0x10FFFF + 13,
251 F4 = 0x10FFFF + 14,
252 F5 = 0x10FFFF + 15,
253 F6 = 0x10FFFF + 16,
254 F7 = 0x10FFFF + 17,
255 F8 = 0x10FFFF + 18,
256 F9 = 0x10FFFF + 19,
257 F10 = 0x10FFFF + 20,
258 F11 = 0x10FFFF + 21,
259 F12 = 0x10FFFF + 22,
260 F13 = 0x10FFFF + 23,
261 F14 = 0x10FFFF + 24,
262 F15 = 0x10FFFF + 25,
263 F16 = 0x10FFFF + 26,
264 F17 = 0x10FFFF + 27,
265 F18 = 0x10FFFF + 28,
266 F19 = 0x10FFFF + 29,
267 F20 = 0x10FFFF + 30,
268 F21 = 0x10FFFF + 31,
269 F22 = 0x10FFFF + 32,
270 F23 = 0x10FFFF + 33,
271 F24 = 0x10FFFF + 34,
272 PrintScreen = 0x10FFFF + 35,
273 Menu = 0x10FFFF + 36,
274 };
@ ArrowRight
Definition key.hpp:239
@ Ctrl_R
Definition key.hpp:114
@ Ctrl_B
Definition key.hpp:98
@ Caret
Definition key.hpp:193
@ Minus
Definition key.hpp:142
@ Tilde
Definition key.hpp:225
@ Percent
Definition key.hpp:133
@ Ctrl_X
Definition key.hpp:120
@ Ctrl_A
Definition key.hpp:97
@ Ctrl_Y
Definition key.hpp:121
@ Eight
Definition key.hpp:153
@ Ctrl_J
Definition key.hpp:106
@ Hyphen
Definition key.hpp:141
@ CTRL_QuestionMark
Definition key.hpp:226
@ Ctrl_N
Definition key.hpp:110
@ OpenChevron
Definition key.hpp:158
@ CloseBracket
Definition key.hpp:192
@ QuestionMark
Definition key.hpp:162
@ Ctrl_O
Definition key.hpp:111
@ Ampersand
Definition key.hpp:134
@ ExclamationMark
Definition key.hpp:129
@ Ctrl_BackSlash
Definition key.hpp:124
@ Three
Definition key.hpp:148
@ ArrowLeft
Definition key.hpp:238
@ PageDown
Definition key.hpp:247
@ Ctrl_S
Definition key.hpp:115
@ PageUp
Definition key.hpp:246
@ Apostrophe
Definition key.hpp:135
@ Ctrl_Underscore
Definition key.hpp:127
@ Backslash
Definition key.hpp:191
@ OpenBrace
Definition key.hpp:222
@ Dollar
Definition key.hpp:132
@ Ctrl_K
Definition key.hpp:107
@ Ctrl_Z
Definition key.hpp:122
@ Ctrl_P
Definition key.hpp:112
@ Ctrl_G
Definition key.hpp:103
@ Arobase
Definition key.hpp:163
@ Ctrl_F
Definition key.hpp:102
@ Ctrl_M
Definition key.hpp:109
@ GreaterThan
Definition key.hpp:160
@ Quote
Definition key.hpp:130
@ PrintScreen
Definition key.hpp:272
@ Ctrl_D
Definition key.hpp:100
@ Ctrl_E
Definition key.hpp:101
@ Seven
Definition key.hpp:152
@ Ctrl_Caret
Definition key.hpp:126
@ Enter
Definition key.hpp:231
@ Underscore
Definition key.hpp:194
@ Ctrl_I
Definition key.hpp:105
@ OpenBracket
Definition key.hpp:190
@ Period
Definition key.hpp:143
@ Equal
Definition key.hpp:159
@ Ctrl_Arobase
Definition key.hpp:96
@ ArrowUp
Definition key.hpp:240
@ CloseParenthesis
Definition key.hpp:137
@ Semicolon
Definition key.hpp:156
@ Ctrl_OpenBracket
Definition key.hpp:123
@ Comma
Definition key.hpp:140
@ OpenParenthesis
Definition key.hpp:136
@ Colon
Definition key.hpp:155
@ GraveAccent
Definition key.hpp:195
@ LessThan
Definition key.hpp:157
@ Ctrl_L
Definition key.hpp:108
@ Backspace
Definition key.hpp:229
@ Ctrl_CloseBracket
Definition key.hpp:125
@ Ctrl_U
Definition key.hpp:117
@ Ctrl_H
Definition key.hpp:104
@ NoKey
Definition key.hpp:92
@ Ctrl_V
Definition key.hpp:118
@ CloseChevron
Definition key.hpp:161
@ Slash
Definition key.hpp:144
@ Close_Brace
Definition key.hpp:224
@ Ctrl_C
Definition key.hpp:99
@ Ctrl_T
Definition key.hpp:116
@ ArrowDown
Definition key.hpp:241
@ Ctrl_Q
Definition key.hpp:113
@ Numeric5
Definition key.hpp:242
@ VerticalBar
Definition key.hpp:223
@ Space
Definition key.hpp:128
@ Asterisk
Definition key.hpp:138
@ Ctrl_W
Definition key.hpp:119
@ Insert
Definition key.hpp:244

Constructor & Destructor Documentation

◆ Key() [1/7]

Term::Key::Key ( )
inlineconstexpr

Definition at line 276 of file key.hpp.

276: value(NoKey) {}
std::int32_t value
Definition key.hpp:421

◆ Key() [2/7]

Term::Key::Key ( const Key & key)
constexprdefault

◆ Key() [3/7]

Term::Key::Key ( const Value & v)
inlineconstexpr

Definition at line 280 of file key.hpp.

280: value(static_cast<std::int32_t>(v)) {}

◆ Key() [4/7]

Term::Key::Key ( char val)
inlineexplicitconstexpr

Definition at line 287 of file key.hpp.

287: value(static_cast<std::int32_t>(val)) {}

◆ Key() [5/7]

Term::Key::Key ( std::int32_t val)
inlineconstexpr

Definition at line 294 of file key.hpp.

294: value(val) {}

◆ Key() [6/7]

Term::Key::Key ( std::size_t val)
inlineexplicitconstexpr

Definition at line 301 of file key.hpp.

301: value(static_cast<std::int32_t>(val)) {}

◆ Key() [7/7]

Term::Key::Key ( char32_t val)
inlineexplicitconstexpr

Definition at line 308 of file key.hpp.

308: value(static_cast<std::int32_t>(val)) {}

Member Function Documentation

◆ append_name()

void Term::Key::append_name ( std::string & strOut) const

Definition at line 16 of file key.cpp.

17{
18 Term::Key key = *this;
19 if(key == Term::Key::NoKey) return;
20 if(key.hasAlt())
21 {
22 strOut += "Alt+";
23 key = static_cast<Term::Key>(key.value - static_cast<std::int32_t>(Term::MetaKey::Value::Alt));
24 }
25 if(key.hasCtrl())
26 {
27 strOut += "Ctrl+";
28 if(!key.iscntrl()) key = static_cast<Term::Key>(key.value - static_cast<std::int32_t>(Term::MetaKey::Value::Ctrl));
29 }
30 if(key == Term::Key::Tab) strOut += "Tab";
31 else if(key == Term::Key::Enter)
32 strOut += "Enter";
33 else if(key == Term::Key::Esc)
34 strOut += "Esc";
35 else if(key == Term::Key::Backspace)
36 strOut += "Backspace";
37 else if(key == Term::Key::Del)
38 strOut += "Del";
39 else if(key.iscntrl())
40 strOut += static_cast<char>(key.value + 64);
41 else if(key == Term::Key::Space)
42 strOut += "Space";
43 else if(key.isunicode()) { strOut += Term::Private::utf32_to_utf8(static_cast<char32_t>(this->value)); }
44 else
45 {
46 switch(key)
47 {
48 case Term::Key::ArrowLeft: strOut += "Left Arrow"; break;
49 case Term::Key::ArrowRight: strOut += "Right Arrow"; break;
50 case Term::Key::ArrowUp: strOut += "Up arrow"; break;
51 case Term::Key::ArrowDown: strOut += "Down arrow"; break;
52 case Term::Key::Numeric5: strOut += "5 Numeric pad"; break;
53 case Term::Key::Home: strOut += "Home"; break;
54 case Term::Key::Insert: strOut += "Insert"; break;
55 case Term::Key::End: strOut += "End"; break;
56 case Term::Key::PageUp: strOut += "Page up"; break;
57 case Term::Key::PageDown: strOut += "Page down"; break;
58 case Term::Key::F1: strOut += "F1"; break;
59 case Term::Key::F2: strOut += "F2"; break;
60 case Term::Key::F3: strOut += "F3"; break;
61 case Term::Key::F4: strOut += "F4"; break;
62 case Term::Key::F5: strOut += "F5"; break;
63 case Term::Key::F6: strOut += "F6"; break;
64 case Term::Key::F7: strOut += "F7"; break;
65 case Term::Key::F8: strOut += "F8"; break;
66 case Term::Key::F9: strOut += "F9"; break;
67 case Term::Key::F10: strOut += "F10"; break;
68 case Term::Key::F11: strOut += "F11"; break;
69 case Term::Key::F12: strOut += "F12"; break;
70 case Term::Key::F13: strOut += "F13"; break;
71 case Term::Key::F14: strOut += "F14"; break;
72 case Term::Key::F15: strOut += "F15"; break;
73 case Term::Key::F16: strOut += "F16"; break;
74 case Term::Key::F17: strOut += "F17"; break;
75 case Term::Key::F18: strOut += "F18"; break;
76 case Term::Key::F19: strOut += "F19"; break;
77 case Term::Key::F20: strOut += "F20"; break;
78 case Term::Key::F21: strOut += "F21"; break;
79 case Term::Key::F22: strOut += "F22"; break;
80 case Term::Key::F23: strOut += "F23"; break;
81 case Term::Key::F24: strOut += "F24"; break;
82 case Term::Key::PrintScreen: strOut += "Print Screen"; break;
83 case Term::Key::Menu: strOut += "Menu"; break;
84 default: break;
85 }
86 }
87}
constexpr bool hasCtrl() const
Definition key.hpp:403
constexpr bool hasAlt() const
Definition key.hpp:410
constexpr bool iscntrl() const
Definition key.hpp:377
constexpr bool isunicode() const
Definition key.hpp:389
std::string utf32_to_utf8(const char32_t &codepoint, const bool &exception=false)
Encode a codepoint using UTF-8 std::string .
Definition unicode.cpp:55

◆ empty()

bool Term::Key::empty ( ) const
inlineconstexpr

Definition at line 412 of file key.hpp.

412{ return (this->value == Key::NoKey); }

◆ hasAlt()

bool Term::Key::hasAlt ( ) const
inlineconstexpr

Definition at line 410 of file key.hpp.

410{ return (this->value & static_cast<std::int32_t>(MetaKey::Value::Alt)) == static_cast<std::int32_t>(MetaKey::Value::Alt); }

◆ hasCtrl()

bool Term::Key::hasCtrl ( ) const
inlineconstexpr

Definition at line 403 of file key.hpp.

404 {
405 // Need to suppress the TAB etc...
406 return ((this->iscntrl() || this->hasCtrlAll()) && *this != Key::Backspace && *this != Key::Tab && *this != Key::Esc && *this != Key::Enter && *this != Key::Del);
407 }
constexpr bool hasCtrlAll() const
Definition key.hpp:400

◆ hasCtrlAll()

bool Term::Key::hasCtrlAll ( ) const
inlineconstexpr

Definition at line 400 of file key.hpp.

400{ return this->iscntrl() || ((this->value & static_cast<std::int32_t>(MetaKey::Value::Ctrl)) == static_cast<std::int32_t>(MetaKey::Value::Ctrl)); }

◆ isalnum()

bool Term::Key::isalnum ( ) const
inlineconstexpr

Definition at line 385 of file key.hpp.

385{ return (this->isdigit() || this->isalpha()); }
constexpr bool isdigit() const
Definition key.hpp:383
constexpr bool isalpha() const
Definition key.hpp:382

◆ isalpha()

bool Term::Key::isalpha ( ) const
inlineconstexpr

Definition at line 382 of file key.hpp.

382{ return (this->isupper() || this->islower()); }
constexpr bool islower() const
Definition key.hpp:381
constexpr bool isupper() const
Definition key.hpp:380

◆ isASCII()

bool Term::Key::isASCII ( ) const
inlineconstexpr

Definition at line 394 of file key.hpp.

394{ return *this >= Key::Null && *this <= Key::Del; }

◆ isblank()

bool Term::Key::isblank ( ) const
inlineconstexpr

Definition at line 378 of file key.hpp.

378{ return *this == Key::Tab || *this == Key::Space; }

◆ iscntrl()

bool Term::Key::iscntrl ( ) const
inlineconstexpr

Definition at line 377 of file key.hpp.

377{ return (*this >= Key::Null && *this <= Key::Ctrl_Underscore) || *this == Key::Del; }

◆ isdigit()

bool Term::Key::isdigit ( ) const
inlineconstexpr

Definition at line 383 of file key.hpp.

383{ return *this >= Key::Zero && *this <= Key::Nine; }

◆ isExtendedASCII()

bool Term::Key::isExtendedASCII ( ) const
inlineconstexpr

Definition at line 397 of file key.hpp.

397{ return *this >= Key::Null && this->value <= 255L; }

◆ isgraph()

bool Term::Key::isgraph ( ) const
inlineconstexpr

Definition at line 387 of file key.hpp.

387{ return (this->isalnum() || this->ispunct()); }
constexpr bool ispunct() const
Definition key.hpp:386
constexpr bool isalnum() const
Definition key.hpp:385

◆ islower()

bool Term::Key::islower ( ) const
inlineconstexpr

Definition at line 381 of file key.hpp.

381{ return *this >= Key::a && *this <= Key::z; }

◆ isprint()

bool Term::Key::isprint ( ) const
inlineconstexpr

Definition at line 388 of file key.hpp.

388{ return (this->isgraph() || *this == Key::Space); }
constexpr bool isgraph() const
Definition key.hpp:387

◆ ispunct()

bool Term::Key::ispunct ( ) const
inlineconstexpr

Definition at line 386 of file key.hpp.

386{ return (*this >= Key::ExclamationMark && *this <= Key::Slash) || (*this >= Key::Colon && *this <= Key::Arobase) || (*this >= Key::OpenBracket && *this <= Key::GraveAccent) || (*this >= Key::OpenBrace && *this <= Key::Tilde); }

◆ isspace()

bool Term::Key::isspace ( ) const
inlineconstexpr

Definition at line 379 of file key.hpp.

379{ return this->isblank() || (*this >= Key::Ctrl_J && *this <= Key::Enter); }
constexpr bool isblank() const
Definition key.hpp:378

◆ isunicode()

bool Term::Key::isunicode ( ) const
inlineconstexpr

Definition at line 389 of file key.hpp.

389{ return *this >= Key::Null && this->value <= 0x10FFFFL; }

◆ isupper()

bool Term::Key::isupper ( ) const
inlineconstexpr

Definition at line 380 of file key.hpp.

380{ return *this >= Key::A && *this <= Key::Z; }

◆ isxdigit()

bool Term::Key::isxdigit ( ) const
inlineconstexpr

Definition at line 384 of file key.hpp.

384{ return this->isdigit() || (*this >= Key::A && *this <= Key::F) || (*this >= Key::a && *this <= Key::f); }

◆ name()

std::string Term::Key::name ( ) const

Definition at line 89 of file key.cpp.

90{
91 std::string str;
92 this->append_name(str);
93 return str;
94}
void append_name(std::string &strOut) const
Definition key.cpp:16
std::string str() const
Definition key.cpp:96

◆ operator std::int32_t()

Term::Key::operator std::int32_t ( ) const
inlineconstexpr

Definition at line 315 of file key.hpp.

315{ return this->value; }

◆ operator=() [1/6]

Key & Term::Key::operator= ( char val)
inline

Definition at line 288 of file key.hpp.

289 {
290 value = static_cast<std::int32_t>(val);
291 return *this;
292 }

◆ operator=() [2/6]

Key & Term::Key::operator= ( char32_t val)
inline

Definition at line 309 of file key.hpp.

310 {
311 value = static_cast<std::int32_t>(val);
312 return *this;
313 }

◆ operator=() [3/6]

Key & Term::Key::operator= ( const Key & key)
inlinedefault

◆ operator=() [4/6]

Key & Term::Key::operator= ( const Value & v)
inline

Definition at line 281 of file key.hpp.

282 {
283 this->value = static_cast<std::int32_t>(v);
284 return *this;
285 }

◆ operator=() [5/6]

Key & Term::Key::operator= ( std::int32_t val)
inline

Definition at line 295 of file key.hpp.

296 {
297 value = val;
298 return *this;
299 }

◆ operator=() [6/6]

Key & Term::Key::operator= ( std::size_t val)
inline

Definition at line 302 of file key.hpp.

303 {
304 value = static_cast<std::int32_t>(val);
305 return *this;
306 }

◆ str()

std::string Term::Key::str ( ) const

Definition at line 96 of file key.cpp.

96{ return Term::Private::utf32_to_utf8(static_cast<char32_t>(this->value)); }

◆ tolower()

Key Term::Key::tolower ( ) const
inlineconstexpr

Definition at line 390 of file key.hpp.

390{ return (this->isalpha() && this->isupper()) ? Key(this->value + 32) : *this; }
constexpr Key()
Definition key.hpp:276

◆ toupper()

Key Term::Key::toupper ( ) const
inlineconstexpr

Definition at line 391 of file key.hpp.

391{ return (this->isalpha() && this->islower()) ? Key(this->value - 32) : *this; }

Friends And Related Symbol Documentation

◆ operator!= [1/9]

bool operator!= ( char l,
Key r )
friend

Definition at line 329 of file key.hpp.

329{ return !(l == r); }

◆ operator!= [2/9]

bool operator!= ( char32_t l,
Key r )
friend

Definition at line 331 of file key.hpp.

331{ return !(l == r); }

◆ operator!= [3/9]

bool operator!= ( Key l,
char r )
friend

Definition at line 328 of file key.hpp.

328{ return !(l == r); }

◆ operator!= [4/9]

bool operator!= ( Key l,
char32_t r )
friend

Definition at line 330 of file key.hpp.

330{ return !(l == r); }

◆ operator!= [5/9]

bool operator!= ( Key l,
Key r )
friend

Definition at line 327 of file key.hpp.

327{ return !(l == r); }

◆ operator!= [6/9]

bool operator!= ( Key l,
std::int32_t r )
friend

Definition at line 332 of file key.hpp.

332{ return !(l == r); }

◆ operator!= [7/9]

bool operator!= ( Key l,
std::size_t r )
friend

Definition at line 334 of file key.hpp.

334{ return !(l == r); }

◆ operator!= [8/9]

bool operator!= ( std::int32_t l,
Key r )
friend

Definition at line 333 of file key.hpp.

333{ return !(l == r); }

◆ operator!= [9/9]

bool operator!= ( std::size_t l,
Key r )
friend

Definition at line 335 of file key.hpp.

335{ return !(l == r); }

◆ operator< [1/9]

bool operator< ( char l,
Key r )
friend

Definition at line 339 of file key.hpp.

339{ return Key(l) < r; }

◆ operator< [2/9]

bool operator< ( char32_t l,
Key r )
friend

Definition at line 341 of file key.hpp.

341{ return Key(l) < r; }

◆ operator< [3/9]

bool operator< ( Key l,
char r )
friend

Definition at line 338 of file key.hpp.

338{ return l < Key(r); }

◆ operator< [4/9]

bool operator< ( Key l,
char32_t r )
friend

Definition at line 340 of file key.hpp.

340{ return l < Key(r); }

◆ operator< [5/9]

bool operator< ( Key l,
Key r )
friend

Definition at line 337 of file key.hpp.

337{ return l.value < r.value; }

◆ operator< [6/9]

bool operator< ( Key l,
std::int32_t r )
friend

Definition at line 342 of file key.hpp.

342{ return l < Key(r); }

◆ operator< [7/9]

bool operator< ( Key l,
std::size_t r )
friend

Definition at line 344 of file key.hpp.

344{ return static_cast<std::size_t>(l.value) < r; }

◆ operator< [8/9]

bool operator< ( std::int32_t l,
Key r )
friend

Definition at line 343 of file key.hpp.

343{ return Key(l) < r; }

◆ operator< [9/9]

bool operator< ( std::size_t l,
Key r )
friend

Definition at line 345 of file key.hpp.

345{ return l < static_cast<std::size_t>(r.value); }

◆ operator<= [1/9]

bool operator<= ( char l,
Key r )
friend

Definition at line 369 of file key.hpp.

369{ return !(l > r); }

◆ operator<= [2/9]

bool operator<= ( char32_t l,
Key r )
friend

Definition at line 371 of file key.hpp.

371{ return !(l > r); }

◆ operator<= [3/9]

bool operator<= ( Key l,
char r )
friend

Definition at line 368 of file key.hpp.

368{ return !(l > r); }

◆ operator<= [4/9]

bool operator<= ( Key l,
char32_t r )
friend

Definition at line 370 of file key.hpp.

370{ return !(l > r); }

◆ operator<= [5/9]

bool operator<= ( Key l,
Key r )
friend

Definition at line 367 of file key.hpp.

367{ return !(l > r); }

◆ operator<= [6/9]

bool operator<= ( Key l,
std::int32_t r )
friend

Definition at line 372 of file key.hpp.

372{ return !(l > r); }

◆ operator<= [7/9]

bool operator<= ( Key l,
std::size_t r )
friend

Definition at line 374 of file key.hpp.

374{ return !(l > r); }

◆ operator<= [8/9]

bool operator<= ( std::int32_t l,
Key r )
friend

Definition at line 373 of file key.hpp.

373{ return !(l > r); }

◆ operator<= [9/9]

bool operator<= ( std::size_t l,
Key r )
friend

Definition at line 375 of file key.hpp.

375{ return !(l > r); }

◆ operator== [1/9]

bool operator== ( char l,
Key r )
friend

Definition at line 319 of file key.hpp.

319{ return Key(l) == r; }

◆ operator== [2/9]

bool operator== ( char32_t l,
Key r )
friend

Definition at line 321 of file key.hpp.

321{ return Key(l) == r; }

◆ operator== [3/9]

bool operator== ( Key l,
char r )
friend

Definition at line 318 of file key.hpp.

318{ return l == Key(r); }

◆ operator== [4/9]

bool operator== ( Key l,
char32_t r )
friend

Definition at line 320 of file key.hpp.

320{ return l == Key(r); }

◆ operator== [5/9]

bool operator== ( Key l,
Key r )
friend

Definition at line 317 of file key.hpp.

317{ return l.value == r.value; }

◆ operator== [6/9]

bool operator== ( Key l,
std::int32_t r )
friend

Definition at line 322 of file key.hpp.

322{ return l == Key(r); }

◆ operator== [7/9]

bool operator== ( Key l,
std::size_t r )
friend

Definition at line 324 of file key.hpp.

324{ return static_cast<std::size_t>(l.value) == r; }

◆ operator== [8/9]

bool operator== ( std::int32_t l,
Key r )
friend

Definition at line 323 of file key.hpp.

323{ return Key(l) == r; }

◆ operator== [9/9]

bool operator== ( std::size_t l,
Key r )
friend

Definition at line 325 of file key.hpp.

325{ return l == static_cast<std::size_t>(r.value); }

◆ operator> [1/9]

bool operator> ( char l,
Key r )
friend

Definition at line 359 of file key.hpp.

359{ return r < l; }

◆ operator> [2/9]

bool operator> ( char32_t l,
Key r )
friend

Definition at line 361 of file key.hpp.

361{ return r < l; }

◆ operator> [3/9]

bool operator> ( Key l,
char r )
friend

Definition at line 358 of file key.hpp.

358{ return r < l; }

◆ operator> [4/9]

bool operator> ( Key l,
char32_t r )
friend

Definition at line 360 of file key.hpp.

360{ return r < l; }

◆ operator> [5/9]

bool operator> ( Key l,
Key r )
friend

Definition at line 357 of file key.hpp.

357{ return r < l; }

◆ operator> [6/9]

bool operator> ( Key l,
std::int32_t r )
friend

Definition at line 362 of file key.hpp.

362{ return r < l; }

◆ operator> [7/9]

bool operator> ( Key l,
std::size_t r )
friend

Definition at line 364 of file key.hpp.

364{ return r < l; }

◆ operator> [8/9]

bool operator> ( std::int32_t l,
Key r )
friend

Definition at line 363 of file key.hpp.

363{ return r < l; }

◆ operator> [9/9]

bool operator> ( std::size_t l,
Key r )
friend

Definition at line 365 of file key.hpp.

365{ return r < l; }

◆ operator>= [1/9]

bool operator>= ( char l,
Key r )
friend

Definition at line 349 of file key.hpp.

349{ return !(l < r); }

◆ operator>= [2/9]

bool operator>= ( char32_t l,
Key r )
friend

Definition at line 351 of file key.hpp.

351{ return !(l < r); }

◆ operator>= [3/9]

bool operator>= ( Key l,
char r )
friend

Definition at line 348 of file key.hpp.

348{ return !(l < r); }

◆ operator>= [4/9]

bool operator>= ( Key l,
char32_t r )
friend

Definition at line 350 of file key.hpp.

350{ return !(l < r); }

◆ operator>= [5/9]

bool operator>= ( Key l,
Key r )
friend

Definition at line 347 of file key.hpp.

347{ return !(l < r); }

◆ operator>= [6/9]

bool operator>= ( Key l,
std::int32_t r )
friend

Definition at line 352 of file key.hpp.

352{ return !(l < r); }

◆ operator>= [7/9]

bool operator>= ( Key l,
std::size_t r )
friend

Definition at line 354 of file key.hpp.

354{ return !(l < r); }

◆ operator>= [8/9]

bool operator>= ( std::int32_t l,
Key r )
friend

Definition at line 353 of file key.hpp.

353{ return !(l < r); }

◆ operator>= [9/9]

bool operator>= ( std::size_t l,
Key r )
friend

Definition at line 355 of file key.hpp.

355{ return !(l < r); }

Member Data Documentation

◆ value

std::int32_t Term::Key::value

Definition at line 421 of file key.hpp.


The documentation for this class was generated from the following files: