-
Notifications
You must be signed in to change notification settings - Fork 313
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
Add Windows support for raw_display #448
Conversation
1563e39
to
2f15904
Compare
2f15904
to
f4fd669
Compare
self._old_termios_settings = termios.tcgetattr(fd) | ||
tty.setcbreak(fd) | ||
|
||
self.signal_init() | ||
if IS_WINDOWS: | ||
hOut = win32.GetStdHandle(win32.STD_OUTPUT_HANDLE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be hood if such long branches will be in own methods like:
if IS_WINDOWS:
self.windows_signal_init()
else:
self.signal_init()
@@ -274,6 +310,14 @@ def _stop(self): | |||
if self._old_signal_keys: | |||
self.tty_signal_keys(*(self._old_signal_keys + (fd,))) | |||
|
|||
if IS_WINDOWS: | |||
hOut = win32.GetStdHandle(win32.STD_OUTPUT_HANDLE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here windows_stop
will be good method
@@ -395,6 +439,10 @@ def unhook_event_loop(self, event_loop): | |||
""" | |||
Remove any hooks added by hook_event_loop. | |||
""" | |||
if self._input_thread is not None: | |||
self._input_thread.should_exit = True | |||
self._input_thread = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no wait
/ join
?
buf = fcntl.ioctl(self._term_output_file.fileno(), | ||
termios.TIOCGWINSZ, ' '*4) | ||
y, x = struct.unpack('hh', buf) | ||
if IS_WINDOWS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to make dedicated methods for both branches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please split logic to reduce platform specific if
/else
branches size
Restore PR urwid#448 with pick of urwid#447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop globally due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe Skip tests: * TwistedEventLoop is not supported under windows * ZMQEventLoop is not supported under windows
Restore PR urwid#448 with pick of urwid#447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop globally due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe Skip tests: * TwistedEventLoop is not supported under windows * ZMQEventLoop is not supported under windows
Restore PR urwid#448 with pick of urwid#447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop globally due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe Skip tests: * TwistedEventLoop is not supported under windows * ZMQEventLoop is not supported under windows
Restore PR urwid#448 with pick of urwid#447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop globally due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe Skip tests: * TwistedEventLoop is not supported under windows * ZMQEventLoop is not supported under windows
Restore PR urwid#448 with pick of urwid#447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop globally due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe Skip tests: * TwistedEventLoop is not supported under windows * ZMQEventLoop is not supported under windows
Restore PR urwid#448 with pick of urwid#447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop on windows due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe Skip tests: * ZMQEventLoop is not supported under windows
Restore PR urwid#448 with pick of urwid#447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop on windows due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe Skip tests: * ZMQEventLoop is not supported under windows
Restore PR urwid#448 with pick of urwid#447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop on windows due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe Skip tests: * ZMQEventLoop is not supported under windows * `AsyncioEventLoop`, `TornadoEventLoop` and `TwistedEventLoop`: * Issues with asyncio loop (changes between python version, select support) * Twisted and tornado tests show race conditions
* Vterm is fully not supported under windows * Do not import ZMQEventLoop on windows due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe * on windows11 console encoding is detected as cp1252, BTW it's validated manually that cms uses UTF-8 * fix 24 bit colors terminal Skip tests: * ZMQEventLoop is not supported under windows * `AsyncioEventLoop`, `TornadoEventLoop` and `TwistedEventLoop`: * Issues with asyncio loop (changes between python version, select support) * Twisted and tornado tests show race conditions
* Vterm is fully not supported under windows * Do not import ZMQEventLoop on windows due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe * on windows11 console encoding is detected as cp1252, BTW it's validated manually that cms uses UTF-8 * fix 24 bit colors terminal Skip tests: * ZMQEventLoop is not supported under windows * `AsyncioEventLoop`, `TornadoEventLoop` and `TwistedEventLoop`: * Issues with asyncio loop (changes between python version, select support) * Twisted and tornado tests show race conditions
* Restore PR #448 with pick of #447 for `tty_signal_keys` * Vterm is fully not supported under windows * Do not import ZMQEventLoop on windows due to python crash * rework test for event loops to be windows compatible: on windows `select` do not support pipe * on windows11 console encoding is detected as cp1252, BTW it's validated manually that cms uses UTF-8 * fix 24 bit colors terminal Skip tests: * ZMQEventLoop is not supported under windows * `AsyncioEventLoop`, `TornadoEventLoop` and `TwistedEventLoop`: * Issues with asyncio loop (changes between python version, select support) * Twisted and tornado tests show race conditions * Make shared base class for raw display * Reduce amount of copy-paste * Base class is abstract (too huge difference in concrete implementations) * use `selectors.DefaultSelector` instead of `select.select` Automatically select OS specific optimal route by python stdlib.
Restored updated, tested and merged |
I totally missed the comments in March, my apologies. Thanks for taking care of things, this is super duper fantastic! 😃 🍰 🚀 |
Checklist
master
orpython-dual-support
branchtox
successfully in local environment (yes, but I do not have 2.7, 3.5, and pypy at hand)Description:
Inspired by @asmith-kepler's fantastic work in #447, I set out to implement Windows support for raw_display. Turns out that this is all working pretty seamlessly with the latest Windows console improvements. 🎉
Main changes:
socket.socketpair()
instead ofos.pipe()
on all OSes as Windows doesn't support non-socket file descriptors inselect()
. This probably has a tiny amount of overhead, but works across all platforms.