kakoune

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

json_ui.hh (1950B)


      1 #ifndef json_ui_hh_INCLUDED
      2 #define json_ui_hh_INCLUDED
      3 
      4 #include "user_interface.hh"
      5 #include "event_manager.hh"
      6 #include "coord.hh"
      7 #include "string.hh"
      8 
      9 namespace Kakoune
     10 {
     11 
     12 struct Value;
     13 
     14 class JsonUI : public UserInterface
     15 {
     16 public:
     17     JsonUI();
     18 
     19     JsonUI(const JsonUI&) = delete;
     20     JsonUI& operator=(const JsonUI&) = delete;
     21 
     22     bool is_ok() const override { return m_stdin_watcher.fd() != -1; }
     23 
     24     void draw(const DisplayBuffer& display_buffer,
     25               DisplayCoord cursor_pos,
     26               const Face& default_face,
     27               const Face& buffer_padding,
     28               ColumnCount widget_columns) override;
     29 
     30     void draw_status(const DisplayLine& prompt,
     31                      const DisplayLine& content,
     32                      const ColumnCount cursor_pos,
     33                      const DisplayLine& mode_line,
     34                      const Face& default_face,
     35                      StatusStyle style) override;
     36 
     37     void menu_show(ConstArrayView<DisplayLine> items,
     38                    DisplayCoord anchor, Face fg, Face bg,
     39                    MenuStyle style) override;
     40     void menu_select(int selected) override;
     41     void menu_hide() override;
     42 
     43     void info_show(const DisplayLine& title, const DisplayLineList& content,
     44                    DisplayCoord anchor, Face face,
     45                    InfoStyle style) override;
     46     void info_hide() override;
     47 
     48     void refresh(bool force) override;
     49 
     50     DisplayCoord dimensions() override;
     51     void set_on_key(OnKeyCallback callback) override;
     52     void set_on_paste(OnPasteCallback callback) override;
     53     void set_ui_options(const Options& options) override;
     54 
     55 private:
     56     void parse_requests(EventMode mode);
     57     void eval_json(const Value& value);
     58 
     59     FDWatcher m_stdin_watcher;
     60     OnKeyCallback m_on_key;
     61     OnPasteCallback m_on_paste;
     62     Vector<Key, MemoryDomain::Client> m_pending_keys;
     63     DisplayCoord m_dimensions;
     64     String m_requests;
     65 };
     66 
     67 }
     68 
     69 #endif // json_ui_hh_INCLUDED