kakoune

Fork of kakoune, an acceptable text editor
git clone git://git.laack.co/kakoune.git
Log | Files | Refs

user_interface.hh (2313B)


      1 #ifndef user_interface_hh_INCLUDED
      2 #define user_interface_hh_INCLUDED
      3 
      4 #include "array_view.hh"
      5 #include "hash_map.hh"
      6 #include "function.hh"
      7 
      8 namespace Kakoune
      9 {
     10 
     11 class String;
     12 class DisplayBuffer;
     13 class DisplayLine;
     14 using DisplayLineList = Vector<DisplayLine, MemoryDomain::Display>;
     15 struct DisplayCoord;
     16 struct Face;
     17 struct Key;
     18 
     19 enum class MenuStyle
     20 {
     21     Prompt,
     22     Search,
     23     Inline
     24 };
     25 
     26 enum class InfoStyle
     27 {
     28     Prompt,
     29     Inline,
     30     InlineAbove,
     31     InlineBelow,
     32     MenuDoc,
     33     Modal
     34 };
     35 
     36 enum class StatusStyle
     37 {
     38     Status,
     39     Command,
     40     Search,
     41     Prompt
     42 };
     43 
     44 enum class EventMode;
     45 
     46 using OnKeyCallback = Function<void(Key key)>;
     47 using OnPasteCallback = Function<void(StringView content)>;
     48 
     49 class UserInterface
     50 {
     51 public:
     52     virtual ~UserInterface() = default;
     53 
     54     virtual bool is_ok() const = 0;
     55 
     56     virtual void menu_show(ConstArrayView<DisplayLine> choices,
     57                            DisplayCoord anchor, Face fg, Face bg,
     58                            MenuStyle style) = 0;
     59     virtual void menu_select(int selected) = 0;
     60     virtual void menu_hide() = 0;
     61 
     62     virtual void info_show(const DisplayLine& title,
     63                            const DisplayLineList& content,
     64                            DisplayCoord anchor, Face face,
     65                            InfoStyle style) = 0;
     66     virtual void info_hide() = 0;
     67 
     68     virtual void draw(const DisplayBuffer& display_buffer,
     69                       DisplayCoord cursor_pos,
     70                       const Face& default_face,
     71                       const Face& padding_face,
     72                       ColumnCount widget_columns) = 0;
     73 
     74     virtual void draw_status(const DisplayLine& prompt,
     75                              const DisplayLine& content,
     76                              const ColumnCount cursor_pos,
     77                              const DisplayLine& mode_line,
     78                              const Face& default_face,
     79                              StatusStyle style) = 0;
     80 
     81     virtual DisplayCoord dimensions() = 0;
     82 
     83     virtual void refresh(bool force) = 0;
     84 
     85     virtual void set_on_key(OnKeyCallback callback) = 0;
     86     virtual void set_on_paste(OnPasteCallback callback) = 0;
     87 
     88     using Options = HashMap<String, String, MemoryDomain::Options>;
     89     virtual void set_ui_options(const Options& options) = 0;
     90 };
     91 
     92 }
     93 
     94 #endif // user_interface_hh_INCLUDED