-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Is there any reason the ws_xpixel
and ws_ypixel
fields of the TIOCSWINSZ call are always 0? Naively, shouldn't it be possible to replace
def _setwinsize(fd, rows, cols):
# Some very old platforms have a bug that causes the value for
# termios.TIOCSWINSZ to be truncated. There was a hack here to work
# around this, but it caused problems with newer platforms so has been
# removed. For details see https://github.com/pexpect/pexpect/issues/39
TIOCSWINSZ = getattr(termios, 'TIOCSWINSZ', -2146929561)
# Note, assume ws_xpixel and ws_ypixel are zero.
s = struct.pack('HHHH', rows, cols, 0, 0)
fcntl.ioctl(fd, TIOCSWINSZ, s)
with
def _setwinsize(fd, rows, cols, pixel_height=0, pixel_width=0):
# Some very old platforms have a bug that causes the value for
# termios.TIOCSWINSZ to be truncated. There was a hack here to work
# around this, but it caused problems with newer platforms so has been
# removed. For details see https://github.com/pexpect/pexpect/issues/39
TIOCSWINSZ = getattr(termios, 'TIOCSWINSZ', -2146929561)
# Note, assume ws_xpixel and ws_ypixel default to zero.
s = struct.pack('HHHH', rows, cols, pixel_width, pixel_height)
fcntl.ioctl(fd, TIOCSWINSZ, s)
I ask because of a long chain of trying to figure out why I couldn't get some things to display correctly in a Poetry shell, which uses pexpect (which uses this). On at least my kernel (Linux 6.10), the terminal is responsive to the values supplied in those fields of the struct. Ideally, it would be nice for pexpect to be able to forward size changes to its children beyond just row and column counts.
I noticed that an old issue mentions portability problems on FreeBSD (pexpect/pexpect#39), but that involved the ioctl
call having a different value. Perhaps someone better informed than me can confirm that implementing this breaks things on other systems.