initial support for binding keys to action chains

This commit is contained in:
Andrzej Rybczak
2012-08-25 04:44:02 +02:00
parent 3a023e40c0
commit 55ae5b1816
6 changed files with 194 additions and 145 deletions

View File

@@ -21,6 +21,7 @@
#ifndef _SETTINGS_H
#define _SETTINGS_H
#include <cassert>
#include <vector>
#include <mpd/client.h>
@@ -45,16 +46,41 @@ struct Column
bool display_empty_tag;
};
struct Bind
{
typedef std::vector<Action *> ActionChain;
Bind(ActionType at) : isThisSingle(true), itsAction(Action::Get(at)) { }
Bind(ActionChain *chain) : isThisSingle(false), itsChain(chain) { }
bool isSingle() const { return isThisSingle; }
ActionChain *getChain() const { assert(!isThisSingle); return itsChain; }
Action *getAction() const { assert(isThisSingle); return itsAction; }
private:
bool isThisSingle;
union {
Action *itsAction;
ActionChain *itsChain;
};
};
struct KeyConfiguration
{
typedef std::pair<
std::multimap<Action::Key, Action *>::iterator
, std::multimap<Action::Key, Action *>::iterator
std::multimap<Action::Key, Bind>::iterator
, std::multimap<Action::Key, Bind>::iterator
> Binding;
void GenerateBindings();
std::multimap<Action::Key, Action *> Bindings;
std::multimap<Action::Key, Bind> Bindings;
private:
template <typename T> void Bind_(wchar_t c, CharType ct, T t)
{
Bindings.insert(std::make_pair(Action::Key(c, ct), Bind(t)));
}
};
struct Configuration