Skip to content
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

Closed
zyedidia opened this issue Sep 1, 2016 · 12 comments
Closed

Support for bracketed paste mode #120

zyedidia opened this issue Sep 1, 2016 · 12 comments
Milestone

Comments

@zyedidia
Copy link
Contributor

zyedidia commented Sep 1, 2016

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.

@gdamore
Copy link
Owner

gdamore commented Sep 3, 2016

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...

@techtonik
Copy link

@gdamore is there a list of features that are missing from terminfo and that make modern TUIs inefficient thanks to that?

@gdamore
Copy link
Owner

gdamore commented Sep 4, 2016

24 bit color.
mouse handling.
combined bg and fg attribute setting
lots of keystroke combinations
and apparently cut and paste
save and restore current palette

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

On Sep 3, 2016, at 11:36 PM, anatoly techtonik notifications@github.com wrote:

@gdamore is there a list of features that are missing from terminfo and that make modern TUIs inefficient thanks to that?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@gdamore
Copy link
Owner

gdamore commented Oct 19, 2016

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!

@gdamore
Copy link
Owner

gdamore commented Jun 12, 2019

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.

@gdamore gdamore closed this as completed Jun 12, 2019
@gdamore gdamore reopened this Jun 12, 2019
@gdamore
Copy link
Owner

gdamore commented Jun 12, 2019

Whoops, I meant to close the PR, not the underlying request (issue).

@gdamore
Copy link
Owner

gdamore commented Aug 30, 2020

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.

@gdamore
Copy link
Owner

gdamore commented Aug 31, 2020

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.)

@gdamore
Copy link
Owner

gdamore commented Oct 16, 2020

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.
The bracketing escape sequences are reported as EventPaste.

My code for this works well on Linux terminals, but Windows terminal seems to lack support for this even under WSL.

@hackerb9
Copy link

hackerb9 commented Jan 4, 2021

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.

@techtonik
Copy link

The reality is that nearly the entire world is using xterm compatible sequences. (The hold outs here are the rxvt crowd... which is annoying.)

The problem needs a reference article or a talk, otherwise it is too narrow for users to vote for.

@gdamore
Copy link
Owner

gdamore commented Jan 5, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants