14#pragma clang diagnostic ignored "-Wshadow"
16#pragma GCC diagnostic ignored "-Wshadow"
17#elif defined(_MSC_VER)
18#pragma warning(disable : 6244)
19#pragma warning(disable : 6246)
27Event Event::Character(std::string input) {
29 event.input_ = std::move(
input);
30 event.type_ = Type::Character;
38 return Event::Character(std::string{
c});
44Event Event::Character(
wchar_t c) {
45 return Event::Character(
to_string(std::wstring{
c}));
52Event Event::Mouse(std::string input,
struct Mouse mouse) {
54 event.input_ = std::move(
input);
55 event.type_ = Type::Mouse;
56 event.data_.mouse =
mouse;
62Event Event::CursorShape(std::string input,
int shape) {
64 event.input_ = std::move(
input);
65 event.type_ = Type::CursorShape;
66 event.data_.cursor_shape = shape;
75 event.input_ = std::move(
input);
81Event Event::CursorPosition(std::string input,
int x,
int y) {
83 event.input_ = std::move(
input);
84 event.type_ = Type::CursorPosition;
85 event.data_.cursor = {
x,
y};
91 static std::map<Event, const char*> event_to_string = {
221 static std::map<Mouse::Button, const char*> mouse_button_string = {
232 static std::map<Mouse::Motion, const char*> mouse_motion_string = {
239 case Type::Character: {
240 return "Event::Character(\"" + input_ +
"\")";
243 std::string out =
"Event::Mouse(\"...\", Mouse{";
244 out += std::string(mouse_button_string[data_.mouse.button]);
246 out += std::string(mouse_motion_string[data_.mouse.motion]);
248 if (data_.mouse.shift) {
249 out +=
".shift = true, ";
251 if (data_.mouse.meta) {
252 out +=
".meta = true, ";
254 if (data_.mouse.control) {
255 out +=
".control = true, ";
257 out +=
".x = " + std::to_string(data_.mouse.x);
259 out +=
".y = " + std::to_string(data_.mouse.y);
263 case Type::CursorShape:
264 return "Event::CursorShape(" + input_ +
", " +
265 std::to_string(data_.cursor_shape) +
")";
266 case Type::CursorPosition:
267 return "Event::CursorPosition(" + input_ +
", " +
268 std::to_string(data_.cursor.x) +
", " +
269 std::to_string(data_.cursor.y) +
")";
271 auto event_it = event_to_string.find(*
this);
272 if (event_it != event_to_string.end()) {
273 return event_it->second;
323const Event
Event::a = Event::Character(
"a");
324const Event
Event::b = Event::Character(
"b");
325const Event
Event::c = Event::Character(
"c");
326const Event
Event::d = Event::Character(
"d");
327const Event
Event::e = Event::Character(
"e");
328const Event
Event::f = Event::Character(
"f");
329const Event
Event::g = Event::Character(
"g");
330const Event
Event::h = Event::Character(
"h");
331const Event
Event::i = Event::Character(
"i");
332const Event
Event::j = Event::Character(
"j");
333const Event
Event::k = Event::Character(
"k");
334const Event
Event::l = Event::Character(
"l");
335const Event
Event::m = Event::Character(
"m");
336const Event
Event::n = Event::Character(
"n");
337const Event
Event::o = Event::Character(
"o");
338const Event
Event::p = Event::Character(
"p");
339const Event
Event::q = Event::Character(
"q");
340const Event
Event::r = Event::Character(
"r");
341const Event
Event::s = Event::Character(
"s");
342const Event
Event::t = Event::Character(
"t");
343const Event
Event::u = Event::Character(
"u");
344const Event
Event::v = Event::Character(
"v");
345const Event
Event::w = Event::Character(
"w");
346const Event
Event::x = Event::Character(
"x");
347const Event
Event::y = Event::Character(
"y");
348const Event
Event::z = Event::Character(
"z");
350const Event
Event::A = Event::Character(
"A");
351const Event
Event::B = Event::Character(
"B");
352const Event
Event::C = Event::Character(
"C");
353const Event
Event::D = Event::Character(
"D");
354const Event
Event::E = Event::Character(
"E");
355const Event
Event::F = Event::Character(
"F");
356const Event
Event::G = Event::Character(
"G");
357const Event
Event::H = Event::Character(
"H");
358const Event
Event::I = Event::Character(
"I");
359const Event
Event::J = Event::Character(
"J");
360const Event
Event::K = Event::Character(
"K");
361const Event
Event::L = Event::Character(
"L");
362const Event
Event::M = Event::Character(
"M");
363const Event
Event::N = Event::Character(
"N");
364const Event
Event::O = Event::Character(
"O");
365const Event
Event::P = Event::Character(
"P");
366const Event
Event::Q = Event::Character(
"Q");
367const Event
Event::R = Event::Character(
"R");
368const Event
Event::S = Event::Character(
"S");
369const Event
Event::T = Event::Character(
"T");
370const Event
Event::U = Event::Character(
"U");
371const Event
Event::V = Event::Character(
"V");
372const Event
Event::W = Event::Character(
"W");
373const Event
Event::X = Event::Character(
"X");
374const Event
Event::Y = Event::Character(
"Y");
375const Event
Event::Z = Event::Character(
"Z");
static const Event TabReverse
@ WheelRight
対応しているターミナルのみ。
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
イベントの文字列表現を返します。
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)
ライブラリのユーザーによって意味が定義されるカスタムイベント。
static const Event ArrowRight
イベントを表します。キープレスイベント、ターミナルのリサイズなど、さまざまなイベントがあります。
マウスイベント。マウスの座標、押されたボタン、 および修飾子(shift, ctrl, meta)が含まれます。
std::string to_string(const std::wstring &s)