#include <stddef.h>
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include <vector>
std::string Stringify(
Event event) {
std::string out;
for (
auto& it : event.
input())
out += " " + std::to_string((unsigned int)it);
out = "(" + out + " ) -> ";
out += "Event::Character(\"" + event.character() + "\")";
out += "mouse";
out += "_left";
break;
out += "_middle";
break;
out += "_right";
break;
out += "_none";
break;
out += "_wheel_up";
break;
out += "_wheel_down";
break;
}
out += "_pressed";
break;
out += "_released";
break;
}
out += "_control";
out += "_shift";
out += "_meta";
out += "(" +
std::to_string(event.
mouse().
x) +
"," +
std::to_string(event.
mouse().
y) +
")";
out += "Event::ArrowLeft";
out += "Event::ArrowRight";
out += "Event::ArrowUp";
out += "Event::ArrowDown";
out += "Event::ArrowLeftCtrl";
} else if (event == Event ::ArrowRightCtrl) {
out += "Event::ArrowRightCtrl";
out += "Event::ArrowUpCtrl";
out += "Event::ArrowDownCtrl";
out += "Event::Backspace";
out += "Event::Delete";
out += "Event::Escape";
out += "Event::Return";
out += "Event::Tab";
out += "Event::TabReverse";
out += "Event::F1";
out += "Event::F2";
out += "Event::F3";
out += "Event::F4";
out += "Event::F5";
out += "Event::F6";
out += "Event::F7";
out += "Event::F8";
out += "Event::F9";
out += "Event::F10";
out += "Event::F11";
out += "Event::F12";
out += "Event::Home";
out += "Event::End";
out += "Event::PageUp";
out += "Event::PageDown";
out += "Custom";
} else {
out += "(special)";
}
return out;
}
int main() {
std::vector<Event> keys;
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i)
children.push_back(
text(Stringify(keys[i])));
});
keys.push_back(event);
return true;
});
screen.Loop(component);
}
static ScreenInteractive TerminalOutput()
Element window(Element title, Element content)
Draw window with a title and a border around the element.
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
std::vector< Element > Elements
Element text(std::wstring text)
Display a piece of unicode text.
Component CatchEvent(Component child, std::function< bool(Event)>)
Element vbox(Elements)
A container displaying elements vertically one by one.
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 PageUp
static const Event Escape
static const Event Custom
static const Event Backspace
static const Event ArrowUp
const std::string & input() const
static const Event ArrowDown
static const Event ArrowUpCtrl
static const Event PageDown
static const Event Return
static const Event ArrowLeft
bool is_character() const
static const Event Delete
static const Event ArrowDownCtrl
static const Event ArrowRight