-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement bracketed paste insert #655
Conversation
cb57eae
to
c9262ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paste is now very fast! Thanks!
@@ -66,6 +67,12 @@ def self.set_default_key_bindings(config, allow_terminfo: true) | |||
end | |||
end | |||
|
|||
def self.set_bracketed_paste_key_bindings(config) | |||
[:emacs, :vi_insert, :vi_command].each do |keymap| | |||
config.add_default_key_binding_by_keymap(keymap, START_BRACKETED_PASTE.bytes, :bracketed_paste_start) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: Bracketed paste doesn't seem like a keybinding since it's sent from the terminal, not the user. Why is it set here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bracketed paste start sequence \e[200~
is very similar to some keys: kf9=\E[20~
, knp=\E[6~
, kpp=\E[5~
.
We can't distinguish them until we read the 5th or 6th bytes. So treating them as same as keybinding is one of the simple way to implement it.
We can think key bindings (processed in class KeyStroke) as a transformation layer of byte stream (includes many kind of escape sequences) to meaningful symbols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. It's similar to the terminal capabilities. Your explanation that it deals with byte streams made sense. Thanks!
Closes #631
Description
Implemented bracketed paste. Directly inserts pasted text.
This will speedup paste (1100 lines in 8sec → 2600 lines in 8sec)
Stops tab-complete while pasting code that includes tab
Code using tab indentation can be pasted to reline
Bracketed paste implementation
Reline had a code for bracketed paste but it seems not working.
(Escape sequence for bracketed paste start and end was also wrong)
Readline compatibility
Readline(>= 8.1) enables bracketed paste by default.
set enable-bracketed-paste off
will disable it.Readline accepts bracketed paste input
"\e[200~text\e[201~"
even if it's disabled in inputrc.inputrc read
Changed inputrc read timing. Reline should read inputrc before
io_gate.prep