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 input) {
30 event.input_ = std::move(
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 input,
struct Mouse mouse) {
55 event.input_ = std::move(
input);
56 event.type_ = Type::Mouse;
57 event.data_.mouse =
mouse;
63Event Event::CursorShape(std::string input,
int shape) {
65 event.input_ = std::move(
input);
66 event.type_ = Type::CursorShape;
67 event.data_.cursor_shape = shape;
76 event.input_ = std::move(
input);
82Event Event::CursorPosition(std::string input,
int x,
int y) {
84 event.input_ = std::move(
input);
85 event.type_ = Type::CursorPosition;
86 event.data_.cursor = {
x,
y};
92 static std::map<Event, const char*> event_to_string = {
222 static std::map<Mouse::Button, const char*> mouse_button_string = {
233 static std::map<Mouse::Motion, const char*> mouse_motion_string = {
240 case Type::Character: {
241 return "Event::Character(\"" + input_ +
"\")";
244 std::string out =
"Event::Mouse(\"...\", Mouse{";
245 out += std::string(mouse_button_string[data_.mouse.button]);
247 out += std::string(mouse_motion_string[data_.mouse.motion]);
249 if (data_.mouse.shift) {
250 out +=
".shift = true, ";
252 if (data_.mouse.meta) {
253 out +=
".meta = true, ";
255 if (data_.mouse.control) {
256 out +=
".control = true, ";
258 out +=
".x = " + std::to_string(data_.mouse.x);
260 out +=
".y = " + std::to_string(data_.mouse.y);
264 case Type::CursorShape:
265 return "Event::CursorShape(" + input_ +
", " +
266 std::to_string(data_.cursor_shape) +
")";
267 case Type::CursorPosition:
268 return "Event::CursorPosition(" + input_ +
", " +
269 std::to_string(data_.cursor.x) +
", " +
270 std::to_string(data_.cursor.y) +
")";
272 auto event_it = event_to_string.find(*
this);
273 if (event_it != event_to_string.end()) {
274 return event_it->second;
324const Event
Event::a = Event::Character(
"a");
325const Event
Event::b = Event::Character(
"b");
326const Event
Event::c = Event::Character(
"c");
327const Event
Event::d = Event::Character(
"d");
328const Event
Event::e = Event::Character(
"e");
329const Event
Event::f = Event::Character(
"f");
330const Event
Event::g = Event::Character(
"g");
331const Event
Event::h = Event::Character(
"h");
332const Event
Event::i = Event::Character(
"i");
333const Event
Event::j = Event::Character(
"j");
334const Event
Event::k = Event::Character(
"k");
335const Event
Event::l = Event::Character(
"l");
336const Event
Event::m = Event::Character(
"m");
337const Event
Event::n = Event::Character(
"n");
338const Event
Event::o = Event::Character(
"o");
339const Event
Event::p = Event::Character(
"p");
340const Event
Event::q = Event::Character(
"q");
341const Event
Event::r = Event::Character(
"r");
342const Event
Event::s = Event::Character(
"s");
343const Event
Event::t = Event::Character(
"t");
344const Event
Event::u = Event::Character(
"u");
345const Event
Event::v = Event::Character(
"v");
346const Event
Event::w = Event::Character(
"w");
347const Event
Event::x = Event::Character(
"x");
348const Event
Event::y = Event::Character(
"y");
349const Event
Event::z = Event::Character(
"z");
351const Event
Event::A = Event::Character(
"A");
352const Event
Event::B = Event::Character(
"B");
353const Event
Event::C = Event::Character(
"C");
354const Event
Event::D = Event::Character(
"D");
355const Event
Event::E = Event::Character(
"E");
356const Event
Event::F = Event::Character(
"F");
357const Event
Event::G = Event::Character(
"G");
358const Event
Event::H = Event::Character(
"H");
359const Event
Event::I = Event::Character(
"I");
360const Event
Event::J = Event::Character(
"J");
361const Event
Event::K = Event::Character(
"K");
362const Event
Event::L = Event::Character(
"L");
363const Event
Event::M = Event::Character(
"M");
364const Event
Event::N = Event::Character(
"N");
365const Event
Event::O = Event::Character(
"O");
366const Event
Event::P = Event::Character(
"P");
367const Event
Event::Q = Event::Character(
"Q");
368const Event
Event::R = Event::Character(
"R");
369const Event
Event::S = Event::Character(
"S");
370const Event
Event::T = Event::Character(
"T");
371const Event
Event::U = Event::Character(
"U");
372const Event
Event::V = Event::Character(
"V");
373const Event
Event::W = Event::Character(
"W");
374const Event
Event::X = Event::Character(
"X");
375const Event
Event::Y = Event::Character(
"Y");
376const 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 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 Event Special(std::string)
An custom event whose meaning is defined by the user of the library.
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(const std::wstring &s)
Convert a std::wstring into a UTF8 std::string.