Closed bczsalba closed 2 years ago
This is not directly related, but this API could solve a lot of issues. It should allow using ANSI sequences normally on Windows terminals.
Doing something like this inside of terminal.py
works great. Not 100%, but it is a solution that works. It has a quirk where if it updates the size before the user is done changing the size it could resize incorrectly.
I can make a pull request for this later today
265 else:
266 from threading import Thread
267 Thread(name="windows_check_resize", target=self._windows_check_resize, daemon=True).start()
268
269 self._diff_buffer = [
270 ["" for _ in range(self.width)] for y in range(self.height)
271 ]
272
273 def _windows_check_resize(self):
274 from time import sleep
275 _previous = get_terminal_size()
276 while True:
277 if _previous != get_terminal_size():
278 self._update_size()
279 _previous = get_terminal_size()
280 sleep(.1)
It has a quirk where if it updates the size before the user is done changing the size it could resize incorrectly.
I think that actually is a bug in the Layout
class, since the same behaviour props up on Linux/MacOS terminals as well (it's particularly easy to trigger in sandbox/layouts.py
, but otherwise it's not very common).
Looks good! It might be worth ensuring your implementation is clear of the issue in #25, btw.
I don't see anything that would recreate the issue.
Also, I have noticed the bug only happens when shrinking the size and works most of the time if not always when increasing the size.
Is your feature request related to a problem? Please describe. The window size change signal (
SIGWINCH
) is not built intosignal
, and PyTermGUI just skips handling it on Windows machines.Describe the solution you'd like Some kind of implementation (hopefully up-to-par with UNIX) for resize events.
Describe alternatives you've considered Creating an asynchronous monitoring loop (#19). Turns out it hangs the program.
Is this feature present in other TUI products? It is in Textual, not sure about others.
Additional context We probably have to interact with the windows API (similar to how Textual does it) This is probably a decently sizeable undertaking, and one that I myself cannot take on at the moment.
Any help would be greatly appreciated here!