Skip to content

Conversation

@ofek
Copy link
Contributor

@ofek ofek commented Jul 31, 2025

This fixes output when running commands on Linux. Additionally, this configures the CLI framework with the current terminal dimensions without the fallback to the shutil module which is costly to import. We should see benefits when they merge my PR.

Example of the previous bad output:

image

@ofek ofek requested a review from a team as a code owner July 31, 2025 22:53
@ofek ofek force-pushed the ofek/terminal-size branch from 3953cbc to 3fd5ef4 Compare July 31, 2025 22:58
os.set_inheritable(child_fd, True)

width, height = terminal_size()
termios.tcsetwinsize(self._fd, (height, width))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Luckily this was introduced recently in 3.11. If this didn't exist we could do something like the following (which I was about to do until I discovered it):

s = struct.pack('HHHH', height, width, 0, 0)
fcntl.ioctl(fd, termios.TIOCSWINSZ, s)

@ofek ofek merged commit 17fe374 into main Aug 1, 2025
20 checks passed
@ofek ofek deleted the ofek/terminal-size branch August 1, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants