2012-06-28 14:11:43 +02:00
|
|
|
#ifndef client_hh_INCLUDED
|
|
|
|
#define client_hh_INCLUDED
|
2012-06-06 01:15:19 +02:00
|
|
|
|
|
|
|
#include "keys.hh"
|
|
|
|
#include "completion.hh"
|
2012-08-15 22:36:45 +02:00
|
|
|
#include "utils.hh"
|
2012-09-03 14:22:02 +02:00
|
|
|
#include "string.hh"
|
2012-06-06 01:15:19 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class Editor;
|
2012-08-05 20:13:41 +02:00
|
|
|
class Context;
|
2012-06-06 01:15:19 +02:00
|
|
|
|
2012-09-03 14:22:02 +02:00
|
|
|
using MenuCallback = std::function<void (int, Context&)>;
|
|
|
|
using PromptCallback = std::function<void (const String&, Context&)>;
|
2012-09-05 00:21:19 +02:00
|
|
|
using KeyCallback = std::function<void (const Key&, Context&)>;
|
2012-09-03 14:22:02 +02:00
|
|
|
|
2012-09-24 19:39:40 +02:00
|
|
|
class ClientMode;
|
2012-09-26 14:22:24 +02:00
|
|
|
enum class InsertMode : unsigned;
|
2012-09-24 19:39:40 +02:00
|
|
|
|
2012-08-15 22:36:45 +02:00
|
|
|
class Client : public SafeCountable
|
2012-06-06 01:15:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2012-09-26 14:13:04 +02:00
|
|
|
Client();
|
2012-09-24 19:24:27 +02:00
|
|
|
~Client();
|
2012-09-03 14:22:02 +02:00
|
|
|
|
2012-09-26 20:07:06 +02:00
|
|
|
void insert(Context& context, InsertMode mode);
|
2012-09-26 14:13:04 +02:00
|
|
|
void repeat_last_insert(Context& context);
|
2012-09-05 14:27:14 +02:00
|
|
|
|
2012-09-03 14:22:02 +02:00
|
|
|
void prompt(const String& prompt, Completer completer,
|
2012-09-26 14:13:04 +02:00
|
|
|
PromptCallback callback, Context& context);
|
2012-06-06 01:15:19 +02:00
|
|
|
|
2012-09-03 14:22:02 +02:00
|
|
|
void menu(const memoryview<String>& choices,
|
2012-09-26 14:13:04 +02:00
|
|
|
MenuCallback callback, Context& context);
|
2012-09-24 19:24:27 +02:00
|
|
|
|
2012-09-05 00:21:19 +02:00
|
|
|
void on_next_key(KeyCallback callback);
|
|
|
|
|
2012-09-03 14:22:02 +02:00
|
|
|
void handle_next_input(Context& context);
|
2012-08-30 21:53:22 +02:00
|
|
|
|
2012-09-03 14:22:02 +02:00
|
|
|
private:
|
2012-09-24 19:39:40 +02:00
|
|
|
friend class ClientMode;
|
|
|
|
std::unique_ptr<ClientMode> m_mode;
|
2012-06-06 01:15:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct prompt_aborted {};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-28 14:11:43 +02:00
|
|
|
#endif // client_hh_INCLUDED
|