ace-oqc 1.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/package.json +7 -0
  2. package/src-noconflict/ace.js +21402 -0
  3. package/src-noconflict/ext-beautify.js +331 -0
  4. package/src-noconflict/ext-elastic_tabstops_lite.js +277 -0
  5. package/src-noconflict/ext-emmet.js +1331 -0
  6. package/src-noconflict/ext-error_marker.js +9 -0
  7. package/src-noconflict/ext-keybinding_menu.js +193 -0
  8. package/src-noconflict/ext-language_tools.js +2166 -0
  9. package/src-noconflict/ext-linking.js +64 -0
  10. package/src-noconflict/ext-modelist.js +248 -0
  11. package/src-noconflict/ext-options.js +799 -0
  12. package/src-noconflict/ext-prompt.js +2806 -0
  13. package/src-noconflict/ext-rtl.js +122 -0
  14. package/src-noconflict/ext-searchbox.js +514 -0
  15. package/src-noconflict/ext-settings_menu.js +820 -0
  16. package/src-noconflict/ext-spellcheck.js +73 -0
  17. package/src-noconflict/ext-split.js +207 -0
  18. package/src-noconflict/ext-static_highlight.js +229 -0
  19. package/src-noconflict/ext-statusbar.js +56 -0
  20. package/src-noconflict/ext-textarea.js +430 -0
  21. package/src-noconflict/ext-themelist.js +67 -0
  22. package/src-noconflict/ext-whitespace.js +213 -0
  23. package/src-noconflict/keybinding-emacs.js +1169 -0
  24. package/src-noconflict/keybinding-sublime.js +422 -0
  25. package/src-noconflict/keybinding-vim.js +6198 -0
  26. package/src-noconflict/mode-abap.js +221 -0
  27. package/src-noconflict/mode-abc.js +271 -0
  28. package/src-noconflict/mode-actionscript.js +275 -0
  29. package/src-noconflict/mode-ada.js +137 -0
  30. package/src-noconflict/mode-apache_conf.js +363 -0
  31. package/src-noconflict/mode-apex.js +457 -0
  32. package/src-noconflict/mode-applescript.js +278 -0
  33. package/src-noconflict/mode-aql.js +102 -0
  34. package/src-noconflict/mode-asciidoc.js +349 -0
  35. package/src-noconflict/mode-asl.js +422 -0
  36. package/src-noconflict/mode-assembly_x86.js +193 -0
  37. package/src-noconflict/mode-autohotkey.js +244 -0
  38. package/src-noconflict/mode-batchfile.js +230 -0
  39. package/src-noconflict/mode-c9search.js +293 -0
  40. package/src-noconflict/mode-c_cpp.js +503 -0
  41. package/src-noconflict/mode-cirru.js +210 -0
  42. package/src-noconflict/mode-clojure.js +315 -0
  43. package/src-noconflict/mode-cobol.js +101 -0
  44. package/src-noconflict/mode-coffee.js +400 -0
  45. package/src-noconflict/mode-coldfusion.js +2596 -0
  46. package/src-noconflict/mode-crystal.js +642 -0
  47. package/src-noconflict/mode-csharp.js +502 -0
  48. package/src-noconflict/mode-csound_document.js +4105 -0
  49. package/src-noconflict/mode-csound_orchestra.js +3035 -0
  50. package/src-noconflict/mode-csound_score.js +462 -0
  51. package/src-noconflict/mode-csp.js +59 -0
  52. package/src-noconflict/mode-css.js +720 -0
  53. package/src-noconflict/mode-curly.js +2564 -0
  54. package/src-noconflict/mode-d.js +520 -0
  55. package/src-noconflict/mode-dart.js +715 -0
  56. package/src-noconflict/mode-diff.js +147 -0
  57. package/src-noconflict/mode-django.js +2595 -0
  58. package/src-noconflict/mode-dockerfile.js +500 -0
  59. package/src-noconflict/mode-dot.js +417 -0
  60. package/src-noconflict/mode-drools.js +498 -0
  61. package/src-noconflict/mode-edifact.js +166 -0
  62. package/src-noconflict/mode-eiffel.js +135 -0
  63. package/src-noconflict/mode-ejs.js +3533 -0
  64. package/src-noconflict/mode-elixir.js +501 -0
  65. package/src-noconflict/mode-elm.js +306 -0
  66. package/src-noconflict/mode-erlang.js +1010 -0
  67. package/src-noconflict/mode-forth.js +297 -0
  68. package/src-noconflict/mode-fortran.js +430 -0
  69. package/src-noconflict/mode-fsharp.js +316 -0
  70. package/src-noconflict/mode-fsl.js +259 -0
  71. package/src-noconflict/mode-ftl.js +1193 -0
  72. package/src-noconflict/mode-gcode.js +93 -0
  73. package/src-noconflict/mode-gherkin.js +168 -0
  74. package/src-noconflict/mode-gitignore.js +59 -0
  75. package/src-noconflict/mode-glsl.js +580 -0
  76. package/src-noconflict/mode-gobstones.js +1090 -0
  77. package/src-noconflict/mode-golang.js +413 -0
  78. package/src-noconflict/mode-graphqlschema.js +214 -0
  79. package/src-noconflict/mode-groovy.js +989 -0
  80. package/src-noconflict/mode-haml.js +1873 -0
  81. package/src-noconflict/mode-handlebars.js +2622 -0
  82. package/src-noconflict/mode-haskell.js +380 -0
  83. package/src-noconflict/mode-haskell_cabal.js +141 -0
  84. package/src-noconflict/mode-haxe.js +386 -0
  85. package/src-noconflict/mode-hjson.js +353 -0
  86. package/src-noconflict/mode-html.js +2509 -0
  87. package/src-noconflict/mode-html_elixir.js +3088 -0
  88. package/src-noconflict/mode-html_ruby.js +3550 -0
  89. package/src-noconflict/mode-ini.js +162 -0
  90. package/src-noconflict/mode-io.js +248 -0
  91. package/src-noconflict/mode-jack.js +346 -0
  92. package/src-noconflict/mode-jade.js +2025 -0
  93. package/src-noconflict/mode-java.js +1038 -0
  94. package/src-noconflict/mode-javascript.js +798 -0
  95. package/src-noconflict/mode-json.js +329 -0
  96. package/src-noconflict/mode-jsoniq.js +2632 -0
  97. package/src-noconflict/mode-jsp.js +1433 -0
  98. package/src-noconflict/mode-jssm.js +325 -0
  99. package/src-noconflict/mode-jsx.js +411 -0
  100. package/src-noconflict/mode-julia.js +303 -0
  101. package/src-noconflict/mode-kotlin.js +797 -0
  102. package/src-noconflict/mode-latex.js +296 -0
  103. package/src-noconflict/mode-less.js +839 -0
  104. package/src-noconflict/mode-liquid.js +2742 -0
  105. package/src-noconflict/mode-lisp.js +112 -0
  106. package/src-noconflict/mode-livescript.js +279 -0
  107. package/src-noconflict/mode-logiql.js +317 -0
  108. package/src-noconflict/mode-logtalk.js +352 -0
  109. package/src-noconflict/mode-lsl.js +343 -0
  110. package/src-noconflict/mode-lua.js +452 -0
  111. package/src-noconflict/mode-luapage.js +3028 -0
  112. package/src-noconflict/mode-lucene.js +154 -0
  113. package/src-noconflict/mode-makefile.js +412 -0
  114. package/src-noconflict/mode-markdown.js +3194 -0
  115. package/src-noconflict/mode-mask.js +1803 -0
  116. package/src-noconflict/mode-matlab.js +263 -0
  117. package/src-noconflict/mode-maze.js +292 -0
  118. package/src-noconflict/mode-mel.js +263 -0
  119. package/src-noconflict/mode-mixal.js +122 -0
  120. package/src-noconflict/mode-mushcode.js +681 -0
  121. package/src-noconflict/mode-mysql.js +167 -0
  122. package/src-noconflict/mode-nginx.js +298 -0
  123. package/src-noconflict/mode-nim.js +363 -0
  124. package/src-noconflict/mode-nix.js +647 -0
  125. package/src-noconflict/mode-nsis.js +312 -0
  126. package/src-noconflict/mode-objectivec.js +740 -0
  127. package/src-noconflict/mode-ocaml.js +421 -0
  128. package/src-noconflict/mode-pascal.js +223 -0
  129. package/src-noconflict/mode-perl.js +381 -0
  130. package/src-noconflict/mode-pgsql.js +1743 -0
  131. package/src-noconflict/mode-php.js +13110 -0
  132. package/src-noconflict/mode-php_laravel_blade.js +13311 -0
  133. package/src-noconflict/mode-pig.js +310 -0
  134. package/src-noconflict/mode-plain_text.js +32 -0
  135. package/src-noconflict/mode-powershell.js +418 -0
  136. package/src-noconflict/mode-praat.js +478 -0
  137. package/src-noconflict/mode-prolog.js +371 -0
  138. package/src-noconflict/mode-properties.js +80 -0
  139. package/src-noconflict/mode-protobuf.js +593 -0
  140. package/src-noconflict/mode-puppet.js +368 -0
  141. package/src-noconflict/mode-python.js +508 -0
  142. package/src-noconflict/mode-r.js +312 -0
  143. package/src-noconflict/mode-razor.js +2875 -0
  144. package/src-noconflict/mode-rdoc.js +243 -0
  145. package/src-noconflict/mode-red.js +450 -0
  146. package/src-noconflict/mode-redshift.js +360 -0
  147. package/src-noconflict/mode-rhtml.js +2808 -0
  148. package/src-noconflict/mode-rst.js +257 -0
  149. package/src-noconflict/mode-ruby.js +1003 -0
  150. package/src-noconflict/mode-rust.js +282 -0
  151. package/src-noconflict/mode-sass.js +529 -0
  152. package/src-noconflict/mode-scad.js +414 -0
  153. package/src-noconflict/mode-scala.js +984 -0
  154. package/src-noconflict/mode-scheme.js +232 -0
  155. package/src-noconflict/mode-scss.js +873 -0
  156. package/src-noconflict/mode-sh.js +449 -0
  157. package/src-noconflict/mode-sjs.js +1015 -0
  158. package/src-noconflict/mode-slim.js +5240 -0
  159. package/src-noconflict/mode-smarty.js +2635 -0
  160. package/src-noconflict/mode-snippets.js +207 -0
  161. package/src-noconflict/mode-soy_template.js +2848 -0
  162. package/src-noconflict/mode-space.js +167 -0
  163. package/src-noconflict/mode-sparql.js +320 -0
  164. package/src-noconflict/mode-sql.js +271 -0
  165. package/src-noconflict/mode-sqlserver.js +445 -0
  166. package/src-noconflict/mode-stylus.js +472 -0
  167. package/src-noconflict/mode-svg.js +1582 -0
  168. package/src-noconflict/mode-swift.js +395 -0
  169. package/src-noconflict/mode-tcl.js +387 -0
  170. package/src-noconflict/mode-terraform.js +400 -0
  171. package/src-noconflict/mode-tex.js +160 -0
  172. package/src-noconflict/mode-text.js +9 -0
  173. package/src-noconflict/mode-textile.js +150 -0
  174. package/src-noconflict/mode-toml.js +153 -0
  175. package/src-noconflict/mode-tsx.js +888 -0
  176. package/src-noconflict/mode-turtle.js +296 -0
  177. package/src-noconflict/mode-twig.js +2693 -0
  178. package/src-noconflict/mode-typescript.js +869 -0
  179. package/src-noconflict/mode-vala.js +677 -0
  180. package/src-noconflict/mode-vbscript.js +635 -0
  181. package/src-noconflict/mode-velocity.js +2792 -0
  182. package/src-noconflict/mode-verilog.js +118 -0
  183. package/src-noconflict/mode-vhdl.js +116 -0
  184. package/src-noconflict/mode-visualforce.js +2640 -0
  185. package/src-noconflict/mode-wollok.js +914 -0
  186. package/src-noconflict/mode-xml.js +676 -0
  187. package/src-noconflict/mode-xquery.js +2644 -0
  188. package/src-noconflict/mode-yaml.js +330 -0
  189. package/src-noconflict/mode-zeek.js +539 -0
  190. package/src-noconflict/qurator-mode.js +120 -0
  191. package/src-noconflict/qurator-worker.js +91 -0
  192. package/src-noconflict/snippets/abap.js +9 -0
  193. package/src-noconflict/snippets/abc.js +45 -0
  194. package/src-noconflict/snippets/actionscript.js +171 -0
  195. package/src-noconflict/snippets/ada.js +9 -0
  196. package/src-noconflict/snippets/apache_conf.js +9 -0
  197. package/src-noconflict/snippets/apex.js +9 -0
  198. package/src-noconflict/snippets/applescript.js +9 -0
  199. package/src-noconflict/snippets/aql.js +9 -0
  200. package/src-noconflict/snippets/asciidoc.js +9 -0
  201. package/src-noconflict/snippets/asl.js +9 -0
  202. package/src-noconflict/snippets/assembly_x86.js +9 -0
  203. package/src-noconflict/snippets/autohotkey.js +9 -0
  204. package/src-noconflict/snippets/batchfile.js +9 -0
  205. package/src-noconflict/snippets/c9search.js +9 -0
  206. package/src-noconflict/snippets/c_cpp.js +145 -0
  207. package/src-noconflict/snippets/cirru.js +9 -0
  208. package/src-noconflict/snippets/clojure.js +104 -0
  209. package/src-noconflict/snippets/cobol.js +9 -0
  210. package/src-noconflict/snippets/coffee.js +109 -0
  211. package/src-noconflict/snippets/coldfusion.js +9 -0
  212. package/src-noconflict/snippets/crystal.js +9 -0
  213. package/src-noconflict/snippets/csharp.js +9 -0
  214. package/src-noconflict/snippets/csound_document.js +24 -0
  215. package/src-noconflict/snippets/csound_orchestra.js +61 -0
  216. package/src-noconflict/snippets/csound_score.js +9 -0
  217. package/src-noconflict/snippets/csp.js +9 -0
  218. package/src-noconflict/snippets/css.js +981 -0
  219. package/src-noconflict/snippets/curly.js +9 -0
  220. package/src-noconflict/snippets/d.js +9 -0
  221. package/src-noconflict/snippets/dart.js +97 -0
  222. package/src-noconflict/snippets/diff.js +25 -0
  223. package/src-noconflict/snippets/django.js +122 -0
  224. package/src-noconflict/snippets/dockerfile.js +9 -0
  225. package/src-noconflict/snippets/dot.js +9 -0
  226. package/src-noconflict/snippets/drools.js +33 -0
  227. package/src-noconflict/snippets/edifact.js +254 -0
  228. package/src-noconflict/snippets/eiffel.js +9 -0
  229. package/src-noconflict/snippets/ejs.js +9 -0
  230. package/src-noconflict/snippets/elixir.js +9 -0
  231. package/src-noconflict/snippets/elm.js +9 -0
  232. package/src-noconflict/snippets/erlang.js +174 -0
  233. package/src-noconflict/snippets/forth.js +9 -0
  234. package/src-noconflict/snippets/fortran.js +9 -0
  235. package/src-noconflict/snippets/fsharp.js +9 -0
  236. package/src-noconflict/snippets/fsl.js +14 -0
  237. package/src-noconflict/snippets/ftl.js +9 -0
  238. package/src-noconflict/snippets/gcode.js +9 -0
  239. package/src-noconflict/snippets/gherkin.js +9 -0
  240. package/src-noconflict/snippets/gitignore.js +9 -0
  241. package/src-noconflict/snippets/glsl.js +9 -0
  242. package/src-noconflict/snippets/gobstones.js +1718 -0
  243. package/src-noconflict/snippets/golang.js +9 -0
  244. package/src-noconflict/snippets/graphqlschema.js +46 -0
  245. package/src-noconflict/snippets/groovy.js +9 -0
  246. package/src-noconflict/snippets/haml.js +34 -0
  247. package/src-noconflict/snippets/handlebars.js +9 -0
  248. package/src-noconflict/snippets/haskell.js +96 -0
  249. package/src-noconflict/snippets/haskell_cabal.js +9 -0
  250. package/src-noconflict/snippets/haxe.js +9 -0
  251. package/src-noconflict/snippets/hjson.js +9 -0
  252. package/src-noconflict/snippets/html.js +867 -0
  253. package/src-noconflict/snippets/html_elixir.js +9 -0
  254. package/src-noconflict/snippets/html_ruby.js +9 -0
  255. package/src-noconflict/snippets/ini.js +9 -0
  256. package/src-noconflict/snippets/io.js +76 -0
  257. package/src-noconflict/snippets/jack.js +9 -0
  258. package/src-noconflict/snippets/jade.js +9 -0
  259. package/src-noconflict/snippets/java.js +254 -0
  260. package/src-noconflict/snippets/javascript.js +209 -0
  261. package/src-noconflict/snippets/json.js +9 -0
  262. package/src-noconflict/snippets/jsoniq.js +75 -0
  263. package/src-noconflict/snippets/jsp.js +113 -0
  264. package/src-noconflict/snippets/jssm.js +9 -0
  265. package/src-noconflict/snippets/jsx.js +9 -0
  266. package/src-noconflict/snippets/julia.js +9 -0
  267. package/src-noconflict/snippets/kotlin.js +9 -0
  268. package/src-noconflict/snippets/latex.js +9 -0
  269. package/src-noconflict/snippets/less.js +9 -0
  270. package/src-noconflict/snippets/liquid.js +895 -0
  271. package/src-noconflict/snippets/lisp.js +9 -0
  272. package/src-noconflict/snippets/livescript.js +9 -0
  273. package/src-noconflict/snippets/logiql.js +9 -0
  274. package/src-noconflict/snippets/logtalk.js +9 -0
  275. package/src-noconflict/snippets/lsl.js +1246 -0
  276. package/src-noconflict/snippets/lua.js +35 -0
  277. package/src-noconflict/snippets/luapage.js +9 -0
  278. package/src-noconflict/snippets/lucene.js +9 -0
  279. package/src-noconflict/snippets/makefile.js +18 -0
  280. package/src-noconflict/snippets/markdown.js +102 -0
  281. package/src-noconflict/snippets/mask.js +9 -0
  282. package/src-noconflict/snippets/matlab.js +9 -0
  283. package/src-noconflict/snippets/maze.js +23 -0
  284. package/src-noconflict/snippets/mel.js +9 -0
  285. package/src-noconflict/snippets/mixal.js +9 -0
  286. package/src-noconflict/snippets/mushcode.js +9 -0
  287. package/src-noconflict/snippets/mysql.js +9 -0
  288. package/src-noconflict/snippets/nginx.js +9 -0
  289. package/src-noconflict/snippets/nim.js +9 -0
  290. package/src-noconflict/snippets/nix.js +9 -0
  291. package/src-noconflict/snippets/nsis.js +9 -0
  292. package/src-noconflict/snippets/objectivec.js +9 -0
  293. package/src-noconflict/snippets/ocaml.js +9 -0
  294. package/src-noconflict/snippets/pascal.js +9 -0
  295. package/src-noconflict/snippets/perl.js +361 -0
  296. package/src-noconflict/snippets/pgsql.js +9 -0
  297. package/src-noconflict/snippets/php.js +397 -0
  298. package/src-noconflict/snippets/php_laravel_blade.js +9 -0
  299. package/src-noconflict/snippets/pig.js +9 -0
  300. package/src-noconflict/snippets/plain_text.js +9 -0
  301. package/src-noconflict/snippets/powershell.js +9 -0
  302. package/src-noconflict/snippets/praat.js +9 -0
  303. package/src-noconflict/snippets/prolog.js +9 -0
  304. package/src-noconflict/snippets/properties.js +9 -0
  305. package/src-noconflict/snippets/protobuf.js +9 -0
  306. package/src-noconflict/snippets/puppet.js +9 -0
  307. package/src-noconflict/snippets/python.js +172 -0
  308. package/src-noconflict/snippets/r.js +135 -0
  309. package/src-noconflict/snippets/razor.js +17 -0
  310. package/src-noconflict/snippets/rdoc.js +9 -0
  311. package/src-noconflict/snippets/red.js +9 -0
  312. package/src-noconflict/snippets/redshift.js +9 -0
  313. package/src-noconflict/snippets/rhtml.js +9 -0
  314. package/src-noconflict/snippets/rst.js +36 -0
  315. package/src-noconflict/snippets/ruby.js +942 -0
  316. package/src-noconflict/snippets/rust.js +9 -0
  317. package/src-noconflict/snippets/sass.js +9 -0
  318. package/src-noconflict/snippets/scad.js +9 -0
  319. package/src-noconflict/snippets/scala.js +9 -0
  320. package/src-noconflict/snippets/scheme.js +9 -0
  321. package/src-noconflict/snippets/scss.js +9 -0
  322. package/src-noconflict/snippets/sh.js +97 -0
  323. package/src-noconflict/snippets/sjs.js +9 -0
  324. package/src-noconflict/snippets/slim.js +9 -0
  325. package/src-noconflict/snippets/smarty.js +9 -0
  326. package/src-noconflict/snippets/snippets.js +23 -0
  327. package/src-noconflict/snippets/soy_template.js +9 -0
  328. package/src-noconflict/snippets/space.js +9 -0
  329. package/src-noconflict/snippets/sparql.js +9 -0
  330. package/src-noconflict/snippets/sql.js +40 -0
  331. package/src-noconflict/snippets/sqlserver.js +83 -0
  332. package/src-noconflict/snippets/stylus.js +9 -0
  333. package/src-noconflict/snippets/svg.js +9 -0
  334. package/src-noconflict/snippets/swift.js +9 -0
  335. package/src-noconflict/snippets/tcl.js +106 -0
  336. package/src-noconflict/snippets/terraform.js +9 -0
  337. package/src-noconflict/snippets/tex.js +204 -0
  338. package/src-noconflict/snippets/text.js +9 -0
  339. package/src-noconflict/snippets/textile.js +44 -0
  340. package/src-noconflict/snippets/toml.js +9 -0
  341. package/src-noconflict/snippets/tsx.js +9 -0
  342. package/src-noconflict/snippets/turtle.js +9 -0
  343. package/src-noconflict/snippets/twig.js +9 -0
  344. package/src-noconflict/snippets/typescript.js +9 -0
  345. package/src-noconflict/snippets/vala.js +200 -0
  346. package/src-noconflict/snippets/vbscript.js +9 -0
  347. package/src-noconflict/snippets/velocity.js +43 -0
  348. package/src-noconflict/snippets/verilog.js +9 -0
  349. package/src-noconflict/snippets/vhdl.js +9 -0
  350. package/src-noconflict/snippets/visualforce.js +9 -0
  351. package/src-noconflict/snippets/wollok.js +98 -0
  352. package/src-noconflict/snippets/xml.js +9 -0
  353. package/src-noconflict/snippets/xquery.js +75 -0
  354. package/src-noconflict/snippets/yaml.js +9 -0
  355. package/src-noconflict/snippets/zeek.js +9 -0
  356. package/src-noconflict/theme-ambiance.js +185 -0
  357. package/src-noconflict/theme-chaos.js +163 -0
  358. package/src-noconflict/theme-chrome.js +135 -0
  359. package/src-noconflict/theme-clouds.js +102 -0
  360. package/src-noconflict/theme-clouds_midnight.js +103 -0
  361. package/src-noconflict/theme-cobalt.js +120 -0
  362. package/src-noconflict/theme-crimson_editor.js +125 -0
  363. package/src-noconflict/theme-dawn.js +115 -0
  364. package/src-noconflict/theme-dracula.js +135 -0
  365. package/src-noconflict/theme-dreamweaver.js +148 -0
  366. package/src-noconflict/theme-eclipse.js +105 -0
  367. package/src-noconflict/theme-github.js +110 -0
  368. package/src-noconflict/theme-gob.js +119 -0
  369. package/src-noconflict/theme-gruvbox.js +89 -0
  370. package/src-noconflict/theme-idle_fingers.js +103 -0
  371. package/src-noconflict/theme-iplastic.js +128 -0
  372. package/src-noconflict/theme-katzenmilch.js +128 -0
  373. package/src-noconflict/theme-kr_theme.js +111 -0
  374. package/src-noconflict/theme-kuroir.js +68 -0
  375. package/src-noconflict/theme-merbivore.js +102 -0
  376. package/src-noconflict/theme-merbivore_soft.js +103 -0
  377. package/src-noconflict/theme-mono_industrial.js +114 -0
  378. package/src-noconflict/theme-monokai.js +112 -0
  379. package/src-noconflict/theme-pastel_on_dark.js +115 -0
  380. package/src-noconflict/theme-solarized_dark.js +95 -0
  381. package/src-noconflict/theme-solarized_light.js +98 -0
  382. package/src-noconflict/theme-sqlserver.js +145 -0
  383. package/src-noconflict/theme-terminal.js +121 -0
  384. package/src-noconflict/theme-textmate.js +137 -0
  385. package/src-noconflict/theme-tomorrow.js +115 -0
  386. package/src-noconflict/theme-tomorrow_night.js +115 -0
  387. package/src-noconflict/theme-tomorrow_night_blue.js +113 -0
  388. package/src-noconflict/theme-tomorrow_night_bright.js +128 -0
  389. package/src-noconflict/theme-tomorrow_night_eighties.js +115 -0
  390. package/src-noconflict/theme-twilight.js +116 -0
  391. package/src-noconflict/theme-vibrant_ink.js +101 -0
  392. package/src-noconflict/theme-xcode.js +95 -0
  393. package/src-noconflict/worker-coffee.js +1470 -0
  394. package/src-noconflict/worker-css.js +9000 -0
  395. package/src-noconflict/worker-html.js +10922 -0
  396. package/src-noconflict/worker-javascript.js +15001 -0
  397. package/src-noconflict/worker-json.js +1715 -0
  398. package/src-noconflict/worker-lua.js +3608 -0
  399. package/src-noconflict/worker-php.js +3687 -0
  400. package/src-noconflict/worker-xml.js +3208 -0
  401. package/src-noconflict/worker-xquery.js +57668 -0
@@ -0,0 +1,2806 @@
1
+ ace.define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module) {
2
+ "use strict";
3
+ var keys = require("../../lib/keys");
4
+ module.exports.getEditorKeybordShortcuts = function(editor) {
5
+ var KEY_MODS = keys.KEY_MODS;
6
+ var keybindings = [];
7
+ var commandMap = {};
8
+ editor.keyBinding.$handlers.forEach(function(handler) {
9
+ var ckb = handler.commandKeyBinding;
10
+ for (var i in ckb) {
11
+ var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase(); });
12
+ var commands = ckb[i];
13
+ if (!Array.isArray(commands))
14
+ commands = [commands];
15
+ commands.forEach(function(command) {
16
+ if (typeof command != "string")
17
+ command = command.name;
18
+ if (commandMap[command]) {
19
+ commandMap[command].key += "|" + key;
20
+ } else {
21
+ commandMap[command] = {key: key, command: command};
22
+ keybindings.push(commandMap[command]);
23
+ }
24
+ });
25
+ }
26
+ });
27
+ return keybindings;
28
+ };
29
+
30
+ });
31
+
32
+ ace.define("ace/autocomplete/popup",["require","exports","module","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom"], function(require, exports, module) {
33
+ "use strict";
34
+
35
+ var Renderer = require("../virtual_renderer").VirtualRenderer;
36
+ var Editor = require("../editor").Editor;
37
+ var Range = require("../range").Range;
38
+ var event = require("../lib/event");
39
+ var lang = require("../lib/lang");
40
+ var dom = require("../lib/dom");
41
+
42
+ var $singleLineEditor = function(el) {
43
+ var renderer = new Renderer(el);
44
+
45
+ renderer.$maxLines = 4;
46
+
47
+ var editor = new Editor(renderer);
48
+
49
+ editor.setHighlightActiveLine(false);
50
+ editor.setShowPrintMargin(false);
51
+ editor.renderer.setShowGutter(false);
52
+ editor.renderer.setHighlightGutterLine(false);
53
+
54
+ editor.$mouseHandler.$focusTimeout = 0;
55
+ editor.$highlightTagPending = true;
56
+
57
+ return editor;
58
+ };
59
+
60
+ var AcePopup = function(parentNode) {
61
+ var el = dom.createElement("div");
62
+ var popup = new $singleLineEditor(el);
63
+
64
+ if (parentNode)
65
+ parentNode.appendChild(el);
66
+ el.style.display = "none";
67
+ popup.renderer.content.style.cursor = "default";
68
+ popup.renderer.setStyle("ace_autocomplete");
69
+
70
+ popup.setOption("displayIndentGuides", false);
71
+ popup.setOption("dragDelay", 150);
72
+
73
+ var noop = function(){};
74
+
75
+ popup.focus = noop;
76
+ popup.$isFocused = true;
77
+
78
+ popup.renderer.$cursorLayer.restartTimer = noop;
79
+ popup.renderer.$cursorLayer.element.style.opacity = 0;
80
+
81
+ popup.renderer.$maxLines = 8;
82
+ popup.renderer.$keepTextAreaAtCursor = false;
83
+
84
+ popup.setHighlightActiveLine(false);
85
+ popup.session.highlight("");
86
+ popup.session.$searchHighlight.clazz = "ace_highlight-marker";
87
+
88
+ popup.on("mousedown", function(e) {
89
+ var pos = e.getDocumentPosition();
90
+ popup.selection.moveToPosition(pos);
91
+ selectionMarker.start.row = selectionMarker.end.row = pos.row;
92
+ e.stop();
93
+ });
94
+
95
+ var lastMouseEvent;
96
+ var hoverMarker = new Range(-1,0,-1,Infinity);
97
+ var selectionMarker = new Range(-1,0,-1,Infinity);
98
+ selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine");
99
+ popup.setSelectOnHover = function(val) {
100
+ if (!val) {
101
+ hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
102
+ } else if (hoverMarker.id) {
103
+ popup.session.removeMarker(hoverMarker.id);
104
+ hoverMarker.id = null;
105
+ }
106
+ };
107
+ popup.setSelectOnHover(false);
108
+ popup.on("mousemove", function(e) {
109
+ if (!lastMouseEvent) {
110
+ lastMouseEvent = e;
111
+ return;
112
+ }
113
+ if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) {
114
+ return;
115
+ }
116
+ lastMouseEvent = e;
117
+ lastMouseEvent.scrollTop = popup.renderer.scrollTop;
118
+ var row = lastMouseEvent.getDocumentPosition().row;
119
+ if (hoverMarker.start.row != row) {
120
+ if (!hoverMarker.id)
121
+ popup.setRow(row);
122
+ setHoverMarker(row);
123
+ }
124
+ });
125
+ popup.renderer.on("beforeRender", function() {
126
+ if (lastMouseEvent && hoverMarker.start.row != -1) {
127
+ lastMouseEvent.$pos = null;
128
+ var row = lastMouseEvent.getDocumentPosition().row;
129
+ if (!hoverMarker.id)
130
+ popup.setRow(row);
131
+ setHoverMarker(row, true);
132
+ }
133
+ });
134
+ popup.renderer.on("afterRender", function() {
135
+ var row = popup.getRow();
136
+ var t = popup.renderer.$textLayer;
137
+ var selected = t.element.childNodes[row - t.config.firstRow];
138
+ if (selected !== t.selectedNode && t.selectedNode)
139
+ dom.removeCssClass(t.selectedNode, "ace_selected");
140
+ t.selectedNode = selected;
141
+ if (selected)
142
+ dom.addCssClass(selected, "ace_selected");
143
+ });
144
+ var hideHoverMarker = function() { setHoverMarker(-1); };
145
+ var setHoverMarker = function(row, suppressRedraw) {
146
+ if (row !== hoverMarker.start.row) {
147
+ hoverMarker.start.row = hoverMarker.end.row = row;
148
+ if (!suppressRedraw)
149
+ popup.session._emit("changeBackMarker");
150
+ popup._emit("changeHoverMarker");
151
+ }
152
+ };
153
+ popup.getHoveredRow = function() {
154
+ return hoverMarker.start.row;
155
+ };
156
+
157
+ event.addListener(popup.container, "mouseout", hideHoverMarker);
158
+ popup.on("hide", hideHoverMarker);
159
+ popup.on("changeSelection", hideHoverMarker);
160
+
161
+ popup.session.doc.getLength = function() {
162
+ return popup.data.length;
163
+ };
164
+ popup.session.doc.getLine = function(i) {
165
+ var data = popup.data[i];
166
+ if (typeof data == "string")
167
+ return data;
168
+ return (data && data.value) || "";
169
+ };
170
+
171
+ var bgTokenizer = popup.session.bgTokenizer;
172
+ bgTokenizer.$tokenizeRow = function(row) {
173
+ var data = popup.data[row];
174
+ var tokens = [];
175
+ if (!data)
176
+ return tokens;
177
+ if (typeof data == "string")
178
+ data = {value: data};
179
+ var caption = data.caption || data.value || data.name;
180
+
181
+ function addToken(value, className) {
182
+ value && tokens.push({
183
+ type: (data.className || "") + (className || ""),
184
+ value: value
185
+ });
186
+ }
187
+
188
+ var lower = caption.toLowerCase();
189
+ var filterText = (popup.filterText || "").toLowerCase();
190
+ var lastIndex = 0;
191
+ var lastI = 0;
192
+ for (var i = 0; i <= filterText.length; i++) {
193
+ if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) {
194
+ var sub = filterText.slice(lastI, i);
195
+ lastI = i;
196
+ var index = lower.indexOf(sub, lastIndex);
197
+ if (index == -1) continue;
198
+ addToken(caption.slice(lastIndex, index), "");
199
+ lastIndex = index + sub.length;
200
+ addToken(caption.slice(index, lastIndex), "completion-highlight");
201
+ }
202
+ }
203
+ addToken(caption.slice(lastIndex, caption.length), "");
204
+
205
+ if (data.meta)
206
+ tokens.push({type: "completion-meta", value: data.meta});
207
+ if (data.message)
208
+ tokens.push({type: "completion-message", value: data.message});
209
+
210
+ return tokens;
211
+ };
212
+ bgTokenizer.$updateOnChange = noop;
213
+ bgTokenizer.start = noop;
214
+
215
+ popup.session.$computeWidth = function() {
216
+ return this.screenWidth = 0;
217
+ };
218
+ popup.isOpen = false;
219
+ popup.isTopdown = false;
220
+ popup.autoSelect = true;
221
+ popup.filterText = "";
222
+
223
+ popup.data = [];
224
+ popup.setData = function(list, filterText) {
225
+ popup.filterText = filterText || "";
226
+ popup.setValue(lang.stringRepeat("\n", list.length), -1);
227
+ popup.data = list || [];
228
+ popup.setRow(0);
229
+ };
230
+ popup.getData = function(row) {
231
+ return popup.data[row];
232
+ };
233
+
234
+ popup.getRow = function() {
235
+ return selectionMarker.start.row;
236
+ };
237
+ popup.setRow = function(line) {
238
+ line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length, line));
239
+ if (selectionMarker.start.row != line) {
240
+ popup.selection.clearSelection();
241
+ selectionMarker.start.row = selectionMarker.end.row = line || 0;
242
+ popup.session._emit("changeBackMarker");
243
+ popup.moveCursorTo(line || 0, 0);
244
+ if (popup.isOpen)
245
+ popup._signal("select");
246
+ }
247
+ };
248
+
249
+ popup.on("changeSelection", function() {
250
+ if (popup.isOpen)
251
+ popup.setRow(popup.selection.lead.row);
252
+ popup.renderer.scrollCursorIntoView();
253
+ });
254
+
255
+ popup.hide = function() {
256
+ this.container.style.display = "none";
257
+ this._signal("hide");
258
+ popup.isOpen = false;
259
+ };
260
+ popup.show = function(pos, lineHeight, topdownOnly) {
261
+ var el = this.container;
262
+ var screenHeight = window.innerHeight;
263
+ var screenWidth = window.innerWidth;
264
+ var renderer = this.renderer;
265
+ var maxH = renderer.$maxLines * lineHeight * 1.4;
266
+ var top = pos.top + this.$borderSize;
267
+ var allowTopdown = top > screenHeight / 2 && !topdownOnly;
268
+ if (allowTopdown && top + lineHeight + maxH > screenHeight) {
269
+ renderer.$maxPixelHeight = top - 2 * this.$borderSize;
270
+ el.style.top = "";
271
+ el.style.bottom = screenHeight - top + "px";
272
+ popup.isTopdown = false;
273
+ } else {
274
+ top += lineHeight;
275
+ renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight;
276
+ el.style.top = top + "px";
277
+ el.style.bottom = "";
278
+ popup.isTopdown = true;
279
+ }
280
+
281
+ el.style.display = "";
282
+
283
+ var left = pos.left;
284
+ if (left + el.offsetWidth > screenWidth)
285
+ left = screenWidth - el.offsetWidth;
286
+
287
+ el.style.left = left + "px";
288
+
289
+ this._signal("show");
290
+ lastMouseEvent = null;
291
+ popup.isOpen = true;
292
+ };
293
+
294
+ popup.goTo = function(where) {
295
+ var row = this.getRow();
296
+ var max = this.session.getLength() - 1;
297
+
298
+ switch(where) {
299
+ case "up": row = row <= 0 ? max : row - 1; break;
300
+ case "down": row = row >= max ? -1 : row + 1; break;
301
+ case "start": row = 0; break;
302
+ case "end": row = max; break;
303
+ }
304
+
305
+ this.setRow(row);
306
+ };
307
+
308
+
309
+ popup.getTextLeftOffset = function() {
310
+ return this.$borderSize + this.renderer.$padding + this.$imageSize;
311
+ };
312
+
313
+ popup.$imageSize = 0;
314
+ popup.$borderSize = 1;
315
+
316
+ return popup;
317
+ };
318
+
319
+ dom.importCssString("\
320
+ .ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\
321
+ background-color: #CAD6FA;\
322
+ z-index: 1;\
323
+ }\
324
+ .ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\
325
+ background-color: #3a674e;\
326
+ }\
327
+ .ace_editor.ace_autocomplete .ace_line-hover {\
328
+ border: 1px solid #abbffe;\
329
+ margin-top: -1px;\
330
+ background: rgba(233,233,253,0.4);\
331
+ position: absolute;\
332
+ z-index: 2;\
333
+ }\
334
+ .ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\
335
+ border: 1px solid rgba(109, 150, 13, 0.8);\
336
+ background: rgba(58, 103, 78, 0.62);\
337
+ }\
338
+ .ace_completion-meta {\
339
+ opacity: 0.5;\
340
+ margin: 0.9em;\
341
+ }\
342
+ .ace_completion-message {\
343
+ color: blue;\
344
+ }\
345
+ .ace_editor.ace_autocomplete .ace_completion-highlight{\
346
+ color: #2d69c7;\
347
+ }\
348
+ .ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\
349
+ color: #93ca12;\
350
+ }\
351
+ .ace_editor.ace_autocomplete {\
352
+ width: 300px;\
353
+ z-index: 200000;\
354
+ border: 1px lightgray solid;\
355
+ position: fixed;\
356
+ box-shadow: 2px 3px 5px rgba(0,0,0,.2);\
357
+ line-height: 1.4;\
358
+ background: #fefefe;\
359
+ color: #111;\
360
+ }\
361
+ .ace_dark.ace_editor.ace_autocomplete {\
362
+ border: 1px #484747 solid;\
363
+ box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\
364
+ line-height: 1.4;\
365
+ background: #25282c;\
366
+ color: #c1c1c1;\
367
+ }", "autocompletion.css", false);
368
+
369
+ exports.AcePopup = AcePopup;
370
+ exports.$singleLineEditor = $singleLineEditor;
371
+ });
372
+
373
+ ace.define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module) {
374
+ "use strict";
375
+
376
+ exports.parForEach = function(array, fn, callback) {
377
+ var completed = 0;
378
+ var arLength = array.length;
379
+ if (arLength === 0)
380
+ callback();
381
+ for (var i = 0; i < arLength; i++) {
382
+ fn(array[i], function(result, err) {
383
+ completed++;
384
+ if (completed === arLength)
385
+ callback(result, err);
386
+ });
387
+ }
388
+ };
389
+
390
+ var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/;
391
+
392
+ exports.retrievePrecedingIdentifier = function(text, pos, regex) {
393
+ regex = regex || ID_REGEX;
394
+ var buf = [];
395
+ for (var i = pos-1; i >= 0; i--) {
396
+ if (regex.test(text[i]))
397
+ buf.push(text[i]);
398
+ else
399
+ break;
400
+ }
401
+ return buf.reverse().join("");
402
+ };
403
+
404
+ exports.retrieveFollowingIdentifier = function(text, pos, regex) {
405
+ regex = regex || ID_REGEX;
406
+ var buf = [];
407
+ for (var i = pos; i < text.length; i++) {
408
+ if (regex.test(text[i]))
409
+ buf.push(text[i]);
410
+ else
411
+ break;
412
+ }
413
+ return buf;
414
+ };
415
+
416
+ exports.getCompletionPrefix = function (editor) {
417
+ var pos = editor.getCursorPosition();
418
+ var line = editor.session.getLine(pos.row);
419
+ var prefix;
420
+ editor.completers.forEach(function(completer) {
421
+ if (completer.identifierRegexps) {
422
+ completer.identifierRegexps.forEach(function(identifierRegex) {
423
+ if (!prefix && identifierRegex)
424
+ prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
425
+ }.bind(this));
426
+ }
427
+ }.bind(this));
428
+ return prefix || this.retrievePrecedingIdentifier(line, pos.column);
429
+ };
430
+
431
+ });
432
+
433
+ ace.define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module) {
434
+ "use strict";
435
+ var dom = require("./lib/dom");
436
+ var oop = require("./lib/oop");
437
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
438
+ var lang = require("./lib/lang");
439
+ var Range = require("./range").Range;
440
+ var RangeList = require("./range_list").RangeList;
441
+ var HashHandler = require("./keyboard/hash_handler").HashHandler;
442
+ var Tokenizer = require("./tokenizer").Tokenizer;
443
+ var clipboard = require("./clipboard");
444
+
445
+ var VARIABLES = {
446
+ CURRENT_WORD: function(editor) {
447
+ return editor.session.getTextRange(editor.session.getWordRange());
448
+ },
449
+ SELECTION: function(editor, name, indentation) {
450
+ var text = editor.session.getTextRange();
451
+ if (indentation)
452
+ return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1");
453
+ return text;
454
+ },
455
+ CURRENT_LINE: function(editor) {
456
+ return editor.session.getLine(editor.getCursorPosition().row);
457
+ },
458
+ PREV_LINE: function(editor) {
459
+ return editor.session.getLine(editor.getCursorPosition().row - 1);
460
+ },
461
+ LINE_INDEX: function(editor) {
462
+ return editor.getCursorPosition().row;
463
+ },
464
+ LINE_NUMBER: function(editor) {
465
+ return editor.getCursorPosition().row + 1;
466
+ },
467
+ SOFT_TABS: function(editor) {
468
+ return editor.session.getUseSoftTabs() ? "YES" : "NO";
469
+ },
470
+ TAB_SIZE: function(editor) {
471
+ return editor.session.getTabSize();
472
+ },
473
+ CLIPBOARD: function(editor) {
474
+ return clipboard.getText && clipboard.getText();
475
+ },
476
+ FILENAME: function(editor) {
477
+ return /[^/\\]*$/.exec(this.FILEPATH(editor))[0];
478
+ },
479
+ FILENAME_BASE: function(editor) {
480
+ return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, "");
481
+ },
482
+ DIRECTORY: function(editor) {
483
+ return this.FILEPATH(editor).replace(/[^/\\]*$/, "");
484
+ },
485
+ FILEPATH: function(editor) { return "/not implemented.txt"; },
486
+ WORKSPACE_NAME: function() { return "Unknown"; },
487
+ FULLNAME: function() { return "Unknown"; },
488
+ BLOCK_COMMENT_START: function(editor) {
489
+ var mode = editor.session.$mode || {};
490
+ return mode.blockComment && mode.blockComment.start || "";
491
+ },
492
+ BLOCK_COMMENT_END: function(editor) {
493
+ var mode = editor.session.$mode || {};
494
+ return mode.blockComment && mode.blockComment.end || "";
495
+ },
496
+ LINE_COMMENT: function(editor) {
497
+ var mode = editor.session.$mode || {};
498
+ return mode.lineCommentStart || "";
499
+ },
500
+ CURRENT_YEAR: date.bind(null, {year: "numeric"}),
501
+ CURRENT_YEAR_SHORT: date.bind(null, {year: "2-digit"}),
502
+ CURRENT_MONTH: date.bind(null, {month: "numeric"}),
503
+ CURRENT_MONTH_NAME: date.bind(null, {month: "long"}),
504
+ CURRENT_MONTH_NAME_SHORT: date.bind(null, {month: "short"}),
505
+ CURRENT_DATE: date.bind(null, {day: "2-digit"}),
506
+ CURRENT_DAY_NAME: date.bind(null, {weekday: "long"}),
507
+ CURRENT_DAY_NAME_SHORT: date.bind(null, {weekday: "short"}),
508
+ CURRENT_HOUR: date.bind(null, {hour: "2-digit", hour12: false}),
509
+ CURRENT_MINUTE: date.bind(null, {minute: "2-digit"}),
510
+ CURRENT_SECOND: date.bind(null, {second: "2-digit"})
511
+ };
512
+
513
+ VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION;
514
+
515
+ function date(dateFormat) {
516
+ var str = new Date().toLocaleString("en-us", dateFormat);
517
+ return str.length == 1 ? "0" + str : str;
518
+ }
519
+
520
+ var SnippetManager = function() {
521
+ this.snippetMap = {};
522
+ this.snippetNameMap = {};
523
+ };
524
+
525
+ (function() {
526
+ oop.implement(this, EventEmitter);
527
+
528
+ this.getTokenizer = function() {
529
+ return SnippetManager.$tokenizer || this.createTokenizer();
530
+ };
531
+
532
+ this.createTokenizer = function() {
533
+ function TabstopToken(str) {
534
+ str = str.substr(1);
535
+ if (/^\d+$/.test(str))
536
+ return [{tabstopId: parseInt(str, 10)}];
537
+ return [{text: str}];
538
+ }
539
+ function escape(ch) {
540
+ return "(?:[^\\\\" + ch + "]|\\\\.)";
541
+ }
542
+ var formatMatcher = {
543
+ regex: "/(" + escape("/") + "+)/",
544
+ onMatch: function(val, state, stack) {
545
+ var ts = stack[0];
546
+ ts.fmtString = true;
547
+ ts.guard = val.slice(1, -1);
548
+ ts.flag = "";
549
+ return "";
550
+ },
551
+ next: "formatString"
552
+ };
553
+
554
+ SnippetManager.$tokenizer = new Tokenizer({
555
+ start: [
556
+ {regex: /\\./, onMatch: function(val, state, stack) {
557
+ var ch = val[1];
558
+ if (ch == "}" && stack.length) {
559
+ val = ch;
560
+ } else if ("`$\\".indexOf(ch) != -1) {
561
+ val = ch;
562
+ }
563
+ return [val];
564
+ }},
565
+ {regex: /}/, onMatch: function(val, state, stack) {
566
+ return [stack.length ? stack.shift() : val];
567
+ }},
568
+ {regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken},
569
+ {regex: /\$\{[\dA-Z_a-z]+/, onMatch: function(str, state, stack) {
570
+ var t = TabstopToken(str.substr(1));
571
+ stack.unshift(t[0]);
572
+ return t;
573
+ }, next: "snippetVar"},
574
+ {regex: /\n/, token: "newline", merge: false}
575
+ ],
576
+ snippetVar: [
577
+ {regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
578
+ var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function(operator) {
579
+ return operator.length == 2 ? operator[1] : "\x00";
580
+ }).split("\x00").map(function(value){
581
+ return {value: value};
582
+ });
583
+ stack[0].choices = choices;
584
+ return [choices[0]];
585
+ }, next: "start"},
586
+ formatMatcher,
587
+ {regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start"}
588
+ ],
589
+ formatString: [
590
+ {regex: /:/, onMatch: function(val, state, stack) {
591
+ if (stack.length && stack[0].expectElse) {
592
+ stack[0].expectElse = false;
593
+ stack[0].ifEnd = {elseEnd: stack[0]};
594
+ return [stack[0].ifEnd];
595
+ }
596
+ return ":";
597
+ }},
598
+ {regex: /\\./, onMatch: function(val, state, stack) {
599
+ var ch = val[1];
600
+ if (ch == "}" && stack.length)
601
+ val = ch;
602
+ else if ("`$\\".indexOf(ch) != -1)
603
+ val = ch;
604
+ else if (ch == "n")
605
+ val = "\n";
606
+ else if (ch == "t")
607
+ val = "\t";
608
+ else if ("ulULE".indexOf(ch) != -1)
609
+ val = {changeCase: ch, local: ch > "a"};
610
+ return [val];
611
+ }},
612
+ {regex: "/\\w*}", onMatch: function(val, state, stack) {
613
+ var next = stack.shift();
614
+ if (next)
615
+ next.flag = val.slice(1, -1);
616
+ this.next = next && next.tabstopId ? "start" : "";
617
+ return [next || val];
618
+ }, next: "start"},
619
+ {regex: /\$(?:\d+|\w+)/, onMatch: function(val, state, stack) {
620
+ return [{text: val.slice(1)}];
621
+ }},
622
+ {regex: /\${\w+/, onMatch: function(val, state, stack) {
623
+ var token = {text: val.slice(2)};
624
+ stack.unshift(token);
625
+ return [token];
626
+ }, next: "formatStringVar"},
627
+ {regex: /\n/, token: "newline", merge: false},
628
+ {regex: /}/, onMatch: function(val, state, stack) {
629
+ var next = stack.shift();
630
+ this.next = next && next.tabstopId ? "start" : "";
631
+ return [next || val];
632
+ }, next: "start"}
633
+ ],
634
+ formatStringVar: [
635
+ {regex: /:\/\w+}/, onMatch: function(val, state, stack) {
636
+ var ts = stack[0];
637
+ ts.formatFunction = val.slice(2, -1);
638
+ return [stack.shift()];
639
+ }, next: "formatString"},
640
+ formatMatcher,
641
+ {regex: /:[\?\-+]?/, onMatch: function(val, state, stack) {
642
+ if (val[1] == "+")
643
+ stack[0].ifEnd = stack[0];
644
+ if (val[1] == "?")
645
+ stack[0].expectElse = true;
646
+ }, next: "formatString"},
647
+ {regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString"}
648
+ ]
649
+ });
650
+ return SnippetManager.$tokenizer;
651
+ };
652
+
653
+ this.tokenizeTmSnippet = function(str, startState) {
654
+ return this.getTokenizer().getLineTokens(str, startState).tokens.map(function(x) {
655
+ return x.value || x;
656
+ });
657
+ };
658
+
659
+ this.getVariableValue = function(editor, name, indentation) {
660
+ if (/^\d+$/.test(name))
661
+ return (this.variables.__ || {})[name] || "";
662
+ if (/^[A-Z]\d+$/.test(name))
663
+ return (this.variables[name[0] + "__"] || {})[name.substr(1)] || "";
664
+
665
+ name = name.replace(/^TM_/, "");
666
+ if (!this.variables.hasOwnProperty(name))
667
+ return "";
668
+ var value = this.variables[name];
669
+ if (typeof value == "function")
670
+ value = this.variables[name](editor, name, indentation);
671
+ return value == null ? "" : value;
672
+ };
673
+
674
+ this.variables = VARIABLES;
675
+ this.tmStrFormat = function(str, ch, editor) {
676
+ if (!ch.fmt) return str;
677
+ var flag = ch.flag || "";
678
+ var re = ch.guard;
679
+ re = new RegExp(re, flag.replace(/[^gim]/g, ""));
680
+ var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt;
681
+ var _self = this;
682
+ var formatted = str.replace(re, function() {
683
+ var oldArgs = _self.variables.__;
684
+ _self.variables.__ = [].slice.call(arguments);
685
+ var fmtParts = _self.resolveVariables(fmtTokens, editor);
686
+ var gChangeCase = "E";
687
+ for (var i = 0; i < fmtParts.length; i++) {
688
+ var ch = fmtParts[i];
689
+ if (typeof ch == "object") {
690
+ fmtParts[i] = "";
691
+ if (ch.changeCase && ch.local) {
692
+ var next = fmtParts[i + 1];
693
+ if (next && typeof next == "string") {
694
+ if (ch.changeCase == "u")
695
+ fmtParts[i] = next[0].toUpperCase();
696
+ else
697
+ fmtParts[i] = next[0].toLowerCase();
698
+ fmtParts[i + 1] = next.substr(1);
699
+ }
700
+ } else if (ch.changeCase) {
701
+ gChangeCase = ch.changeCase;
702
+ }
703
+ } else if (gChangeCase == "U") {
704
+ fmtParts[i] = ch.toUpperCase();
705
+ } else if (gChangeCase == "L") {
706
+ fmtParts[i] = ch.toLowerCase();
707
+ }
708
+ }
709
+ _self.variables.__ = oldArgs;
710
+ return fmtParts.join("");
711
+ });
712
+ return formatted;
713
+ };
714
+
715
+ this.tmFormatFunction = function(str, ch, editor) {
716
+ if (ch.formatFunction == "upcase")
717
+ return str.toUpperCase();
718
+ if (ch.formatFunction == "downcase")
719
+ return str.toLowerCase();
720
+ return str;
721
+ };
722
+
723
+ this.resolveVariables = function(snippet, editor) {
724
+ var result = [];
725
+ var indentation = "";
726
+ var afterNewLine = true;
727
+ for (var i = 0; i < snippet.length; i++) {
728
+ var ch = snippet[i];
729
+ if (typeof ch == "string") {
730
+ result.push(ch);
731
+ if (ch == "\n") {
732
+ afterNewLine = true;
733
+ indentation = "";
734
+ }
735
+ else if (afterNewLine) {
736
+ indentation = /^\t*/.exec(ch)[0];
737
+ afterNewLine = /\S/.test(ch);
738
+ }
739
+ continue;
740
+ }
741
+ if (!ch) continue;
742
+ afterNewLine = false;
743
+
744
+ if (ch.fmtString) {
745
+ var j = snippet.indexOf(ch, i + 1);
746
+ if (j == -1) j = snippet.length;
747
+ ch.fmt = snippet.slice(i + 1, j);
748
+ i = j;
749
+ }
750
+
751
+ if (ch.text) {
752
+ var value = this.getVariableValue(editor, ch.text, indentation) + "";
753
+ if (ch.fmtString)
754
+ value = this.tmStrFormat(value, ch, editor);
755
+ if (ch.formatFunction)
756
+ value = this.tmFormatFunction(value, ch, editor);
757
+
758
+ if (value && !ch.ifEnd) {
759
+ result.push(value);
760
+ gotoNext(ch);
761
+ } else if (!value && ch.ifEnd) {
762
+ gotoNext(ch.ifEnd);
763
+ }
764
+ } else if (ch.elseEnd) {
765
+ gotoNext(ch.elseEnd);
766
+ } else if (ch.tabstopId != null) {
767
+ result.push(ch);
768
+ } else if (ch.changeCase != null) {
769
+ result.push(ch);
770
+ }
771
+ }
772
+ function gotoNext(ch) {
773
+ var i1 = snippet.indexOf(ch, i + 1);
774
+ if (i1 != -1)
775
+ i = i1;
776
+ }
777
+ return result;
778
+ };
779
+
780
+ this.insertSnippetForSelection = function(editor, snippetText) {
781
+ var cursor = editor.getCursorPosition();
782
+ var line = editor.session.getLine(cursor.row);
783
+ var tabString = editor.session.getTabString();
784
+ var indentString = line.match(/^\s*/)[0];
785
+
786
+ if (cursor.column < indentString.length)
787
+ indentString = indentString.slice(0, cursor.column);
788
+
789
+ snippetText = snippetText.replace(/\r/g, "");
790
+ var tokens = this.tokenizeTmSnippet(snippetText);
791
+ tokens = this.resolveVariables(tokens, editor);
792
+ tokens = tokens.map(function(x) {
793
+ if (x == "\n")
794
+ return x + indentString;
795
+ if (typeof x == "string")
796
+ return x.replace(/\t/g, tabString);
797
+ return x;
798
+ });
799
+ var tabstops = [];
800
+ tokens.forEach(function(p, i) {
801
+ if (typeof p != "object")
802
+ return;
803
+ var id = p.tabstopId;
804
+ var ts = tabstops[id];
805
+ if (!ts) {
806
+ ts = tabstops[id] = [];
807
+ ts.index = id;
808
+ ts.value = "";
809
+ ts.parents = {};
810
+ }
811
+ if (ts.indexOf(p) !== -1)
812
+ return;
813
+ if (p.choices && !ts.choices)
814
+ ts.choices = p.choices;
815
+ ts.push(p);
816
+ var i1 = tokens.indexOf(p, i + 1);
817
+ if (i1 === -1)
818
+ return;
819
+
820
+ var value = tokens.slice(i + 1, i1);
821
+ var isNested = value.some(function(t) {return typeof t === "object";});
822
+ if (isNested && !ts.value) {
823
+ ts.value = value;
824
+ } else if (value.length && (!ts.value || typeof ts.value !== "string")) {
825
+ ts.value = value.join("");
826
+ }
827
+ });
828
+ tabstops.forEach(function(ts) {ts.length = 0;});
829
+ var expanding = {};
830
+ function copyValue(val) {
831
+ var copy = [];
832
+ for (var i = 0; i < val.length; i++) {
833
+ var p = val[i];
834
+ if (typeof p == "object") {
835
+ if (expanding[p.tabstopId])
836
+ continue;
837
+ var j = val.lastIndexOf(p, i - 1);
838
+ p = copy[j] || {tabstopId: p.tabstopId};
839
+ }
840
+ copy[i] = p;
841
+ }
842
+ return copy;
843
+ }
844
+ for (var i = 0; i < tokens.length; i++) {
845
+ var p = tokens[i];
846
+ if (typeof p != "object")
847
+ continue;
848
+ var id = p.tabstopId;
849
+ var ts = tabstops[id];
850
+ var i1 = tokens.indexOf(p, i + 1);
851
+ if (expanding[id]) {
852
+ if (expanding[id] === p) {
853
+ delete expanding[id];
854
+ Object.keys(expanding).forEach(function(parentId) {
855
+ ts.parents[parentId] = true;
856
+ });
857
+ }
858
+ continue;
859
+ }
860
+ expanding[id] = p;
861
+ var value = ts.value;
862
+ if (typeof value !== "string")
863
+ value = copyValue(value);
864
+ else if (p.fmt)
865
+ value = this.tmStrFormat(value, p, editor);
866
+ tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p));
867
+
868
+ if (ts.indexOf(p) === -1)
869
+ ts.push(p);
870
+ }
871
+ var row = 0, column = 0;
872
+ var text = "";
873
+ tokens.forEach(function(t) {
874
+ if (typeof t === "string") {
875
+ var lines = t.split("\n");
876
+ if (lines.length > 1){
877
+ column = lines[lines.length - 1].length;
878
+ row += lines.length - 1;
879
+ } else
880
+ column += t.length;
881
+ text += t;
882
+ } else if (t) {
883
+ if (!t.start)
884
+ t.start = {row: row, column: column};
885
+ else
886
+ t.end = {row: row, column: column};
887
+ }
888
+ });
889
+ var range = editor.getSelectionRange();
890
+ var end = editor.session.replace(range, text);
891
+
892
+ var tabstopManager = new TabstopManager(editor);
893
+ var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
894
+ tabstopManager.addTabstops(tabstops, range.start, end, selectionId);
895
+ };
896
+
897
+ this.insertSnippet = function(editor, snippetText) {
898
+ var self = this;
899
+ if (editor.inVirtualSelectionMode)
900
+ return self.insertSnippetForSelection(editor, snippetText);
901
+
902
+ editor.forEachSelection(function() {
903
+ self.insertSnippetForSelection(editor, snippetText);
904
+ }, null, {keepOrder: true});
905
+
906
+ if (editor.tabstopManager)
907
+ editor.tabstopManager.tabNext();
908
+ };
909
+
910
+ this.$getScope = function(editor) {
911
+ var scope = editor.session.$mode.$id || "";
912
+ scope = scope.split("/").pop();
913
+ if (scope === "html" || scope === "php") {
914
+ if (scope === "php" && !editor.session.$mode.inlinePhp)
915
+ scope = "html";
916
+ var c = editor.getCursorPosition();
917
+ var state = editor.session.getState(c.row);
918
+ if (typeof state === "object") {
919
+ state = state[0];
920
+ }
921
+ if (state.substring) {
922
+ if (state.substring(0, 3) == "js-")
923
+ scope = "javascript";
924
+ else if (state.substring(0, 4) == "css-")
925
+ scope = "css";
926
+ else if (state.substring(0, 4) == "php-")
927
+ scope = "php";
928
+ }
929
+ }
930
+
931
+ return scope;
932
+ };
933
+
934
+ this.getActiveScopes = function(editor) {
935
+ var scope = this.$getScope(editor);
936
+ var scopes = [scope];
937
+ var snippetMap = this.snippetMap;
938
+ if (snippetMap[scope] && snippetMap[scope].includeScopes) {
939
+ scopes.push.apply(scopes, snippetMap[scope].includeScopes);
940
+ }
941
+ scopes.push("_");
942
+ return scopes;
943
+ };
944
+
945
+ this.expandWithTab = function(editor, options) {
946
+ var self = this;
947
+ var result = editor.forEachSelection(function() {
948
+ return self.expandSnippetForSelection(editor, options);
949
+ }, null, {keepOrder: true});
950
+ if (result && editor.tabstopManager)
951
+ editor.tabstopManager.tabNext();
952
+ return result;
953
+ };
954
+
955
+ this.expandSnippetForSelection = function(editor, options) {
956
+ var cursor = editor.getCursorPosition();
957
+ var line = editor.session.getLine(cursor.row);
958
+ var before = line.substring(0, cursor.column);
959
+ var after = line.substr(cursor.column);
960
+
961
+ var snippetMap = this.snippetMap;
962
+ var snippet;
963
+ this.getActiveScopes(editor).some(function(scope) {
964
+ var snippets = snippetMap[scope];
965
+ if (snippets)
966
+ snippet = this.findMatchingSnippet(snippets, before, after);
967
+ return !!snippet;
968
+ }, this);
969
+ if (!snippet)
970
+ return false;
971
+ if (options && options.dryRun)
972
+ return true;
973
+ editor.session.doc.removeInLine(cursor.row,
974
+ cursor.column - snippet.replaceBefore.length,
975
+ cursor.column + snippet.replaceAfter.length
976
+ );
977
+
978
+ this.variables.M__ = snippet.matchBefore;
979
+ this.variables.T__ = snippet.matchAfter;
980
+ this.insertSnippetForSelection(editor, snippet.content);
981
+
982
+ this.variables.M__ = this.variables.T__ = null;
983
+ return true;
984
+ };
985
+
986
+ this.findMatchingSnippet = function(snippetList, before, after) {
987
+ for (var i = snippetList.length; i--;) {
988
+ var s = snippetList[i];
989
+ if (s.startRe && !s.startRe.test(before))
990
+ continue;
991
+ if (s.endRe && !s.endRe.test(after))
992
+ continue;
993
+ if (!s.startRe && !s.endRe)
994
+ continue;
995
+
996
+ s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
997
+ s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
998
+ s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
999
+ s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : "";
1000
+ return s;
1001
+ }
1002
+ };
1003
+
1004
+ this.snippetMap = {};
1005
+ this.snippetNameMap = {};
1006
+ this.register = function(snippets, scope) {
1007
+ var snippetMap = this.snippetMap;
1008
+ var snippetNameMap = this.snippetNameMap;
1009
+ var self = this;
1010
+
1011
+ if (!snippets)
1012
+ snippets = [];
1013
+
1014
+ function wrapRegexp(src) {
1015
+ if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
1016
+ src = "(?:" + src + ")";
1017
+
1018
+ return src || "";
1019
+ }
1020
+ function guardedRegexp(re, guard, opening) {
1021
+ re = wrapRegexp(re);
1022
+ guard = wrapRegexp(guard);
1023
+ if (opening) {
1024
+ re = guard + re;
1025
+ if (re && re[re.length - 1] != "$")
1026
+ re = re + "$";
1027
+ } else {
1028
+ re = re + guard;
1029
+ if (re && re[0] != "^")
1030
+ re = "^" + re;
1031
+ }
1032
+ return new RegExp(re);
1033
+ }
1034
+
1035
+ function addSnippet(s) {
1036
+ if (!s.scope)
1037
+ s.scope = scope || "_";
1038
+ scope = s.scope;
1039
+ if (!snippetMap[scope]) {
1040
+ snippetMap[scope] = [];
1041
+ snippetNameMap[scope] = {};
1042
+ }
1043
+
1044
+ var map = snippetNameMap[scope];
1045
+ if (s.name) {
1046
+ var old = map[s.name];
1047
+ if (old)
1048
+ self.unregister(old);
1049
+ map[s.name] = s;
1050
+ }
1051
+ snippetMap[scope].push(s);
1052
+
1053
+ if (s.prefix)
1054
+ s.tabTrigger = s.prefix;
1055
+
1056
+ if (!s.content && s.body)
1057
+ s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body;
1058
+
1059
+ if (s.tabTrigger && !s.trigger) {
1060
+ if (!s.guard && /^\w/.test(s.tabTrigger))
1061
+ s.guard = "\\b";
1062
+ s.trigger = lang.escapeRegExp(s.tabTrigger);
1063
+ }
1064
+
1065
+ if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard)
1066
+ return;
1067
+
1068
+ s.startRe = guardedRegexp(s.trigger, s.guard, true);
1069
+ s.triggerRe = new RegExp(s.trigger);
1070
+
1071
+ s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
1072
+ s.endTriggerRe = new RegExp(s.endTrigger);
1073
+ }
1074
+
1075
+ if (Array.isArray(snippets)) {
1076
+ snippets.forEach(addSnippet);
1077
+ } else {
1078
+ Object.keys(snippets).forEach(function(key) {
1079
+ addSnippet(snippets[key]);
1080
+ });
1081
+ }
1082
+
1083
+ this._signal("registerSnippets", {scope: scope});
1084
+ };
1085
+ this.unregister = function(snippets, scope) {
1086
+ var snippetMap = this.snippetMap;
1087
+ var snippetNameMap = this.snippetNameMap;
1088
+
1089
+ function removeSnippet(s) {
1090
+ var nameMap = snippetNameMap[s.scope||scope];
1091
+ if (nameMap && nameMap[s.name]) {
1092
+ delete nameMap[s.name];
1093
+ var map = snippetMap[s.scope||scope];
1094
+ var i = map && map.indexOf(s);
1095
+ if (i >= 0)
1096
+ map.splice(i, 1);
1097
+ }
1098
+ }
1099
+ if (snippets.content)
1100
+ removeSnippet(snippets);
1101
+ else if (Array.isArray(snippets))
1102
+ snippets.forEach(removeSnippet);
1103
+ };
1104
+ this.parseSnippetFile = function(str) {
1105
+ str = str.replace(/\r/g, "");
1106
+ var list = [], snippet = {};
1107
+ var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
1108
+ var m;
1109
+ while (m = re.exec(str)) {
1110
+ if (m[1]) {
1111
+ try {
1112
+ snippet = JSON.parse(m[1]);
1113
+ list.push(snippet);
1114
+ } catch (e) {}
1115
+ } if (m[4]) {
1116
+ snippet.content = m[4].replace(/^\t/gm, "");
1117
+ list.push(snippet);
1118
+ snippet = {};
1119
+ } else {
1120
+ var key = m[2], val = m[3];
1121
+ if (key == "regex") {
1122
+ var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
1123
+ snippet.guard = guardRe.exec(val)[1];
1124
+ snippet.trigger = guardRe.exec(val)[1];
1125
+ snippet.endTrigger = guardRe.exec(val)[1];
1126
+ snippet.endGuard = guardRe.exec(val)[1];
1127
+ } else if (key == "snippet") {
1128
+ snippet.tabTrigger = val.match(/^\S*/)[0];
1129
+ if (!snippet.name)
1130
+ snippet.name = val;
1131
+ } else if (key) {
1132
+ snippet[key] = val;
1133
+ }
1134
+ }
1135
+ }
1136
+ return list;
1137
+ };
1138
+ this.getSnippetByName = function(name, editor) {
1139
+ var snippetMap = this.snippetNameMap;
1140
+ var snippet;
1141
+ this.getActiveScopes(editor).some(function(scope) {
1142
+ var snippets = snippetMap[scope];
1143
+ if (snippets)
1144
+ snippet = snippets[name];
1145
+ return !!snippet;
1146
+ }, this);
1147
+ return snippet;
1148
+ };
1149
+
1150
+ }).call(SnippetManager.prototype);
1151
+
1152
+
1153
+ var TabstopManager = function(editor) {
1154
+ if (editor.tabstopManager)
1155
+ return editor.tabstopManager;
1156
+ editor.tabstopManager = this;
1157
+ this.$onChange = this.onChange.bind(this);
1158
+ this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
1159
+ this.$onChangeSession = this.onChangeSession.bind(this);
1160
+ this.$onAfterExec = this.onAfterExec.bind(this);
1161
+ this.attach(editor);
1162
+ };
1163
+ (function() {
1164
+ this.attach = function(editor) {
1165
+ this.index = 0;
1166
+ this.ranges = [];
1167
+ this.tabstops = [];
1168
+ this.$openTabstops = null;
1169
+ this.selectedTabstop = null;
1170
+
1171
+ this.editor = editor;
1172
+ this.editor.on("change", this.$onChange);
1173
+ this.editor.on("changeSelection", this.$onChangeSelection);
1174
+ this.editor.on("changeSession", this.$onChangeSession);
1175
+ this.editor.commands.on("afterExec", this.$onAfterExec);
1176
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
1177
+ };
1178
+ this.detach = function() {
1179
+ this.tabstops.forEach(this.removeTabstopMarkers, this);
1180
+ this.ranges = null;
1181
+ this.tabstops = null;
1182
+ this.selectedTabstop = null;
1183
+ this.editor.removeListener("change", this.$onChange);
1184
+ this.editor.removeListener("changeSelection", this.$onChangeSelection);
1185
+ this.editor.removeListener("changeSession", this.$onChangeSession);
1186
+ this.editor.commands.removeListener("afterExec", this.$onAfterExec);
1187
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
1188
+ this.editor.tabstopManager = null;
1189
+ this.editor = null;
1190
+ };
1191
+
1192
+ this.onChange = function(delta) {
1193
+ var isRemove = delta.action[0] == "r";
1194
+ var selectedTabstop = this.selectedTabstop || {};
1195
+ var parents = selectedTabstop.parents || {};
1196
+ var tabstops = (this.tabstops || []).slice();
1197
+ for (var i = 0; i < tabstops.length; i++) {
1198
+ var ts = tabstops[i];
1199
+ var active = ts == selectedTabstop || parents[ts.index];
1200
+ ts.rangeList.$bias = active ? 0 : 1;
1201
+
1202
+ if (delta.action == "remove" && ts !== selectedTabstop) {
1203
+ var parentActive = ts.parents && ts.parents[selectedTabstop.index];
1204
+ var startIndex = ts.rangeList.pointIndex(delta.start, parentActive);
1205
+ startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1;
1206
+ var endIndex = ts.rangeList.pointIndex(delta.end, parentActive);
1207
+ endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1;
1208
+ var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex);
1209
+ for (var j = 0; j < toRemove.length; j++)
1210
+ this.removeRange(toRemove[j]);
1211
+ }
1212
+ ts.rangeList.$onChange(delta);
1213
+ }
1214
+ var session = this.editor.session;
1215
+ if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue())
1216
+ this.detach();
1217
+ };
1218
+ this.updateLinkedFields = function() {
1219
+ var ts = this.selectedTabstop;
1220
+ if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked)
1221
+ return;
1222
+ this.$inChange = true;
1223
+ var session = this.editor.session;
1224
+ var text = session.getTextRange(ts.firstNonLinked);
1225
+ for (var i = 0; i < ts.length; i++) {
1226
+ var range = ts[i];
1227
+ if (!range.linked)
1228
+ continue;
1229
+ var original = range.original;
1230
+ var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor);
1231
+ session.replace(range, fmt);
1232
+ }
1233
+ this.$inChange = false;
1234
+ };
1235
+ this.onAfterExec = function(e) {
1236
+ if (e.command && !e.command.readOnly)
1237
+ this.updateLinkedFields();
1238
+ };
1239
+ this.onChangeSelection = function() {
1240
+ if (!this.editor)
1241
+ return;
1242
+ var lead = this.editor.selection.lead;
1243
+ var anchor = this.editor.selection.anchor;
1244
+ var isEmpty = this.editor.selection.isEmpty();
1245
+ for (var i = 0; i < this.ranges.length; i++) {
1246
+ if (this.ranges[i].linked)
1247
+ continue;
1248
+ var containsLead = this.ranges[i].contains(lead.row, lead.column);
1249
+ var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
1250
+ if (containsLead && containsAnchor)
1251
+ return;
1252
+ }
1253
+ this.detach();
1254
+ };
1255
+ this.onChangeSession = function() {
1256
+ this.detach();
1257
+ };
1258
+ this.tabNext = function(dir) {
1259
+ var max = this.tabstops.length;
1260
+ var index = this.index + (dir || 1);
1261
+ index = Math.min(Math.max(index, 1), max);
1262
+ if (index == max)
1263
+ index = 0;
1264
+ this.selectTabstop(index);
1265
+ if (index === 0)
1266
+ this.detach();
1267
+ };
1268
+ this.selectTabstop = function(index) {
1269
+ this.$openTabstops = null;
1270
+ var ts = this.tabstops[this.index];
1271
+ if (ts)
1272
+ this.addTabstopMarkers(ts);
1273
+ this.index = index;
1274
+ ts = this.tabstops[this.index];
1275
+ if (!ts || !ts.length)
1276
+ return;
1277
+
1278
+ this.selectedTabstop = ts;
1279
+ var range = ts.firstNonLinked || ts;
1280
+ if (ts.choices) range.cursor = range.start;
1281
+ if (!this.editor.inVirtualSelectionMode) {
1282
+ var sel = this.editor.multiSelect;
1283
+ sel.toSingleRange(range);
1284
+ for (var i = 0; i < ts.length; i++) {
1285
+ if (ts.hasLinkedRanges && ts[i].linked)
1286
+ continue;
1287
+ sel.addRange(ts[i].clone(), true);
1288
+ }
1289
+ } else {
1290
+ this.editor.selection.fromOrientedRange(range);
1291
+ }
1292
+
1293
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
1294
+ if (this.selectedTabstop && this.selectedTabstop.choices)
1295
+ this.editor.execCommand("startAutocomplete", {matches: this.selectedTabstop.choices});
1296
+ };
1297
+ this.addTabstops = function(tabstops, start, end) {
1298
+ var useLink = this.useLink || !this.editor.getOption("enableMultiselect");
1299
+
1300
+ if (!this.$openTabstops)
1301
+ this.$openTabstops = [];
1302
+ if (!tabstops[0]) {
1303
+ var p = Range.fromPoints(end, end);
1304
+ moveRelative(p.start, start);
1305
+ moveRelative(p.end, start);
1306
+ tabstops[0] = [p];
1307
+ tabstops[0].index = 0;
1308
+ }
1309
+
1310
+ var i = this.index;
1311
+ var arg = [i + 1, 0];
1312
+ var ranges = this.ranges;
1313
+ tabstops.forEach(function(ts, index) {
1314
+ var dest = this.$openTabstops[index] || ts;
1315
+
1316
+ for (var i = 0; i < ts.length; i++) {
1317
+ var p = ts[i];
1318
+ var range = Range.fromPoints(p.start, p.end || p.start);
1319
+ movePoint(range.start, start);
1320
+ movePoint(range.end, start);
1321
+ range.original = p;
1322
+ range.tabstop = dest;
1323
+ ranges.push(range);
1324
+ if (dest != ts)
1325
+ dest.unshift(range);
1326
+ else
1327
+ dest[i] = range;
1328
+ if (p.fmtString || (dest.firstNonLinked && useLink)) {
1329
+ range.linked = true;
1330
+ dest.hasLinkedRanges = true;
1331
+ } else if (!dest.firstNonLinked)
1332
+ dest.firstNonLinked = range;
1333
+ }
1334
+ if (!dest.firstNonLinked)
1335
+ dest.hasLinkedRanges = false;
1336
+ if (dest === ts) {
1337
+ arg.push(dest);
1338
+ this.$openTabstops[index] = dest;
1339
+ }
1340
+ this.addTabstopMarkers(dest);
1341
+ dest.rangeList = dest.rangeList || new RangeList();
1342
+ dest.rangeList.$bias = 0;
1343
+ dest.rangeList.addList(dest);
1344
+ }, this);
1345
+
1346
+ if (arg.length > 2) {
1347
+ if (this.tabstops.length)
1348
+ arg.push(arg.splice(2, 1)[0]);
1349
+ this.tabstops.splice.apply(this.tabstops, arg);
1350
+ }
1351
+ };
1352
+
1353
+ this.addTabstopMarkers = function(ts) {
1354
+ var session = this.editor.session;
1355
+ ts.forEach(function(range) {
1356
+ if (!range.markerId)
1357
+ range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
1358
+ });
1359
+ };
1360
+ this.removeTabstopMarkers = function(ts) {
1361
+ var session = this.editor.session;
1362
+ ts.forEach(function(range) {
1363
+ session.removeMarker(range.markerId);
1364
+ range.markerId = null;
1365
+ });
1366
+ };
1367
+ this.removeRange = function(range) {
1368
+ var i = range.tabstop.indexOf(range);
1369
+ if (i != -1) range.tabstop.splice(i, 1);
1370
+ i = this.ranges.indexOf(range);
1371
+ if (i != -1) this.ranges.splice(i, 1);
1372
+ i = range.tabstop.rangeList.ranges.indexOf(range);
1373
+ if (i != -1) range.tabstop.splice(i, 1);
1374
+ this.editor.session.removeMarker(range.markerId);
1375
+ if (!range.tabstop.length) {
1376
+ i = this.tabstops.indexOf(range.tabstop);
1377
+ if (i != -1)
1378
+ this.tabstops.splice(i, 1);
1379
+ if (!this.tabstops.length)
1380
+ this.detach();
1381
+ }
1382
+ };
1383
+
1384
+ this.keyboardHandler = new HashHandler();
1385
+ this.keyboardHandler.bindKeys({
1386
+ "Tab": function(editor) {
1387
+ if (exports.snippetManager && exports.snippetManager.expandWithTab(editor))
1388
+ return;
1389
+ editor.tabstopManager.tabNext(1);
1390
+ editor.renderer.scrollCursorIntoView();
1391
+ },
1392
+ "Shift-Tab": function(editor) {
1393
+ editor.tabstopManager.tabNext(-1);
1394
+ editor.renderer.scrollCursorIntoView();
1395
+ },
1396
+ "Esc": function(editor) {
1397
+ editor.tabstopManager.detach();
1398
+ }
1399
+ });
1400
+ }).call(TabstopManager.prototype);
1401
+
1402
+
1403
+
1404
+ var movePoint = function(point, diff) {
1405
+ if (point.row == 0)
1406
+ point.column += diff.column;
1407
+ point.row += diff.row;
1408
+ };
1409
+
1410
+ var moveRelative = function(point, start) {
1411
+ if (point.row == start.row)
1412
+ point.column -= start.column;
1413
+ point.row -= start.row;
1414
+ };
1415
+
1416
+
1417
+ dom.importCssString("\
1418
+ .ace_snippet-marker {\
1419
+ -moz-box-sizing: border-box;\
1420
+ box-sizing: border-box;\
1421
+ background: rgba(194, 193, 208, 0.09);\
1422
+ border: 1px dotted rgba(211, 208, 235, 0.62);\
1423
+ position: absolute;\
1424
+ }", "snippets.css", false);
1425
+
1426
+ exports.snippetManager = new SnippetManager();
1427
+
1428
+
1429
+ var Editor = require("./editor").Editor;
1430
+ (function() {
1431
+ this.insertSnippet = function(content, options) {
1432
+ return exports.snippetManager.insertSnippet(this, content, options);
1433
+ };
1434
+ this.expandSnippet = function(options) {
1435
+ return exports.snippetManager.expandWithTab(this, options);
1436
+ };
1437
+ }).call(Editor.prototype);
1438
+
1439
+ });
1440
+
1441
+ ace.define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config"], function(require, exports, module) {
1442
+ "use strict";
1443
+
1444
+ var HashHandler = require("./keyboard/hash_handler").HashHandler;
1445
+ var AcePopup = require("./autocomplete/popup").AcePopup;
1446
+ var util = require("./autocomplete/util");
1447
+ var lang = require("./lib/lang");
1448
+ var dom = require("./lib/dom");
1449
+ var snippetManager = require("./snippets").snippetManager;
1450
+ var config = require("./config");
1451
+
1452
+ var Autocomplete = function() {
1453
+ this.autoInsert = false;
1454
+ this.autoSelect = true;
1455
+ this.exactMatch = false;
1456
+ this.gatherCompletionsId = 0;
1457
+ this.keyboardHandler = new HashHandler();
1458
+ this.keyboardHandler.bindKeys(this.commands);
1459
+
1460
+ this.blurListener = this.blurListener.bind(this);
1461
+ this.changeListener = this.changeListener.bind(this);
1462
+ this.mousedownListener = this.mousedownListener.bind(this);
1463
+ this.mousewheelListener = this.mousewheelListener.bind(this);
1464
+
1465
+ this.changeTimer = lang.delayedCall(function() {
1466
+ this.updateCompletions(true);
1467
+ }.bind(this));
1468
+
1469
+ this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
1470
+ };
1471
+
1472
+ (function() {
1473
+
1474
+ this.$init = function() {
1475
+ this.popup = new AcePopup(document.body || document.documentElement);
1476
+ this.popup.on("click", function(e) {
1477
+ this.insertMatch();
1478
+ e.stop();
1479
+ }.bind(this));
1480
+ this.popup.focus = this.editor.focus.bind(this.editor);
1481
+ this.popup.on("show", this.tooltipTimer.bind(null, null));
1482
+ this.popup.on("select", this.tooltipTimer.bind(null, null));
1483
+ this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
1484
+ return this.popup;
1485
+ };
1486
+
1487
+ this.getPopup = function() {
1488
+ return this.popup || this.$init();
1489
+ };
1490
+
1491
+ this.openPopup = function(editor, prefix, keepPopupPosition) {
1492
+ if (!this.popup)
1493
+ this.$init();
1494
+
1495
+ this.popup.autoSelect = this.autoSelect;
1496
+
1497
+ this.popup.setData(this.completions.filtered, this.completions.filterText);
1498
+
1499
+ editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
1500
+
1501
+ var renderer = editor.renderer;
1502
+ this.popup.setRow(this.autoSelect ? 0 : -1);
1503
+ if (!keepPopupPosition) {
1504
+ this.popup.setTheme(editor.getTheme());
1505
+ this.popup.setFontSize(editor.getFontSize());
1506
+
1507
+ var lineHeight = renderer.layerConfig.lineHeight;
1508
+
1509
+ var pos = renderer.$cursorLayer.getPixelPosition(this.base, true);
1510
+ pos.left -= this.popup.getTextLeftOffset();
1511
+
1512
+ var rect = editor.container.getBoundingClientRect();
1513
+ pos.top += rect.top - renderer.layerConfig.offset;
1514
+ pos.left += rect.left - editor.renderer.scrollLeft;
1515
+ pos.left += renderer.gutterWidth;
1516
+
1517
+ this.popup.show(pos, lineHeight);
1518
+ } else if (keepPopupPosition && !prefix) {
1519
+ this.detach();
1520
+ }
1521
+ this.changeTimer.cancel();
1522
+ };
1523
+
1524
+ this.detach = function() {
1525
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
1526
+ this.editor.off("changeSelection", this.changeListener);
1527
+ this.editor.off("blur", this.blurListener);
1528
+ this.editor.off("mousedown", this.mousedownListener);
1529
+ this.editor.off("mousewheel", this.mousewheelListener);
1530
+ this.changeTimer.cancel();
1531
+ this.hideDocTooltip();
1532
+
1533
+ this.gatherCompletionsId += 1;
1534
+ if (this.popup && this.popup.isOpen)
1535
+ this.popup.hide();
1536
+
1537
+ if (this.base)
1538
+ this.base.detach();
1539
+ this.activated = false;
1540
+ this.completions = this.base = null;
1541
+ };
1542
+
1543
+ this.changeListener = function(e) {
1544
+ var cursor = this.editor.selection.lead;
1545
+ if (cursor.row != this.base.row || cursor.column < this.base.column) {
1546
+ this.detach();
1547
+ }
1548
+ if (this.activated)
1549
+ this.changeTimer.schedule();
1550
+ else
1551
+ this.detach();
1552
+ };
1553
+
1554
+ this.blurListener = function(e) {
1555
+ var el = document.activeElement;
1556
+ var text = this.editor.textInput.getElement();
1557
+ var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget);
1558
+ var container = this.popup && this.popup.container;
1559
+ if (el != text && el.parentNode != container && !fromTooltip
1560
+ && el != this.tooltipNode && e.relatedTarget != text
1561
+ ) {
1562
+ this.detach();
1563
+ }
1564
+ };
1565
+
1566
+ this.mousedownListener = function(e) {
1567
+ this.detach();
1568
+ };
1569
+
1570
+ this.mousewheelListener = function(e) {
1571
+ this.detach();
1572
+ };
1573
+
1574
+ this.goTo = function(where) {
1575
+ this.popup.goTo(where);
1576
+ };
1577
+
1578
+ this.insertMatch = function(data, options) {
1579
+ if (!data)
1580
+ data = this.popup.getData(this.popup.getRow());
1581
+ if (!data)
1582
+ return false;
1583
+
1584
+ var completions = this.completions;
1585
+ this.editor.startOperation({command: {name: "insertMatch"}});
1586
+ if (data.completer && data.completer.insertMatch) {
1587
+ data.completer.insertMatch(this.editor, data);
1588
+ } else {
1589
+ if (completions.filterText) {
1590
+ var ranges = this.editor.selection.getAllRanges();
1591
+ for (var i = 0, range; range = ranges[i]; i++) {
1592
+ range.start.column -= completions.filterText.length;
1593
+ this.editor.session.remove(range);
1594
+ }
1595
+ }
1596
+ if (data.snippet)
1597
+ snippetManager.insertSnippet(this.editor, data.snippet);
1598
+ else
1599
+ this.editor.execCommand("insertstring", data.value || data);
1600
+ }
1601
+ if (this.completions == completions)
1602
+ this.detach();
1603
+ this.editor.endOperation();
1604
+ };
1605
+
1606
+
1607
+ this.commands = {
1608
+ "Up": function(editor) { editor.completer.goTo("up"); },
1609
+ "Down": function(editor) { editor.completer.goTo("down"); },
1610
+ "Ctrl-Up|Ctrl-Home": function(editor) { editor.completer.goTo("start"); },
1611
+ "Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
1612
+
1613
+ "Esc": function(editor) { editor.completer.detach(); },
1614
+ "Return": function(editor) { return editor.completer.insertMatch(); },
1615
+ "Shift-Return": function(editor) { editor.completer.insertMatch(null, {deleteSuffix: true}); },
1616
+ "Tab": function(editor) {
1617
+ var result = editor.completer.insertMatch();
1618
+ if (!result && !editor.tabstopManager)
1619
+ editor.completer.goTo("down");
1620
+ else
1621
+ return result;
1622
+ },
1623
+
1624
+ "PageUp": function(editor) { editor.completer.popup.gotoPageUp(); },
1625
+ "PageDown": function(editor) { editor.completer.popup.gotoPageDown(); }
1626
+ };
1627
+
1628
+ this.gatherCompletions = function(editor, callback) {
1629
+ var session = editor.getSession();
1630
+ var pos = editor.getCursorPosition();
1631
+
1632
+ var prefix = util.getCompletionPrefix(editor);
1633
+
1634
+ this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
1635
+ this.base.$insertRight = true;
1636
+
1637
+ var matches = [];
1638
+ var total = editor.completers.length;
1639
+ editor.completers.forEach(function(completer, i) {
1640
+ completer.getCompletions(editor, session, pos, prefix, function(err, results) {
1641
+ if (!err && results)
1642
+ matches = matches.concat(results);
1643
+ callback(null, {
1644
+ prefix: util.getCompletionPrefix(editor),
1645
+ matches: matches,
1646
+ finished: (--total === 0)
1647
+ });
1648
+ });
1649
+ });
1650
+ return true;
1651
+ };
1652
+
1653
+ this.showPopup = function(editor, options) {
1654
+ if (this.editor)
1655
+ this.detach();
1656
+
1657
+ this.activated = true;
1658
+
1659
+ this.editor = editor;
1660
+ if (editor.completer != this) {
1661
+ if (editor.completer)
1662
+ editor.completer.detach();
1663
+ editor.completer = this;
1664
+ }
1665
+
1666
+ editor.on("changeSelection", this.changeListener);
1667
+ editor.on("blur", this.blurListener);
1668
+ editor.on("mousedown", this.mousedownListener);
1669
+ editor.on("mousewheel", this.mousewheelListener);
1670
+
1671
+ this.updateCompletions(false, options);
1672
+ };
1673
+
1674
+ this.updateCompletions = function(keepPopupPosition, options) {
1675
+ if (keepPopupPosition && this.base && this.completions) {
1676
+ var pos = this.editor.getCursorPosition();
1677
+ var prefix = this.editor.session.getTextRange({start: this.base, end: pos});
1678
+ if (prefix == this.completions.filterText)
1679
+ return;
1680
+ this.completions.setFilter(prefix);
1681
+ if (!this.completions.filtered.length)
1682
+ return this.detach();
1683
+ if (this.completions.filtered.length == 1
1684
+ && this.completions.filtered[0].value == prefix
1685
+ && !this.completions.filtered[0].snippet)
1686
+ return this.detach();
1687
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1688
+ return;
1689
+ }
1690
+
1691
+ if (options && options.matches) {
1692
+ var pos = this.editor.getSelectionRange().start;
1693
+ this.base = this.editor.session.doc.createAnchor(pos.row, pos.column);
1694
+ this.base.$insertRight = true;
1695
+ this.completions = new FilteredList(options.matches);
1696
+ return this.openPopup(this.editor, "", keepPopupPosition);
1697
+ }
1698
+ var _id = this.gatherCompletionsId;
1699
+ var detachIfFinished = function(results) {
1700
+ if (!results.finished) return;
1701
+ return this.detach();
1702
+ }.bind(this);
1703
+
1704
+ var processResults = function(results) {
1705
+ var prefix = results.prefix;
1706
+ var matches = results.matches;
1707
+
1708
+ this.completions = new FilteredList(matches);
1709
+
1710
+ if (this.exactMatch)
1711
+ this.completions.exactMatch = true;
1712
+
1713
+ this.completions.setFilter(prefix);
1714
+ var filtered = this.completions.filtered;
1715
+ if (!filtered.length)
1716
+ return detachIfFinished(results);
1717
+ if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet)
1718
+ return detachIfFinished(results);
1719
+ if (this.autoInsert && filtered.length == 1 && results.finished)
1720
+ return this.insertMatch(filtered[0]);
1721
+
1722
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1723
+ }.bind(this);
1724
+
1725
+ var isImmediate = true;
1726
+ var immediateResults = null;
1727
+ this.gatherCompletions(this.editor, function(err, results) {
1728
+ var prefix = results.prefix;
1729
+ var matches = results && results.matches;
1730
+
1731
+ if (!matches || !matches.length)
1732
+ return detachIfFinished(results);
1733
+ if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId)
1734
+ return;
1735
+ if (isImmediate) {
1736
+ immediateResults = results;
1737
+ return;
1738
+ }
1739
+
1740
+ processResults(results);
1741
+ }.bind(this));
1742
+
1743
+ isImmediate = false;
1744
+ if (immediateResults) {
1745
+ var results = immediateResults;
1746
+ immediateResults = null;
1747
+ processResults(results);
1748
+ }
1749
+ };
1750
+
1751
+ this.cancelContextMenu = function() {
1752
+ this.editor.$mouseHandler.cancelContextMenu();
1753
+ };
1754
+
1755
+ this.updateDocTooltip = function() {
1756
+ var popup = this.popup;
1757
+ var all = popup.data;
1758
+ var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
1759
+ var doc = null;
1760
+ if (!selected || !this.editor || !this.popup.isOpen)
1761
+ return this.hideDocTooltip();
1762
+ this.editor.completers.some(function(completer) {
1763
+ if (completer.getDocTooltip)
1764
+ doc = completer.getDocTooltip(selected);
1765
+ return doc;
1766
+ });
1767
+ if (!doc && typeof selected != "string")
1768
+ doc = selected;
1769
+
1770
+ if (typeof doc == "string")
1771
+ doc = {docText: doc};
1772
+ if (!doc || !(doc.docHTML || doc.docText))
1773
+ return this.hideDocTooltip();
1774
+ this.showDocTooltip(doc);
1775
+ };
1776
+
1777
+ this.showDocTooltip = function(item) {
1778
+ if (!this.tooltipNode) {
1779
+ this.tooltipNode = dom.createElement("div");
1780
+ this.tooltipNode.className = "ace_tooltip ace_doc-tooltip";
1781
+ this.tooltipNode.style.margin = 0;
1782
+ this.tooltipNode.style.pointerEvents = "auto";
1783
+ this.tooltipNode.tabIndex = -1;
1784
+ this.tooltipNode.onblur = this.blurListener.bind(this);
1785
+ this.tooltipNode.onclick = this.onTooltipClick.bind(this);
1786
+ }
1787
+
1788
+ var tooltipNode = this.tooltipNode;
1789
+ if (item.docHTML) {
1790
+ tooltipNode.innerHTML = item.docHTML;
1791
+ } else if (item.docText) {
1792
+ tooltipNode.textContent = item.docText;
1793
+ }
1794
+
1795
+ if (!tooltipNode.parentNode)
1796
+ document.body.appendChild(tooltipNode);
1797
+ var popup = this.popup;
1798
+ var rect = popup.container.getBoundingClientRect();
1799
+ tooltipNode.style.top = popup.container.style.top;
1800
+ tooltipNode.style.bottom = popup.container.style.bottom;
1801
+
1802
+ tooltipNode.style.display = "block";
1803
+ if (window.innerWidth - rect.right < 320) {
1804
+ if (rect.left < 320) {
1805
+ if(popup.isTopdown) {
1806
+ tooltipNode.style.top = rect.bottom + "px";
1807
+ tooltipNode.style.left = rect.left + "px";
1808
+ tooltipNode.style.right = "";
1809
+ tooltipNode.style.bottom = "";
1810
+ } else {
1811
+ tooltipNode.style.top = popup.container.offsetTop - tooltipNode.offsetHeight + "px";
1812
+ tooltipNode.style.left = rect.left + "px";
1813
+ tooltipNode.style.right = "";
1814
+ tooltipNode.style.bottom = "";
1815
+ }
1816
+ } else {
1817
+ tooltipNode.style.right = window.innerWidth - rect.left + "px";
1818
+ tooltipNode.style.left = "";
1819
+ }
1820
+ } else {
1821
+ tooltipNode.style.left = (rect.right + 1) + "px";
1822
+ tooltipNode.style.right = "";
1823
+ }
1824
+ };
1825
+
1826
+ this.hideDocTooltip = function() {
1827
+ this.tooltipTimer.cancel();
1828
+ if (!this.tooltipNode) return;
1829
+ var el = this.tooltipNode;
1830
+ if (!this.editor.isFocused() && document.activeElement == el)
1831
+ this.editor.focus();
1832
+ this.tooltipNode = null;
1833
+ if (el.parentNode)
1834
+ el.parentNode.removeChild(el);
1835
+ };
1836
+
1837
+ this.onTooltipClick = function(e) {
1838
+ var a = e.target;
1839
+ while (a && a != this.tooltipNode) {
1840
+ if (a.nodeName == "A" && a.href) {
1841
+ a.rel = "noreferrer";
1842
+ a.target = "_blank";
1843
+ break;
1844
+ }
1845
+ a = a.parentNode;
1846
+ }
1847
+ };
1848
+
1849
+ this.destroy = function() {
1850
+ this.detach();
1851
+ if (this.popup) {
1852
+ this.popup.destroy();
1853
+ var el = this.popup.container;
1854
+ if (el && el.parentNode)
1855
+ el.parentNode.removeChild(el);
1856
+ }
1857
+ if (this.editor && this.editor.completer == this)
1858
+ this.editor.completer == null;
1859
+ this.popup = null;
1860
+ };
1861
+
1862
+ }).call(Autocomplete.prototype);
1863
+
1864
+
1865
+ Autocomplete.for = function(editor) {
1866
+ if (editor.completer) {
1867
+ return editor.completer;
1868
+ }
1869
+ if (config.get("sharedPopups")) {
1870
+ if (!Autocomplete.$shared)
1871
+ Autocomplete.$sharedInstance = new Autocomplete();
1872
+ editor.completer = Autocomplete.$sharedInstance;
1873
+ } else {
1874
+ editor.completer = new Autocomplete();
1875
+ editor.once("destroy", function(e, editor) {
1876
+ editor.completer.destroy();
1877
+ });
1878
+ }
1879
+ return editor.completer;
1880
+ };
1881
+
1882
+ Autocomplete.startCommand = {
1883
+ name: "startAutocomplete",
1884
+ exec: function(editor, options) {
1885
+ var completer = Autocomplete.for(editor);
1886
+ completer.autoInsert = false;
1887
+ completer.autoSelect = true;
1888
+ completer.showPopup(editor, options);
1889
+ completer.cancelContextMenu();
1890
+ },
1891
+ bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
1892
+ };
1893
+
1894
+ var FilteredList = function(array, filterText) {
1895
+ this.all = array;
1896
+ this.filtered = array;
1897
+ this.filterText = filterText || "";
1898
+ this.exactMatch = false;
1899
+ };
1900
+ (function(){
1901
+ this.setFilter = function(str) {
1902
+ if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0)
1903
+ var matches = this.filtered;
1904
+ else
1905
+ var matches = this.all;
1906
+
1907
+ this.filterText = str;
1908
+ matches = this.filterCompletions(matches, this.filterText);
1909
+ matches = matches.sort(function(a, b) {
1910
+ return b.exactMatch - a.exactMatch || b.$score - a.$score
1911
+ || (a.caption || a.value).localeCompare(b.caption || b.value);
1912
+ });
1913
+ var prev = null;
1914
+ matches = matches.filter(function(item){
1915
+ var caption = item.snippet || item.caption || item.value;
1916
+ if (caption === prev) return false;
1917
+ prev = caption;
1918
+ return true;
1919
+ });
1920
+
1921
+ this.filtered = matches;
1922
+ };
1923
+ this.filterCompletions = function(items, needle) {
1924
+ var results = [];
1925
+ var upper = needle.toUpperCase();
1926
+ var lower = needle.toLowerCase();
1927
+ loop: for (var i = 0, item; item = items[i]; i++) {
1928
+ var caption = item.caption || item.value || item.snippet;
1929
+ if (!caption) continue;
1930
+ var lastIndex = -1;
1931
+ var matchMask = 0;
1932
+ var penalty = 0;
1933
+ var index, distance;
1934
+
1935
+ if (this.exactMatch) {
1936
+ if (needle !== caption.substr(0, needle.length))
1937
+ continue loop;
1938
+ } else {
1939
+ var fullMatchIndex = caption.toLowerCase().indexOf(lower);
1940
+ if (fullMatchIndex > -1) {
1941
+ penalty = fullMatchIndex;
1942
+ } else {
1943
+ for (var j = 0; j < needle.length; j++) {
1944
+ var i1 = caption.indexOf(lower[j], lastIndex + 1);
1945
+ var i2 = caption.indexOf(upper[j], lastIndex + 1);
1946
+ index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
1947
+ if (index < 0)
1948
+ continue loop;
1949
+ distance = index - lastIndex - 1;
1950
+ if (distance > 0) {
1951
+ if (lastIndex === -1)
1952
+ penalty += 10;
1953
+ penalty += distance;
1954
+ matchMask = matchMask | (1 << j);
1955
+ }
1956
+ lastIndex = index;
1957
+ }
1958
+ }
1959
+ }
1960
+ item.matchMask = matchMask;
1961
+ item.exactMatch = penalty ? 0 : 1;
1962
+ item.$score = (item.score || 0) - penalty;
1963
+ results.push(item);
1964
+ }
1965
+ return results;
1966
+ };
1967
+ }).call(FilteredList.prototype);
1968
+
1969
+ exports.Autocomplete = Autocomplete;
1970
+ exports.FilteredList = FilteredList;
1971
+
1972
+ });
1973
+
1974
+ ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
1975
+ 'use strict';
1976
+ var dom = require("../../lib/dom");
1977
+ var cssText = "#ace_settingsmenu, #kbshortcutmenu {\
1978
+ background-color: #F7F7F7;\
1979
+ color: black;\
1980
+ box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\
1981
+ padding: 1em 0.5em 2em 1em;\
1982
+ overflow: auto;\
1983
+ position: absolute;\
1984
+ margin: 0;\
1985
+ bottom: 0;\
1986
+ right: 0;\
1987
+ top: 0;\
1988
+ z-index: 9991;\
1989
+ cursor: default;\
1990
+ }\
1991
+ .ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\
1992
+ box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\
1993
+ background-color: rgba(255, 255, 255, 0.6);\
1994
+ color: black;\
1995
+ }\
1996
+ .ace_optionsMenuEntry:hover {\
1997
+ background-color: rgba(100, 100, 100, 0.1);\
1998
+ transition: all 0.3s\
1999
+ }\
2000
+ .ace_closeButton {\
2001
+ background: rgba(245, 146, 146, 0.5);\
2002
+ border: 1px solid #F48A8A;\
2003
+ border-radius: 50%;\
2004
+ padding: 7px;\
2005
+ position: absolute;\
2006
+ right: -8px;\
2007
+ top: -8px;\
2008
+ z-index: 100000;\
2009
+ }\
2010
+ .ace_closeButton{\
2011
+ background: rgba(245, 146, 146, 0.9);\
2012
+ }\
2013
+ .ace_optionsMenuKey {\
2014
+ color: darkslateblue;\
2015
+ font-weight: bold;\
2016
+ }\
2017
+ .ace_optionsMenuCommand {\
2018
+ color: darkcyan;\
2019
+ font-weight: normal;\
2020
+ }\
2021
+ .ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
2022
+ vertical-align: middle;\
2023
+ }\
2024
+ .ace_optionsMenuEntry button[ace_selected_button=true] {\
2025
+ background: #e7e7e7;\
2026
+ box-shadow: 1px 0px 2px 0px #adadad inset;\
2027
+ border-color: #adadad;\
2028
+ }\
2029
+ .ace_optionsMenuEntry button {\
2030
+ background: white;\
2031
+ border: 1px solid lightgray;\
2032
+ margin: 0px;\
2033
+ }\
2034
+ .ace_optionsMenuEntry button:hover{\
2035
+ background: #f0f0f0;\
2036
+ }";
2037
+ dom.importCssString(cssText, "settings_menu.css", false);
2038
+
2039
+ module.exports.overlayPage = function overlayPage(editor, contentElement, callback) {
2040
+ var closer = document.createElement('div');
2041
+ var ignoreFocusOut = false;
2042
+
2043
+ function documentEscListener(e) {
2044
+ if (e.keyCode === 27) {
2045
+ close();
2046
+ }
2047
+ }
2048
+
2049
+ function close() {
2050
+ if (!closer) return;
2051
+ document.removeEventListener('keydown', documentEscListener);
2052
+ closer.parentNode.removeChild(closer);
2053
+ if (editor) {
2054
+ editor.focus();
2055
+ }
2056
+ closer = null;
2057
+ callback && callback();
2058
+ }
2059
+ function setIgnoreFocusOut(ignore) {
2060
+ ignoreFocusOut = ignore;
2061
+ if (ignore) {
2062
+ closer.style.pointerEvents = "none";
2063
+ contentElement.style.pointerEvents = "auto";
2064
+ }
2065
+ }
2066
+
2067
+ closer.style.cssText = 'margin: 0; padding: 0; ' +
2068
+ 'position: fixed; top:0; bottom:0; left:0; right:0;' +
2069
+ 'z-index: 9990; ' +
2070
+ (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : '');
2071
+ closer.addEventListener('click', function(e) {
2072
+ if (!ignoreFocusOut) {
2073
+ close();
2074
+ }
2075
+ });
2076
+ document.addEventListener('keydown', documentEscListener);
2077
+
2078
+ contentElement.addEventListener('click', function (e) {
2079
+ e.stopPropagation();
2080
+ });
2081
+
2082
+ closer.appendChild(contentElement);
2083
+ document.body.appendChild(closer);
2084
+ if (editor) {
2085
+ editor.blur();
2086
+ }
2087
+ return {
2088
+ close: close,
2089
+ setIgnoreFocusOut: setIgnoreFocusOut
2090
+ };
2091
+ };
2092
+
2093
+ });
2094
+
2095
+ ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
2096
+ "use strict";
2097
+
2098
+ var modes = [];
2099
+ function getModeForPath(path) {
2100
+ var mode = modesByName.text;
2101
+ var fileName = path.split(/[\/\\]/).pop();
2102
+ for (var i = 0; i < modes.length; i++) {
2103
+ if (modes[i].supportsFile(fileName)) {
2104
+ mode = modes[i];
2105
+ break;
2106
+ }
2107
+ }
2108
+ return mode;
2109
+ }
2110
+
2111
+ var Mode = function(name, caption, extensions) {
2112
+ this.name = name;
2113
+ this.caption = caption;
2114
+ this.mode = "ace/mode/" + name;
2115
+ this.extensions = extensions;
2116
+ var re;
2117
+ if (/\^/.test(extensions)) {
2118
+ re = extensions.replace(/\|(\^)?/g, function(a, b){
2119
+ return "$|" + (b ? "^" : "^.*\\.");
2120
+ }) + "$";
2121
+ } else {
2122
+ re = "^.*\\.(" + extensions + ")$";
2123
+ }
2124
+
2125
+ this.extRe = new RegExp(re, "gi");
2126
+ };
2127
+
2128
+ Mode.prototype.supportsFile = function(filename) {
2129
+ return filename.match(this.extRe);
2130
+ };
2131
+ var supportedModes = {
2132
+ ABAP: ["abap"],
2133
+ ABC: ["abc"],
2134
+ ActionScript:["as"],
2135
+ ADA: ["ada|adb"],
2136
+ Alda: ["alda"],
2137
+ Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
2138
+ Apex: ["apex|cls|trigger|tgr"],
2139
+ AQL: ["aql"],
2140
+ AsciiDoc: ["asciidoc|adoc"],
2141
+ ASL: ["dsl|asl|asl.json"],
2142
+ Assembly_x86:["asm|a"],
2143
+ AutoHotKey: ["ahk"],
2144
+ BatchFile: ["bat|cmd"],
2145
+ C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
2146
+ C9Search: ["c9search_results"],
2147
+ Cirru: ["cirru|cr"],
2148
+ Clojure: ["clj|cljs"],
2149
+ Cobol: ["CBL|COB"],
2150
+ coffee: ["coffee|cf|cson|^Cakefile"],
2151
+ ColdFusion: ["cfm"],
2152
+ Crystal: ["cr"],
2153
+ CSharp: ["cs"],
2154
+ Csound_Document: ["csd"],
2155
+ Csound_Orchestra: ["orc"],
2156
+ Csound_Score: ["sco"],
2157
+ CSS: ["css"],
2158
+ Curly: ["curly"],
2159
+ D: ["d|di"],
2160
+ Dart: ["dart"],
2161
+ Diff: ["diff|patch"],
2162
+ Dockerfile: ["^Dockerfile"],
2163
+ Dot: ["dot"],
2164
+ Drools: ["drl"],
2165
+ Edifact: ["edi"],
2166
+ Eiffel: ["e|ge"],
2167
+ EJS: ["ejs"],
2168
+ Elixir: ["ex|exs"],
2169
+ Elm: ["elm"],
2170
+ Erlang: ["erl|hrl"],
2171
+ Forth: ["frt|fs|ldr|fth|4th"],
2172
+ Fortran: ["f|f90"],
2173
+ FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
2174
+ FSL: ["fsl"],
2175
+ FTL: ["ftl"],
2176
+ Gcode: ["gcode"],
2177
+ Gherkin: ["feature"],
2178
+ Gitignore: ["^.gitignore"],
2179
+ Glsl: ["glsl|frag|vert"],
2180
+ Gobstones: ["gbs"],
2181
+ golang: ["go"],
2182
+ GraphQLSchema: ["gql"],
2183
+ Groovy: ["groovy"],
2184
+ HAML: ["haml"],
2185
+ Handlebars: ["hbs|handlebars|tpl|mustache"],
2186
+ Haskell: ["hs"],
2187
+ Haskell_Cabal: ["cabal"],
2188
+ haXe: ["hx"],
2189
+ Hjson: ["hjson"],
2190
+ HTML: ["html|htm|xhtml|vue|we|wpy"],
2191
+ HTML_Elixir: ["eex|html.eex"],
2192
+ HTML_Ruby: ["erb|rhtml|html.erb"],
2193
+ INI: ["ini|conf|cfg|prefs"],
2194
+ Io: ["io"],
2195
+ Jack: ["jack"],
2196
+ Jade: ["jade|pug"],
2197
+ Java: ["java"],
2198
+ JavaScript: ["js|jsm|jsx"],
2199
+ JSON: ["json"],
2200
+ JSON5: ["json5"],
2201
+ JSONiq: ["jq"],
2202
+ JSP: ["jsp"],
2203
+ JSSM: ["jssm|jssm_state"],
2204
+ JSX: ["jsx"],
2205
+ Julia: ["jl"],
2206
+ Kotlin: ["kt|kts"],
2207
+ LaTeX: ["tex|latex|ltx|bib"],
2208
+ Latte: ["latte"],
2209
+ LESS: ["less"],
2210
+ Liquid: ["liquid"],
2211
+ Lisp: ["lisp"],
2212
+ LiveScript: ["ls"],
2213
+ LogiQL: ["logic|lql"],
2214
+ LSL: ["lsl"],
2215
+ Lua: ["lua"],
2216
+ LuaPage: ["lp"],
2217
+ Lucene: ["lucene"],
2218
+ Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
2219
+ Markdown: ["md|markdown"],
2220
+ Mask: ["mask"],
2221
+ MATLAB: ["matlab"],
2222
+ Maze: ["mz"],
2223
+ MediaWiki: ["wiki|mediawiki"],
2224
+ MEL: ["mel"],
2225
+ MIPS: ["s|asm"],
2226
+ MIXAL: ["mixal"],
2227
+ MUSHCode: ["mc|mush"],
2228
+ MySQL: ["mysql"],
2229
+ Nginx: ["nginx|conf"],
2230
+ Nim: ["nim"],
2231
+ Nix: ["nix"],
2232
+ NSIS: ["nsi|nsh"],
2233
+ Nunjucks: ["nunjucks|nunjs|nj|njk"],
2234
+ ObjectiveC: ["m|mm"],
2235
+ OCaml: ["ml|mli"],
2236
+ Pascal: ["pas|p"],
2237
+ Perl: ["pl|pm"],
2238
+ pgSQL: ["pgsql"],
2239
+ PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
2240
+ PHP_Laravel_blade: ["blade.php"],
2241
+ Pig: ["pig"],
2242
+ Powershell: ["ps1"],
2243
+ Praat: ["praat|praatscript|psc|proc"],
2244
+ Prisma: ["prisma"],
2245
+ Prolog: ["plg|prolog"],
2246
+ Properties: ["properties"],
2247
+ Protobuf: ["proto"],
2248
+ Puppet: ["epp|pp"],
2249
+ Python: ["py"],
2250
+ QML: ["qml"],
2251
+ R: ["r"],
2252
+ Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"],
2253
+ Razor: ["cshtml|asp"],
2254
+ RDoc: ["Rd"],
2255
+ Red: ["red|reds"],
2256
+ RHTML: ["Rhtml"],
2257
+ RST: ["rst"],
2258
+ Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
2259
+ Rust: ["rs"],
2260
+ SASS: ["sass"],
2261
+ SCAD: ["scad"],
2262
+ Scala: ["scala|sbt"],
2263
+ Scheme: ["scm|sm|rkt|oak|scheme"],
2264
+ Scrypt: ["scrypt"],
2265
+ SCSS: ["scss"],
2266
+ SH: ["sh|bash|^.bashrc"],
2267
+ SJS: ["sjs"],
2268
+ Slim: ["slim|skim"],
2269
+ Smarty: ["smarty|tpl"],
2270
+ Smithy: ["smithy"],
2271
+ snippets: ["snippets"],
2272
+ Soy_Template:["soy"],
2273
+ Space: ["space"],
2274
+ SQL: ["sql"],
2275
+ SQLServer: ["sqlserver"],
2276
+ Stylus: ["styl|stylus"],
2277
+ SVG: ["svg"],
2278
+ Swift: ["swift"],
2279
+ Tcl: ["tcl"],
2280
+ Terraform: ["tf", "tfvars", "terragrunt"],
2281
+ Tex: ["tex"],
2282
+ Text: ["txt"],
2283
+ Textile: ["textile"],
2284
+ Toml: ["toml"],
2285
+ TSX: ["tsx"],
2286
+ Twig: ["twig|swig"],
2287
+ Typescript: ["ts|typescript|str"],
2288
+ Vala: ["vala"],
2289
+ VBScript: ["vbs|vb"],
2290
+ Velocity: ["vm"],
2291
+ Verilog: ["v|vh|sv|svh"],
2292
+ VHDL: ["vhd|vhdl"],
2293
+ Visualforce: ["vfp|component|page"],
2294
+ Wollok: ["wlk|wpgm|wtest"],
2295
+ XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
2296
+ XQuery: ["xq"],
2297
+ YAML: ["yaml|yml"],
2298
+ Zeek: ["zeek|bro"],
2299
+ Django: ["html"]
2300
+ };
2301
+
2302
+ var nameOverrides = {
2303
+ ObjectiveC: "Objective-C",
2304
+ CSharp: "C#",
2305
+ golang: "Go",
2306
+ C_Cpp: "C and C++",
2307
+ Csound_Document: "Csound Document",
2308
+ Csound_Orchestra: "Csound",
2309
+ Csound_Score: "Csound Score",
2310
+ coffee: "CoffeeScript",
2311
+ HTML_Ruby: "HTML (Ruby)",
2312
+ HTML_Elixir: "HTML (Elixir)",
2313
+ FTL: "FreeMarker",
2314
+ PHP_Laravel_blade: "PHP (Blade Template)",
2315
+ Perl6: "Perl 6",
2316
+ AutoHotKey: "AutoHotkey / AutoIt"
2317
+ };
2318
+
2319
+ var modesByName = {};
2320
+ for (var name in supportedModes) {
2321
+ var data = supportedModes[name];
2322
+ var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
2323
+ var filename = name.toLowerCase();
2324
+ var mode = new Mode(filename, displayName, data[0]);
2325
+ modesByName[filename] = mode;
2326
+ modes.push(mode);
2327
+ }
2328
+
2329
+ module.exports = {
2330
+ getModeForPath: getModeForPath,
2331
+ modes: modes,
2332
+ modesByName: modesByName
2333
+ };
2334
+
2335
+ });
2336
+
2337
+ ace.define("ace/ext/prompt",["require","exports","module","ace/range","ace/lib/dom","ace/ext/menu_tools/get_editor_keyboard_shortcuts","ace/autocomplete","ace/autocomplete/popup","ace/autocomplete/popup","ace/undomanager","ace/tokenizer","ace/ext/menu_tools/overlay_page","ace/ext/modelist"], function(require, exports, module) {
2338
+ "use strict";
2339
+
2340
+ var Range = require("../range").Range;
2341
+ var dom = require("../lib/dom");
2342
+ var shortcuts = require("../ext/menu_tools/get_editor_keyboard_shortcuts");
2343
+ var FilteredList= require("../autocomplete").FilteredList;
2344
+ var AcePopup = require('../autocomplete/popup').AcePopup;
2345
+ var $singleLineEditor = require('../autocomplete/popup').$singleLineEditor;
2346
+ var UndoManager = require("../undomanager").UndoManager;
2347
+ var Tokenizer = require("../tokenizer").Tokenizer;
2348
+ var overlayPage = require("./menu_tools/overlay_page").overlayPage;
2349
+ var modelist = require("./modelist");
2350
+ var openPrompt;
2351
+
2352
+ function prompt(editor, message, options, callback) {
2353
+ if (typeof message == "object") {
2354
+ return prompt(editor, "", message, options);
2355
+ }
2356
+ if (openPrompt) {
2357
+ var lastPrompt = openPrompt;
2358
+ editor = lastPrompt.editor;
2359
+ lastPrompt.close();
2360
+ if (lastPrompt.name && lastPrompt.name == options.name)
2361
+ return;
2362
+ }
2363
+ if (options.$type)
2364
+ return prompt[options.$type](editor, callback);
2365
+
2366
+ var cmdLine = $singleLineEditor();
2367
+ cmdLine.session.setUndoManager(new UndoManager());
2368
+
2369
+ var el = dom.buildDom(["div", {class: "ace_prompt_container" + (options.hasDescription ? " input-box-with-description" : "")}]);
2370
+ var overlay = overlayPage(editor, el, done);
2371
+ el.appendChild(cmdLine.container);
2372
+
2373
+ if (editor) {
2374
+ editor.cmdLine = cmdLine;
2375
+ cmdLine.setOption("fontSize", editor.getOption("fontSize"));
2376
+ }
2377
+ if (message) {
2378
+ cmdLine.setValue(message, 1);
2379
+ }
2380
+ if (options.selection) {
2381
+ cmdLine.selection.setRange({
2382
+ start: cmdLine.session.doc.indexToPosition(options.selection[0]),
2383
+ end: cmdLine.session.doc.indexToPosition(options.selection[1])
2384
+ });
2385
+ }
2386
+
2387
+ if (options.getCompletions) {
2388
+ var popup = new AcePopup();
2389
+ popup.renderer.setStyle("ace_autocomplete_inline");
2390
+ popup.container.style.display = "block";
2391
+ popup.container.style.maxWidth = "600px";
2392
+ popup.container.style.width = "100%";
2393
+ popup.container.style.marginTop = "3px";
2394
+ popup.renderer.setScrollMargin(2, 2, 0, 0);
2395
+ popup.autoSelect = false;
2396
+ popup.renderer.$maxLines = 15;
2397
+ popup.setRow(-1);
2398
+ popup.on("click", function(e) {
2399
+ var data = popup.getData(popup.getRow());
2400
+ if (!data.error) {
2401
+ cmdLine.setValue(data.value || data.name || data);
2402
+ accept();
2403
+ e.stop();
2404
+ }
2405
+ });
2406
+ el.appendChild(popup.container);
2407
+ updateCompletions();
2408
+ }
2409
+
2410
+ if (options.$rules) {
2411
+ var tokenizer = new Tokenizer(options.$rules);
2412
+ cmdLine.session.bgTokenizer.setTokenizer(tokenizer);
2413
+ }
2414
+
2415
+ if (options.placeholder) {
2416
+ cmdLine.setOption("placeholder", options.placeholder);
2417
+ }
2418
+
2419
+ if (options.hasDescription) {
2420
+ var promptTextContainer = dom.buildDom(["div", {class: "ace_prompt_text_container"}]);
2421
+ dom.buildDom(options.prompt || "Press 'Enter' to confirm or 'Escape' to cancel", promptTextContainer);
2422
+ el.appendChild(promptTextContainer);
2423
+ }
2424
+
2425
+ overlay.setIgnoreFocusOut(options.ignoreFocusOut);
2426
+
2427
+ function accept() {
2428
+ var val;
2429
+ if (popup && popup.getCursorPosition().row > 0) {
2430
+ val = valueFromRecentList();
2431
+ } else {
2432
+ val = cmdLine.getValue();
2433
+ }
2434
+ var curData = popup ? popup.getData(popup.getRow()) : val;
2435
+ if (curData && !curData.error) {
2436
+ done();
2437
+ options.onAccept && options.onAccept({
2438
+ value: val,
2439
+ item: curData
2440
+ }, cmdLine);
2441
+ }
2442
+ }
2443
+
2444
+ var keys = {
2445
+ "Enter": accept,
2446
+ "Esc|Shift-Esc": function() {
2447
+ options.onCancel && options.onCancel(cmdLine.getValue(), cmdLine);
2448
+ done();
2449
+ }
2450
+ };
2451
+
2452
+ if (popup) {
2453
+ Object.assign(keys, {
2454
+ "Up": function(editor) { popup.goTo("up"); valueFromRecentList();},
2455
+ "Down": function(editor) { popup.goTo("down"); valueFromRecentList();},
2456
+ "Ctrl-Up|Ctrl-Home": function(editor) { popup.goTo("start"); valueFromRecentList();},
2457
+ "Ctrl-Down|Ctrl-End": function(editor) { popup.goTo("end"); valueFromRecentList();},
2458
+ "Tab": function(editor) {
2459
+ popup.goTo("down"); valueFromRecentList();
2460
+ },
2461
+ "PageUp": function(editor) { popup.gotoPageUp(); valueFromRecentList();},
2462
+ "PageDown": function(editor) { popup.gotoPageDown(); valueFromRecentList();}
2463
+ });
2464
+ }
2465
+
2466
+ cmdLine.commands.bindKeys(keys);
2467
+
2468
+ function done() {
2469
+ overlay.close();
2470
+ callback && callback();
2471
+ openPrompt = null;
2472
+ }
2473
+
2474
+ cmdLine.on("input", function() {
2475
+ options.onInput && options.onInput();
2476
+ updateCompletions();
2477
+ });
2478
+
2479
+ function updateCompletions() {
2480
+ if (options.getCompletions) {
2481
+ var prefix;
2482
+ if (options.getPrefix) {
2483
+ prefix = options.getPrefix(cmdLine);
2484
+ }
2485
+
2486
+ var completions = options.getCompletions(cmdLine);
2487
+ popup.setData(completions, prefix);
2488
+ popup.resize(true);
2489
+ }
2490
+ }
2491
+
2492
+ function valueFromRecentList() {
2493
+ var current = popup.getData(popup.getRow());
2494
+ if (current && !current.error)
2495
+ return current.value || current.caption || current;
2496
+ }
2497
+
2498
+ cmdLine.resize(true);
2499
+ if (popup) {
2500
+ popup.resize(true);
2501
+ }
2502
+ cmdLine.focus();
2503
+
2504
+ openPrompt = {
2505
+ close: done,
2506
+ name: options.name,
2507
+ editor: editor
2508
+ };
2509
+ }
2510
+
2511
+ prompt.gotoLine = function(editor, callback) {
2512
+ function stringifySelection(selection) {
2513
+ if (!Array.isArray(selection))
2514
+ selection = [selection];
2515
+ return selection.map(function(r) {
2516
+ var cursor = r.isBackwards ? r.start: r.end;
2517
+ var anchor = r.isBackwards ? r.end: r.start;
2518
+ var row = anchor.row;
2519
+ var s = (row + 1) + ":" + anchor.column;
2520
+
2521
+ if (anchor.row == cursor.row) {
2522
+ if (anchor.column != cursor.column)
2523
+ s += ">" + ":" + cursor.column;
2524
+ } else {
2525
+ s += ">" + (cursor.row + 1) + ":" + cursor.column;
2526
+ }
2527
+ return s;
2528
+ }).reverse().join(", ");
2529
+ }
2530
+
2531
+ prompt(editor, ":" + stringifySelection(editor.selection.toJSON()), {
2532
+ name: "gotoLine",
2533
+ selection: [1, Number.MAX_VALUE],
2534
+ onAccept: function(data) {
2535
+ var value = data.value;
2536
+ var _history = prompt.gotoLine._history;
2537
+ if (!_history)
2538
+ prompt.gotoLine._history = _history = [];
2539
+ if (_history.indexOf(value) != -1)
2540
+ _history.splice(_history.indexOf(value), 1);
2541
+ _history.unshift(value);
2542
+ if (_history.length > 20) _history.length = 20;
2543
+
2544
+
2545
+ var pos = editor.getCursorPosition();
2546
+ var ranges = [];
2547
+ value.replace(/^:/, "").split(/,/).map(function(str) {
2548
+ var parts = str.split(/([<>:+-]|c?\d+)|[^c\d<>:+-]+/).filter(Boolean);
2549
+ var i = 0;
2550
+ function readPosition() {
2551
+ var c = parts[i++];
2552
+ if (!c) return;
2553
+ if (c[0] == "c") {
2554
+ var index = parseInt(c.slice(1)) || 0;
2555
+ return editor.session.doc.indexToPosition(index);
2556
+ }
2557
+ var row = pos.row;
2558
+ var column = 0;
2559
+ if (/\d/.test(c)) {
2560
+ row = parseInt(c) - 1;
2561
+ c = parts[i++];
2562
+ }
2563
+ if (c == ":") {
2564
+ c = parts[i++];
2565
+ if (/\d/.test(c)) {
2566
+ column = parseInt(c) || 0;
2567
+ }
2568
+ }
2569
+ return {row: row, column: column};
2570
+ }
2571
+ pos = readPosition();
2572
+ var range = Range.fromPoints(pos, pos);
2573
+ if (parts[i] == ">") {
2574
+ i++;
2575
+ range.end = readPosition();
2576
+ }
2577
+ else if (parts[i] == "<") {
2578
+ i++;
2579
+ range.start = readPosition();
2580
+ }
2581
+ ranges.unshift(range);
2582
+ });
2583
+ editor.selection.fromJSON(ranges);
2584
+ var scrollTop = editor.renderer.scrollTop;
2585
+ editor.renderer.scrollSelectionIntoView(
2586
+ editor.selection.anchor,
2587
+ editor.selection.cursor,
2588
+ 0.5
2589
+ );
2590
+ editor.renderer.animateScrolling(scrollTop);
2591
+ },
2592
+ history: function() {
2593
+ var undoManager = editor.session.getUndoManager();
2594
+ if (!prompt.gotoLine._history)
2595
+ return [];
2596
+ return prompt.gotoLine._history;
2597
+
2598
+ },
2599
+ getCompletions: function(cmdLine) {
2600
+ var value = cmdLine.getValue();
2601
+ var m = value.replace(/^:/, "").split(":");
2602
+ var row = Math.min(parseInt(m[0]) || 1, editor.session.getLength()) - 1;
2603
+ var line = editor.session.getLine(row);
2604
+ var current = value + " " + line;
2605
+ return [current].concat(this.history());
2606
+ },
2607
+ $rules: {
2608
+ start: [{
2609
+ regex: /\d+/,
2610
+ token: "string"
2611
+ }, {
2612
+ regex: /[:,><+\-c]/,
2613
+ token: "keyword"
2614
+ }]
2615
+ }
2616
+ });
2617
+ };
2618
+
2619
+ prompt.commands = function(editor, callback) {
2620
+ function normalizeName(name) {
2621
+ return (name || "").replace(/^./, function(x) {
2622
+ return x.toUpperCase(x);
2623
+ }).replace(/[a-z][A-Z]/g, function(x) {
2624
+ return x[0] + " " + x[1].toLowerCase(x);
2625
+ });
2626
+ }
2627
+ function getEditorCommandsByName(excludeCommands) {
2628
+ var commandsByName = [];
2629
+ var commandMap = {};
2630
+ editor.keyBinding.$handlers.forEach(function(handler) {
2631
+ var platform = handler.platform;
2632
+ var cbn = handler.byName;
2633
+ for (var i in cbn) {
2634
+ var key = cbn[i].bindKey;
2635
+ if (typeof key !== "string") {
2636
+ key = key && key[platform] || "";
2637
+ }
2638
+ var commands = cbn[i];
2639
+ var description = commands.description || normalizeName(commands.name);
2640
+ if (!Array.isArray(commands))
2641
+ commands = [commands];
2642
+ commands.forEach(function(command) {
2643
+ if (typeof command != "string")
2644
+ command = command.name;
2645
+ var needle = excludeCommands.find(function(el) {
2646
+ return el === command;
2647
+ });
2648
+ if (!needle) {
2649
+ if (commandMap[command]) {
2650
+ commandMap[command].key += "|" + key;
2651
+ } else {
2652
+ commandMap[command] = {key: key, command: command, description: description};
2653
+ commandsByName.push(commandMap[command]);
2654
+ }
2655
+ }
2656
+ });
2657
+ }
2658
+ });
2659
+ return commandsByName;
2660
+ }
2661
+ var excludeCommandsList = ["insertstring", "inserttext", "setIndentation", "paste"];
2662
+ var shortcutsArray = getEditorCommandsByName(excludeCommandsList);
2663
+ shortcutsArray = shortcutsArray.map(function(item) {
2664
+ return {value: item.description, meta: item.key, command: item.command};
2665
+ });
2666
+ prompt(editor, "", {
2667
+ name: "commands",
2668
+ selection: [0, Number.MAX_VALUE],
2669
+ maxHistoryCount: 5,
2670
+ onAccept: function(data) {
2671
+ if (data.item) {
2672
+ var commandName = data.item.command;
2673
+ this.addToHistory(data.item);
2674
+
2675
+ editor.execCommand(commandName);
2676
+ }
2677
+ },
2678
+ addToHistory: function(item) {
2679
+ var history = this.history();
2680
+ history.unshift(item);
2681
+ delete item.message;
2682
+ for (var i = 1; i < history.length; i++) {
2683
+ if (history[i]["command"] == item.command ) {
2684
+ history.splice(i, 1);
2685
+ break;
2686
+ }
2687
+ }
2688
+ if (this.maxHistoryCount > 0 && history.length > this.maxHistoryCount) {
2689
+ history.splice(history.length - 1, 1);
2690
+ }
2691
+ prompt.commands.history = history;
2692
+ },
2693
+ history: function() {
2694
+ return prompt.commands.history || [];
2695
+ },
2696
+ getPrefix: function(cmdLine) {
2697
+ var currentPos = cmdLine.getCursorPosition();
2698
+ var filterValue = cmdLine.getValue();
2699
+ return filterValue.substring(0, currentPos.column);
2700
+ },
2701
+ getCompletions: function(cmdLine) {
2702
+ function getFilteredCompletions(commands, prefix) {
2703
+ var resultCommands = JSON.parse(JSON.stringify(commands));
2704
+
2705
+ var filtered = new FilteredList(resultCommands);
2706
+ return filtered.filterCompletions(resultCommands, prefix);
2707
+ }
2708
+
2709
+ function getUniqueCommandList(commands, usedCommands) {
2710
+ if (!usedCommands || !usedCommands.length) {
2711
+ return commands;
2712
+ }
2713
+ var excludeCommands = [];
2714
+ usedCommands.forEach(function(item) {
2715
+ excludeCommands.push(item.command);
2716
+ });
2717
+
2718
+ var resultCommands = [];
2719
+
2720
+ commands.forEach(function(item) {
2721
+ if (excludeCommands.indexOf(item.command) === -1) {
2722
+ resultCommands.push(item);
2723
+ }
2724
+ });
2725
+
2726
+ return resultCommands;
2727
+ }
2728
+
2729
+ var prefix = this.getPrefix(cmdLine);
2730
+ var recentlyUsedCommands = getFilteredCompletions(this.history(), prefix);
2731
+ var otherCommands = getUniqueCommandList(shortcutsArray, recentlyUsedCommands);
2732
+ otherCommands = getFilteredCompletions(otherCommands, prefix);
2733
+
2734
+ if (recentlyUsedCommands.length && otherCommands.length) {
2735
+ recentlyUsedCommands[0]["message"] = " Recently used";
2736
+ otherCommands[0]["message"] = " Other commands";
2737
+ }
2738
+
2739
+ var completions = recentlyUsedCommands.concat(otherCommands);
2740
+ return completions.length > 0 ? completions : [{
2741
+ value: "No matching commands",
2742
+ error: 1
2743
+ }];
2744
+ }
2745
+ });
2746
+ };
2747
+
2748
+ prompt.modes = function(editor, callback) {
2749
+ var modesArray = modelist.modes;
2750
+ modesArray = modesArray.map(function(item) {
2751
+ return {value: item.caption, mode: item.name};
2752
+ });
2753
+ prompt(editor, "", {
2754
+ name: "modes",
2755
+ selection: [0, Number.MAX_VALUE],
2756
+ onAccept: function(data) {
2757
+ if (data.item) {
2758
+ var modeName = "ace/mode/" + data.item.mode;
2759
+ editor.session.setMode(modeName);
2760
+ }
2761
+ },
2762
+ getPrefix: function(cmdLine) {
2763
+ var currentPos = cmdLine.getCursorPosition();
2764
+ var filterValue = cmdLine.getValue();
2765
+ return filterValue.substring(0, currentPos.column);
2766
+ },
2767
+ getCompletions: function(cmdLine) {
2768
+ function getFilteredCompletions(modes, prefix) {
2769
+ var resultCommands = JSON.parse(JSON.stringify(modes));
2770
+
2771
+ var filtered = new FilteredList(resultCommands);
2772
+ return filtered.filterCompletions(resultCommands, prefix);
2773
+ }
2774
+
2775
+ var prefix = this.getPrefix(cmdLine);
2776
+ var completions = getFilteredCompletions(modesArray, prefix);
2777
+ return completions.length > 0 ? completions : [{
2778
+ "caption": "No mode matching",
2779
+ "value": "No mode matching",
2780
+ "error": 1
2781
+ }];
2782
+ }
2783
+ });
2784
+ };
2785
+
2786
+ dom.importCssString(".ace_prompt_container {\
2787
+ max-width: 600px;\
2788
+ width: 100%;\
2789
+ margin: 20px auto;\
2790
+ padding: 3px;\
2791
+ background: white;\
2792
+ border-radius: 2px;\
2793
+ box-shadow: 0px 2px 3px 0px #555;\
2794
+ }", "promtp.css", false);
2795
+
2796
+
2797
+ exports.prompt = prompt;
2798
+
2799
+ }); (function() {
2800
+ ace.require(["ace/ext/prompt"], function(m) {
2801
+ if (typeof module == "object" && typeof exports == "object" && module) {
2802
+ module.exports = m;
2803
+ }
2804
+ });
2805
+ })();
2806
+