How to get terminal width?

Donn Cave donn at u.washington.edu
Wed May 3 20:32:57 EDT 2000


Quoth kc5tja at garnet.armored.net (Samuel A. Falvo II):
| In article <8457258D741DD411BD3D0050DA62365907A13D at huina.oceanic.com>, Doug
| Stanfield wrote:
| >COLUMNS is there on my just installed Mandrake 7, a new Storm install, a Red
| >Hat 5.2, 6.1, and a Mandrake 6.x.  In my world thats almost universal,
| >although the sometimes accessed Solaris system doesn't have it.
|
| With the example you gave above, it's anything *but* universal.  Both Storm
| and Mandrake are RedHat derivatives.
|
| However, I would like to point out that my Debian Potato installation has
| COLUMNS defined.  It would be more useful if it also had a ROWS variable set
| up as well.  :)

That's hysterical.  The Linux I have at hand is none of the above, and
I don't have COLUMNS.  I don't know who normally sets this up, though,
and for all I know it could be because I connected via ssh and not
telnet or rlogin.  That reminds me of another point about COLUMNS -
if you resize your window does COLUMNS change?  That's a question I
I can't check, having access to no system that supports it, but it seems
pretty unlikely.

| The question I'd like to know is, is this a POSIX requirement at all?  That
| might prove to be useful research for when targetting applications that
| require knowledge of terminal width.

I don't know for sure, but I greatly doubt that it's there.  The best
I can say is that the "stty" command appears to be a X/Open Unix standard,
but whether there's any mention of a standard format for the output of
"stty -a" I don't know.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list