elfmz / far2l

Linux port of FAR v2
GNU General Public License v2.0
1.78k stars 173 forks source link

Windows Terminal: clipboard paste totally locks FAR #2329

Closed ClusterM closed 2 months ago

ClusterM commented 2 months ago

I'm using far2l via Windows Terminal and ssh. I have bound the clipboard paste action to Ctrl+Shift+V in terminal settings. So, I can use Ctrl+C and Ctrl+V to copy and paste text inside FAR, it works fine and doesn't conflict.

But when I want to paste text from Windows to remote system using Ctrl+Shift+V FAR totally freaks out. The text is pasted correctly, but then... FAR stops handling any escape sequences:

image image

So, I can't even quit FAR.

Copypasting from remote side to local PC using OSC52 works fine, btw.

upd: Seems like Windows Terminal sends weird escape code sequences. I inspected it.

Steps to reproduce via clean shell:

  1. Copy "test" string to the clipboard
  2. Run Windows Terminal
  3. Connect to Linux via SSH
  4. Type printf "\x1b[?9001h" to enable win32-input-mode
  5. Right-click on the terminal window to paste text from a clipboard

Expected Behavior

;4;20;116;1;0;1_;4;20;116;0;0;1_;18;101;1;0;1_;18;101;0;0;1_;3;31;115;1;0;1_;3;31;115;0;0;1_;4;20;116;1;0;1_;4;20;116;0;0;1_

It's t, e, s, t key presses.

Actual Behavior

;0;27;1;0;1_;0;91;1;0;1_;0;50;1;0;1_;0;48;1;0;1_;0;48;1;0;1_;0;126;1;0;1_4;20;116;1;0;1_4;20;116;0;0;1_;18;101;1;0;1_;18;101;0;0;1_3;31;115;1;0;1_3;31;115;0;0;1_4;20;116;1;0;1_4;20;116;0;0;1_;0;27;1;0;1_;0;91;1;0;1_;0;50;1;0;1_;0;48;1;0;1_;0;49;1;0;1_;0;126;1;0;1_

Decoded:

| Sequence          | Vk | Sc  | Uc  | Kd   | Cs | Rc | Description           |
|-------------------|----|-----|-----|------|----|----|-----------------------|
| `;0;27;1;0;1_`    | 0  | 27  | Esc | Down | 1  | 1  | Key Esc pressed       |
| `;0;91;1;0;1_`    | 0  | 91  | [   | Down | 1  | 1  | Key [ pressed         |
| `;0;50;1;0;1_`    | 0  | 50  | 2   | Down | 1  | 1  | Key 2 pressed         |
| `;0;48;1;0;1_`    | 0  | 48  | 0   | Down | 1  | 1  | Key 0 pressed         |
| `;0;48;1;0;1_`    | 0  | 48  | 0   | Down | 1  | 1  | Key 0 pressed         |
| `;0;126;1;0;1_`   | 0  | 126 | ~   | Down | 1  | 1  | Key ~ pressed         |
| `;4;20;116;1;0;1_`| 4  | 20  | t   | Down | 0  | 1  | Key t pressed         |
| `;4;20;116;0;0;1_`| 4  | 20  | t   | Up   | 0  | 1  | Key t released        |
| `;18;101;1;0;1_`  | 18 | 101 | e   | Down | 0  | 1  | Key e pressed         |
| `;18;101;0;0;1_`  | 18 | 101 | e   | Up   | 0  | 1  | Key e released        |
| `;3;31;115;1;0;1_`| 3  | 31  | s   | Down | 0  | 1  | Key s pressed         |
| `;3;31;115;0;0;1_`| 3  | 31  | s   | Up   | 0  | 1  | Key s released        |
| `;4;20;116;1;0;1_`| 4  | 20  | t   | Down | 0  | 1  | Key t pressed         |
| `;4;20;116;0;0;1_`| 4  | 20  | t   | Up   | 0  | 1  | Key t released        |
| `;0;27;1;0;1_`    | 0  | 27  | Esc | Down | 1  | 1  | Key Esc pressed       |
| `;0;91;1;0;1_`    | 0  | 91  | [   | Down | 1  | 1  | Key [ pressed         |
| `;0;50;1;0;1_`    | 0  | 50  | 2   | Down | 1  | 1  | Key 2 pressed         |
| `;0;48;1;0;1_`    | 0  | 48  | 0   | Down | 1  | 1  | Key 0 pressed         |
| `;0;49;1;0;1_`    | 0  | 49  | 1   | Down | 1  | 1  | Key 1 pressed         |
| `;0;126;1;0;1_`   | 0  | 126 | ~   | Down | 1  | 1  | Key ~ pressed         |

As you can see, there are much more key codes for some reason.

ClusterM commented 2 months ago

Seems more like Windows Terminal bug, actually.

ClusterM commented 2 months ago

Issue on the Windows Terminal repo: https://github.com/microsoft/terminal/issues/17656

unxed commented 2 months ago

Have you seen #2072 and #2085? Is it the same problem or a different one?

As I see "Right-click on the terminal window", I guess it is also something mouse-related.

unxed commented 2 months ago

@Dazzar56 can you please take a look at this issue?

ClusterM commented 2 months ago

Have you seen #2072 and #2085? Is it the same problem or a different one?

Seems like it's the same problem, yes.

ClusterM commented 2 months ago

Answer from Microsoft employee: https://github.com/microsoft/terminal/issues/17656#issuecomment-2266329410

ClusterM commented 2 months ago

fix: https://github.com/elfmz/far2l/pull/2333

unxed commented 1 week ago

I have bound the clipboard paste action to Ctrl+Shift+V in terminal settings. So, I can use Ctrl+C and Ctrl+V to copy and paste text inside FAR, it works fine and doesn't conflict.

Just for reference, how to set it up.

изображение