1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-21 10:40:53 +03:00
kakoune/src/keys.hh
2012-04-14 01:17:09 +00:00

52 lines
846 B
C++

#ifndef keys_hh_INCLUDED
#define keys_hh_INCLUDED
#include <vector>
#include "string.hh"
namespace Kakoune
{
struct Key
{
enum class Modifiers
{
None = 0,
Control = 1,
Alt = 2,
ControlAlt = 3
};
Modifiers modifiers;
Character key;
Key(Modifiers modifiers, Character key)
: modifiers(modifiers), key(key) {}
bool operator==(const Key& other) const
{ return modifiers == other.modifiers and key == other.key; }
};
typedef std::vector<Key> KeyList;
KeyList parse_keys(const String& str);
}
namespace std
{
template<>
struct hash<Kakoune::Key> : unary_function<const Kakoune::Key&, size_t>
{
size_t operator()(const Kakoune::Key& key) const
{
return static_cast<size_t>(key.modifiers) * 1024 + key.key;
}
};
}
#endif // keys_hh_INCLUDED