[fpc-pascal] terminal width/height

Michalis Kamburelis michalis at camelot.homedns.org
Sat May 14 08:54:37 CEST 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.
> 
> Thanks,
> David
> 

If you use Video unit, check ScreenWidth/Height variables.

If you use Crt,
- under UNIX look also at ScreenWidth/Height variables.
- Under Win32 (I say it only looking at Crt sources) you should be able 
to use initial values of WindMaxX and WindMaxY (they seem to be 
initialized at the initialization of Crt on Win32 to screen size).

BTW to devels interested in Crt unit:

- under UNIX WindMaxX, WindMaxY, WindMinX, WindMinY are broken. Unix Crt 
implementation uses private variables WinMaxX, WinMaxY, WinMinX, WinMinY 
(without "d" in the middle), I think that this should be changed to use 
public variables WindMaxX, WindMaxY, WindMinX, WindMinY.

- under Win32, functions GetScreenWidth/Height could be made public 
under names ScreenWidth/Height (without "Get"), this would be compatible 
with Unix Crt.

Michalis




More information about the fpc-pascal mailing list