video unit
Screen handling unit.
The Video unit implements a screen access layer which is system
independent. It can be used to write on the screen in a system-independent
way, which should be optimal on all platforms for which the unit is
implemented.
The working of the Video is simple: After calling InitVideo,
the array VideoBuf contains a representation of the video screen of
size ScreenWidth*ScreenHeight, going from left to right and top to
bottom when walking the array elements: VideoBuf[0] contains the
character and color code of the top-left character on the screen.
VideoBuf[ScreenWidth] contains the data for the character in the
first column of the second row on the screen, and so on.
To write to the 'screen', the text to be written should be written to the
VideoBuf array. Calling UpdateScreen will then copy the text to
the screen in the most optimal way. (an example can be found further on).
The color attribute is a combination of the foreground and background color, plus the blink bit. The bits describe the various color combinations:
- bits 0-3
- The foreground color. Can be set using all color constants.
- bits 4-6
- The background color. Can be set using a subset of the color constants.
- bit 7
- The blinking bit. If this bit is set, the character will appear blinking.
Each possible color has a constant associated with it, see the constants section for a list of constants.
The foreground and background color can be combined to a color attribute with the following code:
Attr:=ForeGroundColor + (BackGroundColor shl 4);
The color attribute can be logically or-ed with the blink attribute to produce a blinking character:
Atrr:=Attr or blink;
But not all drivers may support this.
The contents of the VideoBuf array may be modified: This is 'writing'
to the screen. As soon as everything that needs to be written in the array
is in the VideoBuf array, calling UpdateScreen will copy the
contents of the array screen to the screen, in a manner that is as efficient
as possible.
The updating of the screen can be prohibited to optimize performance; To this end, the LockScreenUpdate function can be used: This will increment an internal counter. As long as the counter differs from zero, calling UpdateScreen will not do anything. The counter can be lowered with UnlockScreenUpdate. When it reaches zero, the next call to UpdateScreen will actually update the screen. This is useful when having nested procedures that do a lot of screen writing.
The video unit also presents an interface for custom screen drivers, thus it is possible to override the default screen driver with a custom screen driver, see the SetVideoDriver call. The current video driver can be retrieved using the GetVideoDriver call.
crt unit.
Doing so will result in very strange behaviour, possibly program crashes.
Classes and records
TEnhancedVideoCell | record | |
TVideoDriver | record | Video driver record. |
TVideoMode | record | Record type describing a video mode. |
Procedures and functions
ActivateCodePage | procedure | |
ClearScreen | procedure | Clear the video screen. |
DefaultErrorHandler | function | Default error handling routine. |
DoneEnhancedVideo | procedure | |
DoneVideo | procedure | Disable video driver. |
equal(TEnhancedVideoCell,TEnhancedVideoCell):Boolean | operator | |
ExtendedGraphemeClusterDisplayWidth | function | |
GetActiveCodePage | function | |
GetCapabilities | function | Get current driver capabilities. |
GetCursorType | function | Get screen cursor type. |
GetLegacyCodePage | function | |
GetLockScreenCount | function | Get the screen lock update count. |
GetSupportedCodePage | function | |
GetSupportedCodePageCount | function | |
GetVideoDriver | procedure | Get a copy of the current video driver. |
GetVideoMode | procedure | Return current video mode. |
GetVideoModeCount | function | Get the number of video modes supported by the driver. |
GetVideoModeData | function | Get the specifications for a video mode. |
InitEnhancedVideo | procedure | |
InitVideo | procedure | Initialize video driver. |
LockScreenUpdate | procedure | Prevent further screen updates. |
SetCursorPos | procedure | Set write cursor position. |
SetCursorType | procedure | Set cursor type. |
SetVideoDriver | function | Install a new video driver. |
SetVideoMode | function | Set current video mode. |
StringDisplayWidth | function | |
UnlockScreenUpdate | procedure | Unlock screen update. |
UpdateScreen | procedure | Update physical screen with internal screen image. |
UpdateScreenArea | procedure |
Types
PEnhancedVideoCell | type | |
PVideoBuf | type | Pointer type to . |
PVideoCell | type | Pointer type to . |
PVideoMode | type | Pointer to record. |
TEnhancedVideoAttribute | enumeration | |
TEnhancedVideoAttributes | set | |
TEnhancedVideoBuf | type | |
TErrorHandler | procedure type | Error handler prototype. |
TErrorHandlerReturnValue | enumeration | Type used to report and respond to error conditions. |
TVideoBuf | type | Screen array type. |
TVideoCell | type | One cell (=screen position) in the video buffer. |
TVideoModeSelector | procedure type | Video mode selection callback prototype. |
Constants
Black | constant | Black color attribute. |
Blink | constant | Blink attribute. |
Blue | constant | Blue color attribute. |
Brown | constant | Brown color attribute. |
cpBlink | constant | Video driver supports blink attribute. |
cpChangeCursor | constant | Video driver supports changing cursor shape. |
cpChangeFont | constant | Video driver supports changing screen font. |
cpChangeMode | constant | Video driver supports changing mode. |
cpColor | constant | Video driver supports color. |
cpUnderLine | constant | Video driver supports underline attribute. |
crBlock | constant | Block cursor. |
crHalfBlock | constant | Half block cursor. |
crHidden | constant | Hide cursor. |
crUnderLine | constant | Underline cursor. |
Cyan | constant | Cyan color attribute. |
DarkGray | constant | Dark gray color attribute. |
errOk | constant | No error. |
ErrorCode | constant | Error code returned by the last operation. |
ErrorHandler | constant | Error handler routine. |
ErrorInfo | constant | Pointer to extended error information. |
errVioBase | constant | Base value for video errors. |
errVioInit | constant | Video driver initialization error. |
errVioNoSuchMode | constant | Invalid video mode. |
errVioNotSupported | constant | Unsupported video function. |
FVMaxWidth | constant | Maximum screen buffer width. |
Green | constant | Green color attribute. |
LightBlue | constant | Light Blue color attribute. |
LightCyan | constant | Light cyan color attribute. |
LightGray | constant | Light gray color attribute. |
LightGreen | constant | Light green color attribute. |
LightMagenta | constant | Light magenta color attribute. |
LightRed | constant | Light red color attribute. |
LowAscii | constant | Low 32 ASCII character availability. |
Magenta | constant | Magenta color attribute. |
NoExtendedFrame | constant | Disable transformation of control characters on Unix terminals. |
Red | constant | Red color attribute. |
ScreenHeight | constant | Current screen height. |
ScreenWidth | constant | Current screen Width. |
vioOK | constant | No errors occurred. |
White | constant | White color attribute. |
Yellow | constant | Yellow color attribute. |
Variables
CursorLines | variable | Currently visible scanlines of cursor. |
CursorX | variable | Current write cursor X position. |
CursorY | variable | Current write cursor Y position. |
EnhancedVideoBuf | variable | |
OldEnhancedVideoBuf | variable | |
OldVideoBuf | variable | Last written screen image. |
ScreenColor | variable | Indicate whether current screen supports colors. |
VideoBuf | variable | Current screen image. |
VideoBufSize | variable | Size of the screen image. |
Topics
viddriver | topic | Writing a custom video driver. |
vidutil | topic | Examples utility unit. |
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
