pytermgui: [BUG] SIGINT exits leave terminal in dirty state
Describe the bug
When sending SIGINT (ctrl-c) to exit ptg
the terminal continues to capture mouse input until the reset
command is issued.
To Reproduce
- Install pytermgui
- Run
ptg
- Exit with
ctrl-c
- Push mouse buttons
Expected behavior Mouse events are not captured.
Screenshots ASCII cast here
System information
$ ptg --version
PyTermGUI v1.1.0
Python: 3.9.2
Platform: Linux-5.10.0-10-amd64-x86_64-with-glibc2.31
Git commit: 47bed90
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 36 (19 by maintainers)
Just now! Sorry about the delay, I’m currently on vacation.
P.S. Make sure you do
pip install -U pytermgui
to make sure it updates!@bczsalba I noticed that, in the
report_mouse
function, thehover
event corresponds to control code1003
. According to the XTerm documentation, this enables both hover and button press tracking, while1002 (press_hold)
enables just button press tracking.However, by default,
WindowManager.run
enables bothpress_hold
andhover
events. Enabling/disabling both of these at the same time seems to cause the dirty terminal state in my case, as when I callrun
myself only specifying["hover"]
for themouse_events
argument, the issue doesn’t appear anymore.This issue was happening independently of the one @stewartad described-- even when removing the blocking
input(event)
, button presses were still being printed as seen in OP’s case, requiring the above to fix.All of this was in GNOME Terminal 3.44.0.
I was also encountering this bug on the latest release (7.4.0). I noticed that it only occurs when I install the library from PyPI, and not when I install the library from Github. I diffed the files to see if there was anything obvious and found this in
context_managers.py
From PyPI:
From Github:
The code is blocking on the
input(event)
call, and if you Ctrl+C here, then the cleanup code below will not run, leaving the terminal dirty, but any other keypress will exit normally.I am experiencing similar issue, but terminal prints symbols on mouse movement
Well I’m certainly glad to hear that! I have no idea what the issue was, what fixed it or when it was fixed but I’m glad it was!
Thank you for the report!