video.xml 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. <?xml version="1.0" encoding="ISO8859-1"?>
  2. <fpdoc-descriptions>
  3. <!--
  4. $Id$
  5. This file is part of the FPC documentation.
  6. Copyright (C) 1997, by Michael Van Canneyt
  7. The FPC documentation is free text; you can redistribute it and/or
  8. modify it under the terms of the GNU Library General Public License as
  9. published by the Free Software Foundation; either version 2 of the
  10. License, or (at your option) any later version.
  11. The FPC Documentation is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with the FPC documentation; see the file COPYING.LIB. If not,
  17. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. Boston, MA 02111-1307, USA.
  19. -->
  20. <package name="rtl">
  21. <module name="video">
  22. <short>Screen handling unit</short>
  23. <!-- \FPCexampledir{videoex} -->
  24. <descr>
  25. <p>
  26. The <file>Video</file> unit implements a screen access layer which is system
  27. independent. It can be used to write on the screen in a system-independent
  28. way, which should be optimal on all platforms for which the unit is
  29. implemented.
  30. </p>
  31. <p>
  32. The working of the <file>Video</file> is simple: After calling <link id="InitVideo"/>,
  33. the array <var>VideoBuf</var> contains a representation of the video screen of
  34. size <var>ScreenWidth*ScreenHeight</var>, going from left to right and top to
  35. bottom when walking the array elements: <var>VideoBuf[0]</var> contains the
  36. character and color code of the top-left character on the screen.
  37. <var>VideoBuf[ScreenWidth]</var> contains the data for the character in the
  38. first column of the second row on the screen, and so on.
  39. </p>
  40. <p>
  41. To write to the 'screen', the text to be written should be written to the
  42. <var>VideoBuf</var> array. Calling <link id="UpdateScreen"/> will then cp the text to
  43. the screen in the most optimal way. (an example can be found further on).
  44. </p>
  45. <p>
  46. The color attribute is a combination of the foreground and background color,
  47. plus the blink bit. The bits describe the various color combinations:
  48. </p>
  49. <dl>
  50. <dt>bits 0-3</dt>
  51. <dd> The foreground color. Can be set using all color constants.
  52. </dd>
  53. <dt>bits 4-6</dt>
  54. <dd> The background color. Can be set using a subset of the
  55. color constants.
  56. </dd>
  57. <dt>bit 7</dt>
  58. <dd> The blinking bit. If this bit is set, the character will appear
  59. blinking.
  60. </dd>
  61. </dl>
  62. <p>
  63. Each possible color has a constant associated with it, see the constants
  64. section for a list of constants.
  65. </p>
  66. <p>
  67. The foreground and background color can be combined to a color attribute
  68. with the following code:
  69. </p>
  70. <code>
  71. Attr:=ForeGroundColor + (BackGroundColor shl 4);
  72. </code>
  73. <p>
  74. The color attribute can be logically or-ed with the blink attribute to
  75. produce a blinking character:
  76. </p>
  77. <code>
  78. Atrr:=Attr or blink;
  79. </code>
  80. <p>
  81. But not all drivers may support this.
  82. </p>
  83. <p>
  84. The contents of the <var>VideoBuf</var> array may be modified: This is 'writing'
  85. to the screen. As soon as everything that needs to be written in the array
  86. is in the <var>VideoBuf</var> array, calling <var>UpdateScreen</var> will copy the
  87. contents of the array screen to the screen, in a manner that is as efficient
  88. as possible.
  89. </p>
  90. <p>
  91. The updating of the screen can be prohibited to optimize performance; To
  92. this end, the <link id="LockScreenUpdate"/> function can be used: This will
  93. increment an internal counter. As long as the counter differs from zero,
  94. calling <link id="UpdateScreen"/> will not do anything. The counter can be
  95. lowered with <link id="UnlockScreenUpdate"/>. When it reaches zero, the next call
  96. to <link id="UpdateScreen"/> will actually update the screen. This is useful when
  97. having nested procedures that do a lot of screen writing.
  98. </p>
  99. <p>
  100. The video unit also presents an interface for custom screen drivers, thus
  101. it is possible to override the default screen driver with a custom screen
  102. driver, see the <link id="SetVideoDriver"/> call. The current video driver can
  103. be retrieved using the <link id="GetVideoDriver"/> call.
  104. </p>
  105. <remark>
  106. The video unit should <em> not</em> be used together with the <file>crt</file> unit.
  107. Doing so will result in very strange behaviour, possibly program crashes.
  108. </remark>
  109. </descr>
  110. <element name="Black">
  111. <short>Black color attribute</short>
  112. </element>
  113. <element name="Blue">
  114. <short>Blue color attribute</short>
  115. </element>
  116. <element name="Green">
  117. <short>Green color attribute</short>
  118. </element>
  119. <element name="Cyan">
  120. <short>Cyan color attribute</short>
  121. </element>
  122. <element name="Red">
  123. <short>Red color attribute</short>
  124. </element>
  125. <element name="Magenta">
  126. <short>Magenta color attribute</short>
  127. </element>
  128. <element name="Brown">
  129. <short>Brown color attribute</short>
  130. </element>
  131. <element name="LightGray">
  132. <short>Light gray color attribute</short>
  133. </element>
  134. <element name="DarkGray">
  135. <short>Dark gray color attribute</short>
  136. </element>
  137. <element name="LightBlue">
  138. <short>Light Blue color attribute</short>
  139. </element>
  140. <element name="LightGreen">
  141. <short>Light green color attribute</short>
  142. </element>
  143. <element name="LightCyan">
  144. <short>Light cyan color attribute</short>
  145. </element>
  146. <element name="LightRed">
  147. <short>Light red color attribute</short>
  148. </element>
  149. <element name="LightMagenta">
  150. <short>Light magenta color attribute</short>
  151. </element>
  152. <element name="Yellow">
  153. <short>Yellow color attribute</short>
  154. </element>
  155. <element name="White">
  156. <short>White color attribute</short>
  157. </element>
  158. <element name="Blink">
  159. <short>Blink attribute</short>
  160. </element>
  161. <element name="cpUnderLine">
  162. <short>Video driver supports underline attribute</short>
  163. </element>
  164. <element name="cpBlink">
  165. <short>Video driver supports blink attribute</short>
  166. </element>
  167. <element name="cpColor">
  168. <short>Video driver supports color</short>
  169. </element>
  170. <element name="cpChangeFont">
  171. <short>Video driver supports changing screen font.</short>
  172. </element>
  173. <element name="cpChangeMode">
  174. <short>Video driver supports changing mode</short>
  175. </element>
  176. <element name="cpChangeCursor">
  177. <short>Video driver supports changing cursor shape.</short>
  178. </element>
  179. <element name="crHidden">
  180. <short>Hide cursor</short>
  181. </element>
  182. <element name="crUnderLine">
  183. <short>Underline cursor</short>
  184. </element>
  185. <element name="crBlock">
  186. <short>Block cursor</short>
  187. </element>
  188. <element name="crHalfBlock">
  189. <short>Half block cursor</short>
  190. </element>
  191. <element name="vioOK">
  192. <short>No errors occurred</short>
  193. </element>
  194. <element name="errVioBase">
  195. <short>Base value for video errors</short>
  196. </element>
  197. <element name="errOK">
  198. <short>No error</short>
  199. </element>
  200. <element name="errVioInit">
  201. <short>Video driver initialization error.</short>
  202. </element>
  203. <element name="errVioNotSupported">
  204. <short>Unsupported video function</short>
  205. </element>
  206. <element name="errVioNoSuchMode">
  207. <short>Invalid video mode</short>
  208. </element>
  209. <element name="ScreenWidth">
  210. <short>Current screen Width</short>
  211. </element>
  212. <element name="ScreenHeight">
  213. <short>Current screen height</short>
  214. </element>
  215. <element name="LowAscii">
  216. <short>Only use low ascii characters</short>
  217. </element>
  218. <element name="NoExtendedFrame">
  219. <short>Disable transformation of control characters on unix terminals</short>
  220. </element>
  221. <element name="FVMaxWidth">
  222. <short>Maximum screen buffer width.</short>
  223. </element>
  224. <element name="ErrorCode">
  225. <short>Error code returned by the last operation.</short>
  226. </element>
  227. <element name="ErrorInfo">
  228. <short>Pointer to extended error information.</short>
  229. </element>
  230. <element name="ErrorHandler">
  231. <short>Error handler routine</short>
  232. <descr>
  233. The <var>ErrorHandler</var> variable can be set to a custom-error handling
  234. function. It is set by default to the <link id="DefaultErrorHandler"/> function.
  235. </descr>
  236. </element>
  237. <element name="TVideoMode">
  238. <descr>
  239. The <var>TVideoMode</var> record describes a videomode. Its fields are
  240. self-explaining: <var>Col,Row</var> describe the number of columns and
  241. rows on the screen for this mode. <var>Color</var> is <var>True</var> if this mode
  242. supports colors, or <var>False</var> if not.
  243. </descr>
  244. </element>
  245. <element name="PVideoMode">
  246. <short>Pointer to <link id="TVideoMode"/> record.</short>
  247. </element>
  248. <element name="TVideoModeSelector">
  249. <short>Video mode selection callback prototype.</short>
  250. </element>
  251. <element name="TVideoCell">
  252. <short>One cell (=screen position) in the video buffer </short>
  253. <descr>
  254. <var>TVideoCell</var> describes one character on the screen. One of the bytes
  255. contains the color attribute with which the character is drawn on the screen,
  256. and the other byte contains the ASCII code of the character to be drawn. The
  257. exact position of the different bytes in the record is operating system specific.
  258. On most little-endian systems, the high byte represents the color attribute,
  259. while the low-byte represents the ASCII code of the character to be drawn.
  260. </descr>
  261. </element>
  262. <element name="PVideoCell">
  263. <short>Pointer type to <link id="TVideoCell"/></short>
  264. </element>
  265. <element name="TVideoBuf">
  266. <short>Screen array type</short>
  267. <descr>
  268. The <var>TVideoBuf</var> type represents the screen.
  269. </descr>
  270. </element>
  271. <element name="PVideoBuf">
  272. <short>Pointer type to <link id="TVideoBuf"/></short>
  273. </element>
  274. <element name="TErrorHandlerReturnValue">
  275. <short>Type used to report and respond to error conditions</short>
  276. </element>
  277. <element name="TErrorHandlerReturnValue.errRetry">
  278. <short>retry the operation</short>
  279. </element>
  280. <element name="TErrorHandlerReturnValue.errAbort">
  281. <short>abort and return error code</short>
  282. </element>
  283. <element name="TErrorHandlerReturnValue.errContinue">
  284. <short>abort without returning an errorcode.</short>
  285. </element>
  286. <element name="TErrorHandler">
  287. <short>Error handler prototype</short>
  288. <descr>
  289. <p>
  290. The <var>TErrorHandler</var> function is used to register an own error
  291. handling function. It should be used when installing a custom error
  292. handling function, and must return one of the above values.
  293. </p>
  294. <p>
  295. <var>Code</var> should contain the error code for the error condition,
  296. and the <var>Info</var> parameter may contain any data type specific to
  297. the error code passed to the function.
  298. </p>
  299. </descr>
  300. </element>
  301. <element name="TVideoDriver">
  302. <short>Video driver record</short>
  303. <descr>
  304. <p>
  305. <var>TVideoDriver</var> record can be used to install a custom video
  306. driver, with the <link id="SetVideoDriver"/> call.
  307. </p>
  308. <p>
  309. An explanation of all fields can be found there.
  310. </p>
  311. </descr>
  312. </element>
  313. <element name="ScreenColor">
  314. <short>Indicate whether current screen supports colors</short>
  315. <descr>
  316. <var>ScreenColor</var> indicates whether the current screen supports colors.
  317. </descr>
  318. </element>
  319. <element name="CursorX">
  320. <short>Current write cursor X position.</short>
  321. <descr>
  322. Current horizontal position in the screen where items will be written.
  323. </descr>
  324. </element>
  325. <element name="CursorY">
  326. <short>Current write cursor Y position.</short>
  327. <descr>
  328. Current vertical position in the screen where items will be written.
  329. </descr>
  330. </element>
  331. <element name="VideoBuf">
  332. <short>Current screen image.</short>
  333. <descr>
  334. <var>VideoBuf</var> forms the heart of the <file>Video</file> unit: This
  335. variable represents the physical screen. Writing to this
  336. array and calling <link id="UpdateScreen"/> will write the actual characters
  337. to the screen.
  338. </descr>
  339. </element>
  340. <element name="OldVideoBuf">
  341. <short>Last written screen image.</short>
  342. <descr>
  343. <p>
  344. The <var>OldVideoBuf</var> contains the state of the video screen after the last
  345. screen update. The <link id="UpdateScreen"/> function uses this array to decide
  346. which characters on screen should be updated, and which not.
  347. </p>
  348. <p>
  349. Note that the <var>OldVideoBuf</var> array may be ignored by some drivers, so
  350. it should not be used. The Array is in the interface section of the video
  351. unit mainly so drivers that need it can make use of it.
  352. </p>
  353. </descr>
  354. </element>
  355. <element name="VideoBufSize">
  356. <short>Size of the screen image.</short>
  357. <descr>Current size of the video buffer pointed to by <link id="VideoBuf"/></descr>
  358. </element>
  359. <element name="ClearScreen">
  360. <short>Clear the video screen.</short>
  361. <descr>
  362. <var>ClearScreen</var> clears the entire screen, and calls <link id="UpdateScreen"/>
  363. after that. This is done by writing spaces to all character cells of the
  364. video buffer in the default color (lightgray on black, color attribute \$07).
  365. </descr>
  366. <errors>
  367. None.
  368. </errors>
  369. <seealso>
  370. <link id="InitVideo"/>
  371. <link id="UpdateScreen"/>
  372. </seealso>
  373. <example file="videoex/ex3"/>
  374. </element>
  375. <element name="DefaultErrorHandler">
  376. <short>Default error handling routine.</short>
  377. <descr>
  378. <var>DefaultErrorHandler</var> is the default error handler used by the video
  379. driver. It simply sets the error code <var>AErrorCode</var> and <var>AErrorInfo</var>
  380. in the global variables <var>ErrorCode</var> and <var>ErrorInfo</var> and returns
  381. <var>errContinue</var>.
  382. </descr>
  383. <errors>
  384. None.
  385. </errors>
  386. <seealso>
  387. </seealso>
  388. </element>
  389. <element name="DoneVideo">
  390. <short>Disable video driver.</short>
  391. <descr>
  392. <p>
  393. <var>DoneVideo</var> disables the Video driver if the video driver is active. If
  394. the videodriver was already disabled or not yet initialized, it does
  395. nothing. Disabling the driver means it will clean up any allocated
  396. resources, possibly restore the screen in the state it was before
  397. <var>InitVideo</var> was called. Particularly, the <var>VideoBuf</var> and
  398. <var>OldVideoBuf</var> arrays are no longer valid after a call to
  399. <var>DoneVideo</var>.
  400. </p>
  401. <p>
  402. The <var>DoneVideo</var> should always be called if <var>InitVideo</var> was called.
  403. Failing to do so may leave the screen in an unusable state after the program
  404. exits.
  405. </p>
  406. <p>
  407. For an example, see most other functions.
  408. </p>
  409. </descr>
  410. <errors>
  411. Normally none. If the driver reports an error, this is done through the
  412. <var>ErrorCode</var> variable.
  413. </errors>
  414. <seealso>
  415. <link id="InitVideo"/>
  416. </seealso>
  417. </element>
  418. <element name="GetCapabilities">
  419. <short>Get current driver capabilities.</short>
  420. <descr>
  421. <p>
  422. <var>GetCapabilities</var> returns the capabilities of the current driver.
  423. It is an or-ed combination of the following constants:
  424. </p>
  425. <dl>
  426. <dt>cpUnderLine</dt><dd><printshort id="cpUnderLine"/></dd>
  427. <dt>cpBlink</dt><dd><printshort id="cpBlink"/></dd>
  428. <dt>cpColor</dt><dd><printshort id="cpColor"/></dd>
  429. <dt>cpChangeFont</dt><dd><printshort id="cpChangeFont"/></dd>
  430. <dt>cpChangeMode</dt><dd><printshort id="cpChangeMode"/></dd>
  431. <dt>cpChangeCursor</dt><dd><printshort id="cpChangeCursor"/></dd>
  432. </dl>
  433. <p>
  434. Note that the video driver should not yet be initialized to use this
  435. function. It is a property of the driver.
  436. </p>
  437. </descr>
  438. <errors>
  439. None.
  440. </errors>
  441. <seealso>
  442. <link id="GetCursorType"/>
  443. <link id="GetVideoDriver"/>
  444. </seealso>
  445. <example file="videoex/ex4"/>
  446. </element>
  447. <element name="GetCursorType">
  448. <short>Get screen cursor type</short>
  449. <descr>
  450. <p>
  451. <var>GetCursorType</var> returns the current cursor type. It is one of the
  452. following values:
  453. </p>
  454. <dl>
  455. <dt>crHidden</dt><dd><printshort id="crHidden"/></dd>
  456. <dt>crUnderLine</dt><dd><printshort id="crUnderLine"/></dd>
  457. <dt>crBlock</dt><dd><printshort id="crBlock"/></dd>
  458. <dt>crHalfBlock</dt><dd><printshort id="crHalfBlock"/></dd>
  459. </dl>
  460. <p>
  461. Note that not all drivers support all types of cursors.
  462. </p>
  463. </descr>
  464. <errors>
  465. None.
  466. </errors>
  467. <seealso>
  468. <link id="SetCursorType"/>
  469. <link id="GetCapabilities"/>
  470. </seealso>
  471. <example file="videoex/ex5"/>
  472. </element>
  473. <element name="GetLockScreenCount">
  474. <short>Get the screen lock update count.</short>
  475. <descr>
  476. <var>GetLockScreenCount</var> returns the current lock level. When the lock
  477. level is zero, a call to <link id="UpdateScreen"/> will actually update the
  478. screen.
  479. </descr>
  480. <errors>
  481. None.
  482. </errors>
  483. <seealso>
  484. <link id="LockScreenUpdate"/>
  485. <link id="UnlockScreenUpdate"/>
  486. <link id="UpdateScreen"/>
  487. </seealso>
  488. <example file="videoex/ex6"/>
  489. </element>
  490. <element name="GetVideoMode">
  491. <short>Return current video mode</short>
  492. <descr>
  493. </descr>
  494. <seealso>
  495. </seealso>
  496. </element>
  497. <element name="GetVideoDriver">
  498. <short>Get a copy of the current video driver.</short>
  499. <descr>
  500. <var>GetVideoMode</var> returns the settings of the currently active video mode.
  501. The <var>row,col</var> fields indicate the dimensions of the current video mode,
  502. and <var>Color</var> is true if the current video supports colors.
  503. </descr>
  504. <errors>
  505. None.
  506. </errors>
  507. <seealso>
  508. <link id="SetVideoMode"/>
  509. <link id="GetVideoModeData"/>
  510. </seealso>
  511. <example file="videoex/ex7"/>
  512. </element>
  513. <element name="GetVideoModeCount">
  514. <short>Get the number of video modes supported by the driver.</short>
  515. <descr>
  516. <p>
  517. <var>GetVideoModeCount</var> returns the number of video modes that the current
  518. driver supports. If the driver does not support switching of modes, then 1
  519. is returned.
  520. </p>
  521. <p>
  522. This function can be used in conjunction with the <link id="GetVideoModeData"/>
  523. function to retrieve data for the supported video modes.
  524. </p>
  525. </descr>
  526. <errors>
  527. None.
  528. </errors>
  529. <seealso>
  530. <link id="GetVideoModeData"/>
  531. <link id="GetVideoMode"/>
  532. </seealso>
  533. <example file="videoex/ex8"/>
  534. </element>
  535. <element name="GetVideoModeData">
  536. <short>Get the specifications for a video mode</short>
  537. <descr>
  538. <p>
  539. <var>GetVideoModeData</var> returns the characteristics of the <var>Index</var>-th
  540. video mode in <var>Data</var>. <var>Index</var> is zero based, and has a maximum value of
  541. <var>GetVideoModeCount-1</var>. If the current driver does not support setting of
  542. modes (<var>GetVideoModeCount=1</var>) and <var>Index</var> is zero, the current mode
  543. is returned.
  544. </p>
  545. <p>
  546. The function returns <var>True</var> if the mode data was retrieved succesfully,
  547. <var>False</var> otherwise.
  548. </p>
  549. <p>
  550. For an example, see <link id="GetVideoModeCount"/>.
  551. </p>
  552. </descr>
  553. <errors>
  554. In case <var>Index</var> has a wrong value, <var>False</var> is returned.
  555. </errors>
  556. <seealso>
  557. <link id="GetVideoModeCount"/>
  558. <link id="SetVideoMode"/>
  559. <link id="GetVideoMode"/>
  560. </seealso>
  561. </element>
  562. <element name="InitVideo">
  563. <short>Initialize video driver.</short>
  564. <descr>
  565. <p>
  566. <var>InitVideo</var> Initializes the video subsystem. If the video system was
  567. already initialized, it does nothing.
  568. After the driver has been initialized, the <var>VideoBuf</var> and <var>OldVideoBuf</var>
  569. pointers are initialized, based on the <var>ScreenWidth</var> and
  570. <var>ScreenHeight</var> variables. When this is done, the screen is cleared.
  571. </p>
  572. <p>
  573. For an example, see most other functions.
  574. </p>
  575. </descr>
  576. <errors>
  577. if the driver fails to initialize, the <var>ErrorCode</var> variable is set.
  578. </errors>
  579. <seealso>
  580. <link id="DoneVideo"/>
  581. </seealso>
  582. </element>
  583. <element name="LockScreenUpdate">
  584. <short>Prevent further screen updates.</short>
  585. <descr>
  586. <p>
  587. <var>LockScreenUpdate</var> increments the screen update lock count with one.
  588. As long as the screen update lock count is not zero, <link id="UpdateScreen"/>
  589. will not actually update the screen.
  590. </p>
  591. <p>
  592. This function can be used to optimize screen updating: If a lot of writing
  593. on the screen needs to be done (by possibly unknown functions), calling
  594. <var>LockScreenUpdate</var> before the drawing, and <link id="UnlockScreenUpdate"/>
  595. after the drawing, followed by a <link id="UpdateScreen"/> call, all writing will
  596. be shown on screen at once.
  597. </p>
  598. <p>
  599. For an example, see <link id="GetLockScreenCount"/>.
  600. </p>
  601. </descr>
  602. <errors>
  603. None.
  604. </errors>
  605. <seealso>
  606. <link id="UpdateScreen"/>
  607. <link id="UnlockScreenUpdate"/>
  608. <link id="GetLockScreenCount"/>
  609. </seealso>
  610. </element>
  611. <element name="SetCursorPos">
  612. <short>Set write cursor position.</short>
  613. <descr>
  614. <p>
  615. <var>SetCursorPos</var> positions the cursor on the given position: Column
  616. <var>NewCursorX</var> and row <var>NewCursorY</var>. The origin of the screen is the
  617. upper left corner, and has coordinates <var>(0,0)</var>.
  618. </p>
  619. <p>
  620. The current position is stored in the <var>CursorX</var> and <var>CursorY</var>
  621. variables.
  622. </p>
  623. </descr>
  624. <errors>
  625. None.
  626. </errors>
  627. <seealso>
  628. <link id="SetCursorType"/>
  629. </seealso>
  630. <example file="videoex/ex2"/>
  631. </element>
  632. <element name="SetCursorType">
  633. <short>Set cursor type</short>
  634. <descr>
  635. <p>
  636. <var>SetCursorType</var> sets the cursor to the type specified in <var>NewType</var>.
  637. </p>
  638. <dl>
  639. <dt>crHidden</dt><dd><printshort id="crHidden"/></dd>
  640. <dt>crUnderLine</dt><dd><printshort id="crUnderLine"/></dd>
  641. <dt>crBlock</dt><dd><printshort id="crBlock"/></dd>
  642. <dt>crHalfBlock</dt><dd><printshort id="crHalfBlock"/></dd>
  643. </dl>
  644. </descr>
  645. <errors>
  646. None.
  647. </errors>
  648. <seealso>
  649. <link id="SetCursorPos"/>
  650. </seealso>
  651. </element>
  652. <element name="SetVideoDriver">
  653. <short>Install a new video driver.</short>
  654. <descr>
  655. <p>
  656. <var>SetVideoDriver</var> sets the videodriver to be used to <var>Driver</var>. If
  657. the current videodriver is initialized (after a call to <var>InitVideo</var>)
  658. then it does nothing and returns <var>False</var>.
  659. </p>
  660. <p>
  661. A new driver can only be installed if the previous driver was not yet
  662. activated (i.e. before a call to <link id="InitVideo"/>) or after it was
  663. deactivated (i.e after a call to <var>DoneVideo</var>).
  664. </p>
  665. <p>
  666. For more information about installing a videodriver, see <link id="viddriver"/>.
  667. </p>
  668. <p>
  669. For an example, see the section on writing a custom video driver.
  670. </p>
  671. </descr>
  672. <errors>
  673. If the current driver is initialized, then <var>False</var> is returned.
  674. </errors>
  675. <seealso>
  676. <link id="viddriver"/>
  677. </seealso>
  678. </element>
  679. <element name="TVideoMode">
  680. <short>Record type descrbing a video mode.</short>
  681. </element>
  682. <element name="TVideoMode.Col">
  683. <short>Number of columns for display</short>
  684. </element>
  685. <element name="TVideoMode.Row">
  686. <short>Number of rows for display</short>
  687. </element>
  688. <element name="TVideoMode.Color">
  689. <short>Color support</short>
  690. </element>
  691. <element name="SetVideoMode">
  692. <short>Set current video mode.</short>
  693. <descr>
  694. <p>
  695. <var>SetVideoMode</var> sets the video mode to the mode specified in <var>Mode</var>:
  696. </p>
  697. <p>
  698. If the call was succesful, then the screen will have <var>Col</var> columns and
  699. <var>Row</var> rows, and will be displaying in color if <var>Color</var> is
  700. <var>True</var>.
  701. </p>
  702. <p>
  703. The function returns <var>True</var> if the mode was set succesfully, <var>False</var>
  704. otherwise.
  705. </p>
  706. <p>
  707. Note that the video mode may not always be set. E.g. a console on Linux
  708. or a telnet session cannot always set the mode. It is important to check
  709. the error value returned by this function if it was not succesful.
  710. </p>
  711. <p>
  712. The mode can be set when the video driver has not yet been initialized
  713. (i.e. before <link id="InitVideo"/> was called) In that case, the video mode will
  714. be stored, and after the driver was initialized, an attempt will be made to
  715. set the requested mode. Changing the video driver before the call to
  716. <var>InitVideo</var> will clear the stored video mode.
  717. </p>
  718. <p>
  719. To know which modes are valid, use the <link id="GetVideoModeCount"/> and
  720. <link id="GetVideoModeData"/> functions. To retrieve the current video mode,
  721. use the <link id="GetVideoMode"/> procedure.
  722. </p>
  723. </descr>
  724. <errors>
  725. If the specified mode cannot be set, then <var>errVioNoSuchMode</var> may be set
  726. in <var>ErrorCode</var>
  727. </errors>
  728. <seealso>
  729. <link id="GetVideoModeCount"/>
  730. <link id="GetVideoModeData"/>
  731. <link id="GetVideoMode"/>
  732. </seealso>
  733. </element>
  734. <element name="UnlockScreenUpdate">
  735. <short>Unlock screen update.</short>
  736. <descr>
  737. <p>
  738. <var>UnlockScreenUpdate</var> decrements the screen update lock count with one if
  739. it is larger than zero. When the lock count reaches zero, the
  740. <link id="UpdateScreen"/> will actually update the screen. No screen update will
  741. be performed as long as the screen update lock count is nonzero. This
  742. mechanism can be used to increase screen performance in case a lot of
  743. writing is done.
  744. </p>
  745. <p>
  746. It is important to make sure that each call to <link id="LockScreenUpdate"/> is
  747. matched by exactly one call to <var>UnlockScreenUpdate</var>
  748. </p>
  749. <p>
  750. For an example, see <link id="GetLockScreenCount"/>.
  751. </p>
  752. </descr>
  753. <errors>
  754. None.
  755. </errors>
  756. <seealso>
  757. <link id="LockScreenUpdate"/>
  758. <link id="GetLockScreenCount"/>
  759. <link id="UpdateScreen"/>
  760. </seealso>
  761. </element>
  762. <element name="UpdateScreen">
  763. <short>Update physical screen with internal screen image.</short>
  764. <descr>
  765. <p>
  766. <var>UpdateScreen</var> synchronizes the actual screen with the contents
  767. of the <var>VideoBuf</var> internal buffer. The parameter <var>Force</var>
  768. specifies whether the whole screen has to be redrawn (<var>Force=True</var>)
  769. or only parts that have changed since the last update of the screen.
  770. </p>
  771. <p>
  772. The <var>Video</var> unit keeps an internal copy of the screen as it last
  773. wrote it to the screen (in the <var>OldVideoBuf</var> array). The current
  774. contents of <var>VideoBuf</var> are examined to see what locations on the
  775. screen need to be updated. On slow terminals (e.g. a linux telnet
  776. session) this mechanism can speed up the screen redraw considerably.
  777. </p>
  778. <p>
  779. For an example, see most other functions.
  780. </p>
  781. </descr>
  782. <errors>
  783. None.
  784. </errors>
  785. <seealso>
  786. <link id="ClearScreen"/>
  787. </seealso>
  788. </element>
  789. <topic name="viddriver">
  790. <short>Writing a custom video driver</short>
  791. <descr>
  792. <p>
  793. Writing a custom video driver is not difficult, and generally means
  794. implementing a couple of functions, which whould be registered with
  795. the <link id="SetVideoDriver"/> function. The various functions that can be
  796. implemented are located in the <link id="TVideoDriver"/> record:
  797. </p>
  798. <code>
  799. TVideoDriver = Record
  800. InitDriver : Procedure;
  801. DoneDriver : Procedure;
  802. UpdateScreen : Procedure(Force : Boolean);
  803. ClearScreen : Procedure;
  804. SetVideoMode : Function (Const Mode : TVideoMode) : Boolean;
  805. GetVideoModeCount : Function : Word;
  806. GetVideoModeData : Function(Index : Word; Var Data : TVideoMode) : Boolean;
  807. SetCursorPos : procedure (NewCursorX, NewCursorY: Word);
  808. GetCursorType : function : Word;
  809. SetCursorType : procedure (NewType: Word);
  810. GetCapabilities : Function : Word;
  811. end;
  812. </code>
  813. <p>
  814. Not all of these functions must be implemented. In fact, the only absolutely
  815. necessary function to write a functioning driver is the <var>UpdateScreen</var>
  816. function. The general calls in the <file>Video</file> unit will check which
  817. functionality is implemented by the driver.
  818. </p>
  819. <p>
  820. The functionality of these calls is the same as the functionality of the
  821. calls in the video unit, so the expected behaviour can be found in the
  822. previous section. Some of the calls, however, need some additional remarks.
  823. </p>
  824. <dl>
  825. <dt>InitDriver</dt>
  826. <dd> Called by <var>InitVideo</var>, this function should initialize
  827. any data structures needed for the functionality of the driver, maybe do some
  828. screen initializations. The function is guaranteed to be called only once; It
  829. can only be called again after a call to <var>DoneVideo</var>. The variables
  830. <var>ScreenWidth</var> and <var>ScreenHeight</var> should be initialized correctly
  831. after a call to this function, as the <var>InitVideo</var> call will initialize
  832. the <var>VideoBuf</var> and <var>OldVideoBuf</var> arrays based on their values.
  833. </dd>
  834. <dt>DoneDriver</dt>
  835. <dd> This should clean up any structures that have been
  836. initialized in the <var>InitDriver</var> function. It should possibly also
  837. restore the screen as it was before the driver was initialized. The VideoBuf
  838. and <var>OldVideoBuf</var> arrays will be disposed of by the general <var>DoneVideo</var>
  839. call.
  840. </dd>
  841. <dt>UpdateScreen</dt>
  842. <dd> This is the only required function of the driver. It
  843. should update the screen based on the <var>VideoBuf</var> array's contents. It
  844. can optimize this process by comparing the values with values in the
  845. <var>OldVideoBuf</var> array. After updating the screen, the <var>UpdateScreen</var>
  846. procedure should update the <var>OldVideoBuf</var> by itself. If the <var>Force</var>
  847. parameter is <var>True</var>, the whole screen should be updated, not just the
  848. changed values.
  849. </dd>
  850. <dt>ClearScreen</dt>
  851. <dd> If there is a faster way to clear the screen than to
  852. write spaces in all character cells, then it can be implemented here. If the
  853. driver does not implement this function, then the general routines will
  854. write spaces in all video cells, and will call <var>UpdateScreen(True)</var>.
  855. </dd>
  856. <dt>SetVideoMode</dt>
  857. <dd> Should set the desired video mode, if available. It
  858. should return <var>True</var> if the mode was set, <var>False</var> if not.
  859. </dd>
  860. <dt>GetVideoModeCount</dt>
  861. <dd> Should return the number of supported video modes.
  862. If no modes are supported, this function should not be implemented; the
  863. general routines will return 1. (for the current mode)
  864. </dd>
  865. <dt>GetVideoModeData</dt>
  866. <dd> Should return the data for the <var>Index</var>-th mode;
  867. <var>Index</var> is zero based. The function should return true if the data was
  868. returned correctly, false if <var>Index</var> contains an invalid index.
  869. If this is not implemented, then the general routine will return the current
  870. video mode when <var>Index</var> equals 0.
  871. </dd>
  872. <dt>GetCapabilities</dt>
  873. <dd> If this function is not implemented, zero (i.e.
  874. no capabilities) will be returned by the general function.
  875. </dd>
  876. </dl>
  877. <p>
  878. The following unit shows how to override a video driver, with a driver
  879. that writes debug information to a file. The unit can be used in any of
  880. the demonstration programs, by simply including it in the <var>uses</var>
  881. clause. Setting <var>DetailedVideoLogging</var> to
  882. <var>True</var> will create a more detailed log (but will also slow down
  883. functioning)
  884. </p>
  885. </descr>
  886. <example file="videoex/viddbg"/>
  887. </topic>
  888. <topic name="vidutil">
  889. <short>Examples utility unit</short>
  890. <descr>
  891. The examples in this section make use of the unit <file>vidutil</file>, which
  892. contains the <var>TextOut</var> function. This function writes a text to the
  893. screen at a given location. It looks as follows:
  894. </descr>
  895. <example file="videoex/vidutil"/>
  896. </topic>
  897. </module>
  898. </package>
  899. </fpdoc-descriptions>