-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
Support for bracketed paste mode #120
Comments
This looks like another feature which is sadly missing from terminfo. It would be good to know which $TERM values have this, and how to enable it everywhere. And, whether the enablement sequence is destructive anywhere. ncurses falls yet further behind... |
@gdamore is there a list of features that are missing from terminfo and that make modern TUIs inefficient thanks to that? |
24 bit color. I have added special logic for the first four already. Fortunately everyone follows xterm mostly. However its not always easy to determine which of these a particular xterm clone has. And its not always easy to know apriori that a particular term (eg dvtm) is an xterm clone. Sent from my iPhone
|
So looking at this, I think I can enable bracketed paste pretty easily, and I'd do so by in the same mode that we use for enabling Mouse events. We need to create new "event" types, for PasteBegin, and PasteEnd... these could be separate event types, or some kind of new KeyEvent. (KeyPasteBegin, KeyPasteEnd...) Probably the latter is more natural for applications, though architecturally less "clean". I need to think about how this would work on Windows though... there is a clipboard there, and in theory we can notice those events too! |
I think we've addressed the character limit, so pasting doesn't drop things. Do we still need or want a separate bracketed paste though? If so please rebase, fix the conflicts, and resubmit. Thanks. For now I'm closing this one. |
Whoops, I meant to close the PR, not the underlying request (issue). |
My approach to this will be simpler. We can send a special event for paste start, and another for paste end. Applications will then be free to do with this as they want. It should be benign for applications that wish to simply ignore that event. |
The biggest problem I have right now is that I cannot rely on terminfo to tell me anything here. We really need to move beyond ncurses. It's been too slow to adapt, and too many useful things are missing from it, and its maintainer seems to be uninterested in adding to it. The reality is that nearly the entire world is using xterm compatible sequences. (The hold outs here are the rxvt crowd... which is annoying.) |
So the approach here is an opt-in by calling EnablePaste(). Then, if the terminal supports XTerm mouse mode, we will try to enable bracketed paste, and we will parse those events as such. My code for this works well on Linux terminals, but Windows terminal seems to lack support for this even under WSL. |
It appears there may be a better solution possible for this bug: the maintainer for terminfo just told me that the process for adding terminfo support for bracketed paste mode starts with an application, like tcell, making up their own terminfo capabilities and using them as if they already existed. @gdamore, are you interested in adding such code to tcell? I know you've already gone to the trouble of adding special logic to workaround the lack, but it will save other developers from having to do the same in their programs. |
The problem needs a reference article or a talk, otherwise it is too narrow for users to vote for. |
I dunno. Having this in terminfo would have been nice but tbh I haven't come away with a great feeling about the ncurses developer wanting to accommodate other programs. The whole 24bit color fiasco left a sour taste in my mouth. As a result tcell has sort of moved on from terminfo. |
Currently if you paste directly into a tcell program, it will only paste the first few characters because the terminal sends each character as one event, and there is a limit to the amount of events that can be stored in the event channel.
To fix this, it would be good to support bracketed paste which sends "paste events" and is supported on most terminals.
The text was updated successfully, but these errors were encountered: