diff options
| author | Johannes Altmanninger <aclopte@gmail.com> | 2022-12-11 19:30:02 +0100 |
|---|---|---|
| committer | Johannes Altmanninger <aclopte@gmail.com> | 2023-03-11 16:21:57 +0100 |
| commit | b2cf74bb4a8286c5a191c54e947c0b2c9bb7cf96 (patch) | |
| tree | e1a41d87f4b1379f96356c43fa52dc9fb784f36b /src/json_ui.hh | |
| parent | ad36585b7ad236bea7d1c02b0679ae371c3c2a9e (diff) | |
Implement bracketed paste
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
Diffstat (limited to 'src/json_ui.hh')
| -rw-r--r-- | src/json_ui.hh | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/json_ui.hh b/src/json_ui.hh index 7b1abf44..545e4f35 100644 --- a/src/json_ui.hh +++ b/src/json_ui.hh @@ -46,6 +46,7 @@ public: 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: @@ -54,6 +55,7 @@ private: 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; |
