initial support for binding keys to action chains
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user