Message150722
Following comments by Martin and Victor, here is next version: termsize.diff.4
Changes:
- just check for defined(MS_WINDOWS) and rely on <windows.h>.
- rename query_terminal_size to get_terminal_size_raw
This way it should be clearer that the second one is low-level,
and should be less exposed. I don't want to call it
_get_terminal_size() because it is not just an implementation
detail and would sometimes be called directly.
- NotImplementedError is gone. get_terminal_size_raw() is not
defined if not possible.
Non-changes:
- sys.__stdout__.fileno() is not changed to 1, because as Antoine
pointed out, it is set at runtime.
- STDOUT_FILENO: not defined on windows, so just use 1 and add a comment
- fd argument is retained, because we might want to test terminals
opened with openpty.
- two functions: still there. I think that get_terminal_size() should
provide an easy-to-use, even trivial-to-use, way to get a sensible
value without writing a wrapper. In the _majority_ of cases the
wrapper would be something like get_terminal_size() currently.
- named tuple: like Antoine said, it gives nice syntax.
- testing for <sys/ioctl.h>: in termios and other modules, setup.py
first tests if we are on unix. But there might be unices without
TIOCGWINSZ, and non-unix systems where TIOCGWINSZ _is_ defined,
so it seems a functional test is simpler and more robust.
Tested on linux and windows XP. |
|
Date |
User |
Action |
Args |
2012-01-06 12:30:18 | zbysz | set | recipients:
+ zbysz, loewis, amaury.forgeotdarc, pitrou, vstinner, giampaolo.rodola, Arfrever, denilsonsa, neologix, rosslagerwall |
2012-01-06 12:30:17 | zbysz | set | messageid: <1325853017.71.0.936491533882.issue13609@psf.upfronthosting.co.za> |
2012-01-06 12:30:17 | zbysz | link | issue13609 messages |
2012-01-06 12:30:16 | zbysz | create | |
|