VT100.def 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. DEFINITION MODULE VT100;
  2. (*
  3. The POSIX function cfmakeraw() sets the canonical
  4. combination. Applications typically use tcgetattr()
  5. to save the current settings, call cfmakeraw()
  6. to switch to raw mode, and call tcsetattr() with
  7. the saved settings on exit to restore the terminal.
  8. *)
  9. TYPE
  10. screenModes = (M40x25BW,M40x25C,M80x25BW,M80x25C,M320x200C4,M320x200BW,M640x200BW,
  11. M320x200C256,M640x200C,M640x350BW,M640x350C,M640x480BW,M640x480C,M320x200C);
  12. Attribut = (boldAt,dimAt,italicAt,underlineAt,blinkingAt,inverseAt,hiddenAt,
  13. strikethroughAt,doubleunderlineAt);
  14. Colors = (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, Default,
  15. BrightBlack, BrightRed, BrightGreen, BrightYellow,
  16. BrightBlue, BrighMagenta, BrightCyan, BrightWhite);
  17. (*
  18. ESC Code Sequence Reset Sequence Description
  19. ESC[1;34;{...}m Set graphics modes for cell, separated by semicolon (;).
  20. ESC[1m ESC[22m set bold mode.
  21. ESC[2m ESC[22m set dim/faint mode.
  22. ESC[3m ESC[23m set italic mode.
  23. ESC[4m ESC[24m set underline mode.
  24. ESC[5m ESC[25m set blinking mode
  25. ESC[7m ESC[27m set inverse/reverse mode
  26. ESC[8m ESC[28m set hidden/invisible mode
  27. ESC[9m ESC[29m set strikethrough mode.
  28. ESC[21m ESC[24m set double underline
  29. *)
  30. PROCEDURE modesoff; (*OK*)
  31. (* SGR0 Turn off character attributes ^[[m *)
  32. PROCEDURE modesoff1; (*OK*)
  33. (* SGR0 Turn off character attributes ^[[0m *)
  34. PROCEDURE bold; (*OK*)
  35. (* SGR1 Turn bold mode on ^[[1m *)
  36. PROCEDURE lowint; (*OK*)
  37. (* SGR2 Turn low intensity mode on ^[[2m *)
  38. PROCEDURE italic; (*OK*)
  39. (* set italic mode ESC[3m *)
  40. PROCEDURE underline; (*OK*)
  41. (* SGR4 Turn underline mode on ^[[4m *)
  42. PROCEDURE blink; (*OK*)
  43. (* SGR5 Turn blinking mode on ^[[5m *)
  44. PROCEDURE reverse; (*OK*)
  45. (* SGR7 Turn reverse video on ^[[7m *)
  46. PROCEDURE invisible; (*OK*)
  47. (* SGR8 Turn invisible text mode on ^[[8m *)
  48. PROCEDURE strikethrough; (*OK*)
  49. (* ESC[9m ESC[29m set strikethrough mode. *)
  50. PROCEDURE doubleUnderline;
  51. (* ESC[21m *)
  52. PROCEDURE resetbold; (*OK*)
  53. (* SGR1 Turn bold mode on ^[[1m *)
  54. PROCEDURE resetlowint; (*OK*)
  55. (* SGR2 Turn low intensity mode on ^[[2m *)
  56. PROCEDURE resetitalic; (*OK*)
  57. (* set italic mode ESC[3m *)
  58. PROCEDURE resetunderline; (*OK*)
  59. (* SGR4 Turn underline mode on ^[[4m *)
  60. PROCEDURE resetblink; (*OK*)
  61. (* SGR5 Turn blinking mode on ^[[5m *)
  62. PROCEDURE resetreverse; (*OK*)
  63. (* SGR7 Turn reverse video on ^[[7m *)
  64. PROCEDURE resetinvisible; (*OK*)
  65. (* SGR8 Turn invisible text mode on ^[[8m *)
  66. PROCEDURE resetstrikethrough; (*OK*)
  67. (* ESC[9m ESC[29m set strikethrough mode. *)
  68. PROCEDURE resetDoubleUnderline;
  69. (* ESC[24m. *)
  70. (*
  71. ESC Code Sequence Description
  72. ESC[H moves cursor to home position (0, 0)
  73. ESC[{line};{column}H
  74. ESC[{line};{column}f moves cursor to line #, column #
  75. ESC[#A moves cursor up # lines
  76. ESC[#B moves cursor down # lines
  77. ESC[#C moves cursor right # columns
  78. ESC[#D moves cursor left # columns
  79. ESC[#E moves cursor to beginning of next line, # lines down
  80. ESC[#F moves cursor to beginning of previous line, # lines up
  81. ESC[#G moves cursor to column #
  82. ESC[6n request cursor position (reports as ESC[#;#R)
  83. ESC M moves cursor one line up, scrolling if needed
  84. ESC 7 save cursor position (DEC)
  85. ESC 8 restores the cursor to the last saved position (DEC)
  86. ESC[s save cursor position (SCO)
  87. ESC[u restores the cursor to the last saved position (SCO)
  88. *)
  89. PROCEDURE requestCursorPosition(VAR x,y : CARDINAL);
  90. (* ESC[6n request cursor position (reports as ESC[#;#R) *)
  91. PROCEDURE cursorhome; (*OK*)
  92. (* Move cursor to upper left corner ^[[H *)
  93. PROCEDURE cursorhome1; (*OK*)
  94. (* Move cursor to upper left corner ^[[;H *)
  95. PROCEDURE cursorpos(x,y: CARDINAL); (*OK*)
  96. (* CUP Move cursor to screen location v,h ^[[<v>;<h>H *)
  97. PROCEDURE clearscreen; (* OK *)
  98. (* ED2 Clear entire screen ^[[2J *)
  99. (*
  100. Screen Modes
  101. Set Mode
  102. ESC Code Sequence Description
  103. ESC[={value}h Changes the screen width or type to the mode specified by value.
  104. ESC[=0h 40 x 25 monochrome (text)
  105. ESC[=1h 40 x 25 color (text)
  106. ESC[=2h 80 x 25 monochrome (text)
  107. ESC[=3h 80 x 25 color (text)
  108. ESC[=4h 320 x 200 4-color (graphics)
  109. ESC[=5h 320 x 200 monochrome (graphics)
  110. ESC[=6h 640 x 200 monochrome (graphics)
  111. ESC[=7h Enables line wrapping
  112. ESC[=13h 320 x 200 color (graphics)
  113. ESC[=14h 640 x 200 color (16-color graphics)
  114. ESC[=15h 640 x 350 monochrome (2-color graphics)
  115. ESC[=16h 640 x 350 color (16-color graphics)
  116. ESC[=17h 640 x 480 monochrome (2-color graphics)
  117. ESC[=18h 640 x 480 color (16-color graphics)
  118. ESC[=19h 320 x 200 color (256-color graphics)
  119. ESC[={value}l Resets the mode by using the same values that Set Mode uses, except for 7, which disables line wrapping. The last character in this escape sequence is a lowercase L.
  120. Common Private Modes
  121. *)
  122. PROCEDURE screenMode(mode : screenModes);
  123. PROCEDURE resetScreenMode(mode : screenModes);
  124. PROCEDURE lineWrapping;
  125. PROCEDURE resetLineWrapping;
  126. (*
  127. These are some examples of private modes, which are not defined by the specification, but are implemented in most terminals.
  128. ESC Code Sequence Description
  129. ESC[?25l make cursor invisible
  130. ESC[?25h make cursor visible
  131. ESC[?47l restore screen
  132. ESC[?47h save screen
  133. ESC[?1049h enables the alternative buffer
  134. ESC[?1049l disables the alternative buffer
  135. *)
  136. PROCEDURE makeCursorInvisible;
  137. PROCEDURE makeCursorVisible;
  138. PROCEDURE restoreScreen;
  139. PROCEDURE saveScreen;
  140. PROCEDURE enableAlternativeBuffer;
  141. PROCEDURE disableAlternativeBuffer;
  142. (*
  143. Color codes
  144. Most terminals support 8 and 16 colors, as well as 256 (8-bit) colors. These colors are set by the user, but have commonly defined meanings.
  145. 8-16 Colors
  146. Color Name Foreground Color Code Background Color Code
  147. Black 30 40
  148. Red 31 41
  149. Green 32 42
  150. Yellow 33 43
  151. Blue 34 44
  152. Magenta 35 45
  153. Cyan 36 46
  154. White 37 47
  155. Default 39 49
  156. Reset 0 0
  157. Note: the Reset color is the reset code that resets all colors and text effects, Use Default color to reset colors only.
  158. Most terminals, apart from the basic set of 8 colors, also support the "bright" or "bold" colors. These have their own set of codes, mirroring the normal colors, but with an additional ;1 in their codes:
  159. # Set style to bold, red foreground.
  160. \x1b[1;31mHello
  161. # Set style to dimmed white foreground with red background.
  162. \x1b[2;37;41mWorld
  163. Terminals that support the aixterm specification provides bright versions of the ISO colors, without the need to use the bold modifier:
  164. Color Name Foreground Color Code Background Color Code
  165. Bright Black 90 100
  166. Bright Red 91 101
  167. Bright Green 92 102
  168. Bright Yellow 93 103
  169. Bright Blue 94 104
  170. Bright Magenta 95 105
  171. Bright Cyan 96 106
  172. Bright White 97 107
  173. 256 Colors
  174. *)
  175. PROCEDURE setAttribut ( attribut: Attribut; front, back : Colors);
  176. (*
  177. #
  178. # All codes below are for use in VT52 compatibility mode.
  179. #
  180. *)
  181. PROCEDURE VT52setansi; (*OK*)
  182. (* Enter/exit ANSI mode (VT52) ^[< *)
  183. PROCEDURE VT52altkeypad;
  184. (* Enter alternate keypad mode ^[= *)
  185. PROCEDURE VT52numkeypad;
  186. (* Exit alternate keypad mode ^[> *)
  187. PROCEDURE VT52setgr; (* NOT OK*)
  188. (* Use special graphics character set ^[F *)
  189. PROCEDURE VT52resetgr; (* NOT OK*)
  190. (* Use normal US/UK character set ^[G *)
  191. PROCEDURE VT52cursorup; (*OK*)
  192. (* Move cursor up one line ^[A *)
  193. PROCEDURE VT52cursordn; (*OK*)
  194. (* Move cursor down one line ^[B *)
  195. PROCEDURE VT52cursorrt; (*OK*)
  196. (* Move cursor right one char ^[C *)
  197. PROCEDURE VT52cursorlf; (*OK*)
  198. (* Move cursor left one char ^[D *)
  199. PROCEDURE VT52cursorhome; (*OK*)
  200. (* Move cursor to upper left corner ^[H *)
  201. PROCEDURE VT52cursorpos(x, y : CARDINAL); (* NOT OK*)
  202. (* Move cursor to v,h location ^[<v><h> *)
  203. PROCEDURE VT52revindex;
  204. (* Generate a reverse line-feed ^[I *)
  205. PROCEDURE VT52cleareol; (*OK*)
  206. (* Erase to end of current line ^[K *)
  207. PROCEDURE VT52cleareos; (*OK*)
  208. (* Erase to end of screen ^[J *)
  209. PROCEDURE VT52ident;
  210. (* Identify what the terminal is ^[Z *)
  211. PROCEDURE VT52identresp;
  212. (*Correct response to ident ^[/Z *)
  213. PROCEDURE CloseTerminal;
  214. (* PROCEDURE tcsetattr (fd: INTEGER; option: INTEGER; t: TERMIOS) : INTEGER ; *)
  215. PROCEDURE InitTerminal;
  216. (* PROCEDURE tcgetattr (fd: INTEGER; t: TERMIOS) : INTEGER ; *)
  217. END VT100.