[fpc-pascal] terminal width/height

Michael Van Canneyt michael at freepascal.org
Sat May 14 09:34:44 CEST 2005



On Fri, 13 May 2005, David Emerson wrote:

> Hi all,
> 
> Is there a function to query the terminal width and height, as a number of characters?
> 
> For example, in windows 98, the terminal is always 80 characters wide, but the height varies; in linux, the height and width can both change, even while the program is running. I'm throwing some text up on the screen and would like to be able to format it to fit the terminal width and height.

On unix, use fpioctl:

fpioctl(stdinputhandle, TIOCGWINSZ, @WS);

where ws is TWinSize:

  TWinsize = packed record
    ws_row,
    ws_col,
    ws_xpixel,
    ws_ypixel : word;
  end;

fpioctl is in unit unix, TWinSize in unit termio.

Michael.




More information about the fpc-pascal mailing list