15#pragma clang diagnostic ignored "-Wshadow"
17#pragma GCC diagnostic ignored "-Wshadow"
18#elif defined(_MSC_VER)
19#pragma warning(disable : 6244)
20#pragma warning(disable : 6246)
28Event Event::Character(std::string_view input) {
30 event.input_ = std::string(
input);
31 event.type_ = Type::Character;
39 return Event::Character(std::string{
c});
45Event Event::Character(
wchar_t c) {
46 return Event::Character(
to_string(std::wstring{
c}));
53Event Event::Mouse(std::string_view input,
struct Mouse mouse) {
55 event.input_ = std::string(
input);
56 event.type_ = Type::Mouse;
57 event.data_.mouse =
mouse;
63Event Event::CursorShape(std::string_view input,
int shape) {
65 event.input_ = std::string(
input);
66 event.type_ = Type::CursorShape;
67 event.data_.cursor_shape = shape;
76 event.input_ = std::string(
input);
89Event Event::CursorPosition(std::string_view input,
int x,
int y) {
91 event.input_ = std::string(
input);
92 event.type_ = Type::CursorPosition;
93 event.data_.cursor = {
x,
y};
99 static std::map<Event, const char*> event_to_string = {
229 static std::map<Mouse::Button, const char*> mouse_button_string = {
240 static std::map<Mouse::Motion, const char*> mouse_motion_string = {
247 case Type::Character: {
248 return "Event::Character(\"" + input_ +
"\")";
251 std::string out =
"Event::Mouse(\"...\", Mouse{";
252 out += std::string(mouse_button_string[data_.mouse.button]);
254 out += std::string(mouse_motion_string[data_.mouse.motion]);
256 if (data_.mouse.shift) {
257 out +=
".shift = true, ";
259 if (data_.mouse.meta) {
260 out +=
".meta = true, ";
262 if (data_.mouse.control) {
263 out +=
".control = true, ";
265 out +=
".x = " + std::to_string(data_.mouse.x);
267 out +=
".y = " + std::to_string(data_.mouse.y);
271 case Type::CursorShape:
272 return "Event::CursorShape(" + input_ +
", " +
273 std::to_string(data_.cursor_shape) +
")";
274 case Type::CursorPosition:
275 return "Event::CursorPosition(" + input_ +
", " +
276 std::to_string(data_.cursor.x) +
", " +
277 std::to_string(data_.cursor.y) +
")";
279 auto event_it = event_to_string.find(*
this);
280 if (event_it != event_to_string.end()) {
281 return event_it->second;
331const Event
Event::a = Event::Character(
"a");
332const Event
Event::b = Event::Character(
"b");
333const Event
Event::c = Event::Character(
"c");
334const Event
Event::d = Event::Character(
"d");
335const Event
Event::e = Event::Character(
"e");
336const Event
Event::f = Event::Character(
"f");
337const Event
Event::g = Event::Character(
"g");
338const Event
Event::h = Event::Character(
"h");
339const Event
Event::i = Event::Character(
"i");
340const Event
Event::j = Event::Character(
"j");
341const Event
Event::k = Event::Character(
"k");
342const Event
Event::l = Event::Character(
"l");
343const Event
Event::m = Event::Character(
"m");
344const Event
Event::n = Event::Character(
"n");
345const Event
Event::o = Event::Character(
"o");
346const Event
Event::p = Event::Character(
"p");
347const Event
Event::q = Event::Character(
"q");
348const Event
Event::r = Event::Character(
"r");
349const Event
Event::s = Event::Character(
"s");
350const Event
Event::t = Event::Character(
"t");
351const Event
Event::u = Event::Character(
"u");
352const Event
Event::v = Event::Character(
"v");
353const Event
Event::w = Event::Character(
"w");
354const Event
Event::x = Event::Character(
"x");
355const Event
Event::y = Event::Character(
"y");
356const Event
Event::z = Event::Character(
"z");
358const Event
Event::A = Event::Character(
"A");
359const Event
Event::B = Event::Character(
"B");
360const Event
Event::C = Event::Character(
"C");
361const Event
Event::D = Event::Character(
"D");
362const Event
Event::E = Event::Character(
"E");
363const Event
Event::F = Event::Character(
"F");
364const Event
Event::G = Event::Character(
"G");
365const Event
Event::H = Event::Character(
"H");
366const Event
Event::I = Event::Character(
"I");
367const Event
Event::J = Event::Character(
"J");
368const Event
Event::K = Event::Character(
"K");
369const Event
Event::L = Event::Character(
"L");
370const Event
Event::M = Event::Character(
"M");
371const Event
Event::N = Event::Character(
"N");
372const Event
Event::O = Event::Character(
"O");
373const Event
Event::P = Event::Character(
"P");
374const Event
Event::Q = Event::Character(
"Q");
375const Event
Event::R = Event::Character(
"R");
376const Event
Event::S = Event::Character(
"S");
377const Event
Event::T = Event::Character(
"T");
378const Event
Event::U = Event::Character(
"U");
379const Event
Event::V = Event::Character(
"V");
380const Event
Event::W = Event::Character(
"W");
381const Event
Event::X = Event::Character(
"X");
382const Event
Event::Y = Event::Character(
"Y");
383const Event
Event::Z = Event::Character(
"Z");
static const Event TabReverse
@ WheelRight
Supported terminal only.
static const Event ArrowLeftCtrl
static const Event CtrlAltX
static const Event CtrlAltN
static const Event CtrlAltC
static const Event PageUp
static const Event CtrlAltF
static const Event Escape
static const Event CtrlAltI
static const Event CtrlAltP
static const Event CtrlAltE
static const Event CtrlAltJ
static const Event CtrlAltH
static const Event CtrlAltW
static Event Special(std::string_view)
An custom event whose meaning is defined by the user of the library.
static const Event CtrlAltO
static const Event Custom
std::string DebugString() const
Return a string representation of the event.
static const Event CtrlAltM
static const Event Backspace
static const Event CtrlAltR
static const Event ArrowUp
const std::string & input() const
static const Event CtrlAltZ
static const Event ArrowDown
static const Event CtrlAltY
static const Event CtrlAltL
static const Event ArrowUpCtrl
static const Event CtrlAltS
static const Event PageDown
static const Event CtrlAltK
static const Event CtrlAltG
static const Event Return
static const Event CtrlAltU
static const Event CtrlAltT
static const Event CtrlAltA
static const Event ArrowLeft
static const Event CtrlAltB
static const Event Delete
static const Event CtrlAltV
static const Event ArrowDownCtrl
static const Event CtrlAltD
static const Event Insert
static const Event ArrowRightCtrl
static const Event CtrlAltQ
static const Event ArrowRight
Represent an event. It can be key press event, a terminal resize, or more ...
A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift,...
The FTXUI ftxui:: namespace.
std::string to_string(std::wstring_view s)
Convert a std::wstring into a UTF8 std::string.