malxau / yori

Yori is a CMD replacement shell that supports backquotes, job control, and improves tab completion, file matching, aliases, command history, and more.
http://www.malsmith.net/yori/
MIT License
1.23k stars 31 forks source link

"Ctrl Click Select" doesn't work under Windows Terminal #33

Closed spex66 closed 2 years ago

spex66 commented 4 years ago

I've jumped on the Yori train and enjoy it :) context and version:

issue: What I cannot get to work is "ctrl click select", which works fine when yori is started from a simple CMD terminal.

solution approaches:

request:

malxau commented 4 years ago

As far as I know Windows Terminal still doesn't have full mouse support. The current release (0.10) added support for VT based mouse support but the release notes say this does not extend to the "traditional Win32 API." I don't know whether this is something they're working on or what the timelines for it would be, and I can't find it in their set of issues.

I'd really rather not try to use the VT based mouse support. I've tried to point out to the Terminal folks this in the past, but the difference between Linux and Windows is Linux has helper libraries such as ncurses so that an application doesn't need to read raw characters and maintain its own VT state machine to distinguish keystrokes from escaped mouse commands. Windows doesn't have that, at least not inbox, and it's a fairly substantial pile of code to keep and maintain. Ideally Win32 would be that code, translating the VT sequences emitted from the terminal into clearly discrete events that applications can consume, which is what ReadConsoleInput has been doing up until now.

If I were forced to implement this, I'd end up rewriting Win32 on top of VT, and it makes more sense to do that once where all applications can use it, rather than every application doing it for itself.

graphixillusion commented 4 years ago

For me doesn't work in CMD either. To make it works i need to force YORIQUICKEDIT=1 in the env variables. Only one time worked without the env but i didn't understand how. Is there any way to make it works without the variables? And, how to make it works through an ssh session too? Thank you!

malxau commented 4 years ago

When using the traditional console (as opposed to Windows Terminal), make sure Quickedit is disabled. The traditional console offers you the choice of either handling all mouse input itself, implementing its own selection, or giving the mouse input to applications to handle. YORIQUICKEDIT=1 is automating this process by telling the console to give it mouse input; this can be done without the environment variable by changing the shortcut's properties. Note though that this means console selection will be disabled when running other command line programs from that shortcut. For more information, see http://www.malsmith.net/yori/guide/#mouse .

As far as SSH, it looks like this is not currently possible. Yori can only act on mouse input if it is told about mouse input, and that does not appear to occur with SSH. Note that making this work would require the local console to generate sequences describing the mouse input to send to the remote host and have the remote host re-translate those back into Win32 mouse events. That sounds exactly like the missing piece described earlier in this issue.

graphixillusion commented 4 years ago

@malxau thank you for the explanation. I've read already that section in the documentation but i i can't find the section on how to enable/disable quickedit. Btw, i've installed it through scoop and with the default installation, when i start yori, the ctrl+click mouse doesn't work (tried with classic CMD). It starts working only after the setup of the env variable YORIQUICKEDIT=1.

malxau commented 4 years ago

CMD is an alternative shell to Yori which does not implement this feature. I assume what you're referring to is the traditional console, as opposed to Windows Terminal. The traditional console has a series of properties that can be configured per shortcut, per program, and per user - it's quite a mess. The "easiest" way to set these is on the shortcut properties. I'm not familiar with Scoop or where it puts things, so this may not match exactly what you're seeing.

With the default installer on Windows 10, if you have a shortcut on your desktop, right click, select properties. If it's in the start menu, right click, select more, then click open file location. From there you can right click the shortcut and select properties. Under the options tab there's a checkbox labelled "QuickEdit Mode". Ensure that is deselected, then launch Yori again from that shortcut.

If running Windows 8.1 and the shortcut is in the start menu, select the down arrow to view all programs, right click, select open file location, then right click the shortcut, select properties, etc.

In Windows 7 and earlier, you can just right click and select properties of any item in the start menu.

graphixillusion commented 4 years ago

@malxau You are right. By default quickedit mode is enabled. But that tab appears only on classical link file. Scoop manage links in a different way, it creates a "shim". It's useful becouse it auto adds any executables to the env variables, so i can call yori from anywhere. So according to your explanation, the only way to do this is with the YORIQUICKEDIT=1 variable.

malxau commented 4 years ago

My explanation is incomplete. There are three different ways this preference is stored: in the shortcut; per application in the registry; or user level defaults.

If scoop launches Yori without using a shortcut, clicking the system menu in the top left of the window and properties should change the per application registry setting. The system menu in the top left and defaults should change the per user setting. There's no good UI that I know of to delete the per application registry setting, so I personally modify the user defaults and try to leave all shortcuts and applications referring to those; but if you'd like Yori to have different settings to CMD-based windows then changing the application is the only way.

Note that the registry setting is derived from the window title. What is the default title that Scoop launches Yori with?

graphixillusion commented 4 years ago

@malxau scoop just install it: after installation, i can start it directly from the cmd shell, typing "yori". After launch, the title will changes to: "CMD - yori". I followed your instructions and i disabled the quickedit setting in the option tab inside top left corner system menu --> properties. Now it's working as intended. Thank you very much again for the complete explanation.

malxau commented 3 years ago

Going back to where this started, Windows Terminal 1.9 includes Win32 mouse support and Ctrl+Click works there. This requires YORIQUICKEDIT=1 in order to disable quickedit and allow Yori to observe mouse events. The rest of the conversation in this issue about configuring quickedit does not apply to Terminal, and I don't (currently) know how the user configures this setting, but YORIQUICKEDIT allows Yori to configure it programmatically.

With that out of the way, it's feasible to use the two together, so I'll probably have quite a few commits to make them work together better landing soon.

mross002 commented 3 years ago

Excellent news - I just upgraded to Windows Terminal v1.9.1942.0 (stable build released yesterday), and can confirm that ctrl+click now works with my Yori profile from within Windows Terminal!!!

I've been switching back and forth between both apps as my default for the past year or so depending on the type of work I'm doing at the time, as the ctrl+click support has been a deal breaker for me from within WT, and am very happy to now be able to use both at the same time and am setting Yori as my default WT profile. Thanks @malxau for all your great work!