-
Notifications
You must be signed in to change notification settings - Fork 841
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
Async Clipboard #982
Comments
Hey can I take this up ? |
Sounds good to me. @aymanbagabas, whatcha think? |
I think that would be wonderful to add to Bubble Tea! Looking at implementation details, there are a couple of golang clipboard libraries such as https://github.com/atotto/clipboard and https://github.com/golang-design/clipboard, but each has its own shortcomings. The former always assumes programs running locally (no remote sessions support) and the latter uses CGO. Given this, I'm proposing porting atotto/clipboard to bubbletea with a few changes to recognize the program environment variables and use OSC52 when working with remote sessions like SSH. Something along the lines of this API type ClipboardWriteMsg bool
func ClipboardWrite(text string) tea.Cmd {
return func() tea.Msg {
err := copyClipboard()
return ClipboardWriteMsg(err == nil)
}
}
type ClipboardReadMsg string
func ClipboardRead() tea.Cmd {
return func() tea.Msg {
text := readClipboard()
return ClipboardReadMsg(text)
}
}
|
Hey, So tell me if I'm going in the right direction. I'm thinking of adding How do i know if I'm in a ssh session? Check if Does this look good? |
That wouldn't work because
Correct, check for |
Aight I'll fork |
So, I've ported Have a look and let me know if it looks good. |
Hey, Can anyone tell me if I'm going in the right direction? Any input would be appreciated. Thanks |
This adds support to setting the system and primary (X11 & Wayland) clipboards using OSC52. This makes the clipboard commands work even on remote session such as SSH. While this doesn't work on all terminals, most modern terminals support OSC52 including Alacritty, Kitty, Xterm.JS, etc. For terminals, that don't support OSC52, application developers should consider using a Golang clipboard library like https://github.com/atotto/clipboard. OSC52 support can be detected if the terminal responds to a `ReadClipboard` command. Fixes: #982
…#1086) This adds support to setting the system and primary (X11 & Wayland) clipboards using OSC52. This makes the clipboard commands work even on remote session such as SSH. While this doesn't work on all terminals, most modern terminals support OSC52 including Alacritty, Kitty, Xterm.JS, etc. For terminals, that don't support OSC52, application developers should consider using a Golang clipboard library like https://github.com/atotto/clipboard. OSC52 support can be detected if the terminal responds to a `ReadClipboard` command. Fixes: #982
I've been seeing reports that clipboard operations can take a long time in WSL. While moving copy/paste to
Cmd
s won't solve this issue, it's probably worth doing it regardless, both because clipboard stuff is I/O, and to provide a unified copy/paste API to all Bubble Tea applications.Note that we also discussed this in @aymanbagabas's upcoming Kitty Keyboard work.
The text was updated successfully, but these errors were encountered: