Add Event.

This commit is contained in:
Arthur Sonzogni
2018-10-18 22:58:38 +02:00
parent 1a4b2c98b2
commit f94b63fafb
25 changed files with 273 additions and 76 deletions

View File

@@ -15,26 +15,30 @@ class DrawKey : public ftxui::component::Component {
using namespace ftxui::dom;
Children children;
for (size_t i = std::max(0, (int)keys.size() - 10); i < keys.size(); ++i) {
std::string code = "";
for(size_t j = 0; j<5; ++j)
code += " " + std::to_string(keys[i].values[j]);
try {
std::string line = std::to_string(i) + " -> " + std::to_string(keys[i]) +
" (" + char(keys[i]) + ")";
std::string line = code + " -> " + std::to_string(keys[i].values[0]) + " (" +
char(keys[i].values[0]) + ")";
children.push_back(text(to_wstring(line)));
} catch (...) {
std::string line = std::to_string(i) + " -> " + std::to_string(keys[i]) +
" (undefined)";
std::string line =
code + " -> " + std::to_string(keys[i].values[0]) + " (undefined)";
children.push_back(text(to_wstring(line)));
}
}
return vbox(std::move(children));
}
bool Event(int key) override {
keys.push_back(key);
bool OnEvent(ftxui::Event event) override {
keys.push_back(event);
return true;
}
private:
std::vector<int> keys;
std::vector<ftxui::Event> keys;
};
int main(int argc, const char* argv[]) {