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