summaryrefslogtreecommitdiff
path: root/src/client.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-09-05 00:21:19 +0200
committerMaxime Coste <frrrwww@gmail.com>2012-09-05 00:21:19 +0200
commitb23425764edc155e16023b58afa3c42efda1d5cb (patch)
treee1059d44340f9ae6969e9421ac677e6c01828c65 /src/client.hh
parentaac30a27e70054799beb0c137e28c9dc9656efec (diff)
Add client::on_next_key method to run some code when the next key arrives
Diffstat (limited to 'src/client.hh')
-rw-r--r--src/client.hh8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client.hh b/src/client.hh
index da28fc84..c31dd0a6 100644
--- a/src/client.hh
+++ b/src/client.hh
@@ -25,6 +25,7 @@ enum class MenuCommand
using MenuCallback = std::function<void (int, Context&)>;
using PromptCallback = std::function<void (const String&, Context&)>;
+using KeyCallback = std::function<void (const Key&, Context&)>;
class Client : public SafeCountable
{
@@ -41,11 +42,12 @@ public:
void menu(const memoryview<String>& choices,
MenuCallback callback);
+ void on_next_key(KeyCallback callback);
+
void handle_next_input(Context& context);
virtual Key get_key() = 0;
private:
-
virtual void show_menu(const memoryview<String>& choices) = 0;
virtual void menu_ctrl(MenuCommand command) = 0;
@@ -56,6 +58,9 @@ private:
public:
Mode(Client& client) : m_client(client) {}
virtual ~Mode() {}
+ Mode(const Mode&) = delete;
+ Mode& operator=(const Mode&) = delete;
+
virtual void on_key(const Key& key, Context& context) = 0;
protected:
Client& m_client;
@@ -65,6 +70,7 @@ private:
class NormalMode;
class MenuMode;
class PromptMode;
+ class NextKeyMode;
};
struct prompt_aborted {};