#pragma once #include #include #include "command.h" #include "either.h" using namespace std; class KeyInputMachine{ struct TreeNode{ Command *cmd=nullptr; unordered_map *m=nullptr; ~TreeNode(); }; TreeNode root; TreeNode *current=&root; public: KeyInputMachine(); KeyInputMachine(const vector,Command>> &list); KeyInputMachine(const KeyInputMachine&) = delete; //Overwrites if already existent; ambiguous-prefix bindings not permitted //at the moment void insert(const vector &keys,const Command &cmd); //If Left, then true indicates 'still possibilities'; false indicates 'no more //possible sequences left, error' Either input(int key); //Cancel the current input combination void cancel(); }; extern KeyInputMachine global_keyinput;