diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-03-03 16:51:29 +0000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-03-03 20:16:36 +0000 |
| commit | e3cfde6d07cc8b52b46745609c18b3dc79883511 (patch) | |
| tree | 8d0cb753c8b2ad3ed36cc9141b0f5746accea153 /src/keymap_manager.hh | |
| parent | 7d487e3b4cd32d0f9d031f258bf080ac43efdc68 (diff) | |
Add docstring support for mappings, and use them in autoinfo
Fixes #105
Fixes #1100
Closes #1165
Diffstat (limited to 'src/keymap_manager.hh')
| -rw-r--r-- | src/keymap_manager.hh | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/keymap_manager.hh b/src/keymap_manager.hh index 3eeb0ebb..f2782ecb 100644 --- a/src/keymap_manager.hh +++ b/src/keymap_manager.hh @@ -4,6 +4,7 @@ #include "array_view.hh" #include "keys.hh" #include "hash.hh" +#include "string.hh" #include "unordered_map.hh" #include "vector.hh" @@ -29,11 +30,19 @@ public: KeymapManager(KeymapManager& parent) : m_parent(&parent) {} using KeyList = Vector<Key, MemoryDomain::Mapping>; - void map_key(Key key, KeymapMode mode, KeyList mapping); + void map_key(Key key, KeymapMode mode, KeyList mapping, String docstring); void unmap_key(Key key, KeymapMode mode); bool is_mapped(Key key, KeymapMode mode) const; - ConstArrayView<Key> get_mapping(Key key, KeymapMode mode) const; + KeyList get_mapped_keys(KeymapMode mode) const; + + struct KeyMapInfo + { + KeyList keys; + String docstring; + }; + const KeyMapInfo& get_mapping(Key key, KeymapMode mode) const; + private: KeymapManager() : m_parent(nullptr) {} @@ -41,10 +50,8 @@ private: friend class Scope; KeymapManager* m_parent; - using KeyAndMode = std::pair<Key, KeymapMode>; - using Keymap = UnorderedMap<KeyAndMode, KeyList, MemoryDomain::Mapping>; - Keymap m_mapping; + UnorderedMap<KeyAndMode, KeyMapInfo, MemoryDomain::Mapping> m_mapping; }; } |
