blob: 0d376a1bd8aedde5ef9a9af68485484a76c59084 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "keymap_manager.hh"
#include "memoryview.hh"
namespace std
{
template<> struct hash<Kakoune::KeymapMode>
{
size_t operator()(Kakoune::KeymapMode val) const
{
return hash<int>{}((int)val);
}
};
}
namespace Kakoune
{
void KeymapManager::map_key(Key key, KeymapMode mode, std::vector<Key> mapping)
{
m_mapping[{key, mode}] = mapping;
}
void KeymapManager::unmap_key(Key key, KeymapMode mode)
{
m_mapping.erase({key, mode});
}
bool KeymapManager::is_mapped(Key key, KeymapMode mode) const
{
return m_mapping.find({key, mode}) != m_mapping.end() or
(m_parent and m_parent->is_mapped(key, mode));
}
memoryview<Key> KeymapManager::get_mapping(Key key, KeymapMode mode) const
{
auto it = m_mapping.find({key, mode});
if (it != m_mapping.end())
return { it->second };
kak_assert(m_parent);
return m_parent->get_mapping(key, mode);
}
}
|