New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windows: mouse wheel scroll broken since v605 #379
Comments
Could you be more specific which shell is affected and how it can be reproduced? I have no issue with the scroll using less version version 633 in Windows Terminal. Is it Dos shell C:\WINDOWS\system32\cmd.exe affected? |
I just tested less version 590 with both cmd.exe and Windows Terminal. I do not see any difference in mouse scroll behavior with version 633. Windows Terminal scroll works fine and cmd.exe scroll is disabled when less is launched. I could not notice anything happening to the prompt either - it stays the same in both cmd.exe and Windows Terminal. |
Apologies if my description was not clear enough. Let me retry.
What you're describing is when But I was referring to mouse wheel scroll when invoking So the issue happens to me both in windows terminal and in cmd.exe window, but let's focus on cmd.exe window, with these steps:
Expected result (and actual result up to v603): Actual reauls from in v605 and later: Here's a screencast using the official v590 and v608 builds, in cmd.exe console on Windows 10: less-mouse.v590-v608.mp4 |
Was there only my UTF change between v590 and v608? How did you narrow down the cause of the problem to my commit? I just want rule out the other changes before starting digging. The UTF change is quite simple. I do not see anything in the code that can affect the mouse besides the black box function ReadConsoleInputW(). There is no memory copy functions, only simple assignments to stack variables - we can rule out memory corruption here. Though I don't know what ReadConsoleInputW() does internally, I bet it messes with the mouse somehow. |
I (git) bisected it to your commit, compiling and testing in every step of the bisection.
Same. I couldn't put my finger on anything which looks wrong, and yet, for me it breaks in exactly this commit. Can you at least confirm it also breaks for you in this commit (or at least when comparing v590 to v608)? |
If you want, here are my builds of the earlier commit (less.v603-2-g1101069.exe), and the offending commit (less.v603-3-g7b977a2.exe). They're with debug symbols, if you need, built using gcc 13.1 x86_64 from w64devkit. EDIT: reuploaded the same binaries but with different names. I previously used |
I think I found the fix. See my pull request #381. |
On an unrelated subject, should funcs.h and help.c be added to the code base? It is hard to do development if the dependencies are missing. Also I have a suggestion: split Linux and Windows code into different files. This will make it way easier to maintain the code. |
funcs.h is generated at help.c is generated at perl mkhelp.pl < less.hlp > help.c If you don't have perl but do have sh.exe mkhelp.sh < less.hlp > help.c Where mkhelp.sh is: #!/bin/sh
# same as mkhelp.pl, but using posix sh and od
od -b -v -A n | (
d=$(LC_ALL=C date -u)
echo "/* This file was generated by mkhelp.sh from less.hlp at $d */"
echo '#include "less.h"'
echo 'constant char helpdata[] = {'
while read line; do # octal values, typically 16 per line
buf=" " # without line buf it could be slow without builtin printf
for o in $line; do
buf="$buf 0$o,"
done
echo "$buf"
done
echo ' 0 };'
echo 'constant int size_helpdata = sizeof(helpdata) - 1;'
)
Nice (didn't try it out yet). Minor nits: there's some space/tab issue at the patch at the line of Off topic for the mouse wheel subject but relating to the unicode handling - I think that the unicode patch doesn't take surrogate pairs into account. I.e. it always tries to convert a single |
I just tested it, and can confirm it fixes the issue of mouse wheel scroll for me too. |
You have a point about handling Unicode. It was just the first shot at handling it. It will take some work if we want to handle all code bases. I have a few minor improvements/edge cases handling to add. I will send another pull request. On the funcs.h and help.c - I think there should be some pure Windows solution, just using strait VC environment. |
I intend to send a PR for this, at least for I don't know about pure windows solution. Do you mean like powershell? or compiling a C program to be used instead of these scripts? What else do you have on windows which can be used to generate funcs.h and help.c? Windows is pretty weak in the utilities and scripting departments... But if someone adds a good solution, it could be nice, though personally I'm fine with the posix utilities solution. |
For future reference: the exact reason why the Unicode support effectively broke all mouse-related things is due to this sequence of events:
And so mouse never worked since unicode support was added... The underlaying issue is that the unicode code at A trivial fix would be to ensure that unicode is not 0, by changing this at // If multibyte character, return its first byte
if (currentKey.ascii != currentKey.unicode) into this: // If multibyte character, return its first byte
if (currentKey.unicode && currentKey.ascii != currentKey.unicode) or even simpler, just test that it's indeed more than one UTF-8 byte: // If multibyte character, return its first byte
if (currentKey.unicode > 127) (confirmed fixing the mouse wheel issue) |
Fixed in 6fd6739 by avih's last suggestion. |
Is it waiting for me to close it? |
I prefer that the original reporter do the close when possible, but I will do it eventually if you do not. |
Sure. Different projects have different preferences... now I know ;) Thanks for merging a fix. |
Specifically, mouse wheel scroll is broken on Windows since 7b977a2 ("Added support for UTF-8 commands on Windows (#261)") up to and including current master (v635).
@Konstantin-Glukhov since it's your commit, can you (or someone else) confirm that this commit broke mouse wheel? any idea how to fix it?
I debugged it a bit (at this exact commit), and this line:
7b977a2#diff-1de596521a6bd2aaf938f5f87ef7be66407a9e4ee616f3f923574a9a1337a88cR2874
is still getting the negative/non-negative value correctly on scroll down/up, so it does not seem like an issue of incorrect
dwButtonState
value.So I couldn't put my finger on anything which looks wrong, but it doesn't scroll. Scrolling the wheel also seems to mess with the prompt (the status line).
In the the previous commit ("open v604") it scrolls fine and the prompt is fine too.
I didn't try to follow it further.
The text was updated successfully, but these errors were encountered: