nano-for-windows icon indicating copy to clipboard operation
nano-for-windows copied to clipboard

unexpected behavior of `^V` key combo

Open chawyehsu opened this issue 1 year ago • 7 comments

cut/copy and paste will output garbled or invisible text.

example bindings

bind ^X cut main
bind ^C copy main
bind ^V paste main 

Open a file, nanorc for example, use copy/cut binding to copy/cut a line of text, and try to paste with paste binding to a new line.

The same configuration works with nano-win.

chawyehsu avatar Mar 05 '23 12:03 chawyehsu

Quite unexpected. I can't duplicate the issue. I have that exact combination and works not only in Windows Terminal, but also in Wincon, though SSH from Windows or from a Linux system. Could you please describe the setup you are using? I can't do anything without a clear description of the environment.

See here a demo session of copy-n-paste I have just recorded accessing a Windows system from a Linux terminal: ses

okibcn avatar Mar 05 '23 15:03 okibcn

Please note that ^V in Windows Terminal is captured by the terminal app, you have to unbind that key from WT to be usable in WT.

No, it does nothing with WT, not even work in PowerShell/ConsoleHost. Recorded in a brand new Windows 10 VM with a fresh environment, no custom nanorc, no custom PowerShell settings:

nano

Notice the difference with lhmouse's nano-win.

chawyehsu avatar Mar 05 '23 17:03 chawyehsu

Could you please test pate with another key combo such as ^A or ^B, ^D in .nanorc? Just to see whether the problem is the ^V capture or the underlying function.

I am working on integrating the clipboard with the windows clipboard which would eliminate this problem completely.

okibcn avatar Mar 05 '23 17:03 okibcn

Could you please test pate with another key combo such as ^A or ^B, ^D in .nanorc? Just to see whether the problem is the ^V capture or the underlying function.

I just tested with ^A and ^D, and both worked.

chawyehsu avatar Mar 05 '23 17:03 chawyehsu

Thanks. The problem is then the capture of ^V from windows. The same happens with WT. When you press ^V You are actually pasting whatever is in the windows clipboard. Depending on the encoding nano understands it or not. Windows 10 is not fully UTF-8 friendly, so the wincon, the main reason Microsoft deprecated it in favor of Windows Terminal.

The fix with the Windows clipboard will solve that while allowing easy copy-n-paste to/from nano without disabling the mouse in nano.

okibcn avatar Mar 05 '23 18:03 okibcn

In the meantime, you can always disconnect the Ctrl-V combo from Windows Terminal, something required for other editors such as vim. Just read this: https://stackoverflow.com/a/65109836/7691477

Other terminal apps probably don't have the flexibility of overriding the windows key shortcuts. This is why I am implementing the windows clipboard within nano.

okibcn avatar Mar 06 '23 05:03 okibcn

In the meantime, you can always disconnect the Ctrl-V combo from Windows Terminal, something required for other editors such as vim. Just read this: https://stackoverflow.com/a/65109836/7691477

Not my case, I use Shift + Insert most of the time, I don't have ^V combo for my Windows Terminal.

chawyehsu avatar Mar 06 '23 05:03 chawyehsu