summaryrefslogtreecommitdiff
path: root/src/client.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-11-14 21:12:59 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-11-14 21:12:59 +0000
commit8c25d62056d51a0575dda4abc1c541fb2f330f19 (patch)
tree8d6909e142d27a9c5753518b9ae0fa1e76ab7a05 /src/client.hh
parentf8cadc0c573b0e91b7542f26415e5c5cddcc5305 (diff)
extract InputHandler to input_handler.{cc,hh}
Diffstat (limited to 'src/client.hh')
-rw-r--r--src/client.hh88
1 files changed, 2 insertions, 86 deletions
diff --git a/src/client.hh b/src/client.hh
index 37e1ee15..89fb46bc 100644
--- a/src/client.hh
+++ b/src/client.hh
@@ -1,100 +1,16 @@
#ifndef client_hh_INCLUDED
#define client_hh_INCLUDED
-#include "color.hh"
-#include "completion.hh"
-#include "context.hh"
#include "editor.hh"
-#include "keys.hh"
#include "string.hh"
#include "utils.hh"
#include "display_buffer.hh"
+#include "input_handler.hh"
namespace Kakoune
{
-class Editor;
-
-enum class MenuEvent
-{
- Select,
- Abort,
- Validate
-};
-using MenuCallback = std::function<void (int, MenuEvent, Context&)>;
-
-enum class PromptEvent
-{
- Change,
- Abort,
- Validate
-};
-using PromptCallback = std::function<void (const String&, PromptEvent, Context&)>;
-using KeyCallback = std::function<void (Key, Context&)>;
-
-class InputMode;
-enum class InsertMode : unsigned;
-
-class InputHandler : public SafeCountable
-{
-public:
- InputHandler(Editor& editor, String name = "");
- ~InputHandler();
-
- // switch to insert mode
- void insert(InsertMode mode);
- // repeat last insert mode key sequence
- void repeat_last_insert();
-
- // enter prompt mode, callback is called on each change,
- // abort or validation with corresponding PromptEvent value
- // returns to normal mode after validation if callback does
- // not change the mode itself
- void prompt(const String& prompt, ColorPair prompt_colors,
- Completer completer, PromptCallback callback);
- void set_prompt_colors(ColorPair prompt_colors);
-
- // enter menu mode, callback is called on each selection change,
- // abort or validation with corresponding MenuEvent value
- // returns to normal mode after validation if callback does
- // not change the mode itself
- void menu(memoryview<String> choices,
- MenuCallback callback);
-
- // execute callback on next keypress and returns to normal mode
- // if callback does not change the mode itself
- void on_next_key(KeyCallback callback);
-
- // process the given key
- void handle_key(Key key);
-
- void start_recording(char reg);
- bool is_recording() const;
- void stop_recording();
- char recording_reg() const { return m_recording_reg; }
-
- void reset_normal_mode();
-
- Context& context() { return m_context; }
- const Context& context() const { return m_context; }
-
- const InputMode& mode() const { return *m_mode; }
- void clear_mode_trash();
-private:
- Context m_context;
-
- friend class InputMode;
- std::unique_ptr<InputMode> m_mode;
- std::vector<std::unique_ptr<InputMode>> m_mode_trash;
-
- void change_input_mode(InputMode* new_mode);
-
- using Insertion = std::pair<InsertMode, std::vector<Key>>;
- Insertion m_last_insert = {InsertMode::Insert, {}};
-
- char m_recording_reg = 0;
- String m_recorded_keys;
-};
+class UserInterface;
class Client : public SafeCountable
{