Skip to content

Improved routine for terminal dimensions. Works on windows too. - #127

Merged
buxtronix merged 3 commits into
google:masterfrom
harro:terminal-compatibility
Oct 30, 2024
Merged

Improved routine for terminal dimensions. Works on windows too.#127
buxtronix merged 3 commits into
google:masterfrom
harro:terminal-compatibility

Conversation

@harro

@harro harro commented Oct 2, 2024

Copy link
Copy Markdown
Collaborator

No description provided.

@google-cla

google-cla Bot commented Oct 2, 2024

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment thread textfsm/terminal.py
except (ImportError, ModuleNotFoundError):
pass

__version__ = '0.1.1'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed as this was a legacy of terminal.py being its own package.

Comment thread textfsm/terminal.py Outdated
Comment thread textfsm/terminal.py Outdated
# Mutually exclusive to the paging of text and overrides that behaviour.
if opt in ('-s', '--size'):
print('Length: %d, Width: %d' % TerminalSize())
print('Width: %d, Length: %d' % TerminalSize())

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the only user facing change.

@harro

harro commented Oct 3, 2024

Copy link
Copy Markdown
Collaborator Author

Slight change in behaviour, unlikely to be observed by users except for a corner case where environment vars are different (for some reason?) from the terminal size itself.

From https://github.com/python/cpython/blob/main/Lib/shutil.py#L1438 we see that the standard function uses the environment vars in preference to interrogating the terminal itself. The code being replaced here would only fell back to using the environment vars if the call to the terminal failed.

The new behaviour is probably preferable.

@buxtronix
buxtronix merged commit c31b600 into google:master Oct 30, 2024
jhogg pushed a commit to jhogg/textfsmplus that referenced this pull request Dec 16, 2025
…le#127)

* Improved routine for terminal dimensions. Works on windows too.

* Improve clarity or variable names

* Remove TerminalSize function .... no longer needed
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.

2 participants