Skip to content
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

use setcbreak instead of setraw, fixes #53 #54

Merged
merged 1 commit into from
Feb 28, 2021

Conversation

insidewhy
Copy link
Contributor

@insidewhy insidewhy commented May 21, 2020

Tested locally, works much better. setcbreak is definitely a better option than setraw.

See https://www.tutorialspoint.com/terminal-control-functions-in-python for more info.

@magmax magmax merged commit 3317549 into magmax:master Feb 28, 2021
@C0D3D3V
Copy link
Contributor

C0D3D3V commented Mar 8, 2021

This breaks already functioning systems like cutie.
Because the cursor behaviour is quite different.

@insidewhy
Copy link
Contributor Author

@C0D3D3V You could build cutie with just readchar? I thought it was using something like curses. Interesting. I would have thought the majority of use cases for readchar wouldn't want to alter the way the enter key works, is it not something you can work around, or maybe there was already a work around in your code that this breaks and you can remove?

@C0D3D3V
Copy link
Contributor

C0D3D3V commented Mar 9, 2021

Yes, I was a bit hasty, sorry. Cutie still works. Only the keycode of the enter key is wrong as I pointed out in my PR.

@magmax
Copy link
Owner

magmax commented Mar 9, 2021

Wow... Cutie is very similar to inquirer, the reason that made me write readchar XD

Do you think we should revert this?

@insidewhy
Copy link
Contributor Author

I think the majority of people don't want the enter key to do weird unexpected stuff and it should be easier to work around this being on than this being off

@magmax
Copy link
Owner

magmax commented Mar 9, 2021

Reverted as v3.0.4

@C0D3D3V
Copy link
Contributor

C0D3D3V commented Mar 9, 2021

I just tested inquirer with the setcbreak mode, there the same happens as with cutie, the enter key is not recognized because in the mode another keycode is generated (\x0a instead of \x0d). That is actually all, if you adjust the keycode, then it should work as before. But I have not tested everything... that should perhaps be made before such a change (also across all platforms) so that the created tools do not break.

We could also define the enter code to be both "\x0d" and "\x0a", then the problem would not exist.

@insidewhy
Copy link
Contributor Author

Reverted as v3.0.4

Noooo

@magmax
Copy link
Owner

magmax commented Mar 9, 2021

I cannot break previous way of work.
I will add a way to choose if you want one or another later.
Right now, @insidewhy , you can fix your program to the version 3.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants