ace-oqc 1.4.13 → 1.4.14
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.
- package/index.js +71 -0
- package/package.json +3 -3
- package/src-noconflict/ace.js +0 -21402
- package/src-noconflict/ext-beautify.js +0 -331
- package/src-noconflict/ext-elastic_tabstops_lite.js +0 -277
- package/src-noconflict/ext-emmet.js +0 -1331
- package/src-noconflict/ext-error_marker.js +0 -9
- package/src-noconflict/ext-keybinding_menu.js +0 -193
- package/src-noconflict/ext-language_tools.js +0 -2166
- package/src-noconflict/ext-linking.js +0 -64
- package/src-noconflict/ext-modelist.js +0 -248
- package/src-noconflict/ext-options.js +0 -799
- package/src-noconflict/ext-prompt.js +0 -2806
- package/src-noconflict/ext-rtl.js +0 -122
- package/src-noconflict/ext-searchbox.js +0 -514
- package/src-noconflict/ext-settings_menu.js +0 -820
- package/src-noconflict/ext-spellcheck.js +0 -73
- package/src-noconflict/ext-split.js +0 -207
- package/src-noconflict/ext-static_highlight.js +0 -229
- package/src-noconflict/ext-statusbar.js +0 -56
- package/src-noconflict/ext-textarea.js +0 -430
- package/src-noconflict/ext-themelist.js +0 -67
- package/src-noconflict/ext-whitespace.js +0 -213
- package/src-noconflict/keybinding-emacs.js +0 -1169
- package/src-noconflict/keybinding-sublime.js +0 -422
- package/src-noconflict/keybinding-vim.js +0 -6198
- package/src-noconflict/mode-abap.js +0 -221
- package/src-noconflict/mode-abc.js +0 -271
- package/src-noconflict/mode-actionscript.js +0 -275
- package/src-noconflict/mode-ada.js +0 -137
- package/src-noconflict/mode-apache_conf.js +0 -363
- package/src-noconflict/mode-apex.js +0 -457
- package/src-noconflict/mode-applescript.js +0 -278
- package/src-noconflict/mode-aql.js +0 -102
- package/src-noconflict/mode-asciidoc.js +0 -349
- package/src-noconflict/mode-asl.js +0 -422
- package/src-noconflict/mode-assembly_x86.js +0 -193
- package/src-noconflict/mode-autohotkey.js +0 -244
- package/src-noconflict/mode-batchfile.js +0 -230
- package/src-noconflict/mode-c9search.js +0 -293
- package/src-noconflict/mode-c_cpp.js +0 -503
- package/src-noconflict/mode-cirru.js +0 -210
- package/src-noconflict/mode-clojure.js +0 -315
- package/src-noconflict/mode-cobol.js +0 -101
- package/src-noconflict/mode-coffee.js +0 -400
- package/src-noconflict/mode-coldfusion.js +0 -2596
- package/src-noconflict/mode-crystal.js +0 -642
- package/src-noconflict/mode-csharp.js +0 -502
- package/src-noconflict/mode-csound_document.js +0 -4105
- package/src-noconflict/mode-csound_orchestra.js +0 -3035
- package/src-noconflict/mode-csound_score.js +0 -462
- package/src-noconflict/mode-csp.js +0 -59
- package/src-noconflict/mode-css.js +0 -720
- package/src-noconflict/mode-curly.js +0 -2564
- package/src-noconflict/mode-d.js +0 -520
- package/src-noconflict/mode-dart.js +0 -715
- package/src-noconflict/mode-diff.js +0 -147
- package/src-noconflict/mode-django.js +0 -2595
- package/src-noconflict/mode-dockerfile.js +0 -500
- package/src-noconflict/mode-dot.js +0 -417
- package/src-noconflict/mode-drools.js +0 -498
- package/src-noconflict/mode-edifact.js +0 -166
- package/src-noconflict/mode-eiffel.js +0 -135
- package/src-noconflict/mode-ejs.js +0 -3533
- package/src-noconflict/mode-elixir.js +0 -501
- package/src-noconflict/mode-elm.js +0 -306
- package/src-noconflict/mode-erlang.js +0 -1010
- package/src-noconflict/mode-forth.js +0 -297
- package/src-noconflict/mode-fortran.js +0 -430
- package/src-noconflict/mode-fsharp.js +0 -316
- package/src-noconflict/mode-fsl.js +0 -259
- package/src-noconflict/mode-ftl.js +0 -1193
- package/src-noconflict/mode-gcode.js +0 -93
- package/src-noconflict/mode-gherkin.js +0 -168
- package/src-noconflict/mode-gitignore.js +0 -59
- package/src-noconflict/mode-glsl.js +0 -580
- package/src-noconflict/mode-gobstones.js +0 -1090
- package/src-noconflict/mode-golang.js +0 -413
- package/src-noconflict/mode-graphqlschema.js +0 -214
- package/src-noconflict/mode-groovy.js +0 -989
- package/src-noconflict/mode-haml.js +0 -1873
- package/src-noconflict/mode-handlebars.js +0 -2622
- package/src-noconflict/mode-haskell.js +0 -380
- package/src-noconflict/mode-haskell_cabal.js +0 -141
- package/src-noconflict/mode-haxe.js +0 -386
- package/src-noconflict/mode-hjson.js +0 -353
- package/src-noconflict/mode-html.js +0 -2509
- package/src-noconflict/mode-html_elixir.js +0 -3088
- package/src-noconflict/mode-html_ruby.js +0 -3550
- package/src-noconflict/mode-ini.js +0 -162
- package/src-noconflict/mode-io.js +0 -248
- package/src-noconflict/mode-jack.js +0 -346
- package/src-noconflict/mode-jade.js +0 -2025
- package/src-noconflict/mode-java.js +0 -1038
- package/src-noconflict/mode-javascript.js +0 -798
- package/src-noconflict/mode-json.js +0 -329
- package/src-noconflict/mode-jsoniq.js +0 -2632
- package/src-noconflict/mode-jsp.js +0 -1433
- package/src-noconflict/mode-jssm.js +0 -325
- package/src-noconflict/mode-jsx.js +0 -411
- package/src-noconflict/mode-julia.js +0 -303
- package/src-noconflict/mode-kotlin.js +0 -797
- package/src-noconflict/mode-latex.js +0 -296
- package/src-noconflict/mode-less.js +0 -839
- package/src-noconflict/mode-liquid.js +0 -2742
- package/src-noconflict/mode-lisp.js +0 -112
- package/src-noconflict/mode-livescript.js +0 -279
- package/src-noconflict/mode-logiql.js +0 -317
- package/src-noconflict/mode-logtalk.js +0 -352
- package/src-noconflict/mode-lsl.js +0 -343
- package/src-noconflict/mode-lua.js +0 -452
- package/src-noconflict/mode-luapage.js +0 -3028
- package/src-noconflict/mode-lucene.js +0 -154
- package/src-noconflict/mode-makefile.js +0 -412
- package/src-noconflict/mode-markdown.js +0 -3194
- package/src-noconflict/mode-mask.js +0 -1803
- package/src-noconflict/mode-matlab.js +0 -263
- package/src-noconflict/mode-maze.js +0 -292
- package/src-noconflict/mode-mel.js +0 -263
- package/src-noconflict/mode-mixal.js +0 -122
- package/src-noconflict/mode-mushcode.js +0 -681
- package/src-noconflict/mode-mysql.js +0 -167
- package/src-noconflict/mode-nginx.js +0 -298
- package/src-noconflict/mode-nim.js +0 -363
- package/src-noconflict/mode-nix.js +0 -647
- package/src-noconflict/mode-nsis.js +0 -312
- package/src-noconflict/mode-objectivec.js +0 -740
- package/src-noconflict/mode-ocaml.js +0 -421
- package/src-noconflict/mode-pascal.js +0 -223
- package/src-noconflict/mode-perl.js +0 -381
- package/src-noconflict/mode-pgsql.js +0 -1743
- package/src-noconflict/mode-php.js +0 -13110
- package/src-noconflict/mode-php_laravel_blade.js +0 -13311
- package/src-noconflict/mode-pig.js +0 -310
- package/src-noconflict/mode-plain_text.js +0 -32
- package/src-noconflict/mode-powershell.js +0 -418
- package/src-noconflict/mode-praat.js +0 -478
- package/src-noconflict/mode-prolog.js +0 -371
- package/src-noconflict/mode-properties.js +0 -80
- package/src-noconflict/mode-protobuf.js +0 -593
- package/src-noconflict/mode-puppet.js +0 -368
- package/src-noconflict/mode-python.js +0 -508
- package/src-noconflict/mode-r.js +0 -312
- package/src-noconflict/mode-razor.js +0 -2875
- package/src-noconflict/mode-rdoc.js +0 -243
- package/src-noconflict/mode-red.js +0 -450
- package/src-noconflict/mode-redshift.js +0 -360
- package/src-noconflict/mode-rhtml.js +0 -2808
- package/src-noconflict/mode-rst.js +0 -257
- package/src-noconflict/mode-ruby.js +0 -1003
- package/src-noconflict/mode-rust.js +0 -282
- package/src-noconflict/mode-sass.js +0 -529
- package/src-noconflict/mode-scad.js +0 -414
- package/src-noconflict/mode-scala.js +0 -984
- package/src-noconflict/mode-scheme.js +0 -232
- package/src-noconflict/mode-scss.js +0 -873
- package/src-noconflict/mode-sh.js +0 -449
- package/src-noconflict/mode-sjs.js +0 -1015
- package/src-noconflict/mode-slim.js +0 -5240
- package/src-noconflict/mode-smarty.js +0 -2635
- package/src-noconflict/mode-snippets.js +0 -207
- package/src-noconflict/mode-soy_template.js +0 -2848
- package/src-noconflict/mode-space.js +0 -167
- package/src-noconflict/mode-sparql.js +0 -320
- package/src-noconflict/mode-sql.js +0 -271
- package/src-noconflict/mode-sqlserver.js +0 -445
- package/src-noconflict/mode-stylus.js +0 -472
- package/src-noconflict/mode-svg.js +0 -1582
- package/src-noconflict/mode-swift.js +0 -395
- package/src-noconflict/mode-tcl.js +0 -387
- package/src-noconflict/mode-terraform.js +0 -400
- package/src-noconflict/mode-tex.js +0 -160
- package/src-noconflict/mode-text.js +0 -9
- package/src-noconflict/mode-textile.js +0 -150
- package/src-noconflict/mode-toml.js +0 -153
- package/src-noconflict/mode-tsx.js +0 -888
- package/src-noconflict/mode-turtle.js +0 -296
- package/src-noconflict/mode-twig.js +0 -2693
- package/src-noconflict/mode-typescript.js +0 -869
- package/src-noconflict/mode-vala.js +0 -677
- package/src-noconflict/mode-vbscript.js +0 -635
- package/src-noconflict/mode-velocity.js +0 -2792
- package/src-noconflict/mode-verilog.js +0 -118
- package/src-noconflict/mode-vhdl.js +0 -116
- package/src-noconflict/mode-visualforce.js +0 -2640
- package/src-noconflict/mode-wollok.js +0 -914
- package/src-noconflict/mode-xml.js +0 -676
- package/src-noconflict/mode-xquery.js +0 -2644
- package/src-noconflict/mode-yaml.js +0 -330
- package/src-noconflict/mode-zeek.js +0 -539
- package/src-noconflict/qurator-mode.js +0 -120
- package/src-noconflict/qurator-worker.js +0 -91
- package/src-noconflict/snippets/abap.js +0 -9
- package/src-noconflict/snippets/abc.js +0 -45
- package/src-noconflict/snippets/actionscript.js +0 -171
- package/src-noconflict/snippets/ada.js +0 -9
- package/src-noconflict/snippets/apache_conf.js +0 -9
- package/src-noconflict/snippets/apex.js +0 -9
- package/src-noconflict/snippets/applescript.js +0 -9
- package/src-noconflict/snippets/aql.js +0 -9
- package/src-noconflict/snippets/asciidoc.js +0 -9
- package/src-noconflict/snippets/asl.js +0 -9
- package/src-noconflict/snippets/assembly_x86.js +0 -9
- package/src-noconflict/snippets/autohotkey.js +0 -9
- package/src-noconflict/snippets/batchfile.js +0 -9
- package/src-noconflict/snippets/c9search.js +0 -9
- package/src-noconflict/snippets/c_cpp.js +0 -145
- package/src-noconflict/snippets/cirru.js +0 -9
- package/src-noconflict/snippets/clojure.js +0 -104
- package/src-noconflict/snippets/cobol.js +0 -9
- package/src-noconflict/snippets/coffee.js +0 -109
- package/src-noconflict/snippets/coldfusion.js +0 -9
- package/src-noconflict/snippets/crystal.js +0 -9
- package/src-noconflict/snippets/csharp.js +0 -9
- package/src-noconflict/snippets/csound_document.js +0 -24
- package/src-noconflict/snippets/csound_orchestra.js +0 -61
- package/src-noconflict/snippets/csound_score.js +0 -9
- package/src-noconflict/snippets/csp.js +0 -9
- package/src-noconflict/snippets/css.js +0 -981
- package/src-noconflict/snippets/curly.js +0 -9
- package/src-noconflict/snippets/d.js +0 -9
- package/src-noconflict/snippets/dart.js +0 -97
- package/src-noconflict/snippets/diff.js +0 -25
- package/src-noconflict/snippets/django.js +0 -122
- package/src-noconflict/snippets/dockerfile.js +0 -9
- package/src-noconflict/snippets/dot.js +0 -9
- package/src-noconflict/snippets/drools.js +0 -33
- package/src-noconflict/snippets/edifact.js +0 -254
- package/src-noconflict/snippets/eiffel.js +0 -9
- package/src-noconflict/snippets/ejs.js +0 -9
- package/src-noconflict/snippets/elixir.js +0 -9
- package/src-noconflict/snippets/elm.js +0 -9
- package/src-noconflict/snippets/erlang.js +0 -174
- package/src-noconflict/snippets/forth.js +0 -9
- package/src-noconflict/snippets/fortran.js +0 -9
- package/src-noconflict/snippets/fsharp.js +0 -9
- package/src-noconflict/snippets/fsl.js +0 -14
- package/src-noconflict/snippets/ftl.js +0 -9
- package/src-noconflict/snippets/gcode.js +0 -9
- package/src-noconflict/snippets/gherkin.js +0 -9
- package/src-noconflict/snippets/gitignore.js +0 -9
- package/src-noconflict/snippets/glsl.js +0 -9
- package/src-noconflict/snippets/gobstones.js +0 -1718
- package/src-noconflict/snippets/golang.js +0 -9
- package/src-noconflict/snippets/graphqlschema.js +0 -46
- package/src-noconflict/snippets/groovy.js +0 -9
- package/src-noconflict/snippets/haml.js +0 -34
- package/src-noconflict/snippets/handlebars.js +0 -9
- package/src-noconflict/snippets/haskell.js +0 -96
- package/src-noconflict/snippets/haskell_cabal.js +0 -9
- package/src-noconflict/snippets/haxe.js +0 -9
- package/src-noconflict/snippets/hjson.js +0 -9
- package/src-noconflict/snippets/html.js +0 -867
- package/src-noconflict/snippets/html_elixir.js +0 -9
- package/src-noconflict/snippets/html_ruby.js +0 -9
- package/src-noconflict/snippets/ini.js +0 -9
- package/src-noconflict/snippets/io.js +0 -76
- package/src-noconflict/snippets/jack.js +0 -9
- package/src-noconflict/snippets/jade.js +0 -9
- package/src-noconflict/snippets/java.js +0 -254
- package/src-noconflict/snippets/javascript.js +0 -209
- package/src-noconflict/snippets/json.js +0 -9
- package/src-noconflict/snippets/jsoniq.js +0 -75
- package/src-noconflict/snippets/jsp.js +0 -113
- package/src-noconflict/snippets/jssm.js +0 -9
- package/src-noconflict/snippets/jsx.js +0 -9
- package/src-noconflict/snippets/julia.js +0 -9
- package/src-noconflict/snippets/kotlin.js +0 -9
- package/src-noconflict/snippets/latex.js +0 -9
- package/src-noconflict/snippets/less.js +0 -9
- package/src-noconflict/snippets/liquid.js +0 -895
- package/src-noconflict/snippets/lisp.js +0 -9
- package/src-noconflict/snippets/livescript.js +0 -9
- package/src-noconflict/snippets/logiql.js +0 -9
- package/src-noconflict/snippets/logtalk.js +0 -9
- package/src-noconflict/snippets/lsl.js +0 -1246
- package/src-noconflict/snippets/lua.js +0 -35
- package/src-noconflict/snippets/luapage.js +0 -9
- package/src-noconflict/snippets/lucene.js +0 -9
- package/src-noconflict/snippets/makefile.js +0 -18
- package/src-noconflict/snippets/markdown.js +0 -102
- package/src-noconflict/snippets/mask.js +0 -9
- package/src-noconflict/snippets/matlab.js +0 -9
- package/src-noconflict/snippets/maze.js +0 -23
- package/src-noconflict/snippets/mel.js +0 -9
- package/src-noconflict/snippets/mixal.js +0 -9
- package/src-noconflict/snippets/mushcode.js +0 -9
- package/src-noconflict/snippets/mysql.js +0 -9
- package/src-noconflict/snippets/nginx.js +0 -9
- package/src-noconflict/snippets/nim.js +0 -9
- package/src-noconflict/snippets/nix.js +0 -9
- package/src-noconflict/snippets/nsis.js +0 -9
- package/src-noconflict/snippets/objectivec.js +0 -9
- package/src-noconflict/snippets/ocaml.js +0 -9
- package/src-noconflict/snippets/pascal.js +0 -9
- package/src-noconflict/snippets/perl.js +0 -361
- package/src-noconflict/snippets/pgsql.js +0 -9
- package/src-noconflict/snippets/php.js +0 -397
- package/src-noconflict/snippets/php_laravel_blade.js +0 -9
- package/src-noconflict/snippets/pig.js +0 -9
- package/src-noconflict/snippets/plain_text.js +0 -9
- package/src-noconflict/snippets/powershell.js +0 -9
- package/src-noconflict/snippets/praat.js +0 -9
- package/src-noconflict/snippets/prolog.js +0 -9
- package/src-noconflict/snippets/properties.js +0 -9
- package/src-noconflict/snippets/protobuf.js +0 -9
- package/src-noconflict/snippets/puppet.js +0 -9
- package/src-noconflict/snippets/python.js +0 -172
- package/src-noconflict/snippets/r.js +0 -135
- package/src-noconflict/snippets/razor.js +0 -17
- package/src-noconflict/snippets/rdoc.js +0 -9
- package/src-noconflict/snippets/red.js +0 -9
- package/src-noconflict/snippets/redshift.js +0 -9
- package/src-noconflict/snippets/rhtml.js +0 -9
- package/src-noconflict/snippets/rst.js +0 -36
- package/src-noconflict/snippets/ruby.js +0 -942
- package/src-noconflict/snippets/rust.js +0 -9
- package/src-noconflict/snippets/sass.js +0 -9
- package/src-noconflict/snippets/scad.js +0 -9
- package/src-noconflict/snippets/scala.js +0 -9
- package/src-noconflict/snippets/scheme.js +0 -9
- package/src-noconflict/snippets/scss.js +0 -9
- package/src-noconflict/snippets/sh.js +0 -97
- package/src-noconflict/snippets/sjs.js +0 -9
- package/src-noconflict/snippets/slim.js +0 -9
- package/src-noconflict/snippets/smarty.js +0 -9
- package/src-noconflict/snippets/snippets.js +0 -23
- package/src-noconflict/snippets/soy_template.js +0 -9
- package/src-noconflict/snippets/space.js +0 -9
- package/src-noconflict/snippets/sparql.js +0 -9
- package/src-noconflict/snippets/sql.js +0 -40
- package/src-noconflict/snippets/sqlserver.js +0 -83
- package/src-noconflict/snippets/stylus.js +0 -9
- package/src-noconflict/snippets/svg.js +0 -9
- package/src-noconflict/snippets/swift.js +0 -9
- package/src-noconflict/snippets/tcl.js +0 -106
- package/src-noconflict/snippets/terraform.js +0 -9
- package/src-noconflict/snippets/tex.js +0 -204
- package/src-noconflict/snippets/text.js +0 -9
- package/src-noconflict/snippets/textile.js +0 -44
- package/src-noconflict/snippets/toml.js +0 -9
- package/src-noconflict/snippets/tsx.js +0 -9
- package/src-noconflict/snippets/turtle.js +0 -9
- package/src-noconflict/snippets/twig.js +0 -9
- package/src-noconflict/snippets/typescript.js +0 -9
- package/src-noconflict/snippets/vala.js +0 -200
- package/src-noconflict/snippets/vbscript.js +0 -9
- package/src-noconflict/snippets/velocity.js +0 -43
- package/src-noconflict/snippets/verilog.js +0 -9
- package/src-noconflict/snippets/vhdl.js +0 -9
- package/src-noconflict/snippets/visualforce.js +0 -9
- package/src-noconflict/snippets/wollok.js +0 -98
- package/src-noconflict/snippets/xml.js +0 -9
- package/src-noconflict/snippets/xquery.js +0 -75
- package/src-noconflict/snippets/yaml.js +0 -9
- package/src-noconflict/snippets/zeek.js +0 -9
- package/src-noconflict/theme-ambiance.js +0 -185
- package/src-noconflict/theme-chaos.js +0 -163
- package/src-noconflict/theme-chrome.js +0 -135
- package/src-noconflict/theme-clouds.js +0 -102
- package/src-noconflict/theme-clouds_midnight.js +0 -103
- package/src-noconflict/theme-cobalt.js +0 -120
- package/src-noconflict/theme-crimson_editor.js +0 -125
- package/src-noconflict/theme-dawn.js +0 -115
- package/src-noconflict/theme-dracula.js +0 -135
- package/src-noconflict/theme-dreamweaver.js +0 -148
- package/src-noconflict/theme-eclipse.js +0 -105
- package/src-noconflict/theme-github.js +0 -110
- package/src-noconflict/theme-gob.js +0 -119
- package/src-noconflict/theme-gruvbox.js +0 -89
- package/src-noconflict/theme-idle_fingers.js +0 -103
- package/src-noconflict/theme-iplastic.js +0 -128
- package/src-noconflict/theme-katzenmilch.js +0 -128
- package/src-noconflict/theme-kr_theme.js +0 -111
- package/src-noconflict/theme-kuroir.js +0 -68
- package/src-noconflict/theme-merbivore.js +0 -102
- package/src-noconflict/theme-merbivore_soft.js +0 -103
- package/src-noconflict/theme-mono_industrial.js +0 -114
- package/src-noconflict/theme-monokai.js +0 -112
- package/src-noconflict/theme-pastel_on_dark.js +0 -115
- package/src-noconflict/theme-solarized_dark.js +0 -95
- package/src-noconflict/theme-solarized_light.js +0 -98
- package/src-noconflict/theme-sqlserver.js +0 -145
- package/src-noconflict/theme-terminal.js +0 -121
- package/src-noconflict/theme-textmate.js +0 -137
- package/src-noconflict/theme-tomorrow.js +0 -115
- package/src-noconflict/theme-tomorrow_night.js +0 -115
- package/src-noconflict/theme-tomorrow_night_blue.js +0 -113
- package/src-noconflict/theme-tomorrow_night_bright.js +0 -128
- package/src-noconflict/theme-tomorrow_night_eighties.js +0 -115
- package/src-noconflict/theme-twilight.js +0 -116
- package/src-noconflict/theme-vibrant_ink.js +0 -101
- package/src-noconflict/theme-xcode.js +0 -95
- package/src-noconflict/worker-coffee.js +0 -1470
- package/src-noconflict/worker-css.js +0 -9000
- package/src-noconflict/worker-html.js +0 -10922
- package/src-noconflict/worker-javascript.js +0 -15001
- package/src-noconflict/worker-json.js +0 -1715
- package/src-noconflict/worker-lua.js +0 -3608
- package/src-noconflict/worker-php.js +0 -3687
- package/src-noconflict/worker-xml.js +0 -3208
- package/src-noconflict/worker-xquery.js +0 -57668
|
@@ -1,1331 +0,0 @@
|
|
|
1
|
-
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) {
|
|
2
|
-
"use strict";
|
|
3
|
-
var dom = require("./lib/dom");
|
|
4
|
-
var oop = require("./lib/oop");
|
|
5
|
-
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
|
6
|
-
var lang = require("./lib/lang");
|
|
7
|
-
var Range = require("./range").Range;
|
|
8
|
-
var RangeList = require("./range_list").RangeList;
|
|
9
|
-
var HashHandler = require("./keyboard/hash_handler").HashHandler;
|
|
10
|
-
var Tokenizer = require("./tokenizer").Tokenizer;
|
|
11
|
-
var clipboard = require("./clipboard");
|
|
12
|
-
|
|
13
|
-
var VARIABLES = {
|
|
14
|
-
CURRENT_WORD: function(editor) {
|
|
15
|
-
return editor.session.getTextRange(editor.session.getWordRange());
|
|
16
|
-
},
|
|
17
|
-
SELECTION: function(editor, name, indentation) {
|
|
18
|
-
var text = editor.session.getTextRange();
|
|
19
|
-
if (indentation)
|
|
20
|
-
return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1");
|
|
21
|
-
return text;
|
|
22
|
-
},
|
|
23
|
-
CURRENT_LINE: function(editor) {
|
|
24
|
-
return editor.session.getLine(editor.getCursorPosition().row);
|
|
25
|
-
},
|
|
26
|
-
PREV_LINE: function(editor) {
|
|
27
|
-
return editor.session.getLine(editor.getCursorPosition().row - 1);
|
|
28
|
-
},
|
|
29
|
-
LINE_INDEX: function(editor) {
|
|
30
|
-
return editor.getCursorPosition().row;
|
|
31
|
-
},
|
|
32
|
-
LINE_NUMBER: function(editor) {
|
|
33
|
-
return editor.getCursorPosition().row + 1;
|
|
34
|
-
},
|
|
35
|
-
SOFT_TABS: function(editor) {
|
|
36
|
-
return editor.session.getUseSoftTabs() ? "YES" : "NO";
|
|
37
|
-
},
|
|
38
|
-
TAB_SIZE: function(editor) {
|
|
39
|
-
return editor.session.getTabSize();
|
|
40
|
-
},
|
|
41
|
-
CLIPBOARD: function(editor) {
|
|
42
|
-
return clipboard.getText && clipboard.getText();
|
|
43
|
-
},
|
|
44
|
-
FILENAME: function(editor) {
|
|
45
|
-
return /[^/\\]*$/.exec(this.FILEPATH(editor))[0];
|
|
46
|
-
},
|
|
47
|
-
FILENAME_BASE: function(editor) {
|
|
48
|
-
return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, "");
|
|
49
|
-
},
|
|
50
|
-
DIRECTORY: function(editor) {
|
|
51
|
-
return this.FILEPATH(editor).replace(/[^/\\]*$/, "");
|
|
52
|
-
},
|
|
53
|
-
FILEPATH: function(editor) { return "/not implemented.txt"; },
|
|
54
|
-
WORKSPACE_NAME: function() { return "Unknown"; },
|
|
55
|
-
FULLNAME: function() { return "Unknown"; },
|
|
56
|
-
BLOCK_COMMENT_START: function(editor) {
|
|
57
|
-
var mode = editor.session.$mode || {};
|
|
58
|
-
return mode.blockComment && mode.blockComment.start || "";
|
|
59
|
-
},
|
|
60
|
-
BLOCK_COMMENT_END: function(editor) {
|
|
61
|
-
var mode = editor.session.$mode || {};
|
|
62
|
-
return mode.blockComment && mode.blockComment.end || "";
|
|
63
|
-
},
|
|
64
|
-
LINE_COMMENT: function(editor) {
|
|
65
|
-
var mode = editor.session.$mode || {};
|
|
66
|
-
return mode.lineCommentStart || "";
|
|
67
|
-
},
|
|
68
|
-
CURRENT_YEAR: date.bind(null, {year: "numeric"}),
|
|
69
|
-
CURRENT_YEAR_SHORT: date.bind(null, {year: "2-digit"}),
|
|
70
|
-
CURRENT_MONTH: date.bind(null, {month: "numeric"}),
|
|
71
|
-
CURRENT_MONTH_NAME: date.bind(null, {month: "long"}),
|
|
72
|
-
CURRENT_MONTH_NAME_SHORT: date.bind(null, {month: "short"}),
|
|
73
|
-
CURRENT_DATE: date.bind(null, {day: "2-digit"}),
|
|
74
|
-
CURRENT_DAY_NAME: date.bind(null, {weekday: "long"}),
|
|
75
|
-
CURRENT_DAY_NAME_SHORT: date.bind(null, {weekday: "short"}),
|
|
76
|
-
CURRENT_HOUR: date.bind(null, {hour: "2-digit", hour12: false}),
|
|
77
|
-
CURRENT_MINUTE: date.bind(null, {minute: "2-digit"}),
|
|
78
|
-
CURRENT_SECOND: date.bind(null, {second: "2-digit"})
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION;
|
|
82
|
-
|
|
83
|
-
function date(dateFormat) {
|
|
84
|
-
var str = new Date().toLocaleString("en-us", dateFormat);
|
|
85
|
-
return str.length == 1 ? "0" + str : str;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var SnippetManager = function() {
|
|
89
|
-
this.snippetMap = {};
|
|
90
|
-
this.snippetNameMap = {};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
(function() {
|
|
94
|
-
oop.implement(this, EventEmitter);
|
|
95
|
-
|
|
96
|
-
this.getTokenizer = function() {
|
|
97
|
-
return SnippetManager.$tokenizer || this.createTokenizer();
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
this.createTokenizer = function() {
|
|
101
|
-
function TabstopToken(str) {
|
|
102
|
-
str = str.substr(1);
|
|
103
|
-
if (/^\d+$/.test(str))
|
|
104
|
-
return [{tabstopId: parseInt(str, 10)}];
|
|
105
|
-
return [{text: str}];
|
|
106
|
-
}
|
|
107
|
-
function escape(ch) {
|
|
108
|
-
return "(?:[^\\\\" + ch + "]|\\\\.)";
|
|
109
|
-
}
|
|
110
|
-
var formatMatcher = {
|
|
111
|
-
regex: "/(" + escape("/") + "+)/",
|
|
112
|
-
onMatch: function(val, state, stack) {
|
|
113
|
-
var ts = stack[0];
|
|
114
|
-
ts.fmtString = true;
|
|
115
|
-
ts.guard = val.slice(1, -1);
|
|
116
|
-
ts.flag = "";
|
|
117
|
-
return "";
|
|
118
|
-
},
|
|
119
|
-
next: "formatString"
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
SnippetManager.$tokenizer = new Tokenizer({
|
|
123
|
-
start: [
|
|
124
|
-
{regex: /\\./, onMatch: function(val, state, stack) {
|
|
125
|
-
var ch = val[1];
|
|
126
|
-
if (ch == "}" && stack.length) {
|
|
127
|
-
val = ch;
|
|
128
|
-
} else if ("`$\\".indexOf(ch) != -1) {
|
|
129
|
-
val = ch;
|
|
130
|
-
}
|
|
131
|
-
return [val];
|
|
132
|
-
}},
|
|
133
|
-
{regex: /}/, onMatch: function(val, state, stack) {
|
|
134
|
-
return [stack.length ? stack.shift() : val];
|
|
135
|
-
}},
|
|
136
|
-
{regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken},
|
|
137
|
-
{regex: /\$\{[\dA-Z_a-z]+/, onMatch: function(str, state, stack) {
|
|
138
|
-
var t = TabstopToken(str.substr(1));
|
|
139
|
-
stack.unshift(t[0]);
|
|
140
|
-
return t;
|
|
141
|
-
}, next: "snippetVar"},
|
|
142
|
-
{regex: /\n/, token: "newline", merge: false}
|
|
143
|
-
],
|
|
144
|
-
snippetVar: [
|
|
145
|
-
{regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
|
|
146
|
-
var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function(operator) {
|
|
147
|
-
return operator.length == 2 ? operator[1] : "\x00";
|
|
148
|
-
}).split("\x00").map(function(value){
|
|
149
|
-
return {value: value};
|
|
150
|
-
});
|
|
151
|
-
stack[0].choices = choices;
|
|
152
|
-
return [choices[0]];
|
|
153
|
-
}, next: "start"},
|
|
154
|
-
formatMatcher,
|
|
155
|
-
{regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start"}
|
|
156
|
-
],
|
|
157
|
-
formatString: [
|
|
158
|
-
{regex: /:/, onMatch: function(val, state, stack) {
|
|
159
|
-
if (stack.length && stack[0].expectElse) {
|
|
160
|
-
stack[0].expectElse = false;
|
|
161
|
-
stack[0].ifEnd = {elseEnd: stack[0]};
|
|
162
|
-
return [stack[0].ifEnd];
|
|
163
|
-
}
|
|
164
|
-
return ":";
|
|
165
|
-
}},
|
|
166
|
-
{regex: /\\./, onMatch: function(val, state, stack) {
|
|
167
|
-
var ch = val[1];
|
|
168
|
-
if (ch == "}" && stack.length)
|
|
169
|
-
val = ch;
|
|
170
|
-
else if ("`$\\".indexOf(ch) != -1)
|
|
171
|
-
val = ch;
|
|
172
|
-
else if (ch == "n")
|
|
173
|
-
val = "\n";
|
|
174
|
-
else if (ch == "t")
|
|
175
|
-
val = "\t";
|
|
176
|
-
else if ("ulULE".indexOf(ch) != -1)
|
|
177
|
-
val = {changeCase: ch, local: ch > "a"};
|
|
178
|
-
return [val];
|
|
179
|
-
}},
|
|
180
|
-
{regex: "/\\w*}", onMatch: function(val, state, stack) {
|
|
181
|
-
var next = stack.shift();
|
|
182
|
-
if (next)
|
|
183
|
-
next.flag = val.slice(1, -1);
|
|
184
|
-
this.next = next && next.tabstopId ? "start" : "";
|
|
185
|
-
return [next || val];
|
|
186
|
-
}, next: "start"},
|
|
187
|
-
{regex: /\$(?:\d+|\w+)/, onMatch: function(val, state, stack) {
|
|
188
|
-
return [{text: val.slice(1)}];
|
|
189
|
-
}},
|
|
190
|
-
{regex: /\${\w+/, onMatch: function(val, state, stack) {
|
|
191
|
-
var token = {text: val.slice(2)};
|
|
192
|
-
stack.unshift(token);
|
|
193
|
-
return [token];
|
|
194
|
-
}, next: "formatStringVar"},
|
|
195
|
-
{regex: /\n/, token: "newline", merge: false},
|
|
196
|
-
{regex: /}/, onMatch: function(val, state, stack) {
|
|
197
|
-
var next = stack.shift();
|
|
198
|
-
this.next = next && next.tabstopId ? "start" : "";
|
|
199
|
-
return [next || val];
|
|
200
|
-
}, next: "start"}
|
|
201
|
-
],
|
|
202
|
-
formatStringVar: [
|
|
203
|
-
{regex: /:\/\w+}/, onMatch: function(val, state, stack) {
|
|
204
|
-
var ts = stack[0];
|
|
205
|
-
ts.formatFunction = val.slice(2, -1);
|
|
206
|
-
return [stack.shift()];
|
|
207
|
-
}, next: "formatString"},
|
|
208
|
-
formatMatcher,
|
|
209
|
-
{regex: /:[\?\-+]?/, onMatch: function(val, state, stack) {
|
|
210
|
-
if (val[1] == "+")
|
|
211
|
-
stack[0].ifEnd = stack[0];
|
|
212
|
-
if (val[1] == "?")
|
|
213
|
-
stack[0].expectElse = true;
|
|
214
|
-
}, next: "formatString"},
|
|
215
|
-
{regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString"}
|
|
216
|
-
]
|
|
217
|
-
});
|
|
218
|
-
return SnippetManager.$tokenizer;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
this.tokenizeTmSnippet = function(str, startState) {
|
|
222
|
-
return this.getTokenizer().getLineTokens(str, startState).tokens.map(function(x) {
|
|
223
|
-
return x.value || x;
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
this.getVariableValue = function(editor, name, indentation) {
|
|
228
|
-
if (/^\d+$/.test(name))
|
|
229
|
-
return (this.variables.__ || {})[name] || "";
|
|
230
|
-
if (/^[A-Z]\d+$/.test(name))
|
|
231
|
-
return (this.variables[name[0] + "__"] || {})[name.substr(1)] || "";
|
|
232
|
-
|
|
233
|
-
name = name.replace(/^TM_/, "");
|
|
234
|
-
if (!this.variables.hasOwnProperty(name))
|
|
235
|
-
return "";
|
|
236
|
-
var value = this.variables[name];
|
|
237
|
-
if (typeof value == "function")
|
|
238
|
-
value = this.variables[name](editor, name, indentation);
|
|
239
|
-
return value == null ? "" : value;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
this.variables = VARIABLES;
|
|
243
|
-
this.tmStrFormat = function(str, ch, editor) {
|
|
244
|
-
if (!ch.fmt) return str;
|
|
245
|
-
var flag = ch.flag || "";
|
|
246
|
-
var re = ch.guard;
|
|
247
|
-
re = new RegExp(re, flag.replace(/[^gim]/g, ""));
|
|
248
|
-
var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt;
|
|
249
|
-
var _self = this;
|
|
250
|
-
var formatted = str.replace(re, function() {
|
|
251
|
-
var oldArgs = _self.variables.__;
|
|
252
|
-
_self.variables.__ = [].slice.call(arguments);
|
|
253
|
-
var fmtParts = _self.resolveVariables(fmtTokens, editor);
|
|
254
|
-
var gChangeCase = "E";
|
|
255
|
-
for (var i = 0; i < fmtParts.length; i++) {
|
|
256
|
-
var ch = fmtParts[i];
|
|
257
|
-
if (typeof ch == "object") {
|
|
258
|
-
fmtParts[i] = "";
|
|
259
|
-
if (ch.changeCase && ch.local) {
|
|
260
|
-
var next = fmtParts[i + 1];
|
|
261
|
-
if (next && typeof next == "string") {
|
|
262
|
-
if (ch.changeCase == "u")
|
|
263
|
-
fmtParts[i] = next[0].toUpperCase();
|
|
264
|
-
else
|
|
265
|
-
fmtParts[i] = next[0].toLowerCase();
|
|
266
|
-
fmtParts[i + 1] = next.substr(1);
|
|
267
|
-
}
|
|
268
|
-
} else if (ch.changeCase) {
|
|
269
|
-
gChangeCase = ch.changeCase;
|
|
270
|
-
}
|
|
271
|
-
} else if (gChangeCase == "U") {
|
|
272
|
-
fmtParts[i] = ch.toUpperCase();
|
|
273
|
-
} else if (gChangeCase == "L") {
|
|
274
|
-
fmtParts[i] = ch.toLowerCase();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
_self.variables.__ = oldArgs;
|
|
278
|
-
return fmtParts.join("");
|
|
279
|
-
});
|
|
280
|
-
return formatted;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
this.tmFormatFunction = function(str, ch, editor) {
|
|
284
|
-
if (ch.formatFunction == "upcase")
|
|
285
|
-
return str.toUpperCase();
|
|
286
|
-
if (ch.formatFunction == "downcase")
|
|
287
|
-
return str.toLowerCase();
|
|
288
|
-
return str;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
this.resolveVariables = function(snippet, editor) {
|
|
292
|
-
var result = [];
|
|
293
|
-
var indentation = "";
|
|
294
|
-
var afterNewLine = true;
|
|
295
|
-
for (var i = 0; i < snippet.length; i++) {
|
|
296
|
-
var ch = snippet[i];
|
|
297
|
-
if (typeof ch == "string") {
|
|
298
|
-
result.push(ch);
|
|
299
|
-
if (ch == "\n") {
|
|
300
|
-
afterNewLine = true;
|
|
301
|
-
indentation = "";
|
|
302
|
-
}
|
|
303
|
-
else if (afterNewLine) {
|
|
304
|
-
indentation = /^\t*/.exec(ch)[0];
|
|
305
|
-
afterNewLine = /\S/.test(ch);
|
|
306
|
-
}
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
if (!ch) continue;
|
|
310
|
-
afterNewLine = false;
|
|
311
|
-
|
|
312
|
-
if (ch.fmtString) {
|
|
313
|
-
var j = snippet.indexOf(ch, i + 1);
|
|
314
|
-
if (j == -1) j = snippet.length;
|
|
315
|
-
ch.fmt = snippet.slice(i + 1, j);
|
|
316
|
-
i = j;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (ch.text) {
|
|
320
|
-
var value = this.getVariableValue(editor, ch.text, indentation) + "";
|
|
321
|
-
if (ch.fmtString)
|
|
322
|
-
value = this.tmStrFormat(value, ch, editor);
|
|
323
|
-
if (ch.formatFunction)
|
|
324
|
-
value = this.tmFormatFunction(value, ch, editor);
|
|
325
|
-
|
|
326
|
-
if (value && !ch.ifEnd) {
|
|
327
|
-
result.push(value);
|
|
328
|
-
gotoNext(ch);
|
|
329
|
-
} else if (!value && ch.ifEnd) {
|
|
330
|
-
gotoNext(ch.ifEnd);
|
|
331
|
-
}
|
|
332
|
-
} else if (ch.elseEnd) {
|
|
333
|
-
gotoNext(ch.elseEnd);
|
|
334
|
-
} else if (ch.tabstopId != null) {
|
|
335
|
-
result.push(ch);
|
|
336
|
-
} else if (ch.changeCase != null) {
|
|
337
|
-
result.push(ch);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function gotoNext(ch) {
|
|
341
|
-
var i1 = snippet.indexOf(ch, i + 1);
|
|
342
|
-
if (i1 != -1)
|
|
343
|
-
i = i1;
|
|
344
|
-
}
|
|
345
|
-
return result;
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
this.insertSnippetForSelection = function(editor, snippetText) {
|
|
349
|
-
var cursor = editor.getCursorPosition();
|
|
350
|
-
var line = editor.session.getLine(cursor.row);
|
|
351
|
-
var tabString = editor.session.getTabString();
|
|
352
|
-
var indentString = line.match(/^\s*/)[0];
|
|
353
|
-
|
|
354
|
-
if (cursor.column < indentString.length)
|
|
355
|
-
indentString = indentString.slice(0, cursor.column);
|
|
356
|
-
|
|
357
|
-
snippetText = snippetText.replace(/\r/g, "");
|
|
358
|
-
var tokens = this.tokenizeTmSnippet(snippetText);
|
|
359
|
-
tokens = this.resolveVariables(tokens, editor);
|
|
360
|
-
tokens = tokens.map(function(x) {
|
|
361
|
-
if (x == "\n")
|
|
362
|
-
return x + indentString;
|
|
363
|
-
if (typeof x == "string")
|
|
364
|
-
return x.replace(/\t/g, tabString);
|
|
365
|
-
return x;
|
|
366
|
-
});
|
|
367
|
-
var tabstops = [];
|
|
368
|
-
tokens.forEach(function(p, i) {
|
|
369
|
-
if (typeof p != "object")
|
|
370
|
-
return;
|
|
371
|
-
var id = p.tabstopId;
|
|
372
|
-
var ts = tabstops[id];
|
|
373
|
-
if (!ts) {
|
|
374
|
-
ts = tabstops[id] = [];
|
|
375
|
-
ts.index = id;
|
|
376
|
-
ts.value = "";
|
|
377
|
-
ts.parents = {};
|
|
378
|
-
}
|
|
379
|
-
if (ts.indexOf(p) !== -1)
|
|
380
|
-
return;
|
|
381
|
-
if (p.choices && !ts.choices)
|
|
382
|
-
ts.choices = p.choices;
|
|
383
|
-
ts.push(p);
|
|
384
|
-
var i1 = tokens.indexOf(p, i + 1);
|
|
385
|
-
if (i1 === -1)
|
|
386
|
-
return;
|
|
387
|
-
|
|
388
|
-
var value = tokens.slice(i + 1, i1);
|
|
389
|
-
var isNested = value.some(function(t) {return typeof t === "object";});
|
|
390
|
-
if (isNested && !ts.value) {
|
|
391
|
-
ts.value = value;
|
|
392
|
-
} else if (value.length && (!ts.value || typeof ts.value !== "string")) {
|
|
393
|
-
ts.value = value.join("");
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
tabstops.forEach(function(ts) {ts.length = 0;});
|
|
397
|
-
var expanding = {};
|
|
398
|
-
function copyValue(val) {
|
|
399
|
-
var copy = [];
|
|
400
|
-
for (var i = 0; i < val.length; i++) {
|
|
401
|
-
var p = val[i];
|
|
402
|
-
if (typeof p == "object") {
|
|
403
|
-
if (expanding[p.tabstopId])
|
|
404
|
-
continue;
|
|
405
|
-
var j = val.lastIndexOf(p, i - 1);
|
|
406
|
-
p = copy[j] || {tabstopId: p.tabstopId};
|
|
407
|
-
}
|
|
408
|
-
copy[i] = p;
|
|
409
|
-
}
|
|
410
|
-
return copy;
|
|
411
|
-
}
|
|
412
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
413
|
-
var p = tokens[i];
|
|
414
|
-
if (typeof p != "object")
|
|
415
|
-
continue;
|
|
416
|
-
var id = p.tabstopId;
|
|
417
|
-
var ts = tabstops[id];
|
|
418
|
-
var i1 = tokens.indexOf(p, i + 1);
|
|
419
|
-
if (expanding[id]) {
|
|
420
|
-
if (expanding[id] === p) {
|
|
421
|
-
delete expanding[id];
|
|
422
|
-
Object.keys(expanding).forEach(function(parentId) {
|
|
423
|
-
ts.parents[parentId] = true;
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
428
|
-
expanding[id] = p;
|
|
429
|
-
var value = ts.value;
|
|
430
|
-
if (typeof value !== "string")
|
|
431
|
-
value = copyValue(value);
|
|
432
|
-
else if (p.fmt)
|
|
433
|
-
value = this.tmStrFormat(value, p, editor);
|
|
434
|
-
tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p));
|
|
435
|
-
|
|
436
|
-
if (ts.indexOf(p) === -1)
|
|
437
|
-
ts.push(p);
|
|
438
|
-
}
|
|
439
|
-
var row = 0, column = 0;
|
|
440
|
-
var text = "";
|
|
441
|
-
tokens.forEach(function(t) {
|
|
442
|
-
if (typeof t === "string") {
|
|
443
|
-
var lines = t.split("\n");
|
|
444
|
-
if (lines.length > 1){
|
|
445
|
-
column = lines[lines.length - 1].length;
|
|
446
|
-
row += lines.length - 1;
|
|
447
|
-
} else
|
|
448
|
-
column += t.length;
|
|
449
|
-
text += t;
|
|
450
|
-
} else if (t) {
|
|
451
|
-
if (!t.start)
|
|
452
|
-
t.start = {row: row, column: column};
|
|
453
|
-
else
|
|
454
|
-
t.end = {row: row, column: column};
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
var range = editor.getSelectionRange();
|
|
458
|
-
var end = editor.session.replace(range, text);
|
|
459
|
-
|
|
460
|
-
var tabstopManager = new TabstopManager(editor);
|
|
461
|
-
var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
|
|
462
|
-
tabstopManager.addTabstops(tabstops, range.start, end, selectionId);
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
this.insertSnippet = function(editor, snippetText) {
|
|
466
|
-
var self = this;
|
|
467
|
-
if (editor.inVirtualSelectionMode)
|
|
468
|
-
return self.insertSnippetForSelection(editor, snippetText);
|
|
469
|
-
|
|
470
|
-
editor.forEachSelection(function() {
|
|
471
|
-
self.insertSnippetForSelection(editor, snippetText);
|
|
472
|
-
}, null, {keepOrder: true});
|
|
473
|
-
|
|
474
|
-
if (editor.tabstopManager)
|
|
475
|
-
editor.tabstopManager.tabNext();
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
this.$getScope = function(editor) {
|
|
479
|
-
var scope = editor.session.$mode.$id || "";
|
|
480
|
-
scope = scope.split("/").pop();
|
|
481
|
-
if (scope === "html" || scope === "php") {
|
|
482
|
-
if (scope === "php" && !editor.session.$mode.inlinePhp)
|
|
483
|
-
scope = "html";
|
|
484
|
-
var c = editor.getCursorPosition();
|
|
485
|
-
var state = editor.session.getState(c.row);
|
|
486
|
-
if (typeof state === "object") {
|
|
487
|
-
state = state[0];
|
|
488
|
-
}
|
|
489
|
-
if (state.substring) {
|
|
490
|
-
if (state.substring(0, 3) == "js-")
|
|
491
|
-
scope = "javascript";
|
|
492
|
-
else if (state.substring(0, 4) == "css-")
|
|
493
|
-
scope = "css";
|
|
494
|
-
else if (state.substring(0, 4) == "php-")
|
|
495
|
-
scope = "php";
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
return scope;
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
this.getActiveScopes = function(editor) {
|
|
503
|
-
var scope = this.$getScope(editor);
|
|
504
|
-
var scopes = [scope];
|
|
505
|
-
var snippetMap = this.snippetMap;
|
|
506
|
-
if (snippetMap[scope] && snippetMap[scope].includeScopes) {
|
|
507
|
-
scopes.push.apply(scopes, snippetMap[scope].includeScopes);
|
|
508
|
-
}
|
|
509
|
-
scopes.push("_");
|
|
510
|
-
return scopes;
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
this.expandWithTab = function(editor, options) {
|
|
514
|
-
var self = this;
|
|
515
|
-
var result = editor.forEachSelection(function() {
|
|
516
|
-
return self.expandSnippetForSelection(editor, options);
|
|
517
|
-
}, null, {keepOrder: true});
|
|
518
|
-
if (result && editor.tabstopManager)
|
|
519
|
-
editor.tabstopManager.tabNext();
|
|
520
|
-
return result;
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
this.expandSnippetForSelection = function(editor, options) {
|
|
524
|
-
var cursor = editor.getCursorPosition();
|
|
525
|
-
var line = editor.session.getLine(cursor.row);
|
|
526
|
-
var before = line.substring(0, cursor.column);
|
|
527
|
-
var after = line.substr(cursor.column);
|
|
528
|
-
|
|
529
|
-
var snippetMap = this.snippetMap;
|
|
530
|
-
var snippet;
|
|
531
|
-
this.getActiveScopes(editor).some(function(scope) {
|
|
532
|
-
var snippets = snippetMap[scope];
|
|
533
|
-
if (snippets)
|
|
534
|
-
snippet = this.findMatchingSnippet(snippets, before, after);
|
|
535
|
-
return !!snippet;
|
|
536
|
-
}, this);
|
|
537
|
-
if (!snippet)
|
|
538
|
-
return false;
|
|
539
|
-
if (options && options.dryRun)
|
|
540
|
-
return true;
|
|
541
|
-
editor.session.doc.removeInLine(cursor.row,
|
|
542
|
-
cursor.column - snippet.replaceBefore.length,
|
|
543
|
-
cursor.column + snippet.replaceAfter.length
|
|
544
|
-
);
|
|
545
|
-
|
|
546
|
-
this.variables.M__ = snippet.matchBefore;
|
|
547
|
-
this.variables.T__ = snippet.matchAfter;
|
|
548
|
-
this.insertSnippetForSelection(editor, snippet.content);
|
|
549
|
-
|
|
550
|
-
this.variables.M__ = this.variables.T__ = null;
|
|
551
|
-
return true;
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
this.findMatchingSnippet = function(snippetList, before, after) {
|
|
555
|
-
for (var i = snippetList.length; i--;) {
|
|
556
|
-
var s = snippetList[i];
|
|
557
|
-
if (s.startRe && !s.startRe.test(before))
|
|
558
|
-
continue;
|
|
559
|
-
if (s.endRe && !s.endRe.test(after))
|
|
560
|
-
continue;
|
|
561
|
-
if (!s.startRe && !s.endRe)
|
|
562
|
-
continue;
|
|
563
|
-
|
|
564
|
-
s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
|
|
565
|
-
s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
|
|
566
|
-
s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
|
|
567
|
-
s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : "";
|
|
568
|
-
return s;
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
this.snippetMap = {};
|
|
573
|
-
this.snippetNameMap = {};
|
|
574
|
-
this.register = function(snippets, scope) {
|
|
575
|
-
var snippetMap = this.snippetMap;
|
|
576
|
-
var snippetNameMap = this.snippetNameMap;
|
|
577
|
-
var self = this;
|
|
578
|
-
|
|
579
|
-
if (!snippets)
|
|
580
|
-
snippets = [];
|
|
581
|
-
|
|
582
|
-
function wrapRegexp(src) {
|
|
583
|
-
if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
|
|
584
|
-
src = "(?:" + src + ")";
|
|
585
|
-
|
|
586
|
-
return src || "";
|
|
587
|
-
}
|
|
588
|
-
function guardedRegexp(re, guard, opening) {
|
|
589
|
-
re = wrapRegexp(re);
|
|
590
|
-
guard = wrapRegexp(guard);
|
|
591
|
-
if (opening) {
|
|
592
|
-
re = guard + re;
|
|
593
|
-
if (re && re[re.length - 1] != "$")
|
|
594
|
-
re = re + "$";
|
|
595
|
-
} else {
|
|
596
|
-
re = re + guard;
|
|
597
|
-
if (re && re[0] != "^")
|
|
598
|
-
re = "^" + re;
|
|
599
|
-
}
|
|
600
|
-
return new RegExp(re);
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function addSnippet(s) {
|
|
604
|
-
if (!s.scope)
|
|
605
|
-
s.scope = scope || "_";
|
|
606
|
-
scope = s.scope;
|
|
607
|
-
if (!snippetMap[scope]) {
|
|
608
|
-
snippetMap[scope] = [];
|
|
609
|
-
snippetNameMap[scope] = {};
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
var map = snippetNameMap[scope];
|
|
613
|
-
if (s.name) {
|
|
614
|
-
var old = map[s.name];
|
|
615
|
-
if (old)
|
|
616
|
-
self.unregister(old);
|
|
617
|
-
map[s.name] = s;
|
|
618
|
-
}
|
|
619
|
-
snippetMap[scope].push(s);
|
|
620
|
-
|
|
621
|
-
if (s.prefix)
|
|
622
|
-
s.tabTrigger = s.prefix;
|
|
623
|
-
|
|
624
|
-
if (!s.content && s.body)
|
|
625
|
-
s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body;
|
|
626
|
-
|
|
627
|
-
if (s.tabTrigger && !s.trigger) {
|
|
628
|
-
if (!s.guard && /^\w/.test(s.tabTrigger))
|
|
629
|
-
s.guard = "\\b";
|
|
630
|
-
s.trigger = lang.escapeRegExp(s.tabTrigger);
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard)
|
|
634
|
-
return;
|
|
635
|
-
|
|
636
|
-
s.startRe = guardedRegexp(s.trigger, s.guard, true);
|
|
637
|
-
s.triggerRe = new RegExp(s.trigger);
|
|
638
|
-
|
|
639
|
-
s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
|
|
640
|
-
s.endTriggerRe = new RegExp(s.endTrigger);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
if (Array.isArray(snippets)) {
|
|
644
|
-
snippets.forEach(addSnippet);
|
|
645
|
-
} else {
|
|
646
|
-
Object.keys(snippets).forEach(function(key) {
|
|
647
|
-
addSnippet(snippets[key]);
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
this._signal("registerSnippets", {scope: scope});
|
|
652
|
-
};
|
|
653
|
-
this.unregister = function(snippets, scope) {
|
|
654
|
-
var snippetMap = this.snippetMap;
|
|
655
|
-
var snippetNameMap = this.snippetNameMap;
|
|
656
|
-
|
|
657
|
-
function removeSnippet(s) {
|
|
658
|
-
var nameMap = snippetNameMap[s.scope||scope];
|
|
659
|
-
if (nameMap && nameMap[s.name]) {
|
|
660
|
-
delete nameMap[s.name];
|
|
661
|
-
var map = snippetMap[s.scope||scope];
|
|
662
|
-
var i = map && map.indexOf(s);
|
|
663
|
-
if (i >= 0)
|
|
664
|
-
map.splice(i, 1);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
if (snippets.content)
|
|
668
|
-
removeSnippet(snippets);
|
|
669
|
-
else if (Array.isArray(snippets))
|
|
670
|
-
snippets.forEach(removeSnippet);
|
|
671
|
-
};
|
|
672
|
-
this.parseSnippetFile = function(str) {
|
|
673
|
-
str = str.replace(/\r/g, "");
|
|
674
|
-
var list = [], snippet = {};
|
|
675
|
-
var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
|
|
676
|
-
var m;
|
|
677
|
-
while (m = re.exec(str)) {
|
|
678
|
-
if (m[1]) {
|
|
679
|
-
try {
|
|
680
|
-
snippet = JSON.parse(m[1]);
|
|
681
|
-
list.push(snippet);
|
|
682
|
-
} catch (e) {}
|
|
683
|
-
} if (m[4]) {
|
|
684
|
-
snippet.content = m[4].replace(/^\t/gm, "");
|
|
685
|
-
list.push(snippet);
|
|
686
|
-
snippet = {};
|
|
687
|
-
} else {
|
|
688
|
-
var key = m[2], val = m[3];
|
|
689
|
-
if (key == "regex") {
|
|
690
|
-
var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
|
|
691
|
-
snippet.guard = guardRe.exec(val)[1];
|
|
692
|
-
snippet.trigger = guardRe.exec(val)[1];
|
|
693
|
-
snippet.endTrigger = guardRe.exec(val)[1];
|
|
694
|
-
snippet.endGuard = guardRe.exec(val)[1];
|
|
695
|
-
} else if (key == "snippet") {
|
|
696
|
-
snippet.tabTrigger = val.match(/^\S*/)[0];
|
|
697
|
-
if (!snippet.name)
|
|
698
|
-
snippet.name = val;
|
|
699
|
-
} else if (key) {
|
|
700
|
-
snippet[key] = val;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
return list;
|
|
705
|
-
};
|
|
706
|
-
this.getSnippetByName = function(name, editor) {
|
|
707
|
-
var snippetMap = this.snippetNameMap;
|
|
708
|
-
var snippet;
|
|
709
|
-
this.getActiveScopes(editor).some(function(scope) {
|
|
710
|
-
var snippets = snippetMap[scope];
|
|
711
|
-
if (snippets)
|
|
712
|
-
snippet = snippets[name];
|
|
713
|
-
return !!snippet;
|
|
714
|
-
}, this);
|
|
715
|
-
return snippet;
|
|
716
|
-
};
|
|
717
|
-
|
|
718
|
-
}).call(SnippetManager.prototype);
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
var TabstopManager = function(editor) {
|
|
722
|
-
if (editor.tabstopManager)
|
|
723
|
-
return editor.tabstopManager;
|
|
724
|
-
editor.tabstopManager = this;
|
|
725
|
-
this.$onChange = this.onChange.bind(this);
|
|
726
|
-
this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
|
|
727
|
-
this.$onChangeSession = this.onChangeSession.bind(this);
|
|
728
|
-
this.$onAfterExec = this.onAfterExec.bind(this);
|
|
729
|
-
this.attach(editor);
|
|
730
|
-
};
|
|
731
|
-
(function() {
|
|
732
|
-
this.attach = function(editor) {
|
|
733
|
-
this.index = 0;
|
|
734
|
-
this.ranges = [];
|
|
735
|
-
this.tabstops = [];
|
|
736
|
-
this.$openTabstops = null;
|
|
737
|
-
this.selectedTabstop = null;
|
|
738
|
-
|
|
739
|
-
this.editor = editor;
|
|
740
|
-
this.editor.on("change", this.$onChange);
|
|
741
|
-
this.editor.on("changeSelection", this.$onChangeSelection);
|
|
742
|
-
this.editor.on("changeSession", this.$onChangeSession);
|
|
743
|
-
this.editor.commands.on("afterExec", this.$onAfterExec);
|
|
744
|
-
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
|
745
|
-
};
|
|
746
|
-
this.detach = function() {
|
|
747
|
-
this.tabstops.forEach(this.removeTabstopMarkers, this);
|
|
748
|
-
this.ranges = null;
|
|
749
|
-
this.tabstops = null;
|
|
750
|
-
this.selectedTabstop = null;
|
|
751
|
-
this.editor.removeListener("change", this.$onChange);
|
|
752
|
-
this.editor.removeListener("changeSelection", this.$onChangeSelection);
|
|
753
|
-
this.editor.removeListener("changeSession", this.$onChangeSession);
|
|
754
|
-
this.editor.commands.removeListener("afterExec", this.$onAfterExec);
|
|
755
|
-
this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
|
|
756
|
-
this.editor.tabstopManager = null;
|
|
757
|
-
this.editor = null;
|
|
758
|
-
};
|
|
759
|
-
|
|
760
|
-
this.onChange = function(delta) {
|
|
761
|
-
var isRemove = delta.action[0] == "r";
|
|
762
|
-
var selectedTabstop = this.selectedTabstop || {};
|
|
763
|
-
var parents = selectedTabstop.parents || {};
|
|
764
|
-
var tabstops = (this.tabstops || []).slice();
|
|
765
|
-
for (var i = 0; i < tabstops.length; i++) {
|
|
766
|
-
var ts = tabstops[i];
|
|
767
|
-
var active = ts == selectedTabstop || parents[ts.index];
|
|
768
|
-
ts.rangeList.$bias = active ? 0 : 1;
|
|
769
|
-
|
|
770
|
-
if (delta.action == "remove" && ts !== selectedTabstop) {
|
|
771
|
-
var parentActive = ts.parents && ts.parents[selectedTabstop.index];
|
|
772
|
-
var startIndex = ts.rangeList.pointIndex(delta.start, parentActive);
|
|
773
|
-
startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1;
|
|
774
|
-
var endIndex = ts.rangeList.pointIndex(delta.end, parentActive);
|
|
775
|
-
endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1;
|
|
776
|
-
var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex);
|
|
777
|
-
for (var j = 0; j < toRemove.length; j++)
|
|
778
|
-
this.removeRange(toRemove[j]);
|
|
779
|
-
}
|
|
780
|
-
ts.rangeList.$onChange(delta);
|
|
781
|
-
}
|
|
782
|
-
var session = this.editor.session;
|
|
783
|
-
if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue())
|
|
784
|
-
this.detach();
|
|
785
|
-
};
|
|
786
|
-
this.updateLinkedFields = function() {
|
|
787
|
-
var ts = this.selectedTabstop;
|
|
788
|
-
if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked)
|
|
789
|
-
return;
|
|
790
|
-
this.$inChange = true;
|
|
791
|
-
var session = this.editor.session;
|
|
792
|
-
var text = session.getTextRange(ts.firstNonLinked);
|
|
793
|
-
for (var i = 0; i < ts.length; i++) {
|
|
794
|
-
var range = ts[i];
|
|
795
|
-
if (!range.linked)
|
|
796
|
-
continue;
|
|
797
|
-
var original = range.original;
|
|
798
|
-
var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor);
|
|
799
|
-
session.replace(range, fmt);
|
|
800
|
-
}
|
|
801
|
-
this.$inChange = false;
|
|
802
|
-
};
|
|
803
|
-
this.onAfterExec = function(e) {
|
|
804
|
-
if (e.command && !e.command.readOnly)
|
|
805
|
-
this.updateLinkedFields();
|
|
806
|
-
};
|
|
807
|
-
this.onChangeSelection = function() {
|
|
808
|
-
if (!this.editor)
|
|
809
|
-
return;
|
|
810
|
-
var lead = this.editor.selection.lead;
|
|
811
|
-
var anchor = this.editor.selection.anchor;
|
|
812
|
-
var isEmpty = this.editor.selection.isEmpty();
|
|
813
|
-
for (var i = 0; i < this.ranges.length; i++) {
|
|
814
|
-
if (this.ranges[i].linked)
|
|
815
|
-
continue;
|
|
816
|
-
var containsLead = this.ranges[i].contains(lead.row, lead.column);
|
|
817
|
-
var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
|
|
818
|
-
if (containsLead && containsAnchor)
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
this.detach();
|
|
822
|
-
};
|
|
823
|
-
this.onChangeSession = function() {
|
|
824
|
-
this.detach();
|
|
825
|
-
};
|
|
826
|
-
this.tabNext = function(dir) {
|
|
827
|
-
var max = this.tabstops.length;
|
|
828
|
-
var index = this.index + (dir || 1);
|
|
829
|
-
index = Math.min(Math.max(index, 1), max);
|
|
830
|
-
if (index == max)
|
|
831
|
-
index = 0;
|
|
832
|
-
this.selectTabstop(index);
|
|
833
|
-
if (index === 0)
|
|
834
|
-
this.detach();
|
|
835
|
-
};
|
|
836
|
-
this.selectTabstop = function(index) {
|
|
837
|
-
this.$openTabstops = null;
|
|
838
|
-
var ts = this.tabstops[this.index];
|
|
839
|
-
if (ts)
|
|
840
|
-
this.addTabstopMarkers(ts);
|
|
841
|
-
this.index = index;
|
|
842
|
-
ts = this.tabstops[this.index];
|
|
843
|
-
if (!ts || !ts.length)
|
|
844
|
-
return;
|
|
845
|
-
|
|
846
|
-
this.selectedTabstop = ts;
|
|
847
|
-
var range = ts.firstNonLinked || ts;
|
|
848
|
-
if (ts.choices) range.cursor = range.start;
|
|
849
|
-
if (!this.editor.inVirtualSelectionMode) {
|
|
850
|
-
var sel = this.editor.multiSelect;
|
|
851
|
-
sel.toSingleRange(range);
|
|
852
|
-
for (var i = 0; i < ts.length; i++) {
|
|
853
|
-
if (ts.hasLinkedRanges && ts[i].linked)
|
|
854
|
-
continue;
|
|
855
|
-
sel.addRange(ts[i].clone(), true);
|
|
856
|
-
}
|
|
857
|
-
} else {
|
|
858
|
-
this.editor.selection.fromOrientedRange(range);
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
|
862
|
-
if (this.selectedTabstop && this.selectedTabstop.choices)
|
|
863
|
-
this.editor.execCommand("startAutocomplete", {matches: this.selectedTabstop.choices});
|
|
864
|
-
};
|
|
865
|
-
this.addTabstops = function(tabstops, start, end) {
|
|
866
|
-
var useLink = this.useLink || !this.editor.getOption("enableMultiselect");
|
|
867
|
-
|
|
868
|
-
if (!this.$openTabstops)
|
|
869
|
-
this.$openTabstops = [];
|
|
870
|
-
if (!tabstops[0]) {
|
|
871
|
-
var p = Range.fromPoints(end, end);
|
|
872
|
-
moveRelative(p.start, start);
|
|
873
|
-
moveRelative(p.end, start);
|
|
874
|
-
tabstops[0] = [p];
|
|
875
|
-
tabstops[0].index = 0;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
var i = this.index;
|
|
879
|
-
var arg = [i + 1, 0];
|
|
880
|
-
var ranges = this.ranges;
|
|
881
|
-
tabstops.forEach(function(ts, index) {
|
|
882
|
-
var dest = this.$openTabstops[index] || ts;
|
|
883
|
-
|
|
884
|
-
for (var i = 0; i < ts.length; i++) {
|
|
885
|
-
var p = ts[i];
|
|
886
|
-
var range = Range.fromPoints(p.start, p.end || p.start);
|
|
887
|
-
movePoint(range.start, start);
|
|
888
|
-
movePoint(range.end, start);
|
|
889
|
-
range.original = p;
|
|
890
|
-
range.tabstop = dest;
|
|
891
|
-
ranges.push(range);
|
|
892
|
-
if (dest != ts)
|
|
893
|
-
dest.unshift(range);
|
|
894
|
-
else
|
|
895
|
-
dest[i] = range;
|
|
896
|
-
if (p.fmtString || (dest.firstNonLinked && useLink)) {
|
|
897
|
-
range.linked = true;
|
|
898
|
-
dest.hasLinkedRanges = true;
|
|
899
|
-
} else if (!dest.firstNonLinked)
|
|
900
|
-
dest.firstNonLinked = range;
|
|
901
|
-
}
|
|
902
|
-
if (!dest.firstNonLinked)
|
|
903
|
-
dest.hasLinkedRanges = false;
|
|
904
|
-
if (dest === ts) {
|
|
905
|
-
arg.push(dest);
|
|
906
|
-
this.$openTabstops[index] = dest;
|
|
907
|
-
}
|
|
908
|
-
this.addTabstopMarkers(dest);
|
|
909
|
-
dest.rangeList = dest.rangeList || new RangeList();
|
|
910
|
-
dest.rangeList.$bias = 0;
|
|
911
|
-
dest.rangeList.addList(dest);
|
|
912
|
-
}, this);
|
|
913
|
-
|
|
914
|
-
if (arg.length > 2) {
|
|
915
|
-
if (this.tabstops.length)
|
|
916
|
-
arg.push(arg.splice(2, 1)[0]);
|
|
917
|
-
this.tabstops.splice.apply(this.tabstops, arg);
|
|
918
|
-
}
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
this.addTabstopMarkers = function(ts) {
|
|
922
|
-
var session = this.editor.session;
|
|
923
|
-
ts.forEach(function(range) {
|
|
924
|
-
if (!range.markerId)
|
|
925
|
-
range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
|
|
926
|
-
});
|
|
927
|
-
};
|
|
928
|
-
this.removeTabstopMarkers = function(ts) {
|
|
929
|
-
var session = this.editor.session;
|
|
930
|
-
ts.forEach(function(range) {
|
|
931
|
-
session.removeMarker(range.markerId);
|
|
932
|
-
range.markerId = null;
|
|
933
|
-
});
|
|
934
|
-
};
|
|
935
|
-
this.removeRange = function(range) {
|
|
936
|
-
var i = range.tabstop.indexOf(range);
|
|
937
|
-
if (i != -1) range.tabstop.splice(i, 1);
|
|
938
|
-
i = this.ranges.indexOf(range);
|
|
939
|
-
if (i != -1) this.ranges.splice(i, 1);
|
|
940
|
-
i = range.tabstop.rangeList.ranges.indexOf(range);
|
|
941
|
-
if (i != -1) range.tabstop.splice(i, 1);
|
|
942
|
-
this.editor.session.removeMarker(range.markerId);
|
|
943
|
-
if (!range.tabstop.length) {
|
|
944
|
-
i = this.tabstops.indexOf(range.tabstop);
|
|
945
|
-
if (i != -1)
|
|
946
|
-
this.tabstops.splice(i, 1);
|
|
947
|
-
if (!this.tabstops.length)
|
|
948
|
-
this.detach();
|
|
949
|
-
}
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
this.keyboardHandler = new HashHandler();
|
|
953
|
-
this.keyboardHandler.bindKeys({
|
|
954
|
-
"Tab": function(editor) {
|
|
955
|
-
if (exports.snippetManager && exports.snippetManager.expandWithTab(editor))
|
|
956
|
-
return;
|
|
957
|
-
editor.tabstopManager.tabNext(1);
|
|
958
|
-
editor.renderer.scrollCursorIntoView();
|
|
959
|
-
},
|
|
960
|
-
"Shift-Tab": function(editor) {
|
|
961
|
-
editor.tabstopManager.tabNext(-1);
|
|
962
|
-
editor.renderer.scrollCursorIntoView();
|
|
963
|
-
},
|
|
964
|
-
"Esc": function(editor) {
|
|
965
|
-
editor.tabstopManager.detach();
|
|
966
|
-
}
|
|
967
|
-
});
|
|
968
|
-
}).call(TabstopManager.prototype);
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
var movePoint = function(point, diff) {
|
|
973
|
-
if (point.row == 0)
|
|
974
|
-
point.column += diff.column;
|
|
975
|
-
point.row += diff.row;
|
|
976
|
-
};
|
|
977
|
-
|
|
978
|
-
var moveRelative = function(point, start) {
|
|
979
|
-
if (point.row == start.row)
|
|
980
|
-
point.column -= start.column;
|
|
981
|
-
point.row -= start.row;
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
dom.importCssString("\
|
|
986
|
-
.ace_snippet-marker {\
|
|
987
|
-
-moz-box-sizing: border-box;\
|
|
988
|
-
box-sizing: border-box;\
|
|
989
|
-
background: rgba(194, 193, 208, 0.09);\
|
|
990
|
-
border: 1px dotted rgba(211, 208, 235, 0.62);\
|
|
991
|
-
position: absolute;\
|
|
992
|
-
}", "snippets.css", false);
|
|
993
|
-
|
|
994
|
-
exports.snippetManager = new SnippetManager();
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
var Editor = require("./editor").Editor;
|
|
998
|
-
(function() {
|
|
999
|
-
this.insertSnippet = function(content, options) {
|
|
1000
|
-
return exports.snippetManager.insertSnippet(this, content, options);
|
|
1001
|
-
};
|
|
1002
|
-
this.expandSnippet = function(options) {
|
|
1003
|
-
return exports.snippetManager.expandWithTab(this, options);
|
|
1004
|
-
};
|
|
1005
|
-
}).call(Editor.prototype);
|
|
1006
|
-
|
|
1007
|
-
});
|
|
1008
|
-
|
|
1009
|
-
ace.define("ace/ext/emmet",["require","exports","module","ace/keyboard/hash_handler","ace/editor","ace/snippets","ace/range","ace/config","resources","resources","tabStops","resources","utils","actions"], function(require, exports, module) {
|
|
1010
|
-
"use strict";
|
|
1011
|
-
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
|
1012
|
-
var Editor = require("../editor").Editor;
|
|
1013
|
-
var snippetManager = require("../snippets").snippetManager;
|
|
1014
|
-
var Range = require("../range").Range;
|
|
1015
|
-
var config = require("../config");
|
|
1016
|
-
var emmet, emmetPath;
|
|
1017
|
-
function AceEmmetEditor() {}
|
|
1018
|
-
|
|
1019
|
-
AceEmmetEditor.prototype = {
|
|
1020
|
-
setupContext: function(editor) {
|
|
1021
|
-
this.ace = editor;
|
|
1022
|
-
this.indentation = editor.session.getTabString();
|
|
1023
|
-
if (!emmet)
|
|
1024
|
-
emmet = window.emmet;
|
|
1025
|
-
var resources = emmet.resources || emmet.require("resources");
|
|
1026
|
-
resources.setVariable("indentation", this.indentation);
|
|
1027
|
-
this.$syntax = null;
|
|
1028
|
-
this.$syntax = this.getSyntax();
|
|
1029
|
-
},
|
|
1030
|
-
getSelectionRange: function() {
|
|
1031
|
-
var range = this.ace.getSelectionRange();
|
|
1032
|
-
var doc = this.ace.session.doc;
|
|
1033
|
-
return {
|
|
1034
|
-
start: doc.positionToIndex(range.start),
|
|
1035
|
-
end: doc.positionToIndex(range.end)
|
|
1036
|
-
};
|
|
1037
|
-
},
|
|
1038
|
-
createSelection: function(start, end) {
|
|
1039
|
-
var doc = this.ace.session.doc;
|
|
1040
|
-
this.ace.selection.setRange({
|
|
1041
|
-
start: doc.indexToPosition(start),
|
|
1042
|
-
end: doc.indexToPosition(end)
|
|
1043
|
-
});
|
|
1044
|
-
},
|
|
1045
|
-
getCurrentLineRange: function() {
|
|
1046
|
-
var ace = this.ace;
|
|
1047
|
-
var row = ace.getCursorPosition().row;
|
|
1048
|
-
var lineLength = ace.session.getLine(row).length;
|
|
1049
|
-
var index = ace.session.doc.positionToIndex({row: row, column: 0});
|
|
1050
|
-
return {
|
|
1051
|
-
start: index,
|
|
1052
|
-
end: index + lineLength
|
|
1053
|
-
};
|
|
1054
|
-
},
|
|
1055
|
-
getCaretPos: function(){
|
|
1056
|
-
var pos = this.ace.getCursorPosition();
|
|
1057
|
-
return this.ace.session.doc.positionToIndex(pos);
|
|
1058
|
-
},
|
|
1059
|
-
setCaretPos: function(index){
|
|
1060
|
-
var pos = this.ace.session.doc.indexToPosition(index);
|
|
1061
|
-
this.ace.selection.moveToPosition(pos);
|
|
1062
|
-
},
|
|
1063
|
-
getCurrentLine: function() {
|
|
1064
|
-
var row = this.ace.getCursorPosition().row;
|
|
1065
|
-
return this.ace.session.getLine(row);
|
|
1066
|
-
},
|
|
1067
|
-
replaceContent: function(value, start, end, noIndent) {
|
|
1068
|
-
if (end == null)
|
|
1069
|
-
end = start == null ? this.getContent().length : start;
|
|
1070
|
-
if (start == null)
|
|
1071
|
-
start = 0;
|
|
1072
|
-
|
|
1073
|
-
var editor = this.ace;
|
|
1074
|
-
var doc = editor.session.doc;
|
|
1075
|
-
var range = Range.fromPoints(doc.indexToPosition(start), doc.indexToPosition(end));
|
|
1076
|
-
editor.session.remove(range);
|
|
1077
|
-
|
|
1078
|
-
range.end = range.start;
|
|
1079
|
-
|
|
1080
|
-
value = this.$updateTabstops(value);
|
|
1081
|
-
snippetManager.insertSnippet(editor, value);
|
|
1082
|
-
},
|
|
1083
|
-
getContent: function(){
|
|
1084
|
-
return this.ace.getValue();
|
|
1085
|
-
},
|
|
1086
|
-
getSyntax: function() {
|
|
1087
|
-
if (this.$syntax)
|
|
1088
|
-
return this.$syntax;
|
|
1089
|
-
var syntax = this.ace.session.$modeId.split("/").pop();
|
|
1090
|
-
if (syntax == "html" || syntax == "php") {
|
|
1091
|
-
var cursor = this.ace.getCursorPosition();
|
|
1092
|
-
var state = this.ace.session.getState(cursor.row);
|
|
1093
|
-
if (typeof state != "string")
|
|
1094
|
-
state = state[0];
|
|
1095
|
-
if (state) {
|
|
1096
|
-
state = state.split("-");
|
|
1097
|
-
if (state.length > 1)
|
|
1098
|
-
syntax = state[0];
|
|
1099
|
-
else if (syntax == "php")
|
|
1100
|
-
syntax = "html";
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
return syntax;
|
|
1104
|
-
},
|
|
1105
|
-
getProfileName: function() {
|
|
1106
|
-
var resources = emmet.resources || emmet.require("resources");
|
|
1107
|
-
switch (this.getSyntax()) {
|
|
1108
|
-
case "css": return "css";
|
|
1109
|
-
case "xml":
|
|
1110
|
-
case "xsl":
|
|
1111
|
-
return "xml";
|
|
1112
|
-
case "html":
|
|
1113
|
-
var profile = resources.getVariable("profile");
|
|
1114
|
-
if (!profile)
|
|
1115
|
-
profile = this.ace.session.getLines(0,2).join("").search(/<!DOCTYPE[^>]+XHTML/i) != -1 ? "xhtml": "html";
|
|
1116
|
-
return profile;
|
|
1117
|
-
default:
|
|
1118
|
-
var mode = this.ace.session.$mode;
|
|
1119
|
-
return mode.emmetConfig && mode.emmetConfig.profile || "xhtml";
|
|
1120
|
-
}
|
|
1121
|
-
},
|
|
1122
|
-
prompt: function(title) {
|
|
1123
|
-
return prompt(title); // eslint-disable-line no-alert
|
|
1124
|
-
},
|
|
1125
|
-
getSelection: function() {
|
|
1126
|
-
return this.ace.session.getTextRange();
|
|
1127
|
-
},
|
|
1128
|
-
getFilePath: function() {
|
|
1129
|
-
return "";
|
|
1130
|
-
},
|
|
1131
|
-
$updateTabstops: function(value) {
|
|
1132
|
-
var base = 1000;
|
|
1133
|
-
var zeroBase = 0;
|
|
1134
|
-
var lastZero = null;
|
|
1135
|
-
var ts = emmet.tabStops || emmet.require('tabStops');
|
|
1136
|
-
var resources = emmet.resources || emmet.require("resources");
|
|
1137
|
-
var settings = resources.getVocabulary("user");
|
|
1138
|
-
var tabstopOptions = {
|
|
1139
|
-
tabstop: function(data) {
|
|
1140
|
-
var group = parseInt(data.group, 10);
|
|
1141
|
-
var isZero = group === 0;
|
|
1142
|
-
if (isZero)
|
|
1143
|
-
group = ++zeroBase;
|
|
1144
|
-
else
|
|
1145
|
-
group += base;
|
|
1146
|
-
|
|
1147
|
-
var placeholder = data.placeholder;
|
|
1148
|
-
if (placeholder) {
|
|
1149
|
-
placeholder = ts.processText(placeholder, tabstopOptions);
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}';
|
|
1153
|
-
|
|
1154
|
-
if (isZero) {
|
|
1155
|
-
lastZero = [data.start, result];
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
return result;
|
|
1159
|
-
},
|
|
1160
|
-
escape: function(ch) {
|
|
1161
|
-
if (ch == '$') return '\\$';
|
|
1162
|
-
if (ch == '\\') return '\\\\';
|
|
1163
|
-
return ch;
|
|
1164
|
-
}
|
|
1165
|
-
};
|
|
1166
|
-
|
|
1167
|
-
value = ts.processText(value, tabstopOptions);
|
|
1168
|
-
|
|
1169
|
-
if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) {
|
|
1170
|
-
value += '${0}';
|
|
1171
|
-
} else if (lastZero) {
|
|
1172
|
-
var common = emmet.utils ? emmet.utils.common : emmet.require('utils');
|
|
1173
|
-
value = common.replaceSubstring(value, '${0}', lastZero[0], lastZero[1]);
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
return value;
|
|
1177
|
-
}
|
|
1178
|
-
};
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
var keymap = {
|
|
1182
|
-
expand_abbreviation: {"mac": "ctrl+alt+e", "win": "alt+e"},
|
|
1183
|
-
match_pair_outward: {"mac": "ctrl+d", "win": "ctrl+,"},
|
|
1184
|
-
match_pair_inward: {"mac": "ctrl+j", "win": "ctrl+shift+0"},
|
|
1185
|
-
matching_pair: {"mac": "ctrl+alt+j", "win": "alt+j"},
|
|
1186
|
-
next_edit_point: "alt+right",
|
|
1187
|
-
prev_edit_point: "alt+left",
|
|
1188
|
-
toggle_comment: {"mac": "command+/", "win": "ctrl+/"},
|
|
1189
|
-
split_join_tag: {"mac": "shift+command+'", "win": "shift+ctrl+`"},
|
|
1190
|
-
remove_tag: {"mac": "command+'", "win": "shift+ctrl+;"},
|
|
1191
|
-
evaluate_math_expression: {"mac": "shift+command+y", "win": "shift+ctrl+y"},
|
|
1192
|
-
increment_number_by_1: "ctrl+up",
|
|
1193
|
-
decrement_number_by_1: "ctrl+down",
|
|
1194
|
-
increment_number_by_01: "alt+up",
|
|
1195
|
-
decrement_number_by_01: "alt+down",
|
|
1196
|
-
increment_number_by_10: {"mac": "alt+command+up", "win": "shift+alt+up"},
|
|
1197
|
-
decrement_number_by_10: {"mac": "alt+command+down", "win": "shift+alt+down"},
|
|
1198
|
-
select_next_item: {"mac": "shift+command+.", "win": "shift+ctrl+."},
|
|
1199
|
-
select_previous_item: {"mac": "shift+command+,", "win": "shift+ctrl+,"},
|
|
1200
|
-
reflect_css_value: {"mac": "shift+command+r", "win": "shift+ctrl+r"},
|
|
1201
|
-
|
|
1202
|
-
encode_decode_data_url: {"mac": "shift+ctrl+d", "win": "ctrl+'"},
|
|
1203
|
-
expand_abbreviation_with_tab: "Tab",
|
|
1204
|
-
wrap_with_abbreviation: {"mac": "shift+ctrl+a", "win": "shift+ctrl+a"}
|
|
1205
|
-
};
|
|
1206
|
-
|
|
1207
|
-
var editorProxy = new AceEmmetEditor();
|
|
1208
|
-
exports.commands = new HashHandler();
|
|
1209
|
-
exports.runEmmetCommand = function runEmmetCommand(editor) {
|
|
1210
|
-
if (this.action == "expand_abbreviation_with_tab") {
|
|
1211
|
-
if (!editor.selection.isEmpty())
|
|
1212
|
-
return false;
|
|
1213
|
-
var pos = editor.selection.lead;
|
|
1214
|
-
var token = editor.session.getTokenAt(pos.row, pos.column);
|
|
1215
|
-
if (token && /\btag\b/.test(token.type))
|
|
1216
|
-
return false;
|
|
1217
|
-
}
|
|
1218
|
-
try {
|
|
1219
|
-
editorProxy.setupContext(editor);
|
|
1220
|
-
var actions = emmet.actions || emmet.require("actions");
|
|
1221
|
-
|
|
1222
|
-
if (this.action == "wrap_with_abbreviation") {
|
|
1223
|
-
return setTimeout(function() {
|
|
1224
|
-
actions.run("wrap_with_abbreviation", editorProxy);
|
|
1225
|
-
}, 0);
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
var result = actions.run(this.action, editorProxy);
|
|
1229
|
-
} catch(e) {
|
|
1230
|
-
if (!emmet) {
|
|
1231
|
-
var loading = exports.load(runEmmetCommand.bind(this, editor));
|
|
1232
|
-
if (this.action == "expand_abbreviation_with_tab")
|
|
1233
|
-
return false;
|
|
1234
|
-
return loading;
|
|
1235
|
-
}
|
|
1236
|
-
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
|
|
1237
|
-
config.warn(e);
|
|
1238
|
-
result = false;
|
|
1239
|
-
}
|
|
1240
|
-
return result;
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1243
|
-
for (var command in keymap) {
|
|
1244
|
-
exports.commands.addCommand({
|
|
1245
|
-
name: "emmet:" + command,
|
|
1246
|
-
action: command,
|
|
1247
|
-
bindKey: keymap[command],
|
|
1248
|
-
exec: exports.runEmmetCommand,
|
|
1249
|
-
multiSelectAction: "forEach"
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
exports.updateCommands = function(editor, enabled) {
|
|
1254
|
-
if (enabled) {
|
|
1255
|
-
editor.keyBinding.addKeyboardHandler(exports.commands);
|
|
1256
|
-
} else {
|
|
1257
|
-
editor.keyBinding.removeKeyboardHandler(exports.commands);
|
|
1258
|
-
}
|
|
1259
|
-
};
|
|
1260
|
-
|
|
1261
|
-
exports.isSupportedMode = function(mode) {
|
|
1262
|
-
if (!mode) return false;
|
|
1263
|
-
if (mode.emmetConfig) return true;
|
|
1264
|
-
var id = mode.$id || mode;
|
|
1265
|
-
return /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(id);
|
|
1266
|
-
};
|
|
1267
|
-
|
|
1268
|
-
exports.isAvailable = function(editor, command) {
|
|
1269
|
-
if (/(evaluate_math_expression|expand_abbreviation)$/.test(command))
|
|
1270
|
-
return true;
|
|
1271
|
-
var mode = editor.session.$mode;
|
|
1272
|
-
var isSupported = exports.isSupportedMode(mode);
|
|
1273
|
-
if (isSupported && mode.$modes) {
|
|
1274
|
-
try {
|
|
1275
|
-
editorProxy.setupContext(editor);
|
|
1276
|
-
if (/js|php/.test(editorProxy.getSyntax()))
|
|
1277
|
-
isSupported = false;
|
|
1278
|
-
} catch(e) {}
|
|
1279
|
-
}
|
|
1280
|
-
return isSupported;
|
|
1281
|
-
};
|
|
1282
|
-
|
|
1283
|
-
var onChangeMode = function(e, target) {
|
|
1284
|
-
var editor = target;
|
|
1285
|
-
if (!editor)
|
|
1286
|
-
return;
|
|
1287
|
-
var enabled = exports.isSupportedMode(editor.session.$mode);
|
|
1288
|
-
if (e.enableEmmet === false)
|
|
1289
|
-
enabled = false;
|
|
1290
|
-
if (enabled)
|
|
1291
|
-
exports.load();
|
|
1292
|
-
exports.updateCommands(editor, enabled);
|
|
1293
|
-
};
|
|
1294
|
-
|
|
1295
|
-
exports.load = function(cb) {
|
|
1296
|
-
if (typeof emmetPath !== "string") {
|
|
1297
|
-
config.warn("script for emmet-core is not loaded");
|
|
1298
|
-
return false;
|
|
1299
|
-
}
|
|
1300
|
-
config.loadModule(emmetPath, function() {
|
|
1301
|
-
emmetPath = null;
|
|
1302
|
-
cb && cb();
|
|
1303
|
-
});
|
|
1304
|
-
return true;
|
|
1305
|
-
};
|
|
1306
|
-
|
|
1307
|
-
exports.AceEmmetEditor = AceEmmetEditor;
|
|
1308
|
-
config.defineOptions(Editor.prototype, "editor", {
|
|
1309
|
-
enableEmmet: {
|
|
1310
|
-
set: function(val) {
|
|
1311
|
-
this[val ? "on" : "removeListener"]("changeMode", onChangeMode);
|
|
1312
|
-
onChangeMode({enableEmmet: !!val}, this);
|
|
1313
|
-
},
|
|
1314
|
-
value: true
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1317
|
-
|
|
1318
|
-
exports.setCore = function(e) {
|
|
1319
|
-
if (typeof e == "string")
|
|
1320
|
-
emmetPath = e;
|
|
1321
|
-
else
|
|
1322
|
-
emmet = e;
|
|
1323
|
-
};
|
|
1324
|
-
}); (function() {
|
|
1325
|
-
ace.require(["ace/ext/emmet"], function(m) {
|
|
1326
|
-
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
1327
|
-
module.exports = m;
|
|
1328
|
-
}
|
|
1329
|
-
});
|
|
1330
|
-
})();
|
|
1331
|
-
|