-
-
Notifications
You must be signed in to change notification settings - Fork 329
Add screen.SetClipboard #562
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
Conversation
9bcbde8
to
55866a9
Compare
55866a9
to
420210e
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.
This looks like a good start.
A couple of thoughts.
-
Should we update some of the terminfo descriptions -- it would be good if at least some of the terminal types got this behavior. Certainly I believe at a minimum xterm-256color should have it.
-
I feel like we might also want the ability to get the contents of the paste buffer, although this might be considered contentious I suppose. But think about an application that wants to have a "paste" -- of course there are parts about this that might be concerning from a security perspective, but honestly I don't think we'd be making the situation any worse as a malicious application could still just encode these sequences directly. I imagine that enforcement of the get (the "?" parameter) would need to be done by the terminal emulator itself.
Also, perhaps you want to update AUTHORS? |
I could update
I am not sure how we can check for support of that feature dynamically. For setting the clipboard its easy: just use the
Thanks but there is no need for that. |
I want to think on this. I've been thinking about refactoring some of the "extended" terminal handling, because honestly almost everyone wants all the extra features and they rarely have all the capabilities in terminfo. |
As a TUI instant messaging client developer, I'm interested in having a way to read the system clipboard (in order to upload images easily, from the clipboard). IMO it's fine to have this in tcell wrt security, it's up to the terminal emulator whether to allow this or drop the request. |
Regarding the added example here maybe it would be best to strip that from this PR and instead create a new example which provides a simple menu driven by Edit:
Also at least |
I am close to wanting to merge this -- the only thing I really don't like is that the only way that people get this is with the extended query and using the dynamic terminfo. I really believe this should be included by default. |
Well, it could be hardcoded instead but I have absolutely no idea which of the fake Alternative as written above:
|
So I'm looking in more depth at this. This has copying data to the clipboard, but not retrieval. That's fine for now. I think retrieval is going to require a new event type. Both forms are tied to base64 encoding. |
This is not supported for Windows or WebAssembly yet. It's possible for applications to post to the clipboard using Screen.SetClipboard (any data), and they can retrieve the clipboard (if permitted) using GetClipboard. The terminal may well reject either of these. Retrieval will arrive as a new EventClipboard, if it can. (There is no good way to make this synchronous.) This work was inspired by a PR submitted by Consolatis (#562), and has some work based on it, but it was also substantially improved and now includes both sides of the clipboard access pattern.
I have implemented a superset of this functionality in #714. Additional it works across a very much wider set of terminals. I am not using the Ms sequence to detect this. In fact, I've become disenchanged with terminfo entirely. Instead I look for XT (xterm title title support), or a terminal name starting with "xterm", and if I find it, I assume it supports this capability. Only POSIX terminal support is done -- no support for this on Windows or WebAssembly at this point. |
Fixes #561
I tested this using the following additional change to always prefer dynamic loading of terminfo data: