merge request: on windows return str and linux use cbreaker and overwrite '\n' with '\r' #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'd like to introduce this pull request to make below fix/improve:
readchar
function on windows 10 and linux platformSo even on win 10 I think there should be a decode operation on the return from
msvcrt.getch()
.setcbreak
instead ofsetraw
on linux platform to avoid unwanted, mysteriously-generated blank characters, then overwrite the result by the desired code of "ENTER", instead of usingsetraw
and bear the blank characters.readchar
is running there is no linefeed after each print #53 and (s)he provided a fix in pull request use setcbreak instead of setraw, fixes #53 #54 by changingsetraw
tosetcbreak
. And this was released in v3.0.1.readchar
function to\x0a
(Line feed,'\n'
) from\x0d
(Carriage Return,'\r'
). Where the latter is desired by some other lib (likeinquirer
) from @C0D3D3V 's test.\x0a
(Line feed,'\n'
) and\x0d
(Carriage Return,'\r'
). Also on windows since the line break is defined as '\r\n', but on linux it is defined as '\n' only. I think this should be whysetcbreak
returns\x0a
(Line feed,'\n'
) on linux.setcbreak
instead ofsetraw
to avoid the white spaces issue, and then overwrite the the return to the desired "ENTER KEY" code afterwards in the function (as mentioned before, there should be no modern keyboard which have separate key to generate both\x0a
(Line feed,'\n'
) and\x0d
(Carriage Return,'\r'
)).@magmax would you give this some consideration please.