syntax.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. CHARACTERS
  2. ----------
  3. The following special characters are defined:
  4. # The hashtag is the default character for starting a command and is
  5. subsequently known as the command character or tintin character.
  6. When loading a command file the command character is set to the
  7. first character in the file. The character can also be redefined
  8. using #config. It's adviced not to redefine the command character.
  9. ; The semi-colon is used as the command separator and can be used to
  10. separate two commands. Multiple commands can be strung together as
  11. well. Trailing semi-colons are ignored when reading a script file
  12. as this is a common error.
  13. { } Curly brackets aka braces are used for seperating multi word command
  14. arguments, nesting commands, and nesting variables. Braces cannot
  15. be escaped using \{ \}, to escape { } use \x7B \x7D
  16. " " Quote characters are used for strings in the #math, #if, #switch,
  17. and #case commands. Instead of " " you can use an extra set of
  18. braces { } to define strings, this is suggested if you are
  19. expecting input to contain " characters.
  20. ! The exclamation sign is used to repeat commands, see #help history.
  21. The character can be redefined using #config.
  22. \ An input line starting with a backslash is send verbatim if you are
  23. connected to a server. This character can be configured with
  24. #config.
  25. SUBSTITUTIONS
  26. -------------
  27. $&*@ All variable and function names must begin with an alphabetic
  28. character, followed by any number of alphanumeric characters
  29. and underscores.
  30. $ The dollar sign is used to retrieve the value of a variable.
  31. & The ampersand sign is used to retrieve the index of a variable.
  32. * The astrix sign is used to retrieve the name of a variable.
  33. @ The at sign followed by an alphanumeric string is used for functions.
  34. [ ] Brackets are used for nested variables which function as an
  35. associative array. Associative arrays are also known as tables and
  36. maps. Regex can be used within brackets to match multiple variables.
  37. Variables are ordered alphanumerically.
  38. + - The plus and minus sign is used to access variables by their index,
  39. with the first variable having index 1, and the last variable
  40. having index -1.
  41. %0- %99 The percent sign followed by a number is used for arguments by the
  42. following triggers:
  43. alias, action, button, delay, event, function, substitute, and tick.
  44. &0- &99 The ampersand sign followed by a number is used for arguments in the
  45. regex and replace commands.
  46. <000> Three alphanumeric characters encapsulated by the less- and greater-
  47. than signs are used for 4 and 8 bit color codes.
  48. <0000> Either a B (background) or F (foreground) followed by three
  49. hexadecimal characters encapsulated by < > signs are used for 12
  50. bit color codes. Requires truecolor capable terminal.
  51. <0000000> Either a B (background) or F (foreground) followed by six
  52. hexadecimal characters encapsulated by < > signs are used for 24
  53. bit color codes. Requires truecolor capable terminal.
  54. More information is available at #help color.
  55. \ The back slash is used to escape a character. All available options
  56. are listed at #help escape. Escapes are typically escaped when text
  57. leaves the client, by being send to a server, the shell, or being
  58. displayed on the screen. Escapes try to mimic escapes in PCRE when
  59. possible.
  60. \a 07 bell character.
  61. \t 08 horizontal tab character.
  62. \n 10 line feed character.
  63. \v 11 vertical tab character.
  64. \r 13 carriage return character.
  65. \e 27 escape character.
  66. \c 6 bit control character, \ca for ctrl-a.
  67. \x 8 bit character using 2 hexadecimal numbers.
  68. \u 16 bit unicode character, \uFFFD for example.
  69. \U 21 bit unicode character, \U02AF21 for example.
  70. All variables and functions can be escaped by doubling the sign,
  71. like $$variable_name or @@function_name. To escape a variable
  72. twice use $$$var_name. One escape is removed each time tintin
  73. needs to substitute a variable or function.
  74. All trigger arguments can be escaped by double the ampersand,
  75. like %%1. One escape is removed each time tintin substitutes
  76. trigger arguments.
  77. All command arguments can be escaped by doubling the ampersand,
  78. like &&1. One escape is removed each time tintin substitutes
  79. command arguments.
  80. COORDINATES
  81. -----------
  82. When the 0,0 coordinate is in the upper left corner TinTin++ uses
  83. a y,x / rows,cols notation, starting at 1,1. Subsequently -1,-1
  84. will indicate the bottom right corner. This type of argument is
  85. used by the #showme command.
  86. When the 0,0 coordinate is in the bottom left corner tintin uses
  87. a standard x,y notation. This type of argument is used by the
  88. #map jump command.
  89. SQUARES
  90. -------
  91. A square argument takes 2 coordinates. The first coordinate defines
  92. the upper left corner, the last two coordinates define the bottom
  93. right corner. The upper left corner of the terminal is defines as
  94. 1,1 and the bottom right corner as -1,-1. This type of argument is
  95. used by #draw, #button and #map offset.
  96. PANES
  97. -----
  98. A pane argument takes 4 size values, which are: top pane, bottom
  99. pane, left pane, right pane. When a negative value is provided the
  100. size is the maximum size, minus the value. This type of argument
  101. is used by the #split command.
  102. MATH
  103. ----
  104. Operators Priority Function
  105. ------------------------------------------------
  106. ! 0 logical not
  107. ~ 0 bitwise not
  108. * 1 integer multiply
  109. ** 1 integer power
  110. / 1 integer divide
  111. // 1 integer root
  112. % 1 integer modulo
  113. d 1 integer random dice roll
  114. + 2 integer addition
  115. - 2 integer subtraction
  116. << 3 bitwise shift
  117. >> 3 bitwise shift
  118. > 4 logical greater than
  119. >= 4 logical greater than or equal
  120. < 4 logical less than
  121. <= 4 logical less than or equal
  122. == 5 logical equal (can use regex)
  123. != 5 logical not equal (can use regex)
  124. === 5 string equal
  125. !== 5 string not equal
  126. & 6 bitwise and
  127. ^ 7 bitwise xor
  128. | 8 bitwise or
  129. && 9 logical and
  130. ^^ 10 logical xor
  131. || 11 logical or
  132. ? : The ? : symbols can be used for simple ternary operations.
  133. M,K,m,u These four metric suffixes are allowed for numbers.
  134. { } Braces can be used in #math to perform string operations.
  135. {a} > {b} This checks if the string "a" is greater than "b".
  136. , Commas in numbers are ignored, as well as spaces and tabs.
  137. . Dots can be used in #math to perform floating point calculations.
  138. The precision is set to the highest precision number used in the
  139. calculation.
  140. ( ) Braces can be used in #math to prioritize a calculation.
  141. STATEMENTS
  142. ----------
  143. TT++ has the following commands which behave like statements.
  144. #break
  145. #case {value} {true}
  146. #continue
  147. #default {commands}
  148. #else {commands}
  149. #elseif {expression} {true}
  150. #foreach {list} {variable} {commands}
  151. #if {expression} {true}
  152. #loop {min} {max} {variable} {commands}
  153. #parse {string} {variable} {commands}
  154. #return {value}
  155. #switch {expression} {commands}
  156. #while {expression} {commands}
  157. REGEX
  158. -----
  159. ^ force match of start of line.
  160. $ force match of end of line.
  161. \ escape one character.
  162. %1-%99 lazy match of any text, available at %1-%99.
  163. %0 should be avoided in triggers, and if left alone lists all matches.
  164. { } embed a raw regular expression, matches are stored to %1-%99.
  165. %!{ } embed a raw regular expression, matches are not stored.
  166. [ ] . + | ( ) ? * are treated as normal text unlessed used within
  167. braces. Keep in mind that { } is replaced with ( ) automatically
  168. unless %!{ } is used.
  169. Of the following the (lazy) match is available at %1-%99
  170. %w match zero to any number of word characters.
  171. %W match zero to any number of non word characters.
  172. %d match zero to any number of digits.
  173. %D match zero to any number of non digits.
  174. %s match zero to any number of spaces.
  175. %S match zero to any number of non spaces.
  176. %? match zero or one character.
  177. %. match one character.
  178. %+ match one to any number of characters.
  179. %* match zero to any number of characters.
  180. %i matching becomes case insensitive.
  181. %I matching becomes case sensitive (default).
  182. ESCAPE
  183. ------
  184. \a beep the terminal.
  185. \c send a control character, \ca for ctrl-a.
  186. \e start an escape sequence.
  187. \n send a line feed.
  188. \r send a carriage return.
  189. \t send a horizontal tab.
  190. \x print an 8 bit character using hexadecimal, \xFF for example.
  191. \x7B send the '{' character.
  192. \x7D send the '}' character.
  193. \u print a 16 bit unicode character, \uFFFD for example.
  194. \U print a 21 bit unicode character, \U02AF21 for example.
  195. \v send a vertical tab
  196. COLOR CODES
  197. -----------
  198. <xyz> with x, y, z being parameters
  199. Parameter 'x': VT100 code
  200. 0 - Reset all colors and codes to default
  201. 1 - Bold
  202. 2 - Dim
  203. 4 - Underscore
  204. 5 - Blink
  205. 7 - Reverse
  206. 8 - Skip (use previous code)
  207. Parameter 'y': Foreground color
  208. Parameter 'z': Background color
  209. 0 - Black 5 - Magenta
  210. 1 - Red 6 - Cyan
  211. 2 - Green 7 - White
  212. 3 - Yellow 8 - Skip
  213. 4 - Blue 9 - Default
  214. For xterm 256 colors support use <aaa> to <fff> for RGB foreground
  215. colors and <AAA> to <FFF> for RGB background colors. For the grayscale
  216. foreground colors use <g00> to <g23>, for grayscale background colors
  217. use <G00> to <G23>.
  218. The tertiary colors are as follows:
  219. <acf> - Azure <afc> - Jade
  220. <caf> - Violet <cfa> - Lime
  221. <fac> - Pink <fca> - Orange
  222. Example: #showme <acf>Azure <afc>Jade <caf>Violet
  223. Example: #showme <cfa>Lime <fac>Pink <fca>Orange
  224. For 12 bit truecolor use <F000> to <FFFF> for foreground colors and
  225. <B000> to <BFFF> for background colors.
  226. For 24 bit truecolor use <F000000> to <FFFFFFF> for foreground
  227. colors and <B000000> to <BFFFFFF> for background colors.
  228. HELP
  229. ----
  230. [ ] Argument is optional.
  231. < > Argument is required.
  232. { } Argument is literal.
  233. | Used to separate arguments with multiple options.