videoh.inc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 : Function (Const Mode : TVideoMode) : Boolean;
  28. GetVideoModeCount : Function : Word;
  29. GetVideoModeData : Function(Index : Word; Var Data : TVideoMode) : Boolean;
  30. SetCursorPos : procedure (NewCursorX, NewCursorY: Word);
  31. GetCursorType : function : Word;
  32. SetCursorType : procedure (NewType: Word);
  33. GetCapabilities : Function : Word;
  34. end;
  35. const
  36. { Foreground and background color constants }
  37. Black = 0;
  38. Blue = 1;
  39. Green = 2;
  40. Cyan = 3;
  41. Red = 4;
  42. Magenta = 5;
  43. Brown = 6;
  44. LightGray = 7;
  45. { Foreground color constants }
  46. DarkGray = 8;
  47. LightBlue = 9;
  48. LightGreen = 10;
  49. LightCyan = 11;
  50. LightRed = 12;
  51. LightMagenta = 13;
  52. Yellow = 14;
  53. White = 15;
  54. { Add-in for blinking }
  55. Blink = 128;
  56. { Capabilities bitmask }
  57. cpUnderLine = $0001;
  58. cpBlink = $0002;
  59. cpColor = $0004;
  60. cpChangeFont = $0008;
  61. cpChangeMode = $0010;
  62. cpChangeCursor = $0020;
  63. { Possible cursor types }
  64. crHidden = 0;
  65. crUnderLine = 1;
  66. crBlock = 2;
  67. crHalfBlock = 3;
  68. { Possible error codes }
  69. vioOK = 0;
  70. errVioBase = 1000;
  71. errVioInit = errVioBase + 1; { Initialization error, shouldn't occur on DOS, but may
  72. on Linux }
  73. errVioNotSupported = errVioBase + 2; { call to an unsupported function }
  74. errVioNoSuchMode = errVioBase + 3; { No such video mode }
  75. const
  76. ScreenWidth : Word = 0;
  77. ScreenHeight : Word = 0;
  78. var
  79. ScreenColor : Boolean;
  80. CursorX,
  81. CursorY : Word;
  82. VideoBuf,
  83. OldVideoBuf : PVideoBuf;
  84. VideoBufSize : Longint;
  85. CursorLines : Byte;
  86. const
  87. LowAscii : Boolean = true;
  88. NoExtendedFrame : Boolean = false;
  89. FVMaxWidth = 132;
  90. Procedure LockScreenUpdate;
  91. { Increments the screen update lock count with one.}
  92. Procedure UnlockScreenUpdate;
  93. { Decrements the screen update lock count with one.}
  94. Function GetLockScreenCount : integer;
  95. { Gets the current lock level }
  96. Function SetVideoDriver (Const Driver : TVideoDriver) : Boolean;
  97. { Sets the videodriver to be used }
  98. Procedure GetVideoDriver (Var Driver : TVideoDriver);
  99. { Retrieves the current videodriver }
  100. procedure InitVideo;
  101. { Initializes the video subsystem }
  102. procedure DoneVideo;
  103. { Deinitializes the video subsystem }
  104. function GetCapabilities: Word;
  105. { Return the capabilities of the current environment }
  106. procedure ClearScreen;
  107. { Clears the screen }
  108. procedure UpdateScreen(Force: Boolean);
  109. { Force specifies whether the whole screen has to be redrawn, or (if target
  110. platform supports it) its parts only }
  111. procedure SetCursorPos(NewCursorX, NewCursorY: Word);
  112. { Position the cursor to the given position }
  113. function GetCursorType: Word;
  114. { Return the cursor type: Hidden, UnderLine or Block }
  115. procedure SetCursorType(NewType: Word);
  116. { Set the cursor to the given type }
  117. procedure GetVideoMode(var Mode: TVideoMode);
  118. { Return dimensions of the current video mode }
  119. Function SetVideoMode(Const Mode: TVideoMode) : Boolean;
  120. { Set video-mode to have Mode dimensions, may return errVioNoSuchMode }
  121. Function GetVideoModeCount : Word;
  122. { Get the number of video modes supported by this driver }
  123. Function GetVideoModeData(Index : Word; Var Data: TVideoMode) : Boolean;
  124. { Get the data for Video mode Index. Index is zero based. }
  125. type
  126. TErrorHandlerReturnValue = (errRetry, errAbort, errContinue);
  127. { errRetry = retry the operation,
  128. errAbort = abort, return error code,
  129. errContinue = abort, without returning errorcode }
  130. TErrorHandler = function (Code: Longint; Info: Pointer): TErrorHandlerReturnValue;
  131. { ErrorHandler is the standard procedural interface for all error functions.
  132. Info may contain any data type specific to the error code passed to the
  133. function. }
  134. function DefaultErrorHandler(AErrorCode: Longint; AErrorInfo: Pointer): TErrorHandlerReturnValue;
  135. { Default error handler, simply sets error code, and returns errContinue }
  136. const
  137. errOk = 0;
  138. ErrorCode: Longint = ErrOK;
  139. ErrorInfo: Pointer = nil;
  140. ErrorHandler: TErrorHandler = @DefaultErrorHandler;
  141. {
  142. $Log$
  143. Revision 1.7 2002-09-07 15:07:46 peter
  144. * old logs removed and tabs fixed
  145. }