2
0

videoh.inc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. const
  23. { Foreground and background color constants }
  24. Black = 0;
  25. Blue = 1;
  26. Green = 2;
  27. Cyan = 3;
  28. Red = 4;
  29. Magenta = 5;
  30. Brown = 6;
  31. LightGray = 7;
  32. { Foreground color constants }
  33. DarkGray = 8;
  34. LightBlue = 9;
  35. LightGreen = 10;
  36. LightCyan = 11;
  37. LightRed = 12;
  38. LightMagenta = 13;
  39. Yellow = 14;
  40. White = 15;
  41. { Add-in for blinking }
  42. Blink = 128;
  43. { Capabilities bitmask }
  44. cpUnderLine = $0001;
  45. cpBlink = $0002;
  46. cpColor = $0004;
  47. cpChangeFont = $0008;
  48. cpChangeMode = $0010;
  49. cpChangeCursor = $0020;
  50. { Possible cursor types }
  51. crHidden = 0;
  52. crUnderLine = 1;
  53. crBlock = 2;
  54. crHalfBlock = 3;
  55. { Possible error codes }
  56. vioOK = 0;
  57. errVioBase = 1000;
  58. errVioInit = errVioBase + 1; { Initialization error, shouldn't occur on DOS, but may
  59. on Linux }
  60. errVioNotSupported = errVioBase + 2; { call to an unsupported function }
  61. errVioNoSuchMode = errVioBase + 3; { No such video mode }
  62. const
  63. ScreenWidth : Word = 0;
  64. ScreenHeight : Word = 0;
  65. var
  66. ScreenColor : Boolean;
  67. CursorX,
  68. CursorY : Word;
  69. LockUpdateScreen : Word;
  70. VideoBuf : PVideoBuf;
  71. VideoBufSize : Longint;
  72. CursorLines : Byte;
  73. const
  74. LowAscii : Boolean = true;
  75. NoExtendedFrame : Boolean = false;
  76. FVMaxWidth = 132;
  77. procedure InitVideo;
  78. { Initializes the video subsystem }
  79. procedure DoneVideo;
  80. { Deinitializes the video subsystem }
  81. function GetCapabilities: Word;
  82. { Return the capabilities of the current environment }
  83. procedure ClearScreen;
  84. { Clears the screen }
  85. procedure UpdateScreen(Force: Boolean);
  86. { Force specifies whether the whole screen has to be redrawn, or (if target
  87. platform supports it) its parts only }
  88. procedure SetCursorPos(NewCursorX, NewCursorY: Word);
  89. { Position the cursor to the given position }
  90. function GetCursorType: Word;
  91. { Return the cursor type: Hidden, UnderLine or Block }
  92. procedure SetCursorType(NewType: Word);
  93. { Set the cursor to the given type }
  94. function DefaultVideoModeSelector(const VideoMode: TVideoMode; Params: Longint): Boolean;
  95. procedure GetVideoMode(var Mode: TVideoMode);
  96. { Return dimensions of the current video mode }
  97. procedure SetVideoMode(Mode: TVideoMode);
  98. { Set video-mode to have Mode dimensions, may return errVioNoSuchMode }
  99. procedure RegisterVideoMode(Col, Row: Word; Color: Boolean; VideoModeSelector: TVideoModeSelector; Params: Longint);
  100. { Registers a video mode to be selectable by SetVideoMode }
  101. { moved to interface because we need a way to retrieve the modes }
  102. { System independent part }
  103. type
  104. PVideoModeList = ^TVideoModeList;
  105. TVideoModeList = record
  106. Col, Row: Word;
  107. Color: Boolean;
  108. VideoModeSelector: TVideoModeSelector;
  109. Params: Longint;
  110. Next: PVideoModeList;
  111. end;
  112. const
  113. Modes: PVideoModeList = nil;
  114. type
  115. TErrorHandlerReturnValue = (errRetry, errAbort, errContinue);
  116. { errRetry = retry the operation,
  117. errAbort = abort, return error code,
  118. errContinue = abort, without returning errorcode }
  119. TErrorHandler = function (Code: Longint; Info: Pointer): TErrorHandlerReturnValue;
  120. { ErrorHandler is the standard procedural interface for all error functions.
  121. Info may contain any data type specific to the error code passed to the
  122. function. }
  123. function DefaultErrorHandler(AErrorCode: Longint; AErrorInfo: Pointer): TErrorHandlerReturnValue;
  124. { Default error handler, simply sets error code, and returns errContinue }
  125. const
  126. errOk = 0;
  127. ErrorCode: Longint = ErrOK;
  128. ErrorInfo: Pointer = nil;
  129. ErrorHandler: TErrorHandler = @DefaultErrorHandler;
  130. {
  131. $Log$
  132. Revision 1.2 2001-06-06 17:20:22 jonas
  133. * fixed wrong typed constant procvars in preparation of my fix which will
  134. disallow them in FPC mode (plus some other unmerged changes since
  135. LAST_MERGE)
  136. Revision 1.1 2001/01/13 11:13:12 peter
  137. * API 2 RTL
  138. }