chrisant996 / clink

Bash's powerful command line editing in cmd.exe
https://chrisant996.github.io/clink/
GNU General Public License v3.0
3.44k stars 135 forks source link

CTRL-C does not copy text selected using conhost mouse selection #647

Closed andry81 closed 1 month ago

andry81 commented 1 month ago

If start selection with the mouse: SHIFT+mouse

and then press CTRL-C, then nothing copied.

In the same time the right mouse button click copies the text as expected.

OS: Windows 8.1

clink info

version          : 1.6.18.80e2a3
injected         : clink_dll_x64.dll
system           : 6.3.09600.20778
codepage         : 1251
keyboard langid  : 1033
keyboard layout  : 00000409
chrisant996 commented 1 month ago

Some important questions:

  1. What terminal are you using? The default legacy conhost? Or Windows Terminal? Or a different terminal program?
  2. What text is being selected? Text inside the input line, or text outside the input line?
  3. Is Clink handling the mouse, or is the terminal handling it? Have you specially configured Clink to be able to handle the mouse in the input line?
  4. Is Clink handling the Ctrl-C, or is the terminal handling it? What happens if you run clink echo and then press Ctrl-C?

Unless both the mouse+selecting and the Ctrl-C are handled by the same thing (both by Clink, or both by the terminal), they won't be able to cooperate. For them to cooperate, both have to be handled by the same thing.

It sounds like the terminal is handling the mouse and selection, not Clink. In that case, text anywhere in the screen can be selected, and right click would be interpreted as "Copy".

andry81 commented 1 month ago
1. What terminal are you using?  The default legacy conhost?  Or Windows Terminal?  Or a different terminal program?

conhost

2. What text is being selected?  Text inside the input line, or text outside the input line?

both, but the former sometimes works

3. Is Clink handling the mouse, or is the terminal handling it?  Have you specially configured Clink to be able to handle the mouse in the input line?

didn't change anything, all by default

4. Is Clink handling the Ctrl-C, or is the terminal handling it?  What happens if you run `clink echo` and then press Ctrl-C?

"\C-C"

chrisant996 commented 1 month ago

You can't mix terminal mouse selection and Clink key binding commands. They're completely independent.

Sorry, but there's nothing that can be done to make them work together.

chrisant996 commented 1 month ago

Wait a minute. While in the conhost mouse selection mode, Clink is not active and doesn't even receive any of the input.

I confirmed that with a quick test just now.

Oh, I see what's going on.

Windows 8.1 has some kind of quirk in how it's dealing with console mode changes.

Try running clink set terminal.mouse_input off to make all mouse input go directly to conhost, and never get intercepted by Clink. The side effect of that is you won't be able to use mouse input for Clink itself -- for example, in popup lists.

chrisant996 commented 1 month ago

@andry81 I've been troubleshooting this a bit more on both Win8.1 and Win11.

I'm working on tracking down how the issue correlates with OS version, Quick Edit mode on/off, and the terminal.mouse* settings. If there's a Clink bug, hopefully I'll be able to make a fix. Or if there's an OS issue, hopefully I'll be able to find a workaround.

chrisant996 commented 1 month ago

@andry81 This seems to have nothing to do with Clink:

I use Windows 8.1 and run cmd.exe without Clink in a conhost window. It doesn't matter whether Quick Edit mode is enabled or disabled.

I use the mouse or Alt-Space | Edit | Mark to select text. When I press Ctrl-C, the selection disappears but the text is not copied into the clipboard.

Pressing Enter is what copies the selected text into the clipboard. It's just how conhost works. Clink isn't involved at all.

On Windows 10 and Windows 11, then Ctrl-C seems to be able to copy text after a mouse selection in conhost. But not on Windows 8.1. Maybe it's a feature that was added to conhost in Windows 10. But Clink isn't involved and can't do anything about it.

If you're saying that without Clink on Windows 8.1 you're somehow able to use Ctrl-C instead of Enter to finish the selection and copy it to the clipboard, then that would be surprising and I don't know how that would be possible.

andry81 commented 1 month ago

When I press Ctrl-C, the selection disappears but the text is not copied into the clipboard.

That's right, it has never been working. Not in Win8, nor Win7.

chrisant996 commented 1 month ago

When I press Ctrl-C, the selection disappears but the text is not copied into the clipboard.

That's right, it has never been working. Not in Win8, nor Win7.

Yes. This isn't related to Clink. The same thing happens without Clink. The feature that you want has to come from Windows, but 7 and 8 don't have that feature.

andry81 commented 1 month ago

Yes. This isn't related to Clink. The same thing happens without Clink. The feature that you want has to come from Windows, but 7 and 8 don't have that feature.

Yes, I thought clink has added the feature, because of SHIFT-arrows works.