2011-12-20 20:21:11 +01:00
|
|
|
#ifndef keys_hh_INCLUDED
|
|
|
|
#define keys_hh_INCLUDED
|
|
|
|
|
|
|
|
#include <vector>
|
2012-04-14 03:17:09 +02:00
|
|
|
#include "string.hh"
|
2011-12-20 20:21:11 +01:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
struct Key
|
|
|
|
{
|
|
|
|
enum class Modifiers
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Control = 1,
|
|
|
|
Alt = 2,
|
|
|
|
ControlAlt = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
Modifiers modifiers;
|
2012-04-14 03:17:09 +02:00
|
|
|
Character key;
|
2011-12-20 20:21:11 +01:00
|
|
|
|
2012-09-04 23:54:10 +02:00
|
|
|
constexpr Key(Modifiers modifiers, Character key)
|
2011-12-20 20:21:11 +01:00
|
|
|
: modifiers(modifiers), key(key) {}
|
2011-12-21 15:29:28 +01:00
|
|
|
|
2012-09-04 23:54:10 +02:00
|
|
|
constexpr bool operator==(const Key& other) const
|
2011-12-21 15:29:28 +01:00
|
|
|
{ return modifiers == other.modifiers and key == other.key; }
|
2011-12-20 20:21:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<Key> KeyList;
|
|
|
|
|
2012-04-14 03:17:09 +02:00
|
|
|
KeyList parse_keys(const String& str);
|
2011-12-20 20:21:11 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-12-21 15:29:28 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-20 20:21:11 +01:00
|
|
|
#endif // keys_hh_INCLUDED
|