blob: 3d520d27d56566468e139abf411f5ecf7456bb82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#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&)>;
enum class PromptEvent
{
Change,
Abort,
Validate
};
using PromptCallback = std::function<void (const String&, PromptEvent, 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_available_inputs(Context& context);
private:
friend class InputMode;
std::unique_ptr<InputMode> m_mode;
std::vector<std::unique_ptr<InputMode>> m_mode_trash;
};
struct prompt_aborted {};
}
#endif // input_handler_hh_INCLUDED
|