Bracketed Paste #305

Closed
opened 2021-01-20 15:31:02 +00:00 by JorwLNKwpH · 16 comments

Can foot support bracketed paste? Or did I miss this option somewhere?

Can foot support bracketed paste? Or did I miss this option somewhere?

Foot does support it. There are no options related to it (like disabling it permanently).

How/where is it not working?

Foot does support it. There are no options related to it (like disabling it permanently). How/where is it not working?

Multi-line paste is broken on an irc client, while libvte and kitty work correctly.

Foot automatically pastes each line individually, while the other terminals do not automatically paste anything.

Multi-line paste is broken on an irc client, while libvte and kitty work correctly. Foot automatically pastes each line individually, while the other terminals do not automatically paste anything.

Not working at all, or messing up the multi-line part?

Not working at all, or messing up the multi-line part?

http://thejh.net/misc/website-terminal-copy-paste

Not sure if this is related, but foot fails the second test.

http://thejh.net/misc/website-terminal-copy-paste Not sure if this is related, but foot fails the second test.

That doesn't sound like the same issue. Foot fails to filter out the "bracketed paste" end sequence. I.e. the second test explicitly disables bracketed paste before doing its evil stuff.

Your issue probably has to do with line endings.

That doesn't sound like the same issue. Foot fails to filter out the "bracketed paste" **end** sequence. I.e. the second test explicitly disables bracketed paste before doing its evil stuff. _Your_ issue probably has to do with line endings.
dnkl added the
bug
label 2021-01-20 17:24:26 +00:00

@JorwLNKwpH can you test #307?

I think it fixes your issue, but I'm not sure, since I haven't been able to reproduce it in any application.

@JorwLNKwpH can you test https://codeberg.org/dnkl/foot/pulls/307? I _think_ it fixes your issue, but I'm not sure, since I haven't been able to reproduce it in any application.

The issue here is caused by foot not sending BRACKETED_PASTE terminal mode to notify the application.

The issue here is caused by foot not sending BRACKETED_PASTE terminal mode to notify the application.

Foot automatically pastes each line individually, while the other terminals do not automatically paste anything.

I didn't see this until now. I think there's some confusion about what bracketed paste really is.

It is not about the terminal preventing, or requiring confirmation before pasting multiline text. Nor is it required to filter out any characters.

When bracketed paste is enabled, the terminal will wrap all pasted text in \E[200~ TEXT TEXT \E[201~. This allows the application to differentiate between typed text, and pasted text.

This means there's actually no reason to ask for confirmation before pasting multiline text when bracketed paste mode has been enabled, since the application is expected to be able to deal with it by itself. That's the whole point with bracketed paste mode.

Zsh, for example, supports and enables bracketed paste. This is why, when I paste

echo hello world
ls /usr/bin
cat /etc/passwd

it doesn't execute the above, as can be seen in the screenshot.

To enable bracketed paste mode, the application must send \E[?2004h to the terminal.

> Foot automatically pastes each line individually, while the other terminals do not automatically paste anything. I didn't see this until now. I think there's some confusion about _what_ bracketed paste really is. It is **not** about the terminal preventing, or requiring confirmation before pasting multiline text. Nor is it required to filter out any characters. When bracketed paste is enabled, the terminal will wrap all pasted text in `\E[200~ TEXT TEXT \E[201~`. This allows the application to differentiate between typed text, and pasted text. This means there's actually **no reason** to ask for confirmation before pasting multiline text when bracketed paste mode has been enabled, since the application is expected to be able to deal with it by itself. That's the whole point with bracketed paste mode. Zsh, for example, supports and enables bracketed paste. This is why, when I paste ```sh echo hello world ls /usr/bin cat /etc/passwd ``` it doesn't execute the above, as can be seen in the screenshot. To enable bracketed paste mode, the application **must** send `\E[?2004h` to the terminal.

To enable bracketed paste mode, the application must send \E[?2004h to the terminal.

Is this missing from the foot terminfo by any chance? Because launching the application with TERM=xterm-256color on foot doesn't seem to run into this issue (also alacritty seems broken as well in case that's relevant).

>To enable bracketed paste mode, the application must send \E[?2004h to the terminal. Is this missing from the foot terminfo by any chance? Because launching the application with `TERM=xterm-256color` on foot doesn't seem to run into this issue (also alacritty seems broken as well in case that's relevant).

Is this missing from the foot terminfo by any chance? Because launching the application with TERM=xterm-256color on foot doesn't seem to run into this issue

There's no terminfo capability for enabling bracketed paste, although it's possible that your shell only sends \E[?2004h when $TERM matches some known value.

What shell are you using?

> Is this missing from the foot terminfo by any chance? Because launching the application with `TERM=xterm-256color` on foot doesn't seem to run into this issue There's no terminfo capability for enabling bracketed paste, although it's possible that your shell only sends `\E[?2004h` when `$TERM` matches some known value. What shell are you using?

I'm using fish; I'll try some other shells and report back.

Update: Using foot with foot terminfo on dash or bash does not change anything.

Note that kitty works with kitty terminfo on fish. It could be that the application only detects bracketed paste for certain TERMs.

I'm using fish; I'll try some other shells and report back. Update: Using foot with foot terminfo on dash or bash does not change anything. Note that kitty works with kitty terminfo on fish. It could be that the application only detects bracketed paste for certain `TERM`s.

@JorwLNKwpH remember that the shell will turn off bracketed paste before starting an application. Applications need to enable bracketed paste themselves.

And yes, some applications have the bad habit of checking the name of the terminfo (typically looking for the substring xterm, which is why kitty's terminfo is named xterm-kitty).

Is the sources of this IRC client available for browsing somewhere? Should be pretty easy to see if/how/when it enables bracketed paste.

@JorwLNKwpH remember that the shell will turn **off** bracketed paste before starting an application. Applications need to enable bracketed paste **themselves**. And yes, some applications have the bad habit of checking the _name_ of the terminfo (typically looking for the substring `xterm`, which is why kitty's terminfo is named `xterm-kitty`). Is the sources of this IRC client available for browsing somewhere? Should be pretty easy to see if/how/when it enables bracketed paste.

Note: I don't see why one would bother checking terminfo at all before enabling bracketed paste.

All terminals should ignore the \E[?2004h sequence if they don't support it.

And to the application there's no difference between having tried to enabled bracketed paste, and not enabling it at all. Hence it's better to just try to enable it on all terminals. If it works it works.

Note: I don't see why one would bother checking terminfo **at all** before enabling bracketed paste. All terminals should ignore the `\E[?2004h` sequence if they don't support it. And to the application there's no difference between having **tried** to enabled bracketed paste, and not enabling it at all. Hence it's better to just try to enable it on all terminals. If it works it works.

FWIW, fish does enable bracketed paste in foot with TERM=foot.

FWIW, fish **does** enable bracketed paste in foot with `TERM=foot`.
dnkl added
not-a-bug
and removed
bug
labels 2021-01-22 09:18:32 +00:00

Thanks for the insight. I checked the source code, and it does appear (afaict) to be using terminfo-based checking with xterm as a special case :(

Closing this since the other bracketed/non-bracketed paste issues can be tracked elsewhere.

Thanks for the insight. I checked the source code, and [it](https://github.com/jtdaugherty/vty) does appear (afaict) to be using terminfo-based checking with xterm as a special case :( Closing this since the other bracketed/non-bracketed paste issues can be tracked elsewhere.

vty bundles "bracketed paste mode" with other XTerm extensions that aren't available as terminfo capabilities:

Another note is that this will only allow these modes to be enabled in xterm-like terminals (TERM looks like xterm or screen); terminals that use the TerminfoBased driver don't support these modes yet. That's because terminfo doesn't expose capabilities for these modes so I can't safely enable them.

https://github.com/jtdaugherty/vty/issues/100#issuecomment-228617507

vty bundles "bracketed paste mode" with other XTerm extensions that aren't available as terminfo capabilities: > Another note is that this will only allow these modes to be enabled in xterm-like terminals (TERM looks like xterm or screen); terminals that use the TerminfoBased driver don't support these modes yet. That's because terminfo doesn't expose capabilities for these modes so I can't safely enable them. https://github.com/jtdaugherty/vty/issues/100#issuecomment-228617507
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: dnkl/foot#305
There is no content yet.