2013-10-25 01:01:17 +02:00
|
|
|
#include "keymap_manager.hh"
|
|
|
|
|
2015-01-06 14:40:56 +01:00
|
|
|
#include "array_view.hh"
|
2014-12-16 19:57:19 +01:00
|
|
|
#include "assert.hh"
|
2013-10-25 01:01:17 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2014-12-17 14:20:48 +01:00
|
|
|
void KeymapManager::map_key(Key key, KeymapMode mode, KeyList mapping)
|
2013-10-25 01:01:17 +02:00
|
|
|
{
|
2014-12-17 14:20:48 +01:00
|
|
|
m_mapping[{key, mode}] = std::move(mapping);
|
2013-10-25 01:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2015-01-06 14:40:56 +01:00
|
|
|
ArrayView<Key> KeymapManager::get_mapping(Key key, KeymapMode mode) const
|
2013-10-25 01:01:17 +02:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|