2012-09-24 19:24:27 +02:00
|
|
|
#ifndef user_interface_hh_INCLUDED
|
|
|
|
#define user_interface_hh_INCLUDED
|
|
|
|
|
2015-03-09 14:48:41 +01:00
|
|
|
#include "array_view.hh"
|
2017-03-07 02:12:37 +01:00
|
|
|
#include "hash_map.hh"
|
2012-09-24 19:24:27 +02:00
|
|
|
|
2014-11-12 22:27:07 +01:00
|
|
|
#include <functional>
|
2014-11-11 00:29:16 +01:00
|
|
|
|
2012-09-24 19:24:27 +02:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class String;
|
2012-10-20 20:15:20 +02:00
|
|
|
class DisplayBuffer;
|
2013-04-04 18:50:00 +02:00
|
|
|
class DisplayLine;
|
2019-11-22 11:48:26 +01:00
|
|
|
using DisplayLineList = Vector<DisplayLine, MemoryDomain::Display>;
|
2016-09-22 21:36:26 +02:00
|
|
|
struct DisplayCoord;
|
2014-11-12 22:27:07 +01:00
|
|
|
struct Face;
|
|
|
|
struct Key;
|
2012-09-30 15:18:37 +02:00
|
|
|
|
|
|
|
enum class MenuStyle
|
|
|
|
{
|
|
|
|
Prompt,
|
2018-06-03 04:06:29 +02:00
|
|
|
Search,
|
2012-09-30 15:18:37 +02:00
|
|
|
Inline
|
|
|
|
};
|
2012-09-24 19:24:27 +02:00
|
|
|
|
2014-11-08 18:59:38 +01:00
|
|
|
enum class InfoStyle
|
|
|
|
{
|
|
|
|
Prompt,
|
|
|
|
Inline,
|
2014-11-10 14:28:06 +01:00
|
|
|
InlineAbove,
|
|
|
|
InlineBelow,
|
2017-01-04 12:24:07 +01:00
|
|
|
MenuDoc,
|
|
|
|
Modal
|
2014-11-08 18:59:38 +01:00
|
|
|
};
|
|
|
|
|
2014-11-25 02:00:18 +01:00
|
|
|
enum class EventMode;
|
|
|
|
|
2017-04-12 11:39:17 +02:00
|
|
|
enum class CursorMode
|
|
|
|
{
|
|
|
|
Prompt,
|
|
|
|
Buffer,
|
|
|
|
};
|
|
|
|
|
2016-11-29 22:35:53 +01:00
|
|
|
using OnKeyCallback = std::function<void(Key key)>;
|
2022-12-11 19:30:02 +01:00
|
|
|
using OnPasteCallback = std::function<void(StringView content)>;
|
2013-01-11 19:17:21 +01:00
|
|
|
|
2016-11-29 20:53:11 +01:00
|
|
|
class UserInterface
|
2012-09-24 19:24:27 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-01-08 23:30:15 +01:00
|
|
|
virtual ~UserInterface() = default;
|
2012-12-14 19:04:34 +01:00
|
|
|
|
2018-04-29 14:27:28 +02:00
|
|
|
virtual bool is_ok() const = 0;
|
|
|
|
|
2015-10-05 02:25:23 +02:00
|
|
|
virtual void menu_show(ConstArrayView<DisplayLine> choices,
|
2016-09-22 21:36:26 +02:00
|
|
|
DisplayCoord anchor, Face fg, Face bg,
|
2013-04-04 13:53:47 +02:00
|
|
|
MenuStyle style) = 0;
|
2012-09-24 19:24:27 +02:00
|
|
|
virtual void menu_select(int selected) = 0;
|
|
|
|
virtual void menu_hide() = 0;
|
2012-12-14 19:04:34 +01:00
|
|
|
|
2019-11-22 11:48:26 +01:00
|
|
|
virtual void info_show(const DisplayLine& title,
|
|
|
|
const DisplayLineList& content,
|
2016-09-22 21:36:26 +02:00
|
|
|
DisplayCoord anchor, Face face,
|
2014-11-08 18:59:38 +01:00
|
|
|
InfoStyle style) = 0;
|
2012-12-14 19:04:34 +01:00
|
|
|
virtual void info_hide() = 0;
|
|
|
|
|
2012-10-20 20:15:20 +02:00
|
|
|
virtual void draw(const DisplayBuffer& display_buffer,
|
2016-02-17 14:32:05 +01:00
|
|
|
const Face& default_face,
|
|
|
|
const Face& padding_face) = 0;
|
2015-06-17 22:28:02 +02:00
|
|
|
|
|
|
|
virtual void draw_status(const DisplayLine& status_line,
|
|
|
|
const DisplayLine& mode_line,
|
|
|
|
const Face& default_face) = 0;
|
|
|
|
|
2016-09-22 21:36:26 +02:00
|
|
|
virtual DisplayCoord dimensions() = 0;
|
2013-01-11 19:17:21 +01:00
|
|
|
|
2017-04-12 11:39:17 +02:00
|
|
|
virtual void set_cursor(CursorMode mode, DisplayCoord coord) = 0;
|
|
|
|
|
2016-03-07 14:54:20 +01:00
|
|
|
virtual void refresh(bool force) = 0;
|
2014-04-15 20:19:44 +02:00
|
|
|
|
2016-11-29 22:35:53 +01:00
|
|
|
virtual void set_on_key(OnKeyCallback callback) = 0;
|
2022-12-11 19:30:02 +01:00
|
|
|
virtual void set_on_paste(OnPasteCallback callback) = 0;
|
2014-11-11 00:29:16 +01:00
|
|
|
|
2017-03-07 02:12:37 +01:00
|
|
|
using Options = HashMap<String, String, MemoryDomain::Options>;
|
2014-11-11 00:29:16 +01:00
|
|
|
virtual void set_ui_options(const Options& options) = 0;
|
2012-09-24 19:24:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // user_interface_hh_INCLUDED
|