mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-17 23:52:30 +00:00
rtorrent: Initial key handler implemented.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@239 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
noinst_LIBRARIES = libsub_input.a
|
||||
|
||||
libsub_input_a_SOURCES = \
|
||||
bindings.cc \
|
||||
bindings.h \
|
||||
manager.cc \
|
||||
manager.h
|
||||
|
||||
INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "bindings.h"
|
||||
|
||||
namespace input {
|
||||
|
||||
bool
|
||||
Bindings::pressed(int key) {
|
||||
const_iterator itr = find(key);
|
||||
|
||||
if (itr != end())
|
||||
itr->second();
|
||||
|
||||
return itr != end();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef RTORRENT_INPUT_BINDINGS_H
|
||||
#define RTORRENT_INPUT_BINDINGS_H
|
||||
|
||||
#include <map>
|
||||
#include <sigc++/slot.h>
|
||||
|
||||
namespace input {
|
||||
|
||||
class Bindings : private std::map<int, sigc::slot0<void> > {
|
||||
public:
|
||||
typedef std::map<int, sigc::slot0<void> > Base;
|
||||
|
||||
using Base::iterator;
|
||||
using Base::const_iterator;
|
||||
using Base::reverse_iterator;
|
||||
using Base::const_reverse_iterator;
|
||||
|
||||
using Base::begin;
|
||||
using Base::end;
|
||||
using Base::rbegin;
|
||||
using Base::rend;
|
||||
using Base::find;
|
||||
|
||||
using Base::operator[];
|
||||
|
||||
bool pressed(int key);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include "manager.h"
|
||||
#include "bindings.h"
|
||||
|
||||
namespace input {
|
||||
|
||||
bool
|
||||
Manager::pressed(int key) {
|
||||
return std::find_if(begin(), end(), std::bind2nd(std::mem_fun(&Bindings::pressed), key)) != end();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef RTORRENT_INPUT_MANAGER_H
|
||||
#define RTORRENT_INPUT_MANAGER_H
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace input {
|
||||
|
||||
class Bindings;
|
||||
|
||||
class Manager : private std::list<Bindings*> {
|
||||
public:
|
||||
typedef std::list<Bindings*> Base;
|
||||
|
||||
using Base::iterator;
|
||||
using Base::const_iterator;
|
||||
using Base::reverse_iterator;
|
||||
using Base::const_reverse_iterator;
|
||||
|
||||
using Base::begin;
|
||||
using Base::end;
|
||||
using Base::rbegin;
|
||||
using Base::rend;
|
||||
|
||||
using Base::push_back;
|
||||
using Base::push_front;
|
||||
|
||||
bool pressed(int key);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user