summaryrefslogtreecommitdiff
path: root/src/remote.hh
blob: aa0a31a33a3a558abdc2c753fb3c1332171c695c (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
#ifndef remote_hh_INCLUDED
#define remote_hh_INCLUDED

#include "user_interface.hh"
#include "display_buffer.hh"

namespace Kakoune
{

struct peer_disconnected {};

class RemoteUI : public UserInterface
{
public:
    RemoteUI(int socket);
    ~RemoteUI();

    void print_status(const String& status, CharCount cursor_pos) override;
    void menu_show(const memoryview<String>& choices,
                   const DisplayCoord& anchor, MenuStyle style) override;
    void menu_select(int selected) override;
    void menu_hide() override;
    void draw(const DisplayBuffer& display_buffer,
              const String& mode_line) override;

    bool is_key_available() override;
    Key  get_key() override;
    DisplayCoord dimensions() override;

private:
    int          m_socket;
    DisplayCoord m_dimensions;
};

class RemoteClient
{
public:
    RemoteClient(int socket, UserInterface* ui);

    void process_next_message();
    void write_next_key();

private:
    int                            m_socket;
    std::unique_ptr<UserInterface> m_ui;
    DisplayCoord                   m_dimensions;
};

}

#endif // remote_hh_INCLUDED