kakoune/src/client.hh

67 lines
1.6 KiB
C++
Raw Normal View History

2012-06-28 14:11:43 +02:00
#ifndef client_hh_INCLUDED
#define client_hh_INCLUDED
#include "keys.hh"
#include "completion.hh"
2012-08-15 22:36:45 +02:00
#include "utils.hh"
#include "string.hh"
2012-09-05 14:27:14 +02:00
#include "editor.hh"
namespace Kakoune
{
class Editor;
class Window;
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&)>;
2012-08-15 22:36:45 +02:00
class Client : public SafeCountable
{
public:
Client();
virtual ~Client();
virtual void draw_window(Window& window) = 0;
virtual void print_status(const String& status,
CharCount cursor_pos = -1) = 0;
2012-09-05 14:27:14 +02:00
void insert(Editor& editor, IncrementalInserter::Mode mode);
void repeat_last_insert(Editor& editor, Context& context);
void prompt(const String& prompt, Completer completer,
PromptCallback callback);
void menu(const memoryview<String>& choices,
MenuCallback callback);
void on_next_key(KeyCallback callback);
void handle_next_input(Context& context);
private:
2012-09-05 19:02:06 +02:00
virtual void menu_show(const memoryview<String>& choices) = 0;
virtual void menu_select(int selected) = 0;
virtual void menu_hide() = 0;
2012-09-05 14:27:14 +02:00
virtual Key get_key() = 0;
void reset_normal_mode();
2012-09-05 14:27:14 +02:00
std::pair<IncrementalInserter::Mode, std::vector<Key>> m_last_insert;
class Mode;
std::unique_ptr<Mode> m_mode;
class NormalMode;
class MenuMode;
class PromptMode;
class NextKeyMode;
2012-09-05 14:27:14 +02:00
class InsertMode;
};
struct prompt_aborted {};
}
2012-06-28 14:11:43 +02:00
#endif // client_hh_INCLUDED