IngoMeyer441 / simple-term-menu

A Python package which creates simple interactive menus on the command line.
MIT License
505 stars 44 forks source link

Ability to turn on terminal echo #6

Closed ilyas-dazn closed 4 years ago

ilyas-dazn commented 4 years ago

I'm using simple-term-menu as part of a program I'm working on which requires taking user input. After displaying the first menu in my program then any calls to input() later on will result in the user not being able to see the text they type. I know this is due to the changing of the terminal settings as part of the initialisation of the TerminalMenu object and was wondering if I could reset this before taking user input so that users are able to see what they type

IngoMeyer441 commented 4 years ago

Hey, thanks for using my project and reporting this problem! Are you maybe using an old version? What you describe was a bug in version v0.6.0 which came up with the new preview feature. The latest version is v0.6.7.

ilyas-dazn commented 4 years ago

Hi @IngoHeimbach ,

I have updated to the latest version and everything seems to be working fine, thanks.

Can you point me to the changes which fixed this issue, I'm keen to have a look.

IngoMeyer441 commented 4 years ago

I am glad the issue is really fixed. :smile: In v0.6.0 I had to rearrange quite a lot of code lines and that led to a copy-paste error. The terminal is initialized twice, first in _init_term and then in show. The problem is that the initializing routine saves the old terminal state, so it can be restored in _reset_term when show is exited. Calling the init routine twice overwrites the old terminal state, therefore it cannot be restored on exit which leads to disabled echo and an invisible cursor. v0.6.0 has some other issues which are (hopefully) fixed in v0.6.7. I did my tests in zsh and zsh does some cleanup logic itself, so first I did not notice these bugs at all. Now I run my tests in bash.

ilyas-dazn commented 4 years ago

Makes sense. Thanks again for your assistance. Will be closing this issue now