FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
event.cpp
浏览该文件的文档.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// 本源代码的使用受 MIT 许可证的管辖,该许可证可在 LICENSE 文件中找到。
3#include <map> // for map
4#include <string>
5#include <utility> // for move
6
8#include "ftxui/component/mouse.hpp" // for Mouse
9#include "ftxui/screen/string.hpp" // for to_wstring
10
11// 禁用影子变量的警告,适用于所有编译器。实际上,每个字母都有一个静态事件:
12#ifdef __clang__
13#pragma clang diagnostic ignored "-Wshadow"
14#elif __GNUC__
15#pragma GCC diagnostic ignored "-Wshadow"
16#elif defined(_MSC_VER)
17#pragma warning(disable : 6244)
18#pragma warning(disable : 6246)
19#endif
20
21namespace ftxui {
22
23/// @brief 对应于给定输入字符的事件。
24/// @param input 用户输入的字符。
25// static
26Event Event::Character(std::string input) {
27 Event event;
28 event.input_ = std::move(input);
29 event.type_ = Type::Character;
30 return event;
31}
32
33/// @brief 对应于给定输入字符的事件。
34/// @param c 用户输入的字符。
35// static
36Event Event::Character(char c) {
37 return Event::Character(std::string{c});
38}
39
40/// @brief 对应于给定输入字符的事件。
41/// @param c 用户输入的字符。
42// static
43Event Event::Character(wchar_t c) {
44 return Event::Character(to_string(std::wstring{c}));
45}
46
47/// @brief 对应于给定输入字符序列的事件。
48/// @param input 终端发送的字符序列。
49/// @param mouse 鼠标状态。
50// static
51Event Event::Mouse(std::string input, struct Mouse mouse) {
52 Event event;
53 event.input_ = std::move(input);
54 event.type_ = Type::Mouse;
55 event.data_.mouse = mouse; // NOLINT
56 return event;
57}
58
59/// @brief 对应于终端 DCS(设备控制字符串)的事件。
60// static
61Event Event::CursorShape(std::string input, int shape) {
62 Event event;
63 event.input_ = std::move(input);
64 event.type_ = Type::CursorShape;
65 event.data_.cursor_shape = shape; // NOLINT
66 return event;
67}
68
69/// @brief 一个自定义事件,其含义由库用户定义。
70/// @param input 由开发者定义的任意字符序列。
71// static
72Event Event::Special(std::string input) {
73 Event event;
74 event.input_ = std::move(input);
75 return event;
76}
77
78/// @internal 内部使用
79// static
80Event Event::CursorPosition(std::string input, int x, int y) {
81 Event event;
82 event.input_ = std::move(input);
83 event.type_ = Type::CursorPosition;
84 event.data_.cursor = {x, y}; // NOLINT
85 return event;
86}
87
88/// @brief 返回事件的字符串表示。
89std::string Event::DebugString() const {
90 static std::map<Event, const char*> event_to_string = {
91 // --- Arrow ---
92 {Event::ArrowLeft, "Event::ArrowLeft"},
93 {Event::ArrowRight, "Event::ArrowRight"},
94 {Event::ArrowUp, "Event::ArrowUp"},
95 {Event::ArrowDown, "Event::ArrowDown"},
96
97 // --- ArrowCtrl ---
98 {Event::ArrowLeftCtrl, "Event::ArrowLeftCtrl"},
99 {Event::ArrowRightCtrl, "Event::ArrowRightCtrl"},
100 {Event::ArrowUpCtrl, "Event::ArrowUpCtrl"},
101 {Event::ArrowDownCtrl, "Event::ArrowDownCtrl"},
102
103 // --- Other ---
104 {Event::Backspace, "Event::Backspace"},
105 {Event::Delete, "Event::Delete"},
106 {Event::Escape, "Event::Escape"},
107 {Event::Return, "Event::Return"},
108 {Event::Tab, "Event::Tab"},
109 {Event::TabReverse, "Event::TabReverse"},
110
111 // --- Function keys ---
112 {Event::F1, "Event::F1"},
113 {Event::F2, "Event::F2"},
114 {Event::F3, "Event::F3"},
115 {Event::F4, "Event::F4"},
116 {Event::F5, "Event::F5"},
117 {Event::F6, "Event::F6"},
118 {Event::F7, "Event::F7"},
119 {Event::F8, "Event::F8"},
120 {Event::F9, "Event::F9"},
121 {Event::F10, "Event::F10"},
122 {Event::F11, "Event::F11"},
123 {Event::F12, "Event::F12"},
124
125 // --- Navigation keys ---
126 {Event::Insert, "Event::Insert"},
127 {Event::Home, "Event::Home"},
128 {Event::End, "Event::End"},
129 {Event::PageUp, "Event::PageUp"},
130 {Event::PageDown, "Event::PageDown"},
131
132 // --- Control keys ---
133 {Event::CtrlA, "Event::CtrlA"},
134 {Event::CtrlB, "Event::CtrlB"},
135 {Event::CtrlC, "Event::CtrlC"},
136 {Event::CtrlD, "Event::CtrlD"},
137 {Event::CtrlE, "Event::CtrlE"},
138 {Event::CtrlF, "Event::CtrlF"},
139 {Event::CtrlG, "Event::CtrlG"},
140 {Event::CtrlH, "Event::CtrlH"},
141 {Event::CtrlI, "Event::CtrlI"},
142 {Event::CtrlJ, "Event::CtrlJ"},
143 {Event::CtrlK, "Event::CtrlK"},
144 {Event::CtrlL, "Event::CtrlL"},
145 {Event::CtrlM, "Event::CtrlM"},
146 {Event::CtrlN, "Event::CtrlN"},
147 {Event::CtrlO, "Event::CtrlO"},
148 {Event::CtrlP, "Event::CtrlP"},
149 {Event::CtrlQ, "Event::CtrlQ"},
150 {Event::CtrlR, "Event::CtrlR"},
151 {Event::CtrlS, "Event::CtrlS"},
152 {Event::CtrlT, "Event::CtrlT"},
153 {Event::CtrlU, "Event::CtrlU"},
154 {Event::CtrlV, "Event::CtrlV"},
155 {Event::CtrlW, "Event::CtrlW"},
156 {Event::CtrlX, "Event::CtrlX"},
157 {Event::CtrlY, "Event::CtrlY"},
158 {Event::CtrlZ, "Event::CtrlZ"},
159
160 // --- Alt keys ---
161 {Event::AltA, "Event::AltA"},
162 {Event::AltB, "Event::AltB"},
163 {Event::AltC, "Event::AltC"},
164 {Event::AltD, "Event::AltD"},
165 {Event::AltE, "Event::AltE"},
166 {Event::AltF, "Event::AltF"},
167 {Event::AltG, "Event::AltG"},
168 {Event::AltH, "Event::AltH"},
169 {Event::AltI, "Event::AltI"},
170 {Event::AltJ, "Event::AltJ"},
171 {Event::AltK, "Event::AltK"},
172 {Event::AltL, "Event::AltL"},
173 {Event::AltM, "Event::AltM"},
174 {Event::AltN, "Event::AltN"},
175 {Event::AltO, "Event::AltO"},
176 {Event::AltP, "Event::AltP"},
177 {Event::AltQ, "Event::AltQ"},
178 {Event::AltR, "Event::AltR"},
179 {Event::AltS, "Event::AltS"},
180 {Event::AltT, "Event::AltT"},
181 {Event::AltU, "Event::AltU"},
182 {Event::AltV, "Event::AltV"},
183 {Event::AltW, "Event::AltW"},
184 {Event::AltX, "Event::AltX"},
185 {Event::AltY, "Event::AltY"},
186 {Event::AltZ, "Event::AltZ"},
187
188 // --- CtrlAlt keys ---
189 {Event::CtrlAltA, "Event::CtrlAltA"},
190 {Event::CtrlAltB, "Event::CtrlAltB"},
191 {Event::CtrlAltC, "Event::CtrlAltC"},
192 {Event::CtrlAltD, "Event::CtrlAltD"},
193 {Event::CtrlAltE, "Event::CtrlAltE"},
194 {Event::CtrlAltF, "Event::CtrlAltF"},
195 {Event::CtrlAltG, "Event::CtrlAltG"},
196 {Event::CtrlAltH, "Event::CtrlAltH"},
197 {Event::CtrlAltI, "Event::CtrlAltI"},
198 {Event::CtrlAltJ, "Event::CtrlAltJ"},
199 {Event::CtrlAltK, "Event::CtrlAltK"},
200 {Event::CtrlAltL, "Event::CtrlAltL"},
201 {Event::CtrlAltM, "Event::CtrlAltM"},
202 {Event::CtrlAltN, "Event::CtrlAltN"},
203 {Event::CtrlAltO, "Event::CtrlAltO"},
204 {Event::CtrlAltP, "Event::CtrlAltP"},
205 {Event::CtrlAltQ, "Event::CtrlAltQ"},
206 {Event::CtrlAltR, "Event::CtrlAltR"},
207 {Event::CtrlAltS, "Event::CtrlAltS"},
208 {Event::CtrlAltT, "Event::CtrlAltT"},
209 {Event::CtrlAltU, "Event::CtrlAltU"},
210 {Event::CtrlAltV, "Event::CtrlAltV"},
211 {Event::CtrlAltW, "Event::CtrlAltW"},
212 {Event::CtrlAltX, "Event::CtrlAltX"},
213 {Event::CtrlAltY, "Event::CtrlAltY"},
214 {Event::CtrlAltZ, "Event::CtrlAltZ"},
215
216 // --- Custom ---
217 {Event::Custom, "Event::Custom"},
218 };
219
220 static std::map<Mouse::Button, const char*> mouse_button_string = {
221 {Mouse::Button::Left, ".button = Mouse::Left"},
222 {Mouse::Button::Middle, ".button = Mouse::Middle"},
223 {Mouse::Button::Right, ".button = Mouse::Right"},
224 {Mouse::Button::WheelUp, ".button = Mouse::WheelUp"},
225 {Mouse::Button::WheelDown, ".button = Mouse::WheelDown"},
226 {Mouse::Button::None, ".button = Mouse::None"},
227 {Mouse::Button::WheelLeft, ".button = Mouse::WheelLeft"},
228 {Mouse::Button::WheelRight, ".button = Mouse::WheelRight"},
229 };
230
231 static std::map<Mouse::Motion, const char*> mouse_motion_string = {
232 {Mouse::Motion::Pressed, ".motion = Mouse::Pressed"},
233 {Mouse::Motion::Released, ".motion = Mouse::Released"},
234 {Mouse::Motion::Moved, ".motion = Mouse::Moved"},
235 };
236
237 switch (type_) {
238 case Type::Character: {
239 return "Event::Character(\"" + input_ + "\")";
240 }
241 case Type::Mouse: {
242 std::string out = "Event::Mouse(\"...\", Mouse{";
243 out += std::string(mouse_button_string[data_.mouse.button]);
244 out += ", ";
245 out += std::string(mouse_motion_string[data_.mouse.motion]);
246 out += ", ";
247 if (data_.mouse.shift) {
248 out += ".shift = true, ";
249 }
250 if (data_.mouse.meta) {
251 out += ".meta = true, ";
252 }
253 if (data_.mouse.control) {
254 out += ".control = true, ";
255 }
256 out += ".x = " + std::to_string(data_.mouse.x);
257 out += ", ";
258 out += ".y = " + std::to_string(data_.mouse.y);
259 out += "})";
260 return out;
261 }
262 case Type::CursorShape:
263 return "Event::CursorShape(" + input_ + ", " +
264 std::to_string(data_.cursor_shape) + ")";
265 case Type::CursorPosition:
266 return "Event::CursorPosition(" + input_ + ", " +
267 std::to_string(data_.cursor.x) + ", " +
268 std::to_string(data_.cursor.y) + ")";
269 default: {
270 auto event_it = event_to_string.find(*this);
271 if (event_it != event_to_string.end()) {
272 return event_it->second;
273 }
274
275 return "";
276 }
277 }
278 return "";
279}
280
281// clang-format off
282// NOLINTBEGIN
283
284// --- Arrow ---
285const Event Event::ArrowLeft = Event::Special("\x1B[D");
286const Event Event::ArrowRight = Event::Special("\x1B[C");
287const Event Event::ArrowUp = Event::Special("\x1B[A");
288const Event Event::ArrowDown = Event::Special("\x1B[B");
289const Event Event::ArrowLeftCtrl = Event::Special("\x1B[1;5D");
290const Event Event::ArrowRightCtrl = Event::Special("\x1B[1;5C");
291const Event Event::ArrowUpCtrl = Event::Special("\x1B[1;5A");
292const Event Event::ArrowDownCtrl = Event::Special("\x1B[1;5B");
294const Event Event::Delete = Event::Special("\x1B[3~");
295const Event Event::Escape = Event::Special("\x1B");
296const Event Event::Return = Event::Special({10});
297const Event Event::Tab = Event::Special({9});
298const Event Event::TabReverse = Event::Special({27, 91, 90});
299
300// See https://invisible-island.net/xterm/xterm-function-keys.html
301// We follow xterm-new / vterm-xf86-v4 / mgt / screen
302const Event Event::F1 = Event::Special("\x1BOP");
303const Event Event::F2 = Event::Special("\x1BOQ");
304const Event Event::F3 = Event::Special("\x1BOR");
305const Event Event::F4 = Event::Special("\x1BOS");
306const Event Event::F5 = Event::Special("\x1B[15~");
307const Event Event::F6 = Event::Special("\x1B[17~");
308const Event Event::F7 = Event::Special("\x1B[18~");
309const Event Event::F8 = Event::Special("\x1B[19~");
310const Event Event::F9 = Event::Special("\x1B[20~");
311const Event Event::F10 = Event::Special("\x1B[21~");
312const Event Event::F11 = Event::Special("\x1B[23~");
313const Event Event::F12 = Event::Special("\x1B[24~");
314
315const Event Event::Insert = Event::Special("\x1B[2~");
316const Event Event::Home = Event::Special({27, 91, 72});
317const Event Event::End = Event::Special({27, 91, 70});
318const Event Event::PageUp = Event::Special({27, 91, 53, 126});
319const Event Event::PageDown = Event::Special({27, 91, 54, 126});
320const Event Event::Custom = Event::Special({0});
321
322const Event Event::a = Event::Character("a");
323const Event Event::b = Event::Character("b");
324const Event Event::c = Event::Character("c");
325const Event Event::d = Event::Character("d");
326const Event Event::e = Event::Character("e");
327const Event Event::f = Event::Character("f");
328const Event Event::g = Event::Character("g");
329const Event Event::h = Event::Character("h");
330const Event Event::i = Event::Character("i");
331const Event Event::j = Event::Character("j");
332const Event Event::k = Event::Character("k");
333const Event Event::l = Event::Character("l");
334const Event Event::m = Event::Character("m");
335const Event Event::n = Event::Character("n");
336const Event Event::o = Event::Character("o");
337const Event Event::p = Event::Character("p");
338const Event Event::q = Event::Character("q");
339const Event Event::r = Event::Character("r");
340const Event Event::s = Event::Character("s");
341const Event Event::t = Event::Character("t");
342const Event Event::u = Event::Character("u");
343const Event Event::v = Event::Character("v");
344const Event Event::w = Event::Character("w");
345const Event Event::x = Event::Character("x");
346const Event Event::y = Event::Character("y");
347const Event Event::z = Event::Character("z");
348
349const Event Event::A = Event::Character("A");
350const Event Event::B = Event::Character("B");
351const Event Event::C = Event::Character("C");
352const Event Event::D = Event::Character("D");
353const Event Event::E = Event::Character("E");
354const Event Event::F = Event::Character("F");
355const Event Event::G = Event::Character("G");
356const Event Event::H = Event::Character("H");
357const Event Event::I = Event::Character("I");
358const Event Event::J = Event::Character("J");
359const Event Event::K = Event::Character("K");
360const Event Event::L = Event::Character("L");
361const Event Event::M = Event::Character("M");
362const Event Event::N = Event::Character("N");
363const Event Event::O = Event::Character("O");
364const Event Event::P = Event::Character("P");
365const Event Event::Q = Event::Character("Q");
366const Event Event::R = Event::Character("R");
367const Event Event::S = Event::Character("S");
368const Event Event::T = Event::Character("T");
369const Event Event::U = Event::Character("U");
370const Event Event::V = Event::Character("V");
371const Event Event::W = Event::Character("W");
372const Event Event::X = Event::Character("X");
373const Event Event::Y = Event::Character("Y");
374const Event Event::Z = Event::Character("Z");
375
376const Event Event::CtrlA = Event::Special("\x01");
377const Event Event::CtrlB = Event::Special("\x02");
378const Event Event::CtrlC = Event::Special("\x03");
379const Event Event::CtrlD = Event::Special("\x04");
380const Event Event::CtrlE = Event::Special("\x05");
381const Event Event::CtrlF = Event::Special("\x06");
382const Event Event::CtrlG = Event::Special("\x07");
383const Event Event::CtrlH = Event::Special("\x08");
384const Event Event::CtrlI = Event::Special("\x09");
385const Event Event::CtrlJ = Event::Special("\x0a");
386const Event Event::CtrlK = Event::Special("\x0b");
387const Event Event::CtrlL = Event::Special("\x0c");
388const Event Event::CtrlM = Event::Special("\x0d");
389const Event Event::CtrlN = Event::Special("\x0e");
390const Event Event::CtrlO = Event::Special("\x0f");
391const Event Event::CtrlP = Event::Special("\x10");
392const Event Event::CtrlQ = Event::Special("\x11");
393const Event Event::CtrlR = Event::Special("\x12");
394const Event Event::CtrlS = Event::Special("\x13");
395const Event Event::CtrlT = Event::Special("\x14");
396const Event Event::CtrlU = Event::Special("\x15");
397const Event Event::CtrlV = Event::Special("\x16");
398const Event Event::CtrlW = Event::Special("\x17");
399const Event Event::CtrlX = Event::Special("\x18");
400const Event Event::CtrlY = Event::Special("\x19");
401const Event Event::CtrlZ = Event::Special("\x1a");
402
403const Event Event::AltA = Event::Special("\x1b""a");
404const Event Event::AltB = Event::Special("\x1b""b");
405const Event Event::AltC = Event::Special("\x1b""c");
406const Event Event::AltD = Event::Special("\x1b""d");
407const Event Event::AltE = Event::Special("\x1b""e");
408const Event Event::AltF = Event::Special("\x1b""f");
409const Event Event::AltG = Event::Special("\x1b""g");
410const Event Event::AltH = Event::Special("\x1b""h");
411const Event Event::AltI = Event::Special("\x1b""i");
412const Event Event::AltJ = Event::Special("\x1b""j");
413const Event Event::AltK = Event::Special("\x1b""k");
414const Event Event::AltL = Event::Special("\x1b""l");
415const Event Event::AltM = Event::Special("\x1b""m");
416const Event Event::AltN = Event::Special("\x1b""n");
417const Event Event::AltO = Event::Special("\x1b""o");
418const Event Event::AltP = Event::Special("\x1b""p");
419const Event Event::AltQ = Event::Special("\x1b""q");
420const Event Event::AltR = Event::Special("\x1b""r");
421const Event Event::AltS = Event::Special("\x1b""s");
422const Event Event::AltT = Event::Special("\x1b""t");
423const Event Event::AltU = Event::Special("\x1b""u");
424const Event Event::AltV = Event::Special("\x1b""v");
425const Event Event::AltW = Event::Special("\x1b""w");
426const Event Event::AltX = Event::Special("\x1b""x");
427const Event Event::AltY = Event::Special("\x1b""y");
428const Event Event::AltZ = Event::Special("\x1b""z");
429
430const Event Event::CtrlAltA = Event::Special("\x1b\x01");
431const Event Event::CtrlAltB = Event::Special("\x1b\x02");
432const Event Event::CtrlAltC = Event::Special("\x1b\x03");
433const Event Event::CtrlAltD = Event::Special("\x1b\x04");
434const Event Event::CtrlAltE = Event::Special("\x1b\x05");
435const Event Event::CtrlAltF = Event::Special("\x1b\x06");
436const Event Event::CtrlAltG = Event::Special("\x1b\x07");
437const Event Event::CtrlAltH = Event::Special("\x1b\x08");
438const Event Event::CtrlAltI = Event::Special("\x1b\x09");
439const Event Event::CtrlAltJ = Event::Special("\x1b\x0a");
440const Event Event::CtrlAltK = Event::Special("\x1b\x0b");
441const Event Event::CtrlAltL = Event::Special("\x1b\x0c");
442const Event Event::CtrlAltM = Event::Special("\x1b\x0d");
443const Event Event::CtrlAltN = Event::Special("\x1b\x0e");
444const Event Event::CtrlAltO = Event::Special("\x1b\x0f");
445const Event Event::CtrlAltP = Event::Special("\x1b\x10");
446const Event Event::CtrlAltQ = Event::Special("\x1b\x11");
447const Event Event::CtrlAltR = Event::Special("\x1b\x12");
448const Event Event::CtrlAltS = Event::Special("\x1b\x13");
449const Event Event::CtrlAltT = Event::Special("\x1b\x14");
450const Event Event::CtrlAltU = Event::Special("\x1b\x15");
451const Event Event::CtrlAltV = Event::Special("\x1b\x16");
452const Event Event::CtrlAltW = Event::Special("\x1b\x17");
453const Event Event::CtrlAltX = Event::Special("\x1b\x18");
454const Event Event::CtrlAltY = Event::Special("\x1b\x19");
455const Event Event::CtrlAltZ = Event::Special("\x1b\x1a");
456
457// NOLINTEND
458// clang-format on
459
460} // namespace ftxui
static const Event TabReverse
static const Event j
static const Event CtrlC
@ WheelRight
仅支持的终端。
static const Event CtrlP
static const Event CtrlV
static const Event ArrowLeftCtrl
static const Event CtrlL
static const Event AltT
static const Event w
static const Event CtrlAltX
static const Event D
static const Event CtrlAltN
static const Event a
static const Event AltH
static const Event AltF
static const Event K
static const Event T
static const Event CtrlAltC
static const Event X
static const Event CtrlE
static const Event Q
static const Event u
static const Event PageUp
static const Event h
static const Event CtrlAltF
static const Event CtrlZ
static const Event J
static const Event CtrlU
static const Event AltQ
static const Event b
static const Event Escape
static const Event AltY
static const Event CtrlAltI
static const Event AltL
static const Event AltW
static const Event F12
static const Event E
static const Event m
static const Event N
static const Event CtrlAltP
static const Event CtrlAltE
static const Event F5
static const Event CtrlF
static const Event F3
static const Event CtrlAltJ
static const Event z
static const Event AltK
static const Event B
static const Event H
static const Event CtrlX
static const Event F9
static const Event AltC
static const Event CtrlB
static const Event CtrlAltH
static const Event O
static const Event R
static const Event AltM
static const Event CtrlR
static const Event CtrlAltW
static const Event CtrlAltO
static const Event CtrlY
static const Event Custom
static const Event A
static const Event AltG
static const Event p
static const Event l
static const Event CtrlH
struct Mouse mouse
std::string DebugString() const
返回事件的字符串表示。
static const Event AltO
static const Event CtrlJ
static const Event CtrlAltM
static const Event CtrlS
static const Event Z
static const Event AltR
static const Event CtrlW
static const Event CtrlN
static const Event F2
static const Event CtrlM
static const Event G
static const Event Backspace
static const Event d
static const Event CtrlAltR
static const Event CtrlK
static const Event x
static const Event F7
static const Event ArrowUp
const std::string & input() const
static const Event Tab
static const Event r
static const Event AltU
static const Event CtrlQ
static const Event CtrlAltZ
static const Event AltN
static const Event AltA
static const Event ArrowDown
static const Event End
static const Event F11
static const Event CtrlG
static const Event n
static const Event q
static const Event AltZ
static const Event Home
static const Event C
static const Event AltD
static const Event CtrlAltY
static const Event AltJ
static const Event F8
static const Event CtrlAltL
static const Event U
static const Event o
static const Event AltB
static const Event F4
static const Event t
static const Event y
static const Event ArrowUpCtrl
static const Event k
static const Event CtrlAltS
static const Event s
static const Event I
static const Event CtrlT
static const Event F
static const Event AltI
static const Event F10
static const Event AltP
static const Event PageDown
static const Event Y
static const Event CtrlAltK
static const Event F6
static const Event CtrlAltG
static const Event CtrlA
static const Event i
static const Event AltS
static const Event g
static const Event F1
static const Event S
static const Event Return
static const Event CtrlAltU
static const Event V
static const Event CtrlAltT
static const Event CtrlAltA
static const Event AltE
static const Event P
static const Event CtrlD
static const Event ArrowLeft
static const Event CtrlAltB
static const Event AltV
static const Event v
static const Event e
static const Event CtrlO
static const Event Delete
static const Event CtrlAltV
static const Event ArrowDownCtrl
static const Event AltX
static const Event CtrlAltD
static const Event L
static const Event W
static const Event f
static const Event Insert
static const Event CtrlI
static const Event ArrowRightCtrl
static const Event c
static const Event CtrlAltQ
static const Event M
static Event Special(std::string)
一个自定义事件,其含义由库用户定义。
static const Event ArrowRight
代表一个事件。它可以是按键事件、终端大小调整等等...
一个鼠标事件。它包含鼠标的坐标、按下的按钮以及修饰符(shift、ctrl、meta)。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::string to_string(const std::wstring &s)
将 std::wstring 转换为 UTF8 std::string。