ace-rails-ap 0.0.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. data/lib/ace/rails/version.rb +1 -1
  2. data/vendor/assets/javascripts/ace.js +15680 -1
  3. data/vendor/assets/javascripts/keybinding-emacs.js +367 -1
  4. data/vendor/assets/javascripts/keybinding-vim.js +1635 -1
  5. data/vendor/assets/javascripts/mode-c9search.js +275 -0
  6. data/vendor/assets/javascripts/mode-c_cpp.js +744 -1
  7. data/vendor/assets/javascripts/mode-clojure.js +364 -1
  8. data/vendor/assets/javascripts/mode-coffee.js +527 -1
  9. data/vendor/assets/javascripts/mode-coldfusion.js +1966 -1
  10. data/vendor/assets/javascripts/mode-csharp.js +633 -1
  11. data/vendor/assets/javascripts/mode-css.js +499 -1
  12. data/vendor/assets/javascripts/mode-diff.js +250 -0
  13. data/vendor/assets/javascripts/{mode-c_cpp-uncompressed.js → mode-glsl.js} +147 -244
  14. data/vendor/assets/javascripts/mode-golang.js +681 -1
  15. data/vendor/assets/javascripts/mode-groovy.js +1240 -1
  16. data/vendor/assets/javascripts/mode-haxe.js +633 -1
  17. data/vendor/assets/javascripts/mode-html.js +2064 -1
  18. data/vendor/assets/javascripts/mode-java.js +1202 -1
  19. data/vendor/assets/javascripts/mode-javascript.js +1069 -1
  20. data/vendor/assets/javascripts/mode-json.js +588 -1
  21. data/vendor/assets/javascripts/{mode-haxe-uncompressed.js → mode-jsx.js} +189 -312
  22. data/vendor/assets/javascripts/mode-latex.js +95 -1
  23. data/vendor/assets/javascripts/mode-less.js +512 -1
  24. data/vendor/assets/javascripts/mode-liquid.js +1125 -1
  25. data/vendor/assets/javascripts/mode-lua.js +551 -1
  26. data/vendor/assets/javascripts/{mode-html-uncompressed.js → mode-luahtml.js} +544 -604
  27. data/vendor/assets/javascripts/{mode-coldfusion-uncompressed.js → mode-luapage.js} +2326 -2180
  28. data/vendor/assets/javascripts/mode-markdown.js +2369 -1
  29. data/vendor/assets/javascripts/mode-ocaml.js +464 -1
  30. data/vendor/assets/javascripts/mode-perl.js +432 -1
  31. data/vendor/assets/javascripts/mode-pgsql.js +970 -1
  32. data/vendor/assets/javascripts/mode-php.js +1718 -1
  33. data/vendor/assets/javascripts/mode-powershell.js +610 -1
  34. data/vendor/assets/javascripts/mode-python.js +397 -1
  35. data/vendor/assets/javascripts/mode-ruby.js +318 -1
  36. data/vendor/assets/javascripts/mode-scad.js +732 -1
  37. data/vendor/assets/javascripts/mode-scala.js +1237 -1
  38. data/vendor/assets/javascripts/mode-scss.js +537 -1
  39. data/vendor/assets/javascripts/mode-sh.js +250 -1
  40. data/vendor/assets/javascripts/mode-sql.js +140 -1
  41. data/vendor/assets/javascripts/mode-svg.js +1681 -1
  42. data/vendor/assets/javascripts/mode-tcl.js +320 -0
  43. data/vendor/assets/javascripts/mode-textile.js +182 -1
  44. data/vendor/assets/javascripts/mode-xml.js +829 -1
  45. data/vendor/assets/javascripts/mode-xquery.js +605 -1
  46. data/vendor/assets/javascripts/mode-yaml.js +189 -0
  47. data/vendor/assets/javascripts/theme-chrome.js +213 -1
  48. data/vendor/assets/javascripts/theme-clouds.js +167 -1
  49. data/vendor/assets/javascripts/theme-clouds_midnight.js +168 -1
  50. data/vendor/assets/javascripts/theme-cobalt.js +194 -1
  51. data/vendor/assets/javascripts/theme-crimson_editor.js +200 -1
  52. data/vendor/assets/javascripts/theme-dawn.js +198 -1
  53. data/vendor/assets/javascripts/theme-dreamweaver.js +230 -1
  54. data/vendor/assets/javascripts/theme-eclipse.js +157 -1
  55. data/vendor/assets/javascripts/theme-github.js +182 -0
  56. data/vendor/assets/javascripts/theme-idle_fingers.js +186 -1
  57. data/vendor/assets/javascripts/theme-kr_theme.js +189 -1
  58. data/vendor/assets/javascripts/theme-merbivore.js +189 -1
  59. data/vendor/assets/javascripts/theme-merbivore_soft.js +195 -1
  60. data/vendor/assets/javascripts/theme-mono_industrial.js +197 -1
  61. data/vendor/assets/javascripts/theme-monokai.js +194 -1
  62. data/vendor/assets/javascripts/theme-pastel_on_dark.js +199 -1
  63. data/vendor/assets/javascripts/theme-solarized_dark.js +180 -1
  64. data/vendor/assets/javascripts/theme-solarized_light.js +179 -1
  65. data/vendor/assets/javascripts/theme-textmate.js +216 -0
  66. data/vendor/assets/javascripts/theme-tomorrow.js +213 -1
  67. data/vendor/assets/javascripts/theme-tomorrow_night.js +213 -1
  68. data/vendor/assets/javascripts/theme-tomorrow_night_blue.js +213 -1
  69. data/vendor/assets/javascripts/theme-tomorrow_night_bright.js +213 -1
  70. data/vendor/assets/javascripts/theme-tomorrow_night_eighties.js +209 -1
  71. data/vendor/assets/javascripts/theme-twilight.js +211 -1
  72. data/vendor/assets/javascripts/theme-vibrant_ink.js +190 -1
  73. data/vendor/assets/javascripts/worker-coffee.js +83 -893
  74. data/vendor/assets/javascripts/worker-css.js +88 -1402
  75. data/vendor/assets/javascripts/worker-javascript.js +97 -812
  76. data/vendor/assets/javascripts/worker-json.js +84 -761
  77. data/vendor/assets/javascripts/worker-xquery.js +66464 -0
  78. metadata +12 -195
  79. data/vendor/assets/javascripts/ace-compat-noconflict.js +0 -1
  80. data/vendor/assets/javascripts/ace-compat-uncompressed-noconflict.js +0 -480
  81. data/vendor/assets/javascripts/ace-compat-uncompressed.js +0 -480
  82. data/vendor/assets/javascripts/ace-compat.js +0 -1
  83. data/vendor/assets/javascripts/ace-noconflict.js +0 -10
  84. data/vendor/assets/javascripts/ace-uncompressed-noconflict.js +0 -19976
  85. data/vendor/assets/javascripts/ace-uncompressed.js +0 -19976
  86. data/vendor/assets/javascripts/keybinding-emacs-noconflict.js +0 -1
  87. data/vendor/assets/javascripts/keybinding-emacs-uncompressed-noconflict.js +0 -150
  88. data/vendor/assets/javascripts/keybinding-emacs-uncompressed.js +0 -150
  89. data/vendor/assets/javascripts/keybinding-vim-noconflict.js +0 -1
  90. data/vendor/assets/javascripts/keybinding-vim-uncompressed-noconflict.js +0 -138
  91. data/vendor/assets/javascripts/keybinding-vim-uncompressed.js +0 -138
  92. data/vendor/assets/javascripts/mode-c_cpp-noconflict.js +0 -1
  93. data/vendor/assets/javascripts/mode-c_cpp-uncompressed-noconflict.js +0 -919
  94. data/vendor/assets/javascripts/mode-clojure-noconflict.js +0 -1
  95. data/vendor/assets/javascripts/mode-clojure-uncompressed-noconflict.js +0 -422
  96. data/vendor/assets/javascripts/mode-clojure-uncompressed.js +0 -422
  97. data/vendor/assets/javascripts/mode-coffee-noconflict.js +0 -1
  98. data/vendor/assets/javascripts/mode-coffee-uncompressed-noconflict.js +0 -607
  99. data/vendor/assets/javascripts/mode-coffee-uncompressed.js +0 -607
  100. data/vendor/assets/javascripts/mode-coldfusion-noconflict.js +0 -1
  101. data/vendor/assets/javascripts/mode-coldfusion-uncompressed-noconflict.js +0 -2458
  102. data/vendor/assets/javascripts/mode-csharp-noconflict.js +0 -1
  103. data/vendor/assets/javascripts/mode-csharp-uncompressed-noconflict.js +0 -769
  104. data/vendor/assets/javascripts/mode-csharp-uncompressed.js +0 -769
  105. data/vendor/assets/javascripts/mode-css-noconflict.js +0 -1
  106. data/vendor/assets/javascripts/mode-css-uncompressed-noconflict.js +0 -641
  107. data/vendor/assets/javascripts/mode-css-uncompressed.js +0 -641
  108. data/vendor/assets/javascripts/mode-golang-noconflict.js +0 -1
  109. data/vendor/assets/javascripts/mode-golang-uncompressed-noconflict.js +0 -378
  110. data/vendor/assets/javascripts/mode-golang-uncompressed.js +0 -378
  111. data/vendor/assets/javascripts/mode-groovy-noconflict.js +0 -1
  112. data/vendor/assets/javascripts/mode-groovy-uncompressed-noconflict.js +0 -1393
  113. data/vendor/assets/javascripts/mode-groovy-uncompressed.js +0 -1393
  114. data/vendor/assets/javascripts/mode-haxe-noconflict.js +0 -1
  115. data/vendor/assets/javascripts/mode-haxe-uncompressed-noconflict.js +0 -769
  116. data/vendor/assets/javascripts/mode-html-noconflict.js +0 -1
  117. data/vendor/assets/javascripts/mode-html-uncompressed-noconflict.js +0 -2475
  118. data/vendor/assets/javascripts/mode-java-noconflict.js +0 -1
  119. data/vendor/assets/javascripts/mode-java-uncompressed-noconflict.js +0 -1395
  120. data/vendor/assets/javascripts/mode-java-uncompressed.js +0 -1395
  121. data/vendor/assets/javascripts/mode-javascript-noconflict.js +0 -1
  122. data/vendor/assets/javascripts/mode-javascript-uncompressed-noconflict.js +0 -1226
  123. data/vendor/assets/javascripts/mode-javascript-uncompressed.js +0 -1226
  124. data/vendor/assets/javascripts/mode-json-noconflict.js +0 -1
  125. data/vendor/assets/javascripts/mode-json-uncompressed-noconflict.js +0 -701
  126. data/vendor/assets/javascripts/mode-json-uncompressed.js +0 -701
  127. data/vendor/assets/javascripts/mode-latex-noconflict.js +0 -1
  128. data/vendor/assets/javascripts/mode-latex-uncompressed-noconflict.js +0 -95
  129. data/vendor/assets/javascripts/mode-latex-uncompressed.js +0 -95
  130. data/vendor/assets/javascripts/mode-less-noconflict.js +0 -1
  131. data/vendor/assets/javascripts/mode-less-uncompressed-noconflict.js +0 -655
  132. data/vendor/assets/javascripts/mode-less-uncompressed.js +0 -655
  133. data/vendor/assets/javascripts/mode-liquid-noconflict.js +0 -1
  134. data/vendor/assets/javascripts/mode-liquid-uncompressed-noconflict.js +0 -1353
  135. data/vendor/assets/javascripts/mode-liquid-uncompressed.js +0 -1353
  136. data/vendor/assets/javascripts/mode-lua-noconflict.js +0 -1
  137. data/vendor/assets/javascripts/mode-lua-uncompressed-noconflict.js +0 -523
  138. data/vendor/assets/javascripts/mode-lua-uncompressed.js +0 -523
  139. data/vendor/assets/javascripts/mode-markdown-noconflict.js +0 -1
  140. data/vendor/assets/javascripts/mode-markdown-uncompressed-noconflict.js +0 -2925
  141. data/vendor/assets/javascripts/mode-markdown-uncompressed.js +0 -2925
  142. data/vendor/assets/javascripts/mode-ocaml-noconflict.js +0 -1
  143. data/vendor/assets/javascripts/mode-ocaml-uncompressed-noconflict.js +0 -539
  144. data/vendor/assets/javascripts/mode-ocaml-uncompressed.js +0 -539
  145. data/vendor/assets/javascripts/mode-perl-noconflict.js +0 -1
  146. data/vendor/assets/javascripts/mode-perl-uncompressed-noconflict.js +0 -574
  147. data/vendor/assets/javascripts/mode-perl-uncompressed.js +0 -574
  148. data/vendor/assets/javascripts/mode-pgsql-noconflict.js +0 -1
  149. data/vendor/assets/javascripts/mode-pgsql-uncompressed-noconflict.js +0 -1104
  150. data/vendor/assets/javascripts/mode-pgsql-uncompressed.js +0 -1104
  151. data/vendor/assets/javascripts/mode-php-noconflict.js +0 -1
  152. data/vendor/assets/javascripts/mode-php-uncompressed-noconflict.js +0 -1885
  153. data/vendor/assets/javascripts/mode-php-uncompressed.js +0 -1885
  154. data/vendor/assets/javascripts/mode-powershell-noconflict.js +0 -1
  155. data/vendor/assets/javascripts/mode-powershell-uncompressed-noconflict.js +0 -710
  156. data/vendor/assets/javascripts/mode-powershell-uncompressed.js +0 -710
  157. data/vendor/assets/javascripts/mode-python-noconflict.js +0 -1
  158. data/vendor/assets/javascripts/mode-python-uncompressed-noconflict.js +0 -507
  159. data/vendor/assets/javascripts/mode-python-uncompressed.js +0 -507
  160. data/vendor/assets/javascripts/mode-ruby-noconflict.js +0 -1
  161. data/vendor/assets/javascripts/mode-ruby-uncompressed-noconflict.js +0 -391
  162. data/vendor/assets/javascripts/mode-ruby-uncompressed.js +0 -391
  163. data/vendor/assets/javascripts/mode-scad-noconflict.js +0 -1
  164. data/vendor/assets/javascripts/mode-scad-uncompressed-noconflict.js +0 -907
  165. data/vendor/assets/javascripts/mode-scad-uncompressed.js +0 -907
  166. data/vendor/assets/javascripts/mode-scala-noconflict.js +0 -1
  167. data/vendor/assets/javascripts/mode-scala-uncompressed-noconflict.js +0 -1395
  168. data/vendor/assets/javascripts/mode-scala-uncompressed.js +0 -1395
  169. data/vendor/assets/javascripts/mode-scss-noconflict.js +0 -1
  170. data/vendor/assets/javascripts/mode-scss-uncompressed-noconflict.js +0 -679
  171. data/vendor/assets/javascripts/mode-scss-uncompressed.js +0 -679
  172. data/vendor/assets/javascripts/mode-sh-noconflict.js +0 -1
  173. data/vendor/assets/javascripts/mode-sh-uncompressed-noconflict.js +0 -289
  174. data/vendor/assets/javascripts/mode-sh-uncompressed.js +0 -289
  175. data/vendor/assets/javascripts/mode-sql-noconflict.js +0 -1
  176. data/vendor/assets/javascripts/mode-sql-uncompressed-noconflict.js +0 -159
  177. data/vendor/assets/javascripts/mode-sql-uncompressed.js +0 -159
  178. data/vendor/assets/javascripts/mode-svg-noconflict.js +0 -1
  179. data/vendor/assets/javascripts/mode-svg-uncompressed-noconflict.js +0 -2137
  180. data/vendor/assets/javascripts/mode-svg-uncompressed.js +0 -2137
  181. data/vendor/assets/javascripts/mode-text-noconflict.js +0 -0
  182. data/vendor/assets/javascripts/mode-text-uncompressed-noconflict.js +0 -0
  183. data/vendor/assets/javascripts/mode-text-uncompressed.js +0 -0
  184. data/vendor/assets/javascripts/mode-textile-noconflict.js +0 -1
  185. data/vendor/assets/javascripts/mode-textile-uncompressed-noconflict.js +0 -254
  186. data/vendor/assets/javascripts/mode-textile-uncompressed.js +0 -254
  187. data/vendor/assets/javascripts/mode-xml-noconflict.js +0 -1
  188. data/vendor/assets/javascripts/mode-xml-uncompressed-noconflict.js +0 -1012
  189. data/vendor/assets/javascripts/mode-xml-uncompressed.js +0 -1012
  190. data/vendor/assets/javascripts/mode-xquery-noconflict.js +0 -1
  191. data/vendor/assets/javascripts/mode-xquery-uncompressed-noconflict.js +0 -540
  192. data/vendor/assets/javascripts/mode-xquery-uncompressed.js +0 -540
  193. data/vendor/assets/javascripts/theme-chrome-noconflict.js +0 -1
  194. data/vendor/assets/javascripts/theme-chrome-uncompressed-noconflict.js +0 -207
  195. data/vendor/assets/javascripts/theme-chrome-uncompressed.js +0 -207
  196. data/vendor/assets/javascripts/theme-clouds-noconflict.js +0 -1
  197. data/vendor/assets/javascripts/theme-clouds-uncompressed-noconflict.js +0 -160
  198. data/vendor/assets/javascripts/theme-clouds-uncompressed.js +0 -160
  199. data/vendor/assets/javascripts/theme-clouds_midnight-noconflict.js +0 -1
  200. data/vendor/assets/javascripts/theme-clouds_midnight-uncompressed-noconflict.js +0 -161
  201. data/vendor/assets/javascripts/theme-clouds_midnight-uncompressed.js +0 -161
  202. data/vendor/assets/javascripts/theme-cobalt-noconflict.js +0 -1
  203. data/vendor/assets/javascripts/theme-cobalt-uncompressed-noconflict.js +0 -187
  204. data/vendor/assets/javascripts/theme-cobalt-uncompressed.js +0 -187
  205. data/vendor/assets/javascripts/theme-crimson_editor-noconflict.js +0 -1
  206. data/vendor/assets/javascripts/theme-crimson_editor-uncompressed-noconflict.js +0 -198
  207. data/vendor/assets/javascripts/theme-crimson_editor-uncompressed.js +0 -198
  208. data/vendor/assets/javascripts/theme-dawn-noconflict.js +0 -1
  209. data/vendor/assets/javascripts/theme-dawn-uncompressed-noconflict.js +0 -191
  210. data/vendor/assets/javascripts/theme-dawn-uncompressed.js +0 -191
  211. data/vendor/assets/javascripts/theme-dreamweaver-noconflict.js +0 -1
  212. data/vendor/assets/javascripts/theme-dreamweaver-uncompressed-noconflict.js +0 -227
  213. data/vendor/assets/javascripts/theme-dreamweaver-uncompressed.js +0 -227
  214. data/vendor/assets/javascripts/theme-eclipse-noconflict.js +0 -1
  215. data/vendor/assets/javascripts/theme-eclipse-uncompressed-noconflict.js +0 -147
  216. data/vendor/assets/javascripts/theme-eclipse-uncompressed.js +0 -147
  217. data/vendor/assets/javascripts/theme-idle_fingers-noconflict.js +0 -1
  218. data/vendor/assets/javascripts/theme-idle_fingers-uncompressed-noconflict.js +0 -179
  219. data/vendor/assets/javascripts/theme-idle_fingers-uncompressed.js +0 -179
  220. data/vendor/assets/javascripts/theme-kr_theme-noconflict.js +0 -1
  221. data/vendor/assets/javascripts/theme-kr_theme-uncompressed-noconflict.js +0 -182
  222. data/vendor/assets/javascripts/theme-kr_theme-uncompressed.js +0 -182
  223. data/vendor/assets/javascripts/theme-merbivore-noconflict.js +0 -1
  224. data/vendor/assets/javascripts/theme-merbivore-uncompressed-noconflict.js +0 -182
  225. data/vendor/assets/javascripts/theme-merbivore-uncompressed.js +0 -182
  226. data/vendor/assets/javascripts/theme-merbivore_soft-noconflict.js +0 -1
  227. data/vendor/assets/javascripts/theme-merbivore_soft-uncompressed-noconflict.js +0 -188
  228. data/vendor/assets/javascripts/theme-merbivore_soft-uncompressed.js +0 -188
  229. data/vendor/assets/javascripts/theme-mono_industrial-noconflict.js +0 -1
  230. data/vendor/assets/javascripts/theme-mono_industrial-uncompressed-noconflict.js +0 -190
  231. data/vendor/assets/javascripts/theme-mono_industrial-uncompressed.js +0 -190
  232. data/vendor/assets/javascripts/theme-monokai-noconflict.js +0 -1
  233. data/vendor/assets/javascripts/theme-monokai-uncompressed-noconflict.js +0 -191
  234. data/vendor/assets/javascripts/theme-monokai-uncompressed.js +0 -191
  235. data/vendor/assets/javascripts/theme-pastel_on_dark-noconflict.js +0 -1
  236. data/vendor/assets/javascripts/theme-pastel_on_dark-uncompressed-noconflict.js +0 -192
  237. data/vendor/assets/javascripts/theme-pastel_on_dark-uncompressed.js +0 -192
  238. data/vendor/assets/javascripts/theme-solarized_dark-noconflict.js +0 -1
  239. data/vendor/assets/javascripts/theme-solarized_dark-uncompressed-noconflict.js +0 -176
  240. data/vendor/assets/javascripts/theme-solarized_dark-uncompressed.js +0 -176
  241. data/vendor/assets/javascripts/theme-solarized_light-noconflict.js +0 -1
  242. data/vendor/assets/javascripts/theme-solarized_light-uncompressed-noconflict.js +0 -172
  243. data/vendor/assets/javascripts/theme-solarized_light-uncompressed.js +0 -172
  244. data/vendor/assets/javascripts/theme-textmate-noconflict.js +0 -0
  245. data/vendor/assets/javascripts/theme-textmate-uncompressed-noconflict.js +0 -0
  246. data/vendor/assets/javascripts/theme-textmate-uncompressed.js +0 -0
  247. data/vendor/assets/javascripts/theme-tomorrow-noconflict.js +0 -1
  248. data/vendor/assets/javascripts/theme-tomorrow-uncompressed-noconflict.js +0 -206
  249. data/vendor/assets/javascripts/theme-tomorrow-uncompressed.js +0 -206
  250. data/vendor/assets/javascripts/theme-tomorrow_night-noconflict.js +0 -1
  251. data/vendor/assets/javascripts/theme-tomorrow_night-uncompressed-noconflict.js +0 -206
  252. data/vendor/assets/javascripts/theme-tomorrow_night-uncompressed.js +0 -206
  253. data/vendor/assets/javascripts/theme-tomorrow_night_blue-noconflict.js +0 -1
  254. data/vendor/assets/javascripts/theme-tomorrow_night_blue-uncompressed-noconflict.js +0 -209
  255. data/vendor/assets/javascripts/theme-tomorrow_night_blue-uncompressed.js +0 -209
  256. data/vendor/assets/javascripts/theme-tomorrow_night_bright-noconflict.js +0 -1
  257. data/vendor/assets/javascripts/theme-tomorrow_night_bright-uncompressed-noconflict.js +0 -206
  258. data/vendor/assets/javascripts/theme-tomorrow_night_bright-uncompressed.js +0 -206
  259. data/vendor/assets/javascripts/theme-tomorrow_night_eighties-noconflict.js +0 -1
  260. data/vendor/assets/javascripts/theme-tomorrow_night_eighties-uncompressed-noconflict.js +0 -202
  261. data/vendor/assets/javascripts/theme-tomorrow_night_eighties-uncompressed.js +0 -202
  262. data/vendor/assets/javascripts/theme-twilight-noconflict.js +0 -1
  263. data/vendor/assets/javascripts/theme-twilight-uncompressed-noconflict.js +0 -204
  264. data/vendor/assets/javascripts/theme-twilight-uncompressed.js +0 -204
  265. data/vendor/assets/javascripts/theme-vibrant_ink-noconflict.js +0 -1
  266. data/vendor/assets/javascripts/theme-vibrant_ink-uncompressed-noconflict.js +0 -183
  267. data/vendor/assets/javascripts/theme-vibrant_ink-uncompressed.js +0 -183
@@ -1 +1,605 @@
1
- define("ace/mode/xquery",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/xquery_highlight_rules","ace/mode/behaviour/xquery","ace/range"],function(a,b,c){"use strict";var d=a("../lib/oop"),e=a("./text").Mode,f=a("../tokenizer").Tokenizer,g=a("./xquery_highlight_rules").XQueryHighlightRules,h=a("./behaviour/xquery").XQueryBehaviour,i=a("../range").Range,j=function(a){this.$tokenizer=new f((new g).getRules()),this.$behaviour=new h(a)};d.inherits(j,e),function(){this.getNextLineIndent=function(a,b,c){var d=this.$getIndent(b),e=b.match(/\s*(?:then|else|return|[{\(]|<\w+>)\s*$/);return e&&(d+=c),d},this.checkOutdent=function(a,b,c){return/^\s+$/.test(b)?/^\s*[\}\)]/.test(c):!1},this.autoOutdent=function(a,b,c){var d=b.getLine(c),e=d.match(/^(\s*[\}\)])/);if(!e)return 0;var f=e[1].length,g=b.findMatchingBracket({row:c,column:f});if(!g||g.row==c)return 0;var h=this.$getIndent(b.getLine(g.row));b.replace(new i(c,0,c,f-1),h)},this.$getIndent=function(a){var b=a.match(/^(\s+)/);return b?b[1]:""},this.toggleCommentLines=function(a,b,c,d){var e,f,g=!0,h=/^\s*\(:(.*):\)/;for(e=c;e<=d;e++)if(!h.test(b.getLine(e))){g=!1;break}var j=new i(0,0,0,0);for(e=c;e<=d;e++)f=b.getLine(e),j.start.row=e,j.end.row=e,j.end.column=f.length,b.replace(j,g?f.match(h)[1]:"(:"+f+":)")}}.call(j.prototype),b.Mode=j}),define("ace/mode/xquery_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(a,b,c){"use strict";var d=a("../lib/oop"),e=a("../lib/lang"),f=a("./text_highlight_rules").TextHighlightRules,g=function(){var a=e.arrayToMap("return|for|let|where|order|by|declare|function|variable|xquery|version|option|namespace|import|module|when|encoding|switch|default|try|catch|group|tumbling|sliding|window|start|end|at|only|using|stemming|while|external|if|then|else|as|and|or|typeswitch|case|ascending|descending|empty|in|count|updating|insert|delete|replace|value|node|attribute|text|element|into|of|with|contains".split("|"));this.$rules={start:[{token:"text",regex:"<\\!\\[CDATA\\[",next:"cdata"},{token:"xml_pe",regex:"<\\?.*?\\?>"},{token:"comment",regex:"<\\!--",next:"comment"},{token:"comment",regex:"\\(:",next:"comment"},{token:"text",regex:"<\\/?",next:"tag"},{token:"constant",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:"variable",regex:"\\$[a-zA-Z_][a-zA-Z0-9_\\-:]*\\b"},{token:"string",regex:'".*?"'},{token:"string",regex:"'.*?'"},{token:"text",regex:"\\s+"},{token:"support.function",regex:"\\w[\\w+_\\-:]+(?=\\()"},{token:function(b){return a[b]?"keyword":"identifier"},regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"\\*|=|<|>|\\-|\\+|and|or|eq|ne|lt|gt"},{token:"lparen",regex:"[[({]"},{token:"rparen",regex:"[\\])}]"}],tag:[{token:"text",regex:">",next:"start"},{token:"meta.tag",regex:"[-_a-zA-Z0-9:]+"},{token:"text",regex:"\\s+"},{token:"string",regex:'".*?"'},{token:"string",regex:"'.*?'"}],cdata:[{token:"text",regex:"\\]\\]>",next:"start"},{token:"text",regex:"\\s+"},{token:"text",regex:"(?:[^\\]]|\\](?!\\]>))+"}],comment:[{token:"comment",regex:".*?-->",next:"start"},{token:"comment",regex:".*:\\)",next:"start"},{token:"comment",regex:".+"}]}};d.inherits(g,f),b.XQueryHighlightRules=g}),define("ace/mode/behaviour/xquery",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle"],function(a,b,c){"use strict";var d=a("../../lib/oop"),e=a("../behaviour").Behaviour,f=a("./cstyle").CstyleBehaviour,g=function(a){this.inherit(f,["braces","parens","string_dquotes"]),this.parent=a,this.add("brackets","insertion",function(a,b,c,d,e){if(e=="\n"){var f=c.getCursorPosition(),g=d.doc.getLine(f.row),h=g.substring(f.column,f.column+2);if(h=="</"){var i=this.$getIndent(d.doc.getLine(f.row))+d.getTabString(),j=this.$getIndent(d.doc.getLine(f.row));return{text:"\n"+i+"\n"+j,selection:[1,i.length,1,i.length]}}}return!1}),this.add("slash","insertion",function(b,c,d,e,f){if(f=="/"){var g=d.getCursorPosition(),h=e.doc.getLine(g.row);if(g.column>0&&h.charAt(g.column-1)=="<"){h=h.substring(0,g.column)+"/"+h.substring(g.column);var i=e.doc.getAllLines();i[g.row]=h,a.exec("closeTag",i.join(e.doc.getNewLineCharacter()),g.row)}}return!1})};d.inherits(g,e),b.XQueryBehaviour=g}),define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour"],function(a,b,c){"use strict";var d=a("../../lib/oop"),e=a("../behaviour").Behaviour,f=function(){this.add("braces","insertion",function(a,b,c,d,e){if(e=="{"){var f=c.getSelectionRange(),g=d.doc.getTextRange(f);return g!==""?{text:"{"+g+"}",selection:!1}:{text:"{}",selection:[1,1]}}if(e=="}"){var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column,h.column+1);if(j=="}"){var k=d.$findOpeningBracket("}",{column:h.column+1,row:h.row});if(k!==null)return{text:"",selection:[1,1]}}}else if(e=="\n"){var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column,h.column+1);if(j=="}"){var l=d.findMatchingBracket({row:h.row,column:h.column+1});if(!l)return null;var m=this.getNextLineIndent(a,i.substring(0,i.length-1),d.getTabString()),n=this.$getIndent(d.doc.getLine(l.row));return{text:"\n"+m+"\n"+n,selection:[1,m.length,1,m.length]}}}}),this.add("braces","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&f=="{"){var g=d.doc.getLine(e.start.row),h=g.substring(e.end.column,e.end.column+1);if(h=="}")return e.end.column++,e}}),this.add("parens","insertion",function(a,b,c,d,e){if(e=="("){var f=c.getSelectionRange(),g=d.doc.getTextRange(f);return g!==""?{text:"("+g+")",selection:!1}:{text:"()",selection:[1,1]}}if(e==")"){var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column,h.column+1);if(j==")"){var k=d.$findOpeningBracket(")",{column:h.column+1,row:h.row});if(k!==null)return{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&f=="("){var g=d.doc.getLine(e.start.row),h=g.substring(e.start.column+1,e.start.column+2);if(h==")")return e.end.column++,e}}),this.add("string_dquotes","insertion",function(a,b,c,d,e){if(e=='"'||e=="'"){var f=e,g=c.getSelectionRange(),h=d.doc.getTextRange(g);if(h!=="")return{text:f+h+f,selection:!1};var i=c.getCursorPosition(),j=d.doc.getLine(i.row),k=j.substring(i.column-1,i.column);if(k=="\\")return null;var l=d.getTokens(g.start.row,g.start.row)[0].tokens,m=0,n,o=-1;for(var p=0;p<l.length;p++){n=l[p],n.type=="string"?o=-1:o<0&&(o=n.value.indexOf(f));if(n.value.length+m>g.start.column)break;m+=l[p].value.length}if(!n||o<0&&n.type!=="comment"&&(n.type!=="string"||g.start.column!==n.value.length+m-1&&n.value.lastIndexOf(f)===n.value.length-1))return{text:f+f,selection:[1,1]};if(n&&n.type==="string"){var q=j.substring(i.column,i.column+1);if(q==f)return{text:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&(f=='"'||f=="'")){var g=d.doc.getLine(e.start.row),h=g.substring(e.start.column+1,e.start.column+2);if(h=='"')return e.end.column++,e}})};d.inherits(f,e),b.CstyleBehaviour=f})
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
+ *
4
+ * The contents of this file are subject to the Mozilla Public License Version
5
+ * 1.1 (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ * http://www.mozilla.org/MPL/
8
+ *
9
+ * Software distributed under the License is distributed on an "AS IS" basis,
10
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
+ * for the specific language governing rights and limitations under the
12
+ * License.
13
+ *
14
+ * The Original Code is Ajax.org Code Editor (ACE).
15
+ *
16
+ * The Initial Developer of the Original Code is
17
+ * Ajax.org B.V.
18
+ * Portions created by the Initial Developer are Copyright (C) 2010
19
+ * the Initial Developer. All Rights Reserved.
20
+ *
21
+ * Contributor(s):
22
+ * Wolfgang Meier
23
+ * William Candillon <wcandillon AT gmail DOT com>
24
+ *
25
+ * Alternatively, the contents of this file may be used under the terms of
26
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
27
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
+ * in which case the provisions of the GPL or the LGPL are applicable instead
29
+ * of those above. If you wish to allow use of your version of this file only
30
+ * under the terms of either the GPL or the LGPL, and not to allow others to
31
+ * use your version of this file under the terms of the MPL, indicate your
32
+ * decision by deleting the provisions above and replace them with the notice
33
+ * and other provisions required by the GPL or the LGPL. If you do not delete
34
+ * the provisions above, a recipient may use your version of this file under
35
+ * the terms of any one of the MPL, the GPL or the LGPL.
36
+ *
37
+ * ***** END LICENSE BLOCK ***** */
38
+ define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/worker/worker_client', 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xquery_highlight_rules', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) {
39
+
40
+
41
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
42
+ var oop = require("../lib/oop");
43
+ var TextMode = require("./text").Mode;
44
+ var Tokenizer = require("../tokenizer").Tokenizer;
45
+ var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
46
+ var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
47
+ //var XQueryBackgroundHighlighter = require("./xquery_background_highlighter").XQueryBackgroundHighlighter;
48
+ var Range = require("../range").Range;
49
+
50
+ var Mode = function(parent) {
51
+ this.$tokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
52
+ this.$behaviour = new XQueryBehaviour(parent);
53
+ };
54
+
55
+ oop.inherits(Mode, TextMode);
56
+
57
+ (function() {
58
+
59
+ this.getNextLineIndent = function(state, line, tab) {
60
+ var indent = this.$getIndent(line);
61
+ var match = line.match(/\s*(?:then|else|return|[{\(]|<\w+>)\s*$/);
62
+ if (match)
63
+ indent += tab;
64
+ return indent;
65
+ };
66
+
67
+ this.checkOutdent = function(state, line, input) {
68
+ if (! /^\s+$/.test(line))
69
+ return false;
70
+
71
+ return /^\s*[\}\)]/.test(input);
72
+ };
73
+
74
+ this.autoOutdent = function(state, doc, row) {
75
+ var line = doc.getLine(row);
76
+ var match = line.match(/^(\s*[\}\)])/);
77
+
78
+ if (!match) return 0;
79
+
80
+ var column = match[1].length;
81
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
82
+
83
+ if (!openBracePos || openBracePos.row == row) return 0;
84
+
85
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
86
+ doc.replace(new Range(row, 0, row, column-1), indent);
87
+ };
88
+
89
+ this.$getIndent = function(line) {
90
+ var match = line.match(/^(\s+)/);
91
+ if (match) {
92
+ return match[1];
93
+ }
94
+
95
+ return "";
96
+ };
97
+
98
+ this.toggleCommentLines = function(state, doc, startRow, endRow) {
99
+ var i, line;
100
+ var outdent = true;
101
+ var re = /^\s*\(:(.*):\)/;
102
+
103
+ for (i=startRow; i<= endRow; i++) {
104
+ if (!re.test(doc.getLine(i))) {
105
+ outdent = false;
106
+ break;
107
+ }
108
+ }
109
+
110
+ var range = new Range(0, 0, 0, 0);
111
+ for (i=startRow; i<= endRow; i++) {
112
+ line = doc.getLine(i);
113
+ range.start.row = i;
114
+ range.end.row = i;
115
+ range.end.column = line.length;
116
+
117
+ doc.replace(range, outdent ? line.match(re)[1] : "(:" + line + ":)");
118
+ }
119
+ };
120
+
121
+ this.createWorker = function(session) {
122
+ this.$deltas = [];
123
+ var worker = new WorkerClient(["ace"], "ace/mode/xquery_worker", "XQueryWorker");
124
+ var that = this;
125
+
126
+ session.getDocument().on('change', function(evt){
127
+ that.$deltas.push(evt.data);
128
+ });
129
+
130
+ worker.attachToDocument(session.getDocument());
131
+
132
+ worker.on("start", function(e) {
133
+ //console.log("start");
134
+ that.$deltas = [];
135
+ });
136
+
137
+ worker.on("error", function(e) {
138
+ session.setAnnotations([e.data]);
139
+ });
140
+
141
+ worker.on("ok", function(e) {
142
+ session.clearAnnotations();
143
+ });
144
+
145
+ worker.on("highlight", function(tokens) {
146
+ var firstRow = 0;
147
+ var lastRow = session.getLength() - 1;
148
+
149
+ var lines = tokens.data.lines;
150
+ var states = tokens.data.states;
151
+
152
+ for(var i=0; i < that.$deltas.length; i++)
153
+ {
154
+ var delta = that.$deltas[i];
155
+
156
+ if (delta.action === "insertLines")
157
+ {
158
+ var newLineCount = delta.lines.length;
159
+ for (var i = 0; i < newLineCount; i++) {
160
+ lines.splice(delta.range.start.row + i, 0, undefined);
161
+ states.splice(delta.range.start.row + i, 0, undefined);
162
+ }
163
+ }
164
+ else if (delta.action === "insertText")
165
+ {
166
+ if (session.getDocument().isNewLine(delta.text))
167
+ {
168
+ lines.splice(delta.range.end.row, 0, undefined);
169
+ states.splice(delta.range.end.row, 0, undefined);
170
+ } else {
171
+ lines[delta.range.start.row] = undefined;
172
+ states[delta.range.start.row] = undefined;
173
+ }
174
+ } else if (delta.action === "removeLines") {
175
+ var oldLineCount = delta.lines.length;
176
+ lines.splice(delta.range.start.row, oldLineCount);
177
+ states.splice(delta.range.start.row, oldLineCount);
178
+ } else if (delta.action === "removeText") {
179
+ if (session.getDocument().isNewLine(delta.text))
180
+ {
181
+ lines[delta.range.start.row] = undefined;
182
+ lines.splice(delta.range.end.row, 1);
183
+ states[delta.range.start.row] = undefined;
184
+ states.splice(delta.range.end.row, 1);
185
+ } else {
186
+ lines[delta.range.start.row] = undefined;
187
+ states[delta.range.start.row] = undefined;
188
+ }
189
+ }
190
+ }
191
+ session.bgTokenizer.lines = lines;
192
+ session.bgTokenizer.states = states;
193
+ session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
194
+ });
195
+
196
+ return worker;
197
+ };
198
+
199
+ }).call(Mode.prototype);
200
+
201
+ exports.Mode = Mode;
202
+ });
203
+ define('ace/mode/xquery_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
204
+
205
+
206
+ var oop = require("../lib/oop");
207
+ var lang = require("../lib/lang");
208
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
209
+
210
+ var XQueryHighlightRules = function() {
211
+
212
+ var keywords = lang.arrayToMap(
213
+ ("after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning").split("|")
214
+ );
215
+
216
+ // regexp must not have capturing parentheses
217
+ // regexps are ordered -> the first match is used
218
+
219
+ this.$rules = {
220
+ start : [ {
221
+ token : "text",
222
+ regex : "<\\!\\[CDATA\\[",
223
+ next : "cdata"
224
+ }, {
225
+ token : "xml_pe",
226
+ regex : "<\\?.*?\\?>"
227
+ }, {
228
+ token : "comment",
229
+ regex : "<\\!--",
230
+ next : "comment"
231
+ }, {
232
+ token : "comment",
233
+ regex : "\\(:",
234
+ next : "comment"
235
+ }, {
236
+ token : "text", // opening tag
237
+ regex : "<\\/?",
238
+ next : "tag"
239
+ }, {
240
+ token : "constant", // number
241
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
242
+ }, {
243
+ token : "variable", // variable
244
+ regex : "\\$[a-zA-Z_][a-zA-Z0-9_\\-:]*\\b"
245
+ }, {
246
+ token: "string",
247
+ regex : '".*?"'
248
+ }, {
249
+ token: "string",
250
+ regex : "'.*?'"
251
+ }, {
252
+ token : "text",
253
+ regex : "\\s+"
254
+ }, {
255
+ token: "support.function",
256
+ regex: "\\w[\\w+_\\-:]+(?=\\()"
257
+ }, {
258
+ token : function(value) {
259
+ if (keywords[value])
260
+ return "keyword";
261
+ else
262
+ return "identifier";
263
+ },
264
+ regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
265
+ }, {
266
+ token: "keyword.operator",
267
+ regex: "\\*|=|<|>|\\-|\\+"
268
+ }, {
269
+ token: "lparen",
270
+ regex: "[[({]"
271
+ }, {
272
+ token: "rparen",
273
+ regex: "[\\])}]"
274
+ } ],
275
+
276
+ tag : [ {
277
+ token : "text",
278
+ regex : ">",
279
+ next : "start"
280
+ }, {
281
+ token : "meta.tag",
282
+ regex : "[-_a-zA-Z0-9:]+"
283
+ }, {
284
+ token : "text",
285
+ regex : "\\s+"
286
+ }, {
287
+ token : "string",
288
+ regex : '".*?"'
289
+ }, {
290
+ token : "string",
291
+ regex : "'.*?'"
292
+ } ],
293
+
294
+ cdata : [ {
295
+ token : "comment",
296
+ regex : "\\]\\]>",
297
+ next : "start"
298
+ }, {
299
+ token : "comment",
300
+ regex : "\\s+"
301
+ }, {
302
+ token : "comment",
303
+ regex : "(?:[^\\]]|\\](?!\\]>))+"
304
+ } ],
305
+
306
+ comment : [ {
307
+ token : "comment",
308
+ regex : ".*?-->",
309
+ next : "start"
310
+ }, {
311
+ token: "comment",
312
+ regex : ".*:\\)",
313
+ next : "start"
314
+ }, {
315
+ token : "comment",
316
+ regex : ".+"
317
+ } ]
318
+ };
319
+ };
320
+
321
+ oop.inherits(XQueryHighlightRules, TextHighlightRules);
322
+
323
+ exports.XQueryHighlightRules = XQueryHighlightRules;
324
+ });
325
+ define('ace/mode/behaviour/xquery', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle'], function(require, exports, module) {
326
+
327
+
328
+ var oop = require("../../lib/oop");
329
+ var Behaviour = require('../behaviour').Behaviour;
330
+ var CstyleBehaviour = require('./cstyle').CstyleBehaviour;
331
+
332
+ var XQueryBehaviour = function (parent) {
333
+
334
+ this.inherit(CstyleBehaviour, ["braces", "parens", "string_dquotes"]); // Get string behaviour
335
+ this.parent = parent;
336
+
337
+ // this.add("brackets", "insertion", function (state, action, editor, session, text) {
338
+ // if (text == "\n") {
339
+ // var cursor = editor.getCursorPosition();
340
+ // var line = session.doc.getLine(cursor.row);
341
+ // var rightChars = line.substring(cursor.column, cursor.column + 2);
342
+ // if (rightChars == '</') {
343
+ // var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
344
+ // var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
345
+ //
346
+ // return {
347
+ // text: '\n' + indent + '\n' + next_indent,
348
+ // selection: [1, indent.length, 1, indent.length]
349
+ // }
350
+ // }
351
+ // }
352
+ // return false;
353
+ // });
354
+
355
+ // Check for open tag if user enters / and auto-close it.
356
+ // this.add("slash", "insertion", function (state, action, editor, session, text) {
357
+ // if (text == "/") {
358
+ // var cursor = editor.getCursorPosition();
359
+ // var line = session.doc.getLine(cursor.row);
360
+ // if (cursor.column > 0 && line.charAt(cursor.column - 1) == "<") {
361
+ // line = line.substring(0, cursor.column) + "/" + line.substring(cursor.column);
362
+ // var lines = session.doc.getAllLines();
363
+ // lines[cursor.row] = line;
364
+ // // call mode helper to close the tag if possible
365
+ // parent.exec("closeTag", lines.join(session.doc.getNewLineCharacter()), cursor.row);
366
+ // }
367
+ // }
368
+ // return false;
369
+ // });
370
+ }
371
+ oop.inherits(XQueryBehaviour, Behaviour);
372
+
373
+ exports.XQueryBehaviour = XQueryBehaviour;
374
+ });
375
+
376
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
377
+
378
+
379
+ var oop = require("../../lib/oop");
380
+ var Behaviour = require("../behaviour").Behaviour;
381
+
382
+ var CstyleBehaviour = function () {
383
+
384
+ this.add("braces", "insertion", function (state, action, editor, session, text) {
385
+ if (text == '{') {
386
+ var selection = editor.getSelectionRange();
387
+ var selected = session.doc.getTextRange(selection);
388
+ if (selected !== "") {
389
+ return {
390
+ text: '{' + selected + '}',
391
+ selection: false
392
+ };
393
+ } else {
394
+ return {
395
+ text: '{}',
396
+ selection: [1, 1]
397
+ };
398
+ }
399
+ } else if (text == '}') {
400
+ var cursor = editor.getCursorPosition();
401
+ var line = session.doc.getLine(cursor.row);
402
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
403
+ if (rightChar == '}') {
404
+ var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
405
+ if (matching !== null) {
406
+ return {
407
+ text: '',
408
+ selection: [1, 1]
409
+ };
410
+ }
411
+ }
412
+ } else if (text == "\n") {
413
+ var cursor = editor.getCursorPosition();
414
+ var line = session.doc.getLine(cursor.row);
415
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
416
+ if (rightChar == '}') {
417
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
418
+ if (!openBracePos)
419
+ return null;
420
+
421
+ var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
422
+ var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
423
+
424
+ return {
425
+ text: '\n' + indent + '\n' + next_indent,
426
+ selection: [1, indent.length, 1, indent.length]
427
+ };
428
+ }
429
+ }
430
+ });
431
+
432
+ this.add("braces", "deletion", function (state, action, editor, session, range) {
433
+ var selected = session.doc.getTextRange(range);
434
+ if (!range.isMultiLine() && selected == '{') {
435
+ var line = session.doc.getLine(range.start.row);
436
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
437
+ if (rightChar == '}') {
438
+ range.end.column++;
439
+ return range;
440
+ }
441
+ }
442
+ });
443
+
444
+ this.add("parens", "insertion", function (state, action, editor, session, text) {
445
+ if (text == '(') {
446
+ var selection = editor.getSelectionRange();
447
+ var selected = session.doc.getTextRange(selection);
448
+ if (selected !== "") {
449
+ return {
450
+ text: '(' + selected + ')',
451
+ selection: false
452
+ };
453
+ } else {
454
+ return {
455
+ text: '()',
456
+ selection: [1, 1]
457
+ };
458
+ }
459
+ } else if (text == ')') {
460
+ var cursor = editor.getCursorPosition();
461
+ var line = session.doc.getLine(cursor.row);
462
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
463
+ if (rightChar == ')') {
464
+ var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
465
+ if (matching !== null) {
466
+ return {
467
+ text: '',
468
+ selection: [1, 1]
469
+ };
470
+ }
471
+ }
472
+ }
473
+ });
474
+
475
+ this.add("parens", "deletion", function (state, action, editor, session, range) {
476
+ var selected = session.doc.getTextRange(range);
477
+ if (!range.isMultiLine() && selected == '(') {
478
+ var line = session.doc.getLine(range.start.row);
479
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
480
+ if (rightChar == ')') {
481
+ range.end.column++;
482
+ return range;
483
+ }
484
+ }
485
+ });
486
+
487
+ this.add("brackets", "insertion", function (state, action, editor, session, text) {
488
+ if (text == '[') {
489
+ var selection = editor.getSelectionRange();
490
+ var selected = session.doc.getTextRange(selection);
491
+ if (selected !== "") {
492
+ return {
493
+ text: '[' + selected + ']',
494
+ selection: false
495
+ };
496
+ } else {
497
+ return {
498
+ text: '[]',
499
+ selection: [1, 1]
500
+ };
501
+ }
502
+ } else if (text == ']') {
503
+ var cursor = editor.getCursorPosition();
504
+ var line = session.doc.getLine(cursor.row);
505
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
506
+ if (rightChar == ']') {
507
+ var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
508
+ if (matching !== null) {
509
+ return {
510
+ text: '',
511
+ selection: [1, 1]
512
+ };
513
+ }
514
+ }
515
+ }
516
+ });
517
+
518
+ this.add("brackets", "deletion", function (state, action, editor, session, range) {
519
+ var selected = session.doc.getTextRange(range);
520
+ if (!range.isMultiLine() && selected == '[') {
521
+ var line = session.doc.getLine(range.start.row);
522
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
523
+ if (rightChar == ']') {
524
+ range.end.column++;
525
+ return range;
526
+ }
527
+ }
528
+ });
529
+
530
+ this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
531
+ if (text == '"' || text == "'") {
532
+ var quote = text;
533
+ var selection = editor.getSelectionRange();
534
+ var selected = session.doc.getTextRange(selection);
535
+ if (selected !== "") {
536
+ return {
537
+ text: quote + selected + quote,
538
+ selection: false
539
+ };
540
+ } else {
541
+ var cursor = editor.getCursorPosition();
542
+ var line = session.doc.getLine(cursor.row);
543
+ var leftChar = line.substring(cursor.column-1, cursor.column);
544
+
545
+ // We're escaped.
546
+ if (leftChar == '\\') {
547
+ return null;
548
+ }
549
+
550
+ // Find what token we're inside.
551
+ var tokens = session.getTokens(selection.start.row);
552
+ var col = 0, token;
553
+ var quotepos = -1; // Track whether we're inside an open quote.
554
+
555
+ for (var x = 0; x < tokens.length; x++) {
556
+ token = tokens[x];
557
+ if (token.type == "string") {
558
+ quotepos = -1;
559
+ } else if (quotepos < 0) {
560
+ quotepos = token.value.indexOf(quote);
561
+ }
562
+ if ((token.value.length + col) > selection.start.column) {
563
+ break;
564
+ }
565
+ col += tokens[x].value.length;
566
+ }
567
+
568
+ // Try and be smart about when we auto insert.
569
+ if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
570
+ return {
571
+ text: quote + quote,
572
+ selection: [1,1]
573
+ };
574
+ } else if (token && token.type === "string") {
575
+ // Ignore input and move right one if we're typing over the closing quote.
576
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
577
+ if (rightChar == quote) {
578
+ return {
579
+ text: '',
580
+ selection: [1, 1]
581
+ };
582
+ }
583
+ }
584
+ }
585
+ }
586
+ });
587
+
588
+ this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
589
+ var selected = session.doc.getTextRange(range);
590
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
591
+ var line = session.doc.getLine(range.start.row);
592
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
593
+ if (rightChar == '"') {
594
+ range.end.column++;
595
+ return range;
596
+ }
597
+ }
598
+ });
599
+
600
+ };
601
+
602
+ oop.inherits(CstyleBehaviour, Behaviour);
603
+
604
+ exports.CstyleBehaviour = CstyleBehaviour;
605
+ });