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
feat: bracketed paste #397
Conversation
As discussed with @muesli I changed the PR to always enable bracked paste, unless the option WithoutBracketedPaste is specified on the program. |
key.go
Outdated
// | ||
// The rune array is modified in-place. The returned slice | ||
// is the original slice shortened after the control characters have been removed. | ||
func SanitizeRunes(runes []rune, replaceNewLine rune) []rune { |
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.
Is there any particular reason this function needs to be exported?
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.
Yes it's for use here: charmbracelet/bubbles#214
I'm expecting any widget that wants to handle multi-rune input to need this (regardless of bracketed paste), so it deserves to be a common utility function.
This comment was marked as outdated.
This comment was marked as outdated.
Rebasing. |
1eacdc1
to
23fe7a1
Compare
This comment was marked as outdated.
This comment was marked as outdated.
71d1d7d
to
a38be3c
Compare
@muesli this is ready again. |
@muesli in case you haven't found it already, this patch has a shortcoming: certain terminal emulators feed the pasted datas as non-continuous writes to the terminal buffer, so the bubbletea code can sometimes read less than I will iterate and submit a better version. |
I have added a commit on top of the original branch. @muesli you can look at just the diff for the latest commit to see what you need to change on your branch. |
Bumping. I have a use-case similar to #800 and would love to be able to detect |
Please merge this! |
c0359b4
to
0af1b45
Compare
This introduces support for input via bracketed paste, where escape characters in the pasted input are not interpreted. Pasted input are marked as a special field in the KeyMsg. This is useful because pasted input may need sanitation in individual widgets.
Some terminal emulators feed the bracketed paste data in multiple chunks, which may not be aligned on a 256 byte boundary. So it's possible for `input.Read` to return less than 256 bytes read but while there's still more data to be read to complete a bracketed paste input.
0af1b45
to
0248b32
Compare
First 3 commits from #568, #569 and #570.
Partial fix to #404
This introduces support for input via bracketed paste, where escape
characters in the pasted input are not interpreted.
Pasted input are marked as a special field in the KeyMsg.
This is because pasted input may need sanitation in individual widgets.
cc @maaslalani @muesli