getting *term window dimensions w/o curses
sill at optonline.net
Sun Aug 5 16:42:51 CEST 2001
On 05 Aug 2001 01:05:15 +0300, Erno Kuusela <erno-news at erno.iki.fi> wrote:
> In article <slrn9mopj4.26a.sill at sill.silmarill.org>,
> sill at optonline.net (Andrei Kulakov) writes:
>| Is there some way to get aterm (and other terms) window dimension(s)
>| without curses?
> use google :)
I'm probably not using a good search string, but search for
python get term size without curses
returned nothing on first 2 pages of hits in google groups..
Anyway, this solution doesn't work in 2.1 - termios module doesn't
have this attribute, (TERMIOS is deprecated and doesn't have it either).
>> # Eep! this next should be made rather more portable (ie. fallback to
>> # env vars, then tigetstr("lines"), etc).
>> def getheightwidth():
>> height, width = struct.unpack(
>> "hhhh", ioctl(0, TERMIOS.TIOCGWINSZ ,"\000"*8))[0:2]
>> return height, width
> -- erno
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline
More information about the Python-list