summaryrefslogtreecommitdiff
path: root/src/user_interface.hh
blob: a912b417003eccb1bd8cc0d5c15edaf2d9e4b970 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef user_interface_hh_INCLUDED
#define user_interface_hh_INCLUDED

#include "safe_ptr.hh"
#include "unordered_map.hh"

#include <functional>

namespace Kakoune
{

class String;
class DisplayBuffer;
class DisplayLine;
struct CharCoord;
struct Face;
struct Key;
template<typename T> class ArrayView;

enum class MenuStyle
{
    Prompt,
    Inline
};

enum class InfoStyle
{
    Prompt,
    Inline,
    InlineAbove,
    InlineBelow,
    MenuDoc
};

enum class EventMode;

using InputCallback = std::function<void(EventMode mode)>;

class UserInterface : public SafeCountable
{
public:
    virtual ~UserInterface() {}

    virtual void menu_show(ArrayView<String> choices,
                           CharCoord anchor, Face fg, Face bg,
                           MenuStyle style) = 0;
    virtual void menu_select(int selected) = 0;
    virtual void menu_hide() = 0;

    virtual void info_show(StringView title, StringView content,
                           CharCoord anchor, Face face,
                           InfoStyle style) = 0;
    virtual void info_hide() = 0;

    virtual void draw(const DisplayBuffer& display_buffer,
                      const DisplayLine& status_line,
                      const DisplayLine& mode_line) = 0;
    virtual CharCoord dimensions() = 0;
    virtual bool is_key_available() = 0;
    virtual Key  get_key() = 0;

    virtual void refresh() = 0;

    virtual void set_input_callback(InputCallback callback) = 0;

    using Options = UnorderedMap<String, String>;
    virtual void set_ui_options(const Options& options) = 0;
};

}

#endif // user_interface_hh_INCLUDED