syntax.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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.
  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. easily be escaped and must always be used in pairs.
  16. " " Quote characters are used for strings in the #math, #if, #switch,
  17. and #case commands. It is however suggested to use an extra
  18. set of braces { } to define strings. Quote support will be
  19. phased out eventually since TT++ is typeless.
  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. &0- &99 The ampersand sign followed by a number is used for arguments in the
  38. regex command.
  39. <000> Three alphanumeric characters encapsulated by the less- and greater-
  40. than signs are used for 4 and 8 bit color codes.
  41. <0000> Either a B (background) or F (foreground) followed by three
  42. hexadecimal characters encapsulated by < > signs are used for 12
  43. bit color codes. Requires truecolor capable terminal.
  44. <0000000> Either a B (background) or F (foreground) followed by six
  45. hexadecimal characters encapsulated by < > signs are used for 24
  46. bit color codes. Requires truecolor capable terminal.
  47. More information is available at #help color.
  48. \ The back slash is used to escape a character. Available options
  49. are listed at #help escape. Escapes are typically escaped when text
  50. leaves the client, by being send to a server, the shell, or being
  51. displayed on the screen.
  52. All variables and functions can be escaped by doubling the sign,
  53. like $$variable_name or @@function_name. To escape a variable
  54. twice use $$$var_name. One escape is removed each time tintin
  55. needs to substitute a variable or function.
  56. COORDINATES
  57. -----------
  58. When the 0,0 coordinate is in the upper left corner TinTin++ uses
  59. a y,x / rows,cols notation. When the 0,0 coordinate is in the
  60. bottom left corner tintin uses a x,y / cols/rows notation.
  61. MATH
  62. ----
  63. Operators Priority Function
  64. ------------------------------------------------
  65. ! 0 logical not
  66. ~ 0 bitwise not
  67. * 1 integer multiply
  68. ** 1 integer power
  69. / 1 integer divide
  70. // 1 integer sqrt // 2 or cbrt // 3
  71. % 1 integer modulo
  72. d 1 integer random dice roll
  73. + 2 integer addition
  74. - 2 integer subtraction
  75. << 3 bitwise shift
  76. >> 3 bitwise shift
  77. > 4 logical greater than
  78. >= 4 logical greater than or equal
  79. < 4 logical less than
  80. <= 4 logical less than or equal
  81. == 5 logical equal (can use regex)
  82. != 5 logical not equal (can use regex)
  83. & 6 bitwise and
  84. ^ 7 bitwise xor
  85. | 8 bitwise or
  86. && 9 logical and
  87. ^^ 10 logical xor
  88. || 11 logical or
  89. : The colon can be used in #math to indicate a time value.
  90. 1:30 This means 1 minute and 30 seconds and equals 90 seconds.
  91. 2:1:30 This means 2 hours, 1 minute and 30 seconds.
  92. 6:2:1:30 This means 6 days, 2 hours, 1 minute and 30 seconds.
  93. #math time 6:2:1:30 equals 525690
  94. { } Braces can be used in #math to perform string operations.
  95. {a} > {b} This checks if the string "a" is greater than "b".
  96. , Commas in numbers are ignored, as well as spaces and tabs.
  97. . Dots can be used in #math to perform floating point calculations.
  98. The precision is set to the highest precision number used in the
  99. calculation.
  100. ( ) Braces can be used in #math to prioritize a calculation.
  101. STATEMENTS
  102. ----------
  103. TT++ has the following commands which behave like statements.
  104. #break
  105. #case {value} {true}
  106. #continue
  107. #default {commands}
  108. #else {commands}
  109. #elseif {expression} {true}
  110. #foreach {list} {variable} {commands}
  111. #if {expression} {true}
  112. #loop {min} {max} {variable} {commands}
  113. #parse {string} {variable} {commands}
  114. #return {value}
  115. #switch {expression} {commands}
  116. #while {expression} {commands}
  117. REGEX
  118. -----
  119. ^ force match of start of line.
  120. $ force match of end of line.
  121. \ escape one character.
  122. %1-%99 lazy match of any text, available at %1-%99.
  123. %0 should be avoided in triggers, and if left alone lists all matches.
  124. { } embed a raw regular expression, matches are stored to %1-%99.
  125. %!{ } embed a raw regular expression, matches are not stored.
  126. [ ] . + | ( ) ? * are treated as normal text unlessed used within
  127. braces. Keep in mind that { } is replaced with ( ) automatically
  128. unless %!{ } is used.
  129. Of the following the (lazy) match is available at %1-%99
  130. %w match zero to any number of word characters.
  131. %W match zero to any number of non word characters.
  132. %d match zero to any number of digits.
  133. %D match zero to any number of non digits.
  134. %s match zero to any number of spaces.
  135. %S match zero to any number of non spaces.
  136. %? match zero or one character.
  137. %. match one character.
  138. %+ match one to any number of characters.
  139. %* match zero to any number of characters.
  140. %i matching becomes case insensitive.
  141. %I matching becomes case sensitive (default).
  142. ESCAPE
  143. ------
  144. \a beep the terminal.
  145. \c send a control character, \ca for ctrl-a.
  146. \e start an escape sequence.
  147. \n send a line feed.
  148. \r send a carriage return.
  149. \t send a horizontal tab.
  150. \x print an 8 bit character using hexadecimal, \xFF for example.
  151. \x7B send the '{' character.
  152. \x7D send the '}' character.
  153. \u print a 16 bit unicode character, \uFFFD for example.
  154. \U print a 21 bit unicode character, \U02AF21 for example.
  155. \v send a vertical tab
  156. COLOR CODES
  157. -----------
  158. <xyz> with x, y, z being parameters
  159. Parameter 'x': VT100 code
  160. 0 - Reset all colors and codes to default
  161. 1 - Bold
  162. 2 - Dim
  163. 4 - Underscore
  164. 5 - Blink
  165. 7 - Reverse
  166. 8 - Skip (use previous code)
  167. Parameter 'y': Foreground color
  168. Parameter 'z': Background color
  169. 0 - Black 5 - Magenta
  170. 1 - Red 6 - Cyan
  171. 2 - Green 7 - White
  172. 3 - Yellow 8 - Skip
  173. 4 - Blue 9 - Default
  174. For xterm 256 colors support use <aaa> to <fff> for RGB foreground
  175. colors and <AAA> to <FFF> for RGB background colors. For the grayscale
  176. foreground colors use <g00> to <g23>, for grayscale background colors
  177. use <G00> to <G23>.
  178. The tertiary colors are as follows:
  179. <acf> - Azure <afc> - Jade
  180. <caf> - Violet <cfa> - Lime
  181. <fac> - Pink <fca> - Orange
  182. Example: #showme <acf>Azure <afc>Jade <caf>Violet
  183. Example: #showme <cfa>Lime <fac>Pink <fca>Orange
  184. For 12 bit truecolor use <F000> to <FFFF> for foreground colors and
  185. <B000> to <BFFF> for background colors.
  186. For 24 bit truecolor use \e[38;2;R;G;Bm where R G B are red/green/blue
  187. intensities between 0 and 255. For example: \e[37;2;50;100;150m. Use
  188. \e[48;2;R;G;Bm for background colors.
  189. HELP
  190. ----
  191. [ ] Argument is optional.
  192. < > Argument is required.
  193. { } Argument is literally the same.
  194. | Used to separate arguments with multiple options.
  195. CONFIGURATION DEFAULTS
  196. ----------------------
  197. [AUTO TAB ] [ 5000] Scroll back buffer lines used for tab completion
  198. [BUFFER SIZE ] [ 20000] The size of the scroll back buffer
  199. [CHARSET ] [ AUTO] The character set encoding used by TinTin++
  200. [CHILD LOCK ] [ OFF] TinTin++ is not child locked.
  201. [COLOR MODE ] [ 256] The color code encoding used by TinTin++
  202. [COLOR PATCH ] [ OFF] TinTin++ will leave color handling to the server
  203. [COMMAND COLOR ] [ <078>] The color of echoed commands
  204. [COMMAND ECHO ] [ ON] Your commands are echoed in split mode
  205. [CONNECT RETRY ] [ 0] Seconds TinTin++ sessions try to connect on failure
  206. [CONVERT META ] [ OFF] TinTin++ doesn't convert meta prefixed characters
  207. [HISTORY SIZE ] [ 1000] The size of the command history
  208. [INHERITANCE ] [ ON] The startup session is inherited
  209. [LOG ] [ RAW] The data format of the log files
  210. [LOG LEVEL ] [ HIGH] TinTin++ only logs high level mud data
  211. [MCCP ] [ ON] MCCP is enabled.
  212. [MOUSE TRACKING] [ OFF] Your terminal does not generate mouse events.
  213. [PACKET PATCH ] [ 0.00] Seconds TinTin++ will try to patch broken packets
  214. [RANDOM SEED ] [ AUTO] Seed value used for the random number engine
  215. [REPEAT ENTER ] [ OFF] You send a carriage return on an enter
  216. [REPEAT CHAR ] [ !] The character used for repeating commands
  217. [SCREEN READER ] [ OFF] You are not using a screen reader
  218. [SCROLL LOCK ] [ ON] You do not see mud output while scrolling
  219. [SPEEDWALK ] [ OFF] Your input is not scanned for speedwalk directions
  220. [TINTIN CHAR ] [ #] The character used for TinTin++ commands
  221. [VERBATIM ] [ OFF] Your keyboard input is parsed by TinTin++
  222. [VERBATIM CHAR ] [ \] The character used for unparsed text
  223. [VERBOSE ] [ OFF] Messages while reading in a script file are gagged
  224. [WORDWRAP ] [ ON] Mud output is word wrapped