Skip to content

Provide 80x24 fallback for ansi and vt100 #465

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

Merged
merged 1 commit into from
Mar 31, 2023
Merged

Provide 80x24 fallback for ansi and vt100 #465

merged 1 commit into from
Mar 31, 2023

Conversation

roadriverrail
Copy link
Contributor

Not all terminals will necessarily respond to the TIOCGWINSZ ioctl,
particularly much older ones providing vt100 or ansi terminals, which
will have a fixed 80x24 size. If they respond with some kind of
non-sensical value here, then at least give the ansi and vt100 terminals
their default so they can draw.

Checklist
  • [*] I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • [*] I've branched off the master or python-dual-support branch
  • [*] I've merged fresh upstream into my branch recently
  • [*] I've ran tox successfully in local environment (my pypy isn't set up, but it's otherwise good)
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)
Description:

I've been working with some older machines that present a classic ansi or vt100 terminal, and while ncurses worked just fine with them, the raw_display from urwid did not. I tracked this down to the use of TIOCGWINSZ. This ioctl wasn't providing meaningful dimensions for these old terminals. It looked like urwid was getting 0x0, while screen was getting -1x-1. These terminal types have a fixed width and height as per their termcap descriptions, and they're ubiquitous, so I provided some fallback values should TIOCGWINSZ not give workable dimensions.

I tried to see if a patch like this was rejected in the past, but forgive me if I missed it.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 77.731% when pulling 096ce1f on roadriverrail:fix-zero-dimensions into c93aeb2 on urwid:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 77.731% when pulling 096ce1f on roadriverrail:fix-zero-dimensions into c93aeb2 on urwid:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 77.731% when pulling 096ce1f on roadriverrail:fix-zero-dimensions into c93aeb2 on urwid:master.

@coveralls
Copy link

coveralls commented Feb 16, 2021

Coverage Status

Coverage increased (+0.3%) to 77.795% when pulling 096ce1f on roadriverrail:fix-zero-dimensions into c93aeb2 on urwid:master.

# Provide some lightweight fallbacks in case the TIOCWINSZ doesn't
# give sane answers
if x <= 0 or y <= 0:
if self.term == 'ansi' or self.term == 'vt100':
Copy link
Collaborator

@penguinolog penguinolog Mar 31, 2023

Choose a reason for hiding this comment

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

Suggested change
if self.term == 'ansi' or self.term == 'vt100':
if self.termin('ansi', 'vt100'):

And will be good to join 2 if's

@penguinolog
Copy link
Collaborator

Please rebase: Travis not providing logs (technically not functional) and without logs hard to see what was wrong with current PR

@roadriverrail
Copy link
Contributor Author

Rebased and made the change you suggested (I think). This was apparently open for like 2 years and I've completely forgotten it existed, so forgive me if I'm a little slow on the uptake here.

Copy link
Collaborator

@penguinolog penguinolog left a comment

Choose a reason for hiding this comment

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

This 2 it's can be squashed and LGTM

Comment on lines 686 to 687
if x <= 0 or y <= 0:
if self.term in ('ansi','vt100'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if x <= 0 or y <= 0:
if self.term in ('ansi','vt100'):
if (x <= 0 or y <= 0) and self.term in ('ansi','vt100'):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Not all terminals will necessarily respond to the TIOCGWINSZ ioctl,
particularly much older ones providing vt100 or ansi terminals, which
will have a fixed 80x24 size.  If they respond with some kind of
non-sensical value here, then at least give the ansi and vt100 terminals
their default so they can draw.
@penguinolog penguinolog merged commit 0a5518e into urwid:master Mar 31, 2023
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