[Tutor] How to get terminal settings
Vincent Zee
zenzee at xs4all.nl
Thu Jan 19 22:05:27 CET 2006
On Thursday, 19 January 2006 at 12:37:38 -0800, Danny Yoo wrote:
>
>
> On Thu, 19 Jan 2006, Vincent Zee wrote:
>
> > say you want to write a more-like program. How do you know how many
> > lines the terminal window can display.
>
> Hi Vincent,
>
> It's possible that this information might already be in your environment.
> If you're using the 'bash' shell, and if the 'checkwinsize' option is set
> in bash, then bash should keep track of the window size through LINES and
> COLUMNS. According to the "Art of Unix Programming":
>
> http://www.faqs.org/docs/artu/ch10s04.html
>
> those variables are fairly standard and lots of programs use them. But I
> don't know if other shells go out of their way to maintain consistancy
> with the current terminal size on terminal resizing.
>
> If you want to get at the environment variables, take a look at the
> 'os.environ' dictionary:
>
> http://www.python.org/doc/lib/os-procinfo.html#l2h-1508
>
>
> Alternatively, if you're on Unix, the 'curses' module will get you the
> information you want.
>
> http://www.python.org/doc/lib/module-curses.html
Hi Danny,
thank you for your reply.
I want the program to run on Freebsd and on MacOSX.
On FreeBSD I use the tcsh and on Mac its bash or tcsh.
I looked at the curses module and also to the cursus howto on
python.org but I find it still a bit unclear on how to use it.
There being curses, ncurses and a curses wrapper.
I'm a little confused.
The os.environ didn't give me any hints to screen size so maybe
curses is the way to go.
Any pointers to other curses howto's?
/\
Vincent
More information about the Tutor
mailing list