mirror of
https://github.com/mawww/kakoune.git
synced 2024-09-11 13:00:41 +03:00
Text pasted into Kakoune's normal mode is interpreted as command sequence, which is probably never what the user wants. Text pasted during insert mode will be inserted fine but may trigger auto-indentation hooks which is likely not what users want. Bracketed paste is pair of escape codes sent by terminals that allow applications to distinguish between pasted text and typed text. Let's use this feature to always insert pasted text verbatim, skipping keymap lookup and the InsertChar hook. In future, we could add a dedicated Paste hook. We need to make a decision on whether to paste before or after the selection. I chose "before" because that's what I'm used to. TerminalUI::set_on_key has EventManager::instance().force_signal(0); I'm not sure if we want the same for TerminalUI::set_on_paste? I assume it doesn't matter because they are always called in tandem. Closes #2465
67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
#ifndef json_ui_hh_INCLUDED
|
|
#define json_ui_hh_INCLUDED
|
|
|
|
#include "user_interface.hh"
|
|
#include "event_manager.hh"
|
|
#include "coord.hh"
|
|
#include "string.hh"
|
|
|
|
namespace Kakoune
|
|
{
|
|
|
|
struct Value;
|
|
|
|
class JsonUI : public UserInterface
|
|
{
|
|
public:
|
|
JsonUI();
|
|
|
|
JsonUI(const JsonUI&) = delete;
|
|
JsonUI& operator=(const JsonUI&) = delete;
|
|
|
|
bool is_ok() const override { return m_stdin_watcher.fd() != -1; }
|
|
|
|
void draw(const DisplayBuffer& display_buffer,
|
|
const Face& default_face,
|
|
const Face& buffer_padding) override;
|
|
|
|
void draw_status(const DisplayLine& status_line,
|
|
const DisplayLine& mode_line,
|
|
const Face& default_face) override;
|
|
|
|
void menu_show(ConstArrayView<DisplayLine> items,
|
|
DisplayCoord anchor, Face fg, Face bg,
|
|
MenuStyle style) override;
|
|
void menu_select(int selected) override;
|
|
void menu_hide() override;
|
|
|
|
void info_show(const DisplayLine& title, const DisplayLineList& content,
|
|
DisplayCoord anchor, Face face,
|
|
InfoStyle style) override;
|
|
void info_hide() override;
|
|
|
|
void set_cursor(CursorMode mode, DisplayCoord coord) override;
|
|
|
|
void refresh(bool force) override;
|
|
|
|
DisplayCoord dimensions() override;
|
|
void set_on_key(OnKeyCallback callback) override;
|
|
void set_on_paste(OnPasteCallback callback) override;
|
|
void set_ui_options(const Options& options) override;
|
|
|
|
private:
|
|
void parse_requests(EventMode mode);
|
|
void eval_json(const Value& value);
|
|
|
|
FDWatcher m_stdin_watcher;
|
|
OnKeyCallback m_on_key;
|
|
OnPasteCallback m_on_paste;
|
|
Vector<Key, MemoryDomain::Client> m_pending_keys;
|
|
DisplayCoord m_dimensions;
|
|
String m_requests;
|
|
};
|
|
|
|
}
|
|
|
|
#endif // json_ui_hh_INCLUDED
|