2013-09-13 01:47:23 +04:00
|
|
|
#ifndef client_hh_INCLUDED
|
|
|
|
#define client_hh_INCLUDED
|
2012-06-06 03:15:19 +04:00
|
|
|
|
2013-09-16 22:15:13 +04:00
|
|
|
#include "display_buffer.hh"
|
2014-04-08 00:25:44 +04:00
|
|
|
#include "env_vars.hh"
|
2014-08-12 03:30:13 +04:00
|
|
|
#include "input_handler.hh"
|
|
|
|
#include "safe_ptr.hh"
|
|
|
|
#include "utils.hh"
|
2014-11-11 02:29:16 +03:00
|
|
|
#include "option_manager.hh"
|
2015-11-20 11:50:53 +03:00
|
|
|
#include "enum.hh"
|
2012-06-06 03:15:19 +04:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2013-12-21 00:10:08 +04:00
|
|
|
class Window;
|
2016-11-29 22:53:11 +03:00
|
|
|
class UserInterface;
|
2014-11-13 00:27:07 +03:00
|
|
|
class String;
|
2014-11-25 04:00:18 +03:00
|
|
|
struct Key;
|
|
|
|
|
|
|
|
enum class EventMode;
|
2016-11-29 22:53:11 +03:00
|
|
|
enum class InfoStyle;
|
|
|
|
enum class MenuStyle;
|
|
|
|
|
2013-11-14 22:09:15 +04:00
|
|
|
|
2014-11-11 02:29:16 +03:00
|
|
|
class Client : public SafeCountable, public OptionManagerWatcher
|
2013-11-14 22:09:15 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-12-21 00:10:08 +04:00
|
|
|
Client(std::unique_ptr<UserInterface>&& ui,
|
|
|
|
std::unique_ptr<Window>&& window,
|
2014-04-08 00:25:44 +04:00
|
|
|
SelectionList selections,
|
|
|
|
EnvVarMap env_vars,
|
|
|
|
String name);
|
2017-01-09 01:30:15 +03:00
|
|
|
~Client() override;
|
2013-11-14 22:09:15 +04:00
|
|
|
|
2014-11-11 02:29:16 +03:00
|
|
|
Client(Client&&) = delete;
|
|
|
|
|
2016-11-30 12:47:38 +03:00
|
|
|
bool process_pending_inputs();
|
2013-11-14 22:09:15 +04:00
|
|
|
|
2016-09-22 22:36:26 +03:00
|
|
|
void menu_show(Vector<DisplayLine> choices, BufferCoord anchor, MenuStyle style);
|
2016-02-27 20:23:13 +03:00
|
|
|
void menu_select(int selected);
|
|
|
|
void menu_hide();
|
|
|
|
|
2016-09-22 22:36:26 +03:00
|
|
|
void info_show(String title, String content, BufferCoord anchor, InfoStyle style);
|
2017-01-04 14:24:07 +03:00
|
|
|
void info_hide(bool even_modal = false);
|
2016-02-27 20:23:13 +03:00
|
|
|
|
2016-10-29 13:25:58 +03:00
|
|
|
void print_status(DisplayLine status_line, bool immediate = false);
|
2013-09-16 22:15:13 +04:00
|
|
|
|
2016-11-29 22:53:11 +03:00
|
|
|
DisplayCoord dimensions() const;
|
2016-02-27 20:23:13 +03:00
|
|
|
|
2015-08-23 15:29:24 +03:00
|
|
|
void force_redraw();
|
2016-03-08 02:11:59 +03:00
|
|
|
void redraw_ifn();
|
2013-09-16 22:15:13 +04:00
|
|
|
|
2015-02-12 17:55:02 +03:00
|
|
|
void check_if_buffer_needs_reloading();
|
2013-10-15 21:51:31 +04:00
|
|
|
|
2013-11-14 22:09:15 +04:00
|
|
|
Context& context() { return m_input_handler.context(); }
|
|
|
|
const Context& context() const { return m_input_handler.context(); }
|
|
|
|
|
2014-08-12 22:24:09 +04:00
|
|
|
InputHandler& input_handler() { return m_input_handler; }
|
|
|
|
const InputHandler& input_handler() const { return m_input_handler; }
|
|
|
|
|
2013-12-21 00:10:08 +04:00
|
|
|
void change_buffer(Buffer& buffer);
|
2013-10-11 00:34:19 +04:00
|
|
|
|
2015-03-10 22:33:46 +03:00
|
|
|
StringView get_env_var(StringView name) const;
|
2014-04-08 00:25:44 +04:00
|
|
|
|
2015-11-07 21:24:08 +03:00
|
|
|
Buffer* last_buffer() const { return m_last_buffer.get(); }
|
|
|
|
void set_last_buffer(Buffer* last_buffer) { m_last_buffer = last_buffer; }
|
|
|
|
|
2013-12-21 00:10:08 +04:00
|
|
|
private:
|
2014-11-11 02:29:16 +03:00
|
|
|
void on_option_changed(const Option& option) override;
|
|
|
|
|
2015-02-12 17:55:02 +03:00
|
|
|
void on_buffer_reload_key(Key key);
|
|
|
|
void close_buffer_reload_dialog();
|
|
|
|
void reload_buffer();
|
|
|
|
|
2014-11-29 23:14:52 +03:00
|
|
|
Optional<Key> get_next_key(EventMode mode);
|
|
|
|
|
2013-10-11 00:34:19 +04:00
|
|
|
DisplayLine generate_mode_line() const;
|
|
|
|
|
2013-09-13 01:39:34 +04:00
|
|
|
std::unique_ptr<UserInterface> m_ui;
|
2013-12-21 00:10:08 +04:00
|
|
|
std::unique_ptr<Window> m_window;
|
|
|
|
|
2014-04-08 00:25:44 +04:00
|
|
|
EnvVarMap m_env_vars;
|
|
|
|
|
2013-12-21 00:10:08 +04:00
|
|
|
InputHandler m_input_handler;
|
2013-02-18 17:07:30 +04:00
|
|
|
|
2013-09-16 22:15:13 +04:00
|
|
|
DisplayLine m_status_line;
|
2014-07-07 23:13:08 +04:00
|
|
|
DisplayLine m_mode_line;
|
2014-11-25 04:00:18 +03:00
|
|
|
|
2016-03-08 02:11:59 +03:00
|
|
|
enum PendingUI : int
|
|
|
|
{
|
|
|
|
MenuShow = 1 << 0,
|
|
|
|
MenuSelect = 1 << 1,
|
|
|
|
MenuHide = 1 << 2,
|
|
|
|
InfoShow = 1 << 3,
|
|
|
|
InfoHide = 1 << 4,
|
|
|
|
StatusLine = 1 << 5,
|
|
|
|
Draw = 1 << 6,
|
|
|
|
Refresh = 1 << 7,
|
|
|
|
};
|
|
|
|
int m_ui_pending = 0;
|
|
|
|
|
2016-02-27 20:23:13 +03:00
|
|
|
struct Menu
|
|
|
|
{
|
|
|
|
Vector<DisplayLine> items;
|
2016-09-22 22:36:26 +03:00
|
|
|
BufferCoord anchor;
|
|
|
|
DisplayCoord ui_anchor;
|
2016-02-27 20:23:13 +03:00
|
|
|
MenuStyle style;
|
|
|
|
int selected;
|
2017-01-30 02:37:42 +03:00
|
|
|
} m_menu{};
|
2016-02-27 20:23:13 +03:00
|
|
|
|
|
|
|
struct Info
|
|
|
|
{
|
|
|
|
String title;
|
|
|
|
String content;
|
2016-09-22 22:36:26 +03:00
|
|
|
BufferCoord anchor;
|
|
|
|
DisplayCoord ui_anchor;
|
2016-02-27 20:23:13 +03:00
|
|
|
InfoStyle style;
|
2017-01-30 02:37:42 +03:00
|
|
|
} m_info{};
|
2016-02-27 20:23:13 +03:00
|
|
|
|
2015-01-14 22:16:32 +03:00
|
|
|
Vector<Key, MemoryDomain::Client> m_pending_keys;
|
2015-02-12 17:55:02 +03:00
|
|
|
|
|
|
|
bool m_buffer_reload_dialog_opened = false;
|
2015-11-07 21:24:08 +03:00
|
|
|
|
|
|
|
SafePtr<Buffer> m_last_buffer;
|
2012-06-06 03:15:19 +04:00
|
|
|
};
|
|
|
|
|
2015-11-20 11:50:53 +03:00
|
|
|
enum class Autoreload
|
|
|
|
{
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
Ask
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr Array<EnumDesc<Autoreload>, 5> enum_desc(Autoreload)
|
|
|
|
{
|
|
|
|
return { {
|
|
|
|
{ Autoreload::Yes, "yes" },
|
|
|
|
{ Autoreload::No, "no" },
|
|
|
|
{ Autoreload::Ask, "ask" },
|
|
|
|
{ Autoreload::Yes, "true" },
|
|
|
|
{ Autoreload::No, "false" }
|
|
|
|
} };
|
|
|
|
}
|
|
|
|
|
2012-06-06 03:15:19 +04:00
|
|
|
}
|
|
|
|
|
2013-09-13 01:47:23 +04:00
|
|
|
#endif // client_hh_INCLUDED
|