summaryrefslogtreecommitdiff
path: root/src/input_handler.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_handler.hh')
-rw-r--r--src/input_handler.hh50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/input_handler.hh b/src/input_handler.hh
new file mode 100644
index 00000000..3e35de6d
--- /dev/null
+++ b/src/input_handler.hh
@@ -0,0 +1,50 @@
+#ifndef input_handler_hh_INCLUDED
+#define input_handler_hh_INCLUDED
+
+#include "keys.hh"
+#include "completion.hh"
+#include "utils.hh"
+#include "string.hh"
+
+namespace Kakoune
+{
+
+class Editor;
+class Context;
+
+using MenuCallback = std::function<void (int, Context&)>;
+using PromptCallback = std::function<void (const String&, Context&)>;
+using KeyCallback = std::function<void (const Key&, Context&)>;
+
+class InputMode;
+enum class InsertMode : unsigned;
+
+class InputHandler : public SafeCountable
+{
+public:
+ InputHandler();
+ ~InputHandler();
+
+ void insert(Context& context, InsertMode mode);
+ void repeat_last_insert(Context& context);
+
+ void prompt(const String& prompt, Completer completer,
+ PromptCallback callback, Context& context);
+
+ void menu(const memoryview<String>& choices,
+ MenuCallback callback, Context& context);
+
+ void on_next_key(KeyCallback callback);
+
+ void handle_next_input(Context& context);
+
+private:
+ friend class InputMode;
+ std::unique_ptr<InputMode> m_mode;
+};
+
+struct prompt_aborted {};
+
+}
+
+#endif // input_handler_hh_INCLUDED