How to get terminal width?
Bjorn Pettersen
bjorn at roguewave.com
Fri May 5 14:23:10 EDT 2000
Donn Cave wrote:
>
> Quoth Bjorn Pettersen <bjorn at roguewave.com>:
> | Paul Jackson wrote:
> | >
> | > "stty size" isn't defined on my Irix box, but:
> | >
> | > tput cols
> | >
> | > works on each of my Irix, SuSE and TurboLinux boxes,
> | > issuing simply the number of columns.
> |
> | Well, we're getting closer :-)
> |
> | The above doesn't work on:
> |
> | SunOS 4.1.4 (not present)
> | SunOS 5.4 (wrong result)
> |
> | But does work on:
> |
> | RedHat 6.0
> | Solaris 2.6, 2.7 (7), 8
> | HPUX 10.20, 11
> | AIX 4.2, 4.3
> | IRIX64 6.2, 6.5
> | Dec 3.2
>
> And it works on
> FreeBSD 4.0, and
> BeOS 4.5 and 5.0
>
> However - "tput" is really mainly about terminal-specific information
> retrieved from termcap/terminfo, and that shows in a couple of ways.
> On BeOS, and I bet a few other platforms, I get "80" regardless of
> my actual window size. It can get the information from the terminal
> description, and that's probably legitimate if not ideal. Tput also
> fails when the terminal type is unknown (a marginal problem, but could
> be worse than you might think, if the platform suffers from the all
> too common terminfo vs. termcap split.) All this goes back to the
> dark ages when we had real terminals, with more or less fixed screen sizes.
I also got 80 on SunOS 5.4, but I got the correct result on all the
others. Probably means that if you get back 80, you really can't tell
if it's real or not though...
-- bjorn
More information about the Python-list
mailing list