Closed suresttexas00 closed 3 years ago
@magmax .. Can we discuss?? I found the problem. The test suite is substituting its get_char function for the actual function in our code... which works when YOUR readkey was processing the keystrokes (not real keystrokes, but just a stream of values). As a result, when the test suite passes "\x1b ....", the stream returns x1b
and the factory function returns that to the test code. The internal functions for get_char
for linux or windows never get run.
This test suite does not properly test our code. I have just tweaked it to allow passing the factory function test stream...
If you don't like this whole thing, feel free to close it. I admit it is a bit of a mess and maybe you want to start from scratch with what you were doing. I don't like the hacks I implemented around the Travis testing, which created "passing" build, but horrible code...
However, on my own project, I did do a lot of windows testing and mapped most of the windows keys. I would suggest you take advantage of the mappings I made for windows in my other repo: https://github.com/suresttexas00/readkey
I see you already realized about the mess we have to do here. But I think it is better to do the mess here than in a lot of projects.
I started this project thinking it was much easier, but... well, now I am even more happy to have started it, despite maybe it is not the best solution in the world.
Thank you very much for your contributions. I will have a second look as soon as I can.
Not sure where we are with this now... Did you want me to make these changes first, or did you want to approve the pull request and then make the changes yourself?
I've changed the way to use versions. Do not care about them any more. This PR contains a lot of changes. Please, use smaller ones.
Wow, I had forgotten about this. I don't use it anymore and I have no idea where I left off, code-wise. I won't be issuing any more PR's at this time.
Based off of 0.8.0, this version successfully implements the Linux special keys including the ESC.
For both OS types, the new readkey() now wraps a
get_char
method, which is separate from the readchar methods (which only return a character byte). The get_char handles the reading need to get the full keystroke codes.for Linux:
reachar_linux.readchar()
that successfully implements a real blocking bahavior, allowing us to get all queued up characters after an ESC.readchar()
in a non-blocking manner (the default is to block, i.e. wait for a keystroke to be typed).for Windows:
convertchar()
to convert these back to string names like "ctrl_a", if desired.