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)
31 event.input_ = std::move(
input);
32 event.type_ = Type::Character;
59 event.input_ = std::move(
input);
60 event.type_ = Type::Mouse;
61 event.data_.mouse =
mouse;
69 event.input_ = std::move(
input);
70 event.type_ = Type::CursorShape;
71 event.data_.cursor_shape = shape;
81 event.input_ = std::move(
input);
89 event.input_ = std::move(
input);
90 event.type_ = Type::CursorPosition;
91 event.data_.cursor = {
x,
y};
97 static std::map<Event, const char*> event_to_string = {
227 static std::map<Mouse::Button, const char*> mouse_button_string = {
228 {Mouse::Button::Left,
".button = Mouse::Left"},
229 {Mouse::Button::Middle,
".button = Mouse::Middle"},
230 {Mouse::Button::Right,
".button = Mouse::Right"},
231 {Mouse::Button::WheelUp,
".button = Mouse::WheelUp"},
232 {Mouse::Button::WheelDown,
".button = Mouse::WheelDown"},
233 {Mouse::Button::None,
".button = Mouse::None"},
234 {Mouse::Button::WheelLeft,
".button = Mouse::WheelLeft"},
235 {Mouse::Button::WheelRight,
".button = Mouse::WheelRight"},
238 static std::map<Mouse::Motion, const char*> mouse_motion_string = {
239 {Mouse::Motion::Pressed,
".motion = Mouse::Pressed"},
240 {Mouse::Motion::Released,
".motion = Mouse::Released"},
241 {Mouse::Motion::Moved,
".motion = Mouse::Moved"},
245 case Type::Character: {
246 return "Event::Character(\"" + input_ +
"\")";
249 std::string out =
"Event::Mouse(\"...\", Mouse{";
250 out += std::string(mouse_button_string[data_.mouse.button]);
252 out += std::string(mouse_motion_string[data_.mouse.motion]);
254 if (data_.mouse.shift) {
255 out +=
".shift = true, ";
257 if (data_.mouse.meta) {
258 out +=
".meta = true, ";
260 if (data_.mouse.control) {
261 out +=
".control = true, ";
269 case Type::CursorShape:
270 return "Event::CursorShape(" + input_ +
", " +
272 case Type::CursorPosition:
273 return "Event::CursorPosition(" + input_ +
", " +
277 auto event_it = event_to_string.find(*
this);
278 if (event_it != event_to_string.end()) {
279 return event_it->second;
std::string to_string(const std::wstring &s)
Convert a UTF8 std::string into a std::wstring.
Represent an event. It can be key press event, a terminal resize, or more ...
static const Event TabReverse
static const Event ArrowLeftCtrl
static const Event CtrlAltX
static const Event CtrlAltN
static Event CursorShape(std::string, int shape)
An event corresponding to a terminal DCS (Device Control String).
static const Event CtrlAltC
static const Event PageUp
static const Event CtrlAltF
static const Event Escape
static const Event CtrlAltI
static Event Mouse(std::string, Mouse mouse)
An event corresponding to a given typed character.
const std::string & input() const
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 Event Character(std::string)
An event corresponding to a given typed character.
static const Event CtrlAltM
static const Event Backspace
static const Event CtrlAltR
static const Event ArrowUp
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 Event CursorPosition(std::string, int x, int y)
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
A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift,...