[Tutor] How to get terminal settings

Alan Gauld alan.gauld at freenet.co.uk
Fri Jan 20 00:53:06 CET 2006


Assuming you are on a Unix style OS/terminal you can read the 
output of stty. Look at the rows value

Here are a couple of runs of rows at different terminal sizes:

$ stty -a | grep rows
speed 38400 baud; rows 41; columns 80; line = 0;

$ stty -a | grep rows
speed 38400 baud; rows 26; columns 80; line = 0;

A call to Popen should get you what you want.

An alternative technique, and the one useed by the real 
more/less programmes is to use curses to open a display 
window.

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list