Sign in Join
FPDoc Onlineexperiment

Crt unit

CRT - Turbo Pascal screen and keyboard handling unit.

This chapter describes the CRT unit for Free Pascal, under all of Dos, Linux and Windows. The unit was first written for Dos by Florian Klaempfl. The unit was ported to Linux by Mark May and enhanced by Michael Van Canneyt and Peter Vreman. It works on the Linux console, and in xterm and rxvt windows under X-Windows. The functionality for both is the same, except that under Linux the use of an early implementation (versions 0.9.1 and earlier of the compiler) the CRT unit automatically cleared the screen at program startup.

There are some caveats when using the CRT unit:

  • Programs using the CRT unit will not be usable when input/output is being redirected on the command-line.
  • For similar reasons they are not usable as CGI-scripts for use with a webserver.
  • The use of the CRT unit and the graph unit may not always be supported.
  • The CRT unit is not thread safe.
  • On Linux or other Unix OSes, executing other programs that expect special terminal behaviour (using one of the special functions in the Linux unit) will not work. The terminal is set in RAW mode, which will destroy most terminal emulation settings.
  • The CRT unit stems from the TP/Dos area. It is designed to work with single-byte character sets, where 1 char = 1 byte. That means that widestrings or UTF-8 encoded (ansi)strings will not work correctly.

Procedures and functions

AssignCrtprocedureAssign file to CRT.
ClrEolprocedureClear from cursor position till end of line.
ClrScrprocedureClear current window.
cursorbigprocedureShow big cursor.
cursoroffprocedureHide cursor.
cursoronprocedureDisplay cursor.
DelayprocedureDelay program execution.
DelLineprocedureDelete line at cursor position.
GotoXYprocedureSet cursor position on screen.
HighVideoprocedureSwitch to highlighted text mode.
InsLineprocedureInsert an empty line at cursor position.
KeyPressedfunctionCheck if there is a keypress in the keybuffer.
LowVideoprocedureSwitch to low intensity colors.
NormVideoprocedureReturn to normal (startup) modus.
NoSoundprocedureStop system speaker.
ReadKeyfunctionRead key from keybuffer.
SoundprocedureSound system speaker.
TextBackgroundprocedureSet text background.
TextColorprocedureSet text color.
TextModeprocedureSet screen mode.
WhereXfunctionReturn X (horizontal) cursor position.
WhereYfunctionReturn Y (vertical) cursor position.
WindowprocedureCreate new window on screen.

Types

tcrtcoordtypeType to denote CRT coordinates.

Constants

BlackconstantBlack color attribute.
BlinkconstantBlink attribute.
BlueconstantBlue color attribute.
BrownconstantBrown color attribute.
BW40constant40 columns black and white screen mode.
BW80constant80 columns black and white screen mode.
C40constant40 columns color screen mode.
C80constant80 columns color screen mode.
CO40constant40 columns color screen mode.
CO80constant80 columns color screen mode.
CyanconstantCyan color attribute.
DarkGrayconstantDark gray color attribute.
Font8x8constantInternal ROM font mode.
GreenconstantGreen color attribute.
LightBlueconstantLight Blue color attribute.
LightCyanconstantLight cyan color attribute.
LightGrayconstantLight gray color attribute.
LightGreenconstantLight green color attribute.
LightMagentaconstantLight magenta color attribute.
LightRedconstantLight red color attribute.
MagentaconstantMagenta color attribute.
MonoconstantMonochrome screen mode (hercules screens).
RedconstantRed color attribute.
ScreenHeightconstantCurrent screen height.
ScreenWidthconstantCurrent screen width.
WhiteconstantWhite color attribute.
YellowconstantYellow color attribute.

Variables

CheckBreakvariableCheck for CTRL-Break keystroke. Not used.
CheckEOFvariableCheck for EOF on standard input. Not used.
CheckSnowvariableCheck snow on CGA screens. Not used.
DirectVideovariableUse direct video access. DOS only.
LastModevariableLast screen mode.
TextAttrvariableMask to filter text attribute.
WindMaxvariableLower right corner of currently defined window.
WindMaxXvariableX coordinate of lower right corner of the defined window.
WindMaxYvariableY coordinate of lower right corner of the defined window.
WindMinvariableUpper left corner of currently defined window.
WindMinXvariableX coordinate of upper left corner of the defined window.
WindMinYvariableY coordinate of upper left corner of the defined window.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.