videoh.inc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. type
  12. PVideoMode = ^TVideoMode;
  13. TVideoMode = record
  14. Col,Row : Word;
  15. Color : Boolean;
  16. end;
  17. TVideoModeSelector = function (const VideoMode: TVideoMode; Params: Longint): Boolean;
  18. TVideoCell = Word;
  19. PVideoCell = ^TVideoCell;
  20. TVideoBuf = array[0..32759] of TVideoCell;
  21. PVideoBuf = ^TVideoBuf;
  22. TVideoDriver = Record
  23. InitDriver : Procedure;
  24. DoneDriver : Procedure;
  25. UpdateScreen : Procedure(Force : Boolean);
  26. ClearScreen : Procedure;
  27. SetVideoMode : Procedure (Const Mode : TVideoMode; Params : Longint);
  28. HasVideoMode : Function (Const Mode : TVideoMode; Params : Longint) : Boolean;
  29. SetCursorPos : procedure (NewCursorX, NewCursorY: Word);
  30. GetCursorType : function : Word;
  31. SetCursorType : procedure (NewType: Word);
  32. GetCapabilities : Function : Word;
  33. end;
  34. const
  35. { Foreground and background color constants }
  36. Black = 0;
  37. Blue = 1;
  38. Green = 2;
  39. Cyan = 3;
  40. Red = 4;
  41. Magenta = 5;
  42. Brown = 6;
  43. LightGray = 7;
  44. { Foreground color constants }
  45. DarkGray = 8;
  46. LightBlue = 9;
  47. LightGreen = 10;
  48. LightCyan = 11;
  49. LightRed = 12;
  50. LightMagenta = 13;
  51. Yellow = 14;
  52. White = 15;
  53. { Add-in for blinking }
  54. Blink = 128;
  55. { Capabilities bitmask }
  56. cpUnderLine = $0001;
  57. cpBlink = $0002;
  58. cpColor = $0004;
  59. cpChangeFont = $0008;
  60. cpChangeMode = $0010;
  61. cpChangeCursor = $0020;
  62. { Possible cursor types }
  63. crHidden = 0;
  64. crUnderLine = 1;
  65. crBlock = 2;
  66. crHalfBlock = 3;
  67. { Possible error codes }
  68. vioOK = 0;
  69. errVioBase = 1000;
  70. errVioInit = errVioBase + 1; { Initialization error, shouldn't occur on DOS, but may
  71. on Linux }
  72. errVioNotSupported = errVioBase + 2; { call to an unsupported function }
  73. errVioNoSuchMode = errVioBase + 3; { No such video mode }
  74. const
  75. ScreenWidth : Word = 0;
  76. ScreenHeight : Word = 0;
  77. var
  78. ScreenColor : Boolean;
  79. CursorX,
  80. CursorY : Word;
  81. VideoBuf : PVideoBuf;
  82. VideoBufSize : Longint;
  83. CursorLines : Byte;
  84. const
  85. LowAscii : Boolean = true;
  86. NoExtendedFrame : Boolean = false;
  87. FVMaxWidth = 132;
  88. Procedure LockScreenUpdate;
  89. { Increments the screen update lock count with one.}
  90. Procedure UnlockScreenUpdate;
  91. { Decrements the screen update lock count with one.}
  92. Procedure SetVideoDriver (Const Driver : TVideoDriver);
  93. { Sets the videodriver to be used }
  94. Procedure GetVideoDriver (Var Driver : TVideoDriver);
  95. { Retrieves the current videodriver }
  96. procedure InitVideo;
  97. { Initializes the video subsystem }
  98. procedure DoneVideo;
  99. { Deinitializes the video subsystem }
  100. function GetCapabilities: Word;
  101. { Return the capabilities of the current environment }
  102. procedure ClearScreen;
  103. { Clears the screen }
  104. procedure UpdateScreen(Force: Boolean);
  105. { Force specifies whether the whole screen has to be redrawn, or (if target
  106. platform supports it) its parts only }
  107. procedure SetCursorPos(NewCursorX, NewCursorY: Word);
  108. { Position the cursor to the given position }
  109. function GetCursorType: Word;
  110. { Return the cursor type: Hidden, UnderLine or Block }
  111. procedure SetCursorType(NewType: Word);
  112. { Set the cursor to the given type }
  113. function DefaultVideoModeSelector(const VideoMode: TVideoMode; Params: Longint): Boolean;
  114. procedure GetVideoMode(var Mode: TVideoMode);
  115. { Return dimensions of the current video mode }
  116. procedure SetVideoMode(Mode: TVideoMode);
  117. { Set video-mode to have Mode dimensions, may return errVioNoSuchMode }
  118. procedure RegisterVideoMode(Col, Row: Word; Color: Boolean; VideoModeSelector: TVideoModeSelector; Params: Longint);
  119. { Registers a video mode to be selectable by SetVideoMode }
  120. { moved to interface because we need a way to retrieve the modes }
  121. { System independent part }
  122. type
  123. PVideoModeList = ^TVideoModeList;
  124. TVideoModeList = record
  125. Col, Row: Word;
  126. Color: Boolean;
  127. VideoModeSelector: TVideoModeSelector;
  128. Params: Longint;
  129. Next: PVideoModeList;
  130. end;
  131. const
  132. Modes: PVideoModeList = nil;
  133. type
  134. TErrorHandlerReturnValue = (errRetry, errAbort, errContinue);
  135. { errRetry = retry the operation,
  136. errAbort = abort, return error code,
  137. errContinue = abort, without returning errorcode }
  138. TErrorHandler = function (Code: Longint; Info: Pointer): TErrorHandlerReturnValue;
  139. { ErrorHandler is the standard procedural interface for all error functions.
  140. Info may contain any data type specific to the error code passed to the
  141. function. }
  142. function DefaultErrorHandler(AErrorCode: Longint; AErrorInfo: Pointer): TErrorHandlerReturnValue;
  143. { Default error handler, simply sets error code, and returns errContinue }
  144. const
  145. errOk = 0;
  146. ErrorCode: Longint = ErrOK;
  147. ErrorInfo: Pointer = nil;
  148. ErrorHandler: TErrorHandler = @DefaultErrorHandler;
  149. {
  150. $Log$
  151. Revision 1.3 2001-09-21 19:50:18 michael
  152. + Merged driver support from fixbranch
  153. Revision 1.2 2001/06/06 17:20:22 jonas
  154. Revision 1.1.2.3 2001/09/21 18:42:08 michael
  155. + Implemented support for custom video drivers.
  156. Revision 1.1.2.2 2001/06/06 14:27:14 jonas
  157. * fixed wrong typed constant procvars in preparation of my fix which will
  158. disallow them in FPC mode (plus some other unmerged changes since
  159. LAST_MERGE)
  160. Revision 1.1 2001/01/13 11:13:12 peter
  161. * API 2 RTL
  162. }