diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-10-25 00:01:17 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-10-25 00:30:46 +0100 |
| commit | 2c09da50be80dbaf484682689bfd1a685d601573 (patch) | |
| tree | 6fe5efc4ef6ff1c379c388de48fdc0dd96b79981 /src/keymap_manager.hh | |
| parent | 77ac777526a6a05c2d2027e30c0bbcf9720ad5b7 (diff) | |
Add key mapping support
Diffstat (limited to 'src/keymap_manager.hh')
| -rw-r--r-- | src/keymap_manager.hh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/keymap_manager.hh b/src/keymap_manager.hh new file mode 100644 index 00000000..c9887a6b --- /dev/null +++ b/src/keymap_manager.hh @@ -0,0 +1,52 @@ +#ifndef keymap_manager_hh_INCLUDED +#define keymap_manager_hh_INCLUDED + +#include "idvaluemap.hh" +#include "keys.hh" +#include "utils.hh" + +#include <unordered_map> + +namespace Kakoune +{ + +enum class KeymapMode : int +{ + None, + Normal, + Insert, + Prompt, + Menu +}; + +class KeymapManager +{ +public: + KeymapManager(KeymapManager& parent) : m_parent(&parent) {} + + void map_key(Key key, KeymapMode mode, std::vector<Key> mapping); + void unmap_key(Key key, KeymapMode mode); + + bool is_mapped(Key key, KeymapMode mode) const; + memoryview<Key> get_mapping(Key key, KeymapMode mode) const; +private: + KeymapManager() + : m_parent(nullptr) {} + // the only one allowed to construct a root map manager + friend class GlobalKeymaps; + + KeymapManager* m_parent; + + using Keymap = std::unordered_map<std::pair<Key, KeymapMode>, std::vector<Key>>; + Keymap m_mapping; +}; + +class GlobalKeymaps : public KeymapManager, + public Singleton<GlobalKeymaps> +{ +}; + +} + +#endif // keymap_manager_hh_INCLUDED + |
