@tailor-cms/ce-html-edit 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1738 @@
1
+ "use strict";
2
+ var import_style = require("./style.css");
3
+ ace.define("ace/snippets", ["require", "exports", "module", "ace/lib/oop", "ace/lib/event_emitter", "ace/lib/lang", "ace/range", "ace/anchor", "ace/keyboard/hash_handler", "ace/tokenizer", "ace/lib/dom", "ace/editor"], function(acequire, exports2, module2) {
4
+ var oop = acequire("./lib/oop");
5
+ var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
6
+ var lang = acequire("./lib/lang");
7
+ var Range = acequire("./range").Range;
8
+ var Anchor = acequire("./anchor").Anchor;
9
+ var HashHandler = acequire("./keyboard/hash_handler").HashHandler;
10
+ var Tokenizer = acequire("./tokenizer").Tokenizer;
11
+ var comparePoints = Range.comparePoints;
12
+ var SnippetManager = function() {
13
+ this.snippetMap = {};
14
+ this.snippetNameMap = {};
15
+ };
16
+ (function() {
17
+ oop.implement(this, EventEmitter);
18
+ this.getTokenizer = function() {
19
+ function TabstopToken(str, _, stack) {
20
+ str = str.substr(1);
21
+ if (/^\d+$/.test(str) && !stack.inFormatString)
22
+ return [{ tabstopId: parseInt(str, 10) }];
23
+ return [{ text: str }];
24
+ }
25
+ function escape(ch) {
26
+ return "(?:[^\\\\" + ch + "]|\\\\.)";
27
+ }
28
+ SnippetManager.$tokenizer = new Tokenizer({
29
+ start: [
30
+ { regex: /:/, onMatch: function(val, state, stack) {
31
+ if (stack.length && stack[0].expectIf) {
32
+ stack[0].expectIf = false;
33
+ stack[0].elseBranch = stack[0];
34
+ return [stack[0]];
35
+ }
36
+ return ":";
37
+ } },
38
+ { regex: /\\./, onMatch: function(val, state, stack) {
39
+ var ch = val[1];
40
+ if (ch == "}" && stack.length) {
41
+ val = ch;
42
+ } else if ("`$\\".indexOf(ch) != -1) {
43
+ val = ch;
44
+ } else if (stack.inFormatString) {
45
+ if (ch == "n")
46
+ val = "\n";
47
+ else if (ch == "t")
48
+ val = "\n";
49
+ else if ("ulULE".indexOf(ch) != -1) {
50
+ val = { changeCase: ch, local: ch > "a" };
51
+ }
52
+ }
53
+ return [val];
54
+ } },
55
+ { regex: /}/, onMatch: function(val, state, stack) {
56
+ return [stack.length ? stack.shift() : val];
57
+ } },
58
+ { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken },
59
+ { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function(str, state, stack) {
60
+ var t = TabstopToken(str.substr(1), state, stack);
61
+ stack.unshift(t[0]);
62
+ return t;
63
+ }, next: "snippetVar" },
64
+ { regex: /\n/, token: "newline", merge: false }
65
+ ],
66
+ snippetVar: [
67
+ { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
68
+ stack[0].choices = val.slice(1, -1).split(",");
69
+ }, next: "start" },
70
+ {
71
+ regex: "/(" + escape("/") + "+)/(?:(" + escape("/") + "*)/)(\\w*):?",
72
+ onMatch: function(val, state, stack) {
73
+ var ts = stack[0];
74
+ ts.fmtString = val;
75
+ val = this.splitRegex.exec(val);
76
+ ts.guard = val[1];
77
+ ts.fmt = val[2];
78
+ ts.flag = val[3];
79
+ return "";
80
+ },
81
+ next: "start"
82
+ },
83
+ { regex: "`" + escape("`") + "*`", onMatch: function(val, state, stack) {
84
+ stack[0].code = val.splice(1, -1);
85
+ return "";
86
+ }, next: "start" },
87
+ { regex: "\\?", onMatch: function(val, state, stack) {
88
+ if (stack[0])
89
+ stack[0].expectIf = true;
90
+ }, next: "start" },
91
+ { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" }
92
+ ],
93
+ formatString: [
94
+ { regex: "/(" + escape("/") + "+)/", token: "regex" },
95
+ { regex: "", onMatch: function(val, state, stack) {
96
+ stack.inFormatString = true;
97
+ }, next: "start" }
98
+ ]
99
+ });
100
+ SnippetManager.prototype.getTokenizer = function() {
101
+ return SnippetManager.$tokenizer;
102
+ };
103
+ return SnippetManager.$tokenizer;
104
+ };
105
+ this.tokenizeTmSnippet = function(str, startState) {
106
+ return this.getTokenizer().getLineTokens(str, startState).tokens.map(function(x) {
107
+ return x.value || x;
108
+ });
109
+ };
110
+ this.$getDefaultValue = function(editor, name) {
111
+ if (/^[A-Z]\d+$/.test(name)) {
112
+ var i = name.substr(1);
113
+ return (this.variables[name[0] + "__"] || {})[i];
114
+ }
115
+ if (/^\d+$/.test(name)) {
116
+ return (this.variables.__ || {})[name];
117
+ }
118
+ name = name.replace(/^TM_/, "");
119
+ if (!editor)
120
+ return;
121
+ var s = editor.session;
122
+ switch (name) {
123
+ case "CURRENT_WORD":
124
+ var r = s.getWordRange();
125
+ case "SELECTION":
126
+ case "SELECTED_TEXT":
127
+ return s.getTextRange(r);
128
+ case "CURRENT_LINE":
129
+ return s.getLine(editor.getCursorPosition().row);
130
+ case "PREV_LINE":
131
+ return s.getLine(editor.getCursorPosition().row - 1);
132
+ case "LINE_INDEX":
133
+ return editor.getCursorPosition().column;
134
+ case "LINE_NUMBER":
135
+ return editor.getCursorPosition().row + 1;
136
+ case "SOFT_TABS":
137
+ return s.getUseSoftTabs() ? "YES" : "NO";
138
+ case "TAB_SIZE":
139
+ return s.getTabSize();
140
+ case "FILENAME":
141
+ case "FILEPATH":
142
+ return "";
143
+ case "FULLNAME":
144
+ return "Ace";
145
+ }
146
+ };
147
+ this.variables = {};
148
+ this.getVariableValue = function(editor, varName) {
149
+ if (this.variables.hasOwnProperty(varName))
150
+ return this.variables[varName](editor, varName) || "";
151
+ return this.$getDefaultValue(editor, varName) || "";
152
+ };
153
+ this.tmStrFormat = function(str, ch, editor) {
154
+ var flag = ch.flag || "";
155
+ var re = ch.guard;
156
+ re = new RegExp(re, flag.replace(/[^gi]/, ""));
157
+ var fmtTokens = this.tokenizeTmSnippet(ch.fmt, "formatString");
158
+ var _self = this;
159
+ var formatted = str.replace(re, function() {
160
+ _self.variables.__ = arguments;
161
+ var fmtParts = _self.resolveVariables(fmtTokens, editor);
162
+ var gChangeCase = "E";
163
+ for (var i = 0; i < fmtParts.length; i++) {
164
+ var ch2 = fmtParts[i];
165
+ if (typeof ch2 == "object") {
166
+ fmtParts[i] = "";
167
+ if (ch2.changeCase && ch2.local) {
168
+ var next = fmtParts[i + 1];
169
+ if (next && typeof next == "string") {
170
+ if (ch2.changeCase == "u")
171
+ fmtParts[i] = next[0].toUpperCase();
172
+ else
173
+ fmtParts[i] = next[0].toLowerCase();
174
+ fmtParts[i + 1] = next.substr(1);
175
+ }
176
+ } else if (ch2.changeCase) {
177
+ gChangeCase = ch2.changeCase;
178
+ }
179
+ } else if (gChangeCase == "U") {
180
+ fmtParts[i] = ch2.toUpperCase();
181
+ } else if (gChangeCase == "L") {
182
+ fmtParts[i] = ch2.toLowerCase();
183
+ }
184
+ }
185
+ return fmtParts.join("");
186
+ });
187
+ this.variables.__ = null;
188
+ return formatted;
189
+ };
190
+ this.resolveVariables = function(snippet, editor) {
191
+ var result = [];
192
+ for (var i = 0; i < snippet.length; i++) {
193
+ var ch = snippet[i];
194
+ if (typeof ch == "string") {
195
+ result.push(ch);
196
+ } else if (typeof ch != "object") {
197
+ continue;
198
+ } else if (ch.skip) {
199
+ gotoNext(ch);
200
+ } else if (ch.processed < i) {
201
+ continue;
202
+ } else if (ch.text) {
203
+ var value = this.getVariableValue(editor, ch.text);
204
+ if (value && ch.fmtString)
205
+ value = this.tmStrFormat(value, ch);
206
+ ch.processed = i;
207
+ if (ch.expectIf == null) {
208
+ if (value) {
209
+ result.push(value);
210
+ gotoNext(ch);
211
+ }
212
+ } else {
213
+ if (value) {
214
+ ch.skip = ch.elseBranch;
215
+ } else
216
+ gotoNext(ch);
217
+ }
218
+ } else if (ch.tabstopId != null) {
219
+ result.push(ch);
220
+ } else if (ch.changeCase != null) {
221
+ result.push(ch);
222
+ }
223
+ }
224
+ function gotoNext(ch2) {
225
+ var i1 = snippet.indexOf(ch2, i + 1);
226
+ if (i1 != -1)
227
+ i = i1;
228
+ }
229
+ return result;
230
+ };
231
+ this.insertSnippetForSelection = function(editor, snippetText) {
232
+ var cursor = editor.getCursorPosition();
233
+ var line = editor.session.getLine(cursor.row);
234
+ var tabString = editor.session.getTabString();
235
+ var indentString = line.match(/^\s*/)[0];
236
+ if (cursor.column < indentString.length)
237
+ indentString = indentString.slice(0, cursor.column);
238
+ snippetText = snippetText.replace(/\r/g, "");
239
+ var tokens = this.tokenizeTmSnippet(snippetText);
240
+ tokens = this.resolveVariables(tokens, editor);
241
+ tokens = tokens.map(function(x) {
242
+ if (x == "\n")
243
+ return x + indentString;
244
+ if (typeof x == "string")
245
+ return x.replace(/\t/g, tabString);
246
+ return x;
247
+ });
248
+ var tabstops = [];
249
+ tokens.forEach(function(p2, i2) {
250
+ if (typeof p2 != "object")
251
+ return;
252
+ var id2 = p2.tabstopId;
253
+ var ts2 = tabstops[id2];
254
+ if (!ts2) {
255
+ ts2 = tabstops[id2] = [];
256
+ ts2.index = id2;
257
+ ts2.value = "";
258
+ }
259
+ if (ts2.indexOf(p2) !== -1)
260
+ return;
261
+ ts2.push(p2);
262
+ var i12 = tokens.indexOf(p2, i2 + 1);
263
+ if (i12 === -1)
264
+ return;
265
+ var value = tokens.slice(i2 + 1, i12);
266
+ var isNested = value.some(function(t) {
267
+ return typeof t === "object";
268
+ });
269
+ if (isNested && !ts2.value) {
270
+ ts2.value = value;
271
+ } else if (value.length && (!ts2.value || typeof ts2.value !== "string")) {
272
+ ts2.value = value.join("");
273
+ }
274
+ });
275
+ tabstops.forEach(function(ts2) {
276
+ ts2.length = 0;
277
+ });
278
+ var expanding = {};
279
+ function copyValue(val) {
280
+ var copy = [];
281
+ for (var i2 = 0; i2 < val.length; i2++) {
282
+ var p2 = val[i2];
283
+ if (typeof p2 == "object") {
284
+ if (expanding[p2.tabstopId])
285
+ continue;
286
+ var j = val.lastIndexOf(p2, i2 - 1);
287
+ p2 = copy[j] || { tabstopId: p2.tabstopId };
288
+ }
289
+ copy[i2] = p2;
290
+ }
291
+ return copy;
292
+ }
293
+ for (var i = 0; i < tokens.length; i++) {
294
+ var p = tokens[i];
295
+ if (typeof p != "object")
296
+ continue;
297
+ var id = p.tabstopId;
298
+ var i1 = tokens.indexOf(p, i + 1);
299
+ if (expanding[id]) {
300
+ if (expanding[id] === p)
301
+ expanding[id] = null;
302
+ continue;
303
+ }
304
+ var ts = tabstops[id];
305
+ var arg = typeof ts.value == "string" ? [ts.value] : copyValue(ts.value);
306
+ arg.unshift(i + 1, Math.max(0, i1 - i));
307
+ arg.push(p);
308
+ expanding[id] = p;
309
+ tokens.splice.apply(tokens, arg);
310
+ if (ts.indexOf(p) === -1)
311
+ ts.push(p);
312
+ }
313
+ var row = 0, column = 0;
314
+ var text = "";
315
+ tokens.forEach(function(t) {
316
+ if (typeof t === "string") {
317
+ var lines = t.split("\n");
318
+ if (lines.length > 1) {
319
+ column = lines[lines.length - 1].length;
320
+ row += lines.length - 1;
321
+ } else
322
+ column += t.length;
323
+ text += t;
324
+ } else {
325
+ if (!t.start)
326
+ t.start = { row, column };
327
+ else
328
+ t.end = { row, column };
329
+ }
330
+ });
331
+ var range = editor.getSelectionRange();
332
+ var end = editor.session.replace(range, text);
333
+ var tabstopManager = new TabstopManager(editor);
334
+ var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
335
+ tabstopManager.addTabstops(tabstops, range.start, end, selectionId);
336
+ };
337
+ this.insertSnippet = function(editor, snippetText) {
338
+ var self = this;
339
+ if (editor.inVirtualSelectionMode)
340
+ return self.insertSnippetForSelection(editor, snippetText);
341
+ editor.forEachSelection(function() {
342
+ self.insertSnippetForSelection(editor, snippetText);
343
+ }, null, { keepOrder: true });
344
+ if (editor.tabstopManager)
345
+ editor.tabstopManager.tabNext();
346
+ };
347
+ this.$getScope = function(editor) {
348
+ var scope = editor.session.$mode.$id || "";
349
+ scope = scope.split("/").pop();
350
+ if (scope === "html" || scope === "php") {
351
+ if (scope === "php" && !editor.session.$mode.inlinePhp)
352
+ scope = "html";
353
+ var c = editor.getCursorPosition();
354
+ var state = editor.session.getState(c.row);
355
+ if (typeof state === "object") {
356
+ state = state[0];
357
+ }
358
+ if (state.substring) {
359
+ if (state.substring(0, 3) == "js-")
360
+ scope = "javascript";
361
+ else if (state.substring(0, 4) == "css-")
362
+ scope = "css";
363
+ else if (state.substring(0, 4) == "php-")
364
+ scope = "php";
365
+ }
366
+ }
367
+ return scope;
368
+ };
369
+ this.getActiveScopes = function(editor) {
370
+ var scope = this.$getScope(editor);
371
+ var scopes = [scope];
372
+ var snippetMap = this.snippetMap;
373
+ if (snippetMap[scope] && snippetMap[scope].includeScopes) {
374
+ scopes.push.apply(scopes, snippetMap[scope].includeScopes);
375
+ }
376
+ scopes.push("_");
377
+ return scopes;
378
+ };
379
+ this.expandWithTab = function(editor, options) {
380
+ var self = this;
381
+ var result = editor.forEachSelection(function() {
382
+ return self.expandSnippetForSelection(editor, options);
383
+ }, null, { keepOrder: true });
384
+ if (result && editor.tabstopManager)
385
+ editor.tabstopManager.tabNext();
386
+ return result;
387
+ };
388
+ this.expandSnippetForSelection = function(editor, options) {
389
+ var cursor = editor.getCursorPosition();
390
+ var line = editor.session.getLine(cursor.row);
391
+ var before = line.substring(0, cursor.column);
392
+ var after = line.substr(cursor.column);
393
+ var snippetMap = this.snippetMap;
394
+ var snippet;
395
+ this.getActiveScopes(editor).some(function(scope) {
396
+ var snippets = snippetMap[scope];
397
+ if (snippets)
398
+ snippet = this.findMatchingSnippet(snippets, before, after);
399
+ return !!snippet;
400
+ }, this);
401
+ if (!snippet)
402
+ return false;
403
+ if (options && options.dryRun)
404
+ return true;
405
+ editor.session.doc.removeInLine(
406
+ cursor.row,
407
+ cursor.column - snippet.replaceBefore.length,
408
+ cursor.column + snippet.replaceAfter.length
409
+ );
410
+ this.variables.M__ = snippet.matchBefore;
411
+ this.variables.T__ = snippet.matchAfter;
412
+ this.insertSnippetForSelection(editor, snippet.content);
413
+ this.variables.M__ = this.variables.T__ = null;
414
+ return true;
415
+ };
416
+ this.findMatchingSnippet = function(snippetList, before, after) {
417
+ for (var i = snippetList.length; i--; ) {
418
+ var s = snippetList[i];
419
+ if (s.startRe && !s.startRe.test(before))
420
+ continue;
421
+ if (s.endRe && !s.endRe.test(after))
422
+ continue;
423
+ if (!s.startRe && !s.endRe)
424
+ continue;
425
+ s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
426
+ s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
427
+ s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
428
+ s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : "";
429
+ return s;
430
+ }
431
+ };
432
+ this.snippetMap = {};
433
+ this.snippetNameMap = {};
434
+ this.register = function(snippets, scope) {
435
+ var snippetMap = this.snippetMap;
436
+ var snippetNameMap = this.snippetNameMap;
437
+ var self = this;
438
+ if (!snippets)
439
+ snippets = [];
440
+ function wrapRegexp(src) {
441
+ if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
442
+ src = "(?:" + src + ")";
443
+ return src || "";
444
+ }
445
+ function guardedRegexp(re, guard, opening) {
446
+ re = wrapRegexp(re);
447
+ guard = wrapRegexp(guard);
448
+ if (opening) {
449
+ re = guard + re;
450
+ if (re && re[re.length - 1] != "$")
451
+ re = re + "$";
452
+ } else {
453
+ re = re + guard;
454
+ if (re && re[0] != "^")
455
+ re = "^" + re;
456
+ }
457
+ return new RegExp(re);
458
+ }
459
+ function addSnippet(s) {
460
+ if (!s.scope)
461
+ s.scope = scope || "_";
462
+ scope = s.scope;
463
+ if (!snippetMap[scope]) {
464
+ snippetMap[scope] = [];
465
+ snippetNameMap[scope] = {};
466
+ }
467
+ var map = snippetNameMap[scope];
468
+ if (s.name) {
469
+ var old = map[s.name];
470
+ if (old)
471
+ self.unregister(old);
472
+ map[s.name] = s;
473
+ }
474
+ snippetMap[scope].push(s);
475
+ if (s.tabTrigger && !s.trigger) {
476
+ if (!s.guard && /^\w/.test(s.tabTrigger))
477
+ s.guard = "\\b";
478
+ s.trigger = lang.escapeRegExp(s.tabTrigger);
479
+ }
480
+ if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard)
481
+ return;
482
+ s.startRe = guardedRegexp(s.trigger, s.guard, true);
483
+ s.triggerRe = new RegExp(s.trigger, "", true);
484
+ s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
485
+ s.endTriggerRe = new RegExp(s.endTrigger, "", true);
486
+ }
487
+ if (snippets && snippets.content)
488
+ addSnippet(snippets);
489
+ else if (Array.isArray(snippets))
490
+ snippets.forEach(addSnippet);
491
+ this._signal("registerSnippets", { scope });
492
+ };
493
+ this.unregister = function(snippets, scope) {
494
+ var snippetMap = this.snippetMap;
495
+ var snippetNameMap = this.snippetNameMap;
496
+ function removeSnippet(s) {
497
+ var nameMap = snippetNameMap[s.scope || scope];
498
+ if (nameMap && nameMap[s.name]) {
499
+ delete nameMap[s.name];
500
+ var map = snippetMap[s.scope || scope];
501
+ var i = map && map.indexOf(s);
502
+ if (i >= 0)
503
+ map.splice(i, 1);
504
+ }
505
+ }
506
+ if (snippets.content)
507
+ removeSnippet(snippets);
508
+ else if (Array.isArray(snippets))
509
+ snippets.forEach(removeSnippet);
510
+ };
511
+ this.parseSnippetFile = function(str) {
512
+ str = str.replace(/\r/g, "");
513
+ var list = [], snippet = {};
514
+ var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
515
+ var m;
516
+ while (m = re.exec(str)) {
517
+ if (m[1]) {
518
+ try {
519
+ snippet = JSON.parse(m[1]);
520
+ list.push(snippet);
521
+ } catch (e) {
522
+ }
523
+ }
524
+ if (m[4]) {
525
+ snippet.content = m[4].replace(/^\t/gm, "");
526
+ list.push(snippet);
527
+ snippet = {};
528
+ } else {
529
+ var key = m[2], val = m[3];
530
+ if (key == "regex") {
531
+ var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
532
+ snippet.guard = guardRe.exec(val)[1];
533
+ snippet.trigger = guardRe.exec(val)[1];
534
+ snippet.endTrigger = guardRe.exec(val)[1];
535
+ snippet.endGuard = guardRe.exec(val)[1];
536
+ } else if (key == "snippet") {
537
+ snippet.tabTrigger = val.match(/^\S*/)[0];
538
+ if (!snippet.name)
539
+ snippet.name = val;
540
+ } else {
541
+ snippet[key] = val;
542
+ }
543
+ }
544
+ }
545
+ return list;
546
+ };
547
+ this.getSnippetByName = function(name, editor) {
548
+ var snippetMap = this.snippetNameMap;
549
+ var snippet;
550
+ this.getActiveScopes(editor).some(function(scope) {
551
+ var snippets = snippetMap[scope];
552
+ if (snippets)
553
+ snippet = snippets[name];
554
+ return !!snippet;
555
+ }, this);
556
+ return snippet;
557
+ };
558
+ }).call(SnippetManager.prototype);
559
+ var TabstopManager = function(editor) {
560
+ if (editor.tabstopManager)
561
+ return editor.tabstopManager;
562
+ editor.tabstopManager = this;
563
+ this.$onChange = this.onChange.bind(this);
564
+ this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
565
+ this.$onChangeSession = this.onChangeSession.bind(this);
566
+ this.$onAfterExec = this.onAfterExec.bind(this);
567
+ this.attach(editor);
568
+ };
569
+ (function() {
570
+ this.attach = function(editor) {
571
+ this.index = 0;
572
+ this.ranges = [];
573
+ this.tabstops = [];
574
+ this.$openTabstops = null;
575
+ this.selectedTabstop = null;
576
+ this.editor = editor;
577
+ this.editor.on("change", this.$onChange);
578
+ this.editor.on("changeSelection", this.$onChangeSelection);
579
+ this.editor.on("changeSession", this.$onChangeSession);
580
+ this.editor.commands.on("afterExec", this.$onAfterExec);
581
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
582
+ };
583
+ this.detach = function() {
584
+ this.tabstops.forEach(this.removeTabstopMarkers, this);
585
+ this.ranges = null;
586
+ this.tabstops = null;
587
+ this.selectedTabstop = null;
588
+ this.editor.removeListener("change", this.$onChange);
589
+ this.editor.removeListener("changeSelection", this.$onChangeSelection);
590
+ this.editor.removeListener("changeSession", this.$onChangeSession);
591
+ this.editor.commands.removeListener("afterExec", this.$onAfterExec);
592
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
593
+ this.editor.tabstopManager = null;
594
+ this.editor = null;
595
+ };
596
+ this.onChange = function(delta) {
597
+ var isRemove = delta.action[0] == "r";
598
+ var start = delta.start;
599
+ var end = delta.end;
600
+ var startRow = start.row;
601
+ var endRow = end.row;
602
+ var lineDif = endRow - startRow;
603
+ var colDiff = end.column - start.column;
604
+ if (isRemove) {
605
+ lineDif = -lineDif;
606
+ colDiff = -colDiff;
607
+ }
608
+ if (!this.$inChange && isRemove) {
609
+ var ts = this.selectedTabstop;
610
+ var changedOutside = ts && !ts.some(function(r2) {
611
+ return comparePoints(r2.start, start) <= 0 && comparePoints(r2.end, end) >= 0;
612
+ });
613
+ if (changedOutside)
614
+ return this.detach();
615
+ }
616
+ var ranges = this.ranges;
617
+ for (var i = 0; i < ranges.length; i++) {
618
+ var r = ranges[i];
619
+ if (r.end.row < start.row)
620
+ continue;
621
+ if (isRemove && comparePoints(start, r.start) < 0 && comparePoints(end, r.end) > 0) {
622
+ this.removeRange(r);
623
+ i--;
624
+ continue;
625
+ }
626
+ if (r.start.row == startRow && r.start.column > start.column)
627
+ r.start.column += colDiff;
628
+ if (r.end.row == startRow && r.end.column >= start.column)
629
+ r.end.column += colDiff;
630
+ if (r.start.row >= startRow)
631
+ r.start.row += lineDif;
632
+ if (r.end.row >= startRow)
633
+ r.end.row += lineDif;
634
+ if (comparePoints(r.start, r.end) > 0)
635
+ this.removeRange(r);
636
+ }
637
+ if (!ranges.length)
638
+ this.detach();
639
+ };
640
+ this.updateLinkedFields = function() {
641
+ var ts = this.selectedTabstop;
642
+ if (!ts || !ts.hasLinkedRanges)
643
+ return;
644
+ this.$inChange = true;
645
+ var session = this.editor.session;
646
+ var text = session.getTextRange(ts.firstNonLinked);
647
+ for (var i = ts.length; i--; ) {
648
+ var range = ts[i];
649
+ if (!range.linked)
650
+ continue;
651
+ var fmt = exports2.snippetManager.tmStrFormat(text, range.original);
652
+ session.replace(range, fmt);
653
+ }
654
+ this.$inChange = false;
655
+ };
656
+ this.onAfterExec = function(e) {
657
+ if (e.command && !e.command.readOnly)
658
+ this.updateLinkedFields();
659
+ };
660
+ this.onChangeSelection = function() {
661
+ if (!this.editor)
662
+ return;
663
+ var lead = this.editor.selection.lead;
664
+ var anchor = this.editor.selection.anchor;
665
+ var isEmpty = this.editor.selection.isEmpty();
666
+ for (var i = this.ranges.length; i--; ) {
667
+ if (this.ranges[i].linked)
668
+ continue;
669
+ var containsLead = this.ranges[i].contains(lead.row, lead.column);
670
+ var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
671
+ if (containsLead && containsAnchor)
672
+ return;
673
+ }
674
+ this.detach();
675
+ };
676
+ this.onChangeSession = function() {
677
+ this.detach();
678
+ };
679
+ this.tabNext = function(dir) {
680
+ var max = this.tabstops.length;
681
+ var index = this.index + (dir || 1);
682
+ index = Math.min(Math.max(index, 1), max);
683
+ if (index == max)
684
+ index = 0;
685
+ this.selectTabstop(index);
686
+ if (index === 0)
687
+ this.detach();
688
+ };
689
+ this.selectTabstop = function(index) {
690
+ this.$openTabstops = null;
691
+ var ts = this.tabstops[this.index];
692
+ if (ts)
693
+ this.addTabstopMarkers(ts);
694
+ this.index = index;
695
+ ts = this.tabstops[this.index];
696
+ if (!ts || !ts.length)
697
+ return;
698
+ this.selectedTabstop = ts;
699
+ if (!this.editor.inVirtualSelectionMode) {
700
+ var sel = this.editor.multiSelect;
701
+ sel.toSingleRange(ts.firstNonLinked.clone());
702
+ for (var i = ts.length; i--; ) {
703
+ if (ts.hasLinkedRanges && ts[i].linked)
704
+ continue;
705
+ sel.addRange(ts[i].clone(), true);
706
+ }
707
+ if (sel.ranges[0])
708
+ sel.addRange(sel.ranges[0].clone());
709
+ } else {
710
+ this.editor.selection.setRange(ts.firstNonLinked);
711
+ }
712
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
713
+ };
714
+ this.addTabstops = function(tabstops, start, end) {
715
+ if (!this.$openTabstops)
716
+ this.$openTabstops = [];
717
+ if (!tabstops[0]) {
718
+ var p = Range.fromPoints(end, end);
719
+ moveRelative(p.start, start);
720
+ moveRelative(p.end, start);
721
+ tabstops[0] = [p];
722
+ tabstops[0].index = 0;
723
+ }
724
+ var i = this.index;
725
+ var arg = [i + 1, 0];
726
+ var ranges = this.ranges;
727
+ tabstops.forEach(function(ts, index) {
728
+ var dest = this.$openTabstops[index] || ts;
729
+ for (var i2 = ts.length; i2--; ) {
730
+ var p2 = ts[i2];
731
+ var range = Range.fromPoints(p2.start, p2.end || p2.start);
732
+ movePoint(range.start, start);
733
+ movePoint(range.end, start);
734
+ range.original = p2;
735
+ range.tabstop = dest;
736
+ ranges.push(range);
737
+ if (dest != ts)
738
+ dest.unshift(range);
739
+ else
740
+ dest[i2] = range;
741
+ if (p2.fmtString) {
742
+ range.linked = true;
743
+ dest.hasLinkedRanges = true;
744
+ } else if (!dest.firstNonLinked)
745
+ dest.firstNonLinked = range;
746
+ }
747
+ if (!dest.firstNonLinked)
748
+ dest.hasLinkedRanges = false;
749
+ if (dest === ts) {
750
+ arg.push(dest);
751
+ this.$openTabstops[index] = dest;
752
+ }
753
+ this.addTabstopMarkers(dest);
754
+ }, this);
755
+ if (arg.length > 2) {
756
+ if (this.tabstops.length)
757
+ arg.push(arg.splice(2, 1)[0]);
758
+ this.tabstops.splice.apply(this.tabstops, arg);
759
+ }
760
+ };
761
+ this.addTabstopMarkers = function(ts) {
762
+ var session = this.editor.session;
763
+ ts.forEach(function(range) {
764
+ if (!range.markerId)
765
+ range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
766
+ });
767
+ };
768
+ this.removeTabstopMarkers = function(ts) {
769
+ var session = this.editor.session;
770
+ ts.forEach(function(range) {
771
+ session.removeMarker(range.markerId);
772
+ range.markerId = null;
773
+ });
774
+ };
775
+ this.removeRange = function(range) {
776
+ var i = range.tabstop.indexOf(range);
777
+ range.tabstop.splice(i, 1);
778
+ i = this.ranges.indexOf(range);
779
+ this.ranges.splice(i, 1);
780
+ this.editor.session.removeMarker(range.markerId);
781
+ if (!range.tabstop.length) {
782
+ i = this.tabstops.indexOf(range.tabstop);
783
+ if (i != -1)
784
+ this.tabstops.splice(i, 1);
785
+ if (!this.tabstops.length)
786
+ this.detach();
787
+ }
788
+ };
789
+ this.keyboardHandler = new HashHandler();
790
+ this.keyboardHandler.bindKeys({
791
+ "Tab": function(ed) {
792
+ if (exports2.snippetManager && exports2.snippetManager.expandWithTab(ed)) {
793
+ return;
794
+ }
795
+ ed.tabstopManager.tabNext(1);
796
+ },
797
+ "Shift-Tab": function(ed) {
798
+ ed.tabstopManager.tabNext(-1);
799
+ },
800
+ "Esc": function(ed) {
801
+ ed.tabstopManager.detach();
802
+ },
803
+ "Return": function(ed) {
804
+ return false;
805
+ }
806
+ });
807
+ }).call(TabstopManager.prototype);
808
+ Anchor.prototype.onChange;
809
+ var movePoint = function(point, diff) {
810
+ if (point.row == 0)
811
+ point.column += diff.column;
812
+ point.row += diff.row;
813
+ };
814
+ var moveRelative = function(point, start) {
815
+ if (point.row == start.row)
816
+ point.column -= start.column;
817
+ point.row -= start.row;
818
+ };
819
+ acequire("./lib/dom").importCssString(".ace_snippet-marker { -moz-box-sizing: border-box; box-sizing: border-box; background: rgba(194, 193, 208, 0.09); border: 1px dotted rgba(211, 208, 235, 0.62); position: absolute;}");
820
+ exports2.snippetManager = new SnippetManager();
821
+ var Editor = acequire("./editor").Editor;
822
+ (function() {
823
+ this.insertSnippet = function(content, options) {
824
+ return exports2.snippetManager.insertSnippet(this, content, options);
825
+ };
826
+ this.expandSnippet = function(options) {
827
+ return exports2.snippetManager.expandWithTab(this, options);
828
+ };
829
+ }).call(Editor.prototype);
830
+ });
831
+ ace.define("ace/autocomplete/popup", ["require", "exports", "module", "ace/virtual_renderer", "ace/editor", "ace/range", "ace/lib/event", "ace/lib/lang", "ace/lib/dom"], function(acequire, exports2, module2) {
832
+ var Renderer = acequire("../virtual_renderer").VirtualRenderer;
833
+ var Editor = acequire("../editor").Editor;
834
+ var Range = acequire("../range").Range;
835
+ var event = acequire("../lib/event");
836
+ var lang = acequire("../lib/lang");
837
+ var dom = acequire("../lib/dom");
838
+ var $singleLineEditor = function(el) {
839
+ var renderer = new Renderer(el);
840
+ renderer.$maxLines = 4;
841
+ var editor = new Editor(renderer);
842
+ editor.setHighlightActiveLine(false);
843
+ editor.setShowPrintMargin(false);
844
+ editor.renderer.setShowGutter(false);
845
+ editor.renderer.setHighlightGutterLine(false);
846
+ editor.$mouseHandler.$focusWaitTimout = 0;
847
+ editor.$highlightTagPending = true;
848
+ return editor;
849
+ };
850
+ var AcePopup = function(parentNode) {
851
+ var el = dom.createElement("div");
852
+ var popup = new $singleLineEditor(el);
853
+ if (parentNode)
854
+ parentNode.appendChild(el);
855
+ el.style.display = "none";
856
+ popup.renderer.content.style.cursor = "default";
857
+ popup.renderer.setStyle("ace_autocomplete");
858
+ popup.setOption("displayIndentGuides", false);
859
+ popup.setOption("dragDelay", 150);
860
+ var noop = function() {
861
+ };
862
+ popup.focus = noop;
863
+ popup.$isFocused = true;
864
+ popup.renderer.$cursorLayer.restartTimer = noop;
865
+ popup.renderer.$cursorLayer.element.style.opacity = 0;
866
+ popup.renderer.$maxLines = 8;
867
+ popup.renderer.$keepTextAreaAtCursor = false;
868
+ popup.setHighlightActiveLine(false);
869
+ popup.session.highlight("");
870
+ popup.session.$searchHighlight.clazz = "ace_highlight-marker";
871
+ popup.on("mousedown", function(e) {
872
+ var pos = e.getDocumentPosition();
873
+ popup.selection.moveToPosition(pos);
874
+ selectionMarker.start.row = selectionMarker.end.row = pos.row;
875
+ e.stop();
876
+ });
877
+ var lastMouseEvent;
878
+ var hoverMarker = new Range(-1, 0, -1, Infinity);
879
+ var selectionMarker = new Range(-1, 0, -1, Infinity);
880
+ selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine");
881
+ popup.setSelectOnHover = function(val) {
882
+ if (!val) {
883
+ hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
884
+ } else if (hoverMarker.id) {
885
+ popup.session.removeMarker(hoverMarker.id);
886
+ hoverMarker.id = null;
887
+ }
888
+ };
889
+ popup.setSelectOnHover(false);
890
+ popup.on("mousemove", function(e) {
891
+ if (!lastMouseEvent) {
892
+ lastMouseEvent = e;
893
+ return;
894
+ }
895
+ if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) {
896
+ return;
897
+ }
898
+ lastMouseEvent = e;
899
+ lastMouseEvent.scrollTop = popup.renderer.scrollTop;
900
+ var row = lastMouseEvent.getDocumentPosition().row;
901
+ if (hoverMarker.start.row != row) {
902
+ if (!hoverMarker.id)
903
+ popup.setRow(row);
904
+ setHoverMarker(row);
905
+ }
906
+ });
907
+ popup.renderer.on("beforeRender", function() {
908
+ if (lastMouseEvent && hoverMarker.start.row != -1) {
909
+ lastMouseEvent.$pos = null;
910
+ var row = lastMouseEvent.getDocumentPosition().row;
911
+ if (!hoverMarker.id)
912
+ popup.setRow(row);
913
+ setHoverMarker(row, true);
914
+ }
915
+ });
916
+ popup.renderer.on("afterRender", function() {
917
+ var row = popup.getRow();
918
+ var t = popup.renderer.$textLayer;
919
+ var selected = t.element.childNodes[row - t.config.firstRow];
920
+ if (selected == t.selectedNode)
921
+ return;
922
+ if (t.selectedNode)
923
+ dom.removeCssClass(t.selectedNode, "ace_selected");
924
+ t.selectedNode = selected;
925
+ if (selected)
926
+ dom.addCssClass(selected, "ace_selected");
927
+ });
928
+ var hideHoverMarker = function() {
929
+ setHoverMarker(-1);
930
+ };
931
+ var setHoverMarker = function(row, suppressRedraw) {
932
+ if (row !== hoverMarker.start.row) {
933
+ hoverMarker.start.row = hoverMarker.end.row = row;
934
+ if (!suppressRedraw)
935
+ popup.session._emit("changeBackMarker");
936
+ popup._emit("changeHoverMarker");
937
+ }
938
+ };
939
+ popup.getHoveredRow = function() {
940
+ return hoverMarker.start.row;
941
+ };
942
+ event.addListener(popup.container, "mouseout", hideHoverMarker);
943
+ popup.on("hide", hideHoverMarker);
944
+ popup.on("changeSelection", hideHoverMarker);
945
+ popup.session.doc.getLength = function() {
946
+ return popup.data.length;
947
+ };
948
+ popup.session.doc.getLine = function(i) {
949
+ var data = popup.data[i];
950
+ if (typeof data == "string")
951
+ return data;
952
+ return data && data.value || "";
953
+ };
954
+ var bgTokenizer = popup.session.bgTokenizer;
955
+ bgTokenizer.$tokenizeRow = function(row) {
956
+ var data = popup.data[row];
957
+ var tokens = [];
958
+ if (!data)
959
+ return tokens;
960
+ if (typeof data == "string")
961
+ data = { value: data };
962
+ if (!data.caption)
963
+ data.caption = data.value || data.name;
964
+ var last = -1;
965
+ var flag, c;
966
+ for (var i = 0; i < data.caption.length; i++) {
967
+ c = data.caption[i];
968
+ flag = data.matchMask & 1 << i ? 1 : 0;
969
+ if (last !== flag) {
970
+ tokens.push({ type: data.className || (flag ? "completion-highlight" : ""), value: c });
971
+ last = flag;
972
+ } else {
973
+ tokens[tokens.length - 1].value += c;
974
+ }
975
+ }
976
+ if (data.meta) {
977
+ var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
978
+ var metaData = data.meta;
979
+ if (metaData.length + data.caption.length > maxW - 2) {
980
+ metaData = metaData.substr(0, maxW - data.caption.length - 3) + "…";
981
+ }
982
+ tokens.push({ type: "rightAlignedText", value: metaData });
983
+ }
984
+ return tokens;
985
+ };
986
+ bgTokenizer.$updateOnChange = noop;
987
+ bgTokenizer.start = noop;
988
+ popup.session.$computeWidth = function() {
989
+ return this.screenWidth = 0;
990
+ };
991
+ popup.$blockScrolling = Infinity;
992
+ popup.isOpen = false;
993
+ popup.isTopdown = false;
994
+ popup.autoSelect = true;
995
+ popup.data = [];
996
+ popup.setData = function(list) {
997
+ popup.setValue(lang.stringRepeat("\n", list.length), -1);
998
+ popup.data = list || [];
999
+ popup.setRow(0);
1000
+ };
1001
+ popup.getData = function(row) {
1002
+ return popup.data[row];
1003
+ };
1004
+ popup.getRow = function() {
1005
+ return selectionMarker.start.row;
1006
+ };
1007
+ popup.setRow = function(line) {
1008
+ line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length, line));
1009
+ if (selectionMarker.start.row != line) {
1010
+ popup.selection.clearSelection();
1011
+ selectionMarker.start.row = selectionMarker.end.row = line || 0;
1012
+ popup.session._emit("changeBackMarker");
1013
+ popup.moveCursorTo(line || 0, 0);
1014
+ if (popup.isOpen)
1015
+ popup._signal("select");
1016
+ }
1017
+ };
1018
+ popup.on("changeSelection", function() {
1019
+ if (popup.isOpen)
1020
+ popup.setRow(popup.selection.lead.row);
1021
+ popup.renderer.scrollCursorIntoView();
1022
+ });
1023
+ popup.hide = function() {
1024
+ this.container.style.display = "none";
1025
+ this._signal("hide");
1026
+ popup.isOpen = false;
1027
+ };
1028
+ popup.show = function(pos, lineHeight, topdownOnly) {
1029
+ var el2 = this.container;
1030
+ var screenHeight = window.innerHeight;
1031
+ var screenWidth = window.innerWidth;
1032
+ var renderer = this.renderer;
1033
+ var maxH = renderer.$maxLines * lineHeight * 1.4;
1034
+ var top = pos.top + this.$borderSize;
1035
+ var allowTopdown = top > screenHeight / 2 && !topdownOnly;
1036
+ if (allowTopdown && top + lineHeight + maxH > screenHeight) {
1037
+ renderer.$maxPixelHeight = top - 2 * this.$borderSize;
1038
+ el2.style.top = "";
1039
+ el2.style.bottom = screenHeight - top + "px";
1040
+ popup.isTopdown = false;
1041
+ } else {
1042
+ top += lineHeight;
1043
+ renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight;
1044
+ el2.style.top = top + "px";
1045
+ el2.style.bottom = "";
1046
+ popup.isTopdown = true;
1047
+ }
1048
+ el2.style.display = "";
1049
+ this.renderer.$textLayer.checkForSizeChanges();
1050
+ var left = pos.left;
1051
+ if (left + el2.offsetWidth > screenWidth)
1052
+ left = screenWidth - el2.offsetWidth;
1053
+ el2.style.left = left + "px";
1054
+ this._signal("show");
1055
+ lastMouseEvent = null;
1056
+ popup.isOpen = true;
1057
+ };
1058
+ popup.getTextLeftOffset = function() {
1059
+ return this.$borderSize + this.renderer.$padding + this.$imageSize;
1060
+ };
1061
+ popup.$imageSize = 0;
1062
+ popup.$borderSize = 1;
1063
+ return popup;
1064
+ };
1065
+ dom.importCssString(".ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line { background-color: #CAD6FA; z-index: 1;}.ace_editor.ace_autocomplete .ace_line-hover { border: 1px solid #abbffe; margin-top: -1px; background: rgba(233,233,253,0.4);}.ace_editor.ace_autocomplete .ace_line-hover { position: absolute; z-index: 2;}.ace_editor.ace_autocomplete .ace_scroller { background: none; border: none; box-shadow: none;}.ace_rightAlignedText { color: gray; display: inline-block; position: absolute; right: 4px; text-align: right; z-index: -1;}.ace_editor.ace_autocomplete .ace_completion-highlight{ color: #000; text-shadow: 0 0 0.01em;}.ace_editor.ace_autocomplete { width: 280px; z-index: 200000; background: #fbfbfb; color: #444; border: 1px lightgray solid; position: fixed; box-shadow: 2px 3px 5px rgba(0,0,0,.2); line-height: 1.4;}");
1066
+ exports2.AcePopup = AcePopup;
1067
+ });
1068
+ ace.define("ace/autocomplete/util", ["require", "exports", "module"], function(acequire, exports2, module2) {
1069
+ exports2.parForEach = function(array, fn, callback) {
1070
+ var completed = 0;
1071
+ var arLength = array.length;
1072
+ if (arLength === 0)
1073
+ callback();
1074
+ for (var i = 0; i < arLength; i++) {
1075
+ fn(array[i], function(result, err) {
1076
+ completed++;
1077
+ if (completed === arLength)
1078
+ callback(result, err);
1079
+ });
1080
+ }
1081
+ };
1082
+ var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/;
1083
+ exports2.retrievePrecedingIdentifier = function(text, pos, regex) {
1084
+ regex = regex || ID_REGEX;
1085
+ var buf = [];
1086
+ for (var i = pos - 1; i >= 0; i--) {
1087
+ if (regex.test(text[i]))
1088
+ buf.push(text[i]);
1089
+ else
1090
+ break;
1091
+ }
1092
+ return buf.reverse().join("");
1093
+ };
1094
+ exports2.retrieveFollowingIdentifier = function(text, pos, regex) {
1095
+ regex = regex || ID_REGEX;
1096
+ var buf = [];
1097
+ for (var i = pos; i < text.length; i++) {
1098
+ if (regex.test(text[i]))
1099
+ buf.push(text[i]);
1100
+ else
1101
+ break;
1102
+ }
1103
+ return buf;
1104
+ };
1105
+ exports2.getCompletionPrefix = function(editor) {
1106
+ var pos = editor.getCursorPosition();
1107
+ var line = editor.session.getLine(pos.row);
1108
+ var prefix;
1109
+ editor.completers.forEach((function(completer) {
1110
+ if (completer.identifierRegexps) {
1111
+ completer.identifierRegexps.forEach((function(identifierRegex) {
1112
+ if (!prefix && identifierRegex)
1113
+ prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
1114
+ }).bind(this));
1115
+ }
1116
+ }).bind(this));
1117
+ return prefix || this.retrievePrecedingIdentifier(line, pos.column);
1118
+ };
1119
+ });
1120
+ ace.define("ace/autocomplete", ["require", "exports", "module", "ace/keyboard/hash_handler", "ace/autocomplete/popup", "ace/autocomplete/util", "ace/lib/event", "ace/lib/lang", "ace/lib/dom", "ace/snippets"], function(acequire, exports2, module2) {
1121
+ var HashHandler = acequire("./keyboard/hash_handler").HashHandler;
1122
+ var AcePopup = acequire("./autocomplete/popup").AcePopup;
1123
+ var util = acequire("./autocomplete/util");
1124
+ acequire("./lib/event");
1125
+ var lang = acequire("./lib/lang");
1126
+ var dom = acequire("./lib/dom");
1127
+ var snippetManager = acequire("./snippets").snippetManager;
1128
+ var Autocomplete = function() {
1129
+ this.autoInsert = false;
1130
+ this.autoSelect = true;
1131
+ this.exactMatch = false;
1132
+ this.gatherCompletionsId = 0;
1133
+ this.keyboardHandler = new HashHandler();
1134
+ this.keyboardHandler.bindKeys(this.commands);
1135
+ this.blurListener = this.blurListener.bind(this);
1136
+ this.changeListener = this.changeListener.bind(this);
1137
+ this.mousedownListener = this.mousedownListener.bind(this);
1138
+ this.mousewheelListener = this.mousewheelListener.bind(this);
1139
+ this.changeTimer = lang.delayedCall((function() {
1140
+ this.updateCompletions(true);
1141
+ }).bind(this));
1142
+ this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
1143
+ };
1144
+ (function() {
1145
+ this.$init = function() {
1146
+ this.popup = new AcePopup(document.body || document.documentElement);
1147
+ this.popup.on("click", (function(e) {
1148
+ this.insertMatch();
1149
+ e.stop();
1150
+ }).bind(this));
1151
+ this.popup.focus = this.editor.focus.bind(this.editor);
1152
+ this.popup.on("show", this.tooltipTimer.bind(null, null));
1153
+ this.popup.on("select", this.tooltipTimer.bind(null, null));
1154
+ this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
1155
+ return this.popup;
1156
+ };
1157
+ this.getPopup = function() {
1158
+ return this.popup || this.$init();
1159
+ };
1160
+ this.openPopup = function(editor, prefix, keepPopupPosition) {
1161
+ if (!this.popup)
1162
+ this.$init();
1163
+ this.popup.autoSelect = this.autoSelect;
1164
+ this.popup.setData(this.completions.filtered);
1165
+ editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
1166
+ var renderer = editor.renderer;
1167
+ this.popup.setRow(this.autoSelect ? 0 : -1);
1168
+ if (!keepPopupPosition) {
1169
+ this.popup.setTheme(editor.getTheme());
1170
+ this.popup.setFontSize(editor.getFontSize());
1171
+ var lineHeight = renderer.layerConfig.lineHeight;
1172
+ var pos = renderer.$cursorLayer.getPixelPosition(this.base, true);
1173
+ pos.left -= this.popup.getTextLeftOffset();
1174
+ var rect = editor.container.getBoundingClientRect();
1175
+ pos.top += rect.top - renderer.layerConfig.offset;
1176
+ pos.left += rect.left - editor.renderer.scrollLeft;
1177
+ pos.left += renderer.gutterWidth;
1178
+ this.popup.show(pos, lineHeight);
1179
+ } else if (keepPopupPosition && !prefix) {
1180
+ this.detach();
1181
+ }
1182
+ };
1183
+ this.detach = function() {
1184
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
1185
+ this.editor.off("changeSelection", this.changeListener);
1186
+ this.editor.off("blur", this.blurListener);
1187
+ this.editor.off("mousedown", this.mousedownListener);
1188
+ this.editor.off("mousewheel", this.mousewheelListener);
1189
+ this.changeTimer.cancel();
1190
+ this.hideDocTooltip();
1191
+ this.gatherCompletionsId += 1;
1192
+ if (this.popup && this.popup.isOpen)
1193
+ this.popup.hide();
1194
+ if (this.base)
1195
+ this.base.detach();
1196
+ this.activated = false;
1197
+ this.completions = this.base = null;
1198
+ };
1199
+ this.changeListener = function(e) {
1200
+ var cursor = this.editor.selection.lead;
1201
+ if (cursor.row != this.base.row || cursor.column < this.base.column) {
1202
+ this.detach();
1203
+ }
1204
+ if (this.activated)
1205
+ this.changeTimer.schedule();
1206
+ else
1207
+ this.detach();
1208
+ };
1209
+ this.blurListener = function(e) {
1210
+ var el = document.activeElement;
1211
+ var text = this.editor.textInput.getElement();
1212
+ var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget);
1213
+ var container = this.popup && this.popup.container;
1214
+ if (el != text && el.parentNode != container && !fromTooltip && el != this.tooltipNode && e.relatedTarget != text) {
1215
+ this.detach();
1216
+ }
1217
+ };
1218
+ this.mousedownListener = function(e) {
1219
+ this.detach();
1220
+ };
1221
+ this.mousewheelListener = function(e) {
1222
+ this.detach();
1223
+ };
1224
+ this.goTo = function(where) {
1225
+ var row = this.popup.getRow();
1226
+ var max = this.popup.session.getLength() - 1;
1227
+ switch (where) {
1228
+ case "up":
1229
+ row = row <= 0 ? max : row - 1;
1230
+ break;
1231
+ case "down":
1232
+ row = row >= max ? -1 : row + 1;
1233
+ break;
1234
+ case "start":
1235
+ row = 0;
1236
+ break;
1237
+ case "end":
1238
+ row = max;
1239
+ break;
1240
+ }
1241
+ this.popup.setRow(row);
1242
+ };
1243
+ this.insertMatch = function(data, options) {
1244
+ if (!data)
1245
+ data = this.popup.getData(this.popup.getRow());
1246
+ if (!data)
1247
+ return false;
1248
+ if (data.completer && data.completer.insertMatch) {
1249
+ data.completer.insertMatch(this.editor, data);
1250
+ } else {
1251
+ if (this.completions.filterText) {
1252
+ var ranges = this.editor.selection.getAllRanges();
1253
+ for (var i = 0, range; range = ranges[i]; i++) {
1254
+ range.start.column -= this.completions.filterText.length;
1255
+ this.editor.session.remove(range);
1256
+ }
1257
+ }
1258
+ if (data.snippet)
1259
+ snippetManager.insertSnippet(this.editor, data.snippet);
1260
+ else
1261
+ this.editor.execCommand("insertstring", data.value || data);
1262
+ }
1263
+ this.detach();
1264
+ };
1265
+ this.commands = {
1266
+ "Up": function(editor) {
1267
+ editor.completer.goTo("up");
1268
+ },
1269
+ "Down": function(editor) {
1270
+ editor.completer.goTo("down");
1271
+ },
1272
+ "Ctrl-Up|Ctrl-Home": function(editor) {
1273
+ editor.completer.goTo("start");
1274
+ },
1275
+ "Ctrl-Down|Ctrl-End": function(editor) {
1276
+ editor.completer.goTo("end");
1277
+ },
1278
+ "Esc": function(editor) {
1279
+ editor.completer.detach();
1280
+ },
1281
+ "Return": function(editor) {
1282
+ return editor.completer.insertMatch();
1283
+ },
1284
+ "Shift-Return": function(editor) {
1285
+ editor.completer.insertMatch(null, { deleteSuffix: true });
1286
+ },
1287
+ "Tab": function(editor) {
1288
+ var result = editor.completer.insertMatch();
1289
+ if (!result && !editor.tabstopManager)
1290
+ editor.completer.goTo("down");
1291
+ else
1292
+ return result;
1293
+ },
1294
+ "PageUp": function(editor) {
1295
+ editor.completer.popup.gotoPageUp();
1296
+ },
1297
+ "PageDown": function(editor) {
1298
+ editor.completer.popup.gotoPageDown();
1299
+ }
1300
+ };
1301
+ this.gatherCompletions = function(editor, callback) {
1302
+ var session = editor.getSession();
1303
+ var pos = editor.getCursorPosition();
1304
+ var prefix = util.getCompletionPrefix(editor);
1305
+ this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
1306
+ this.base.$insertRight = true;
1307
+ var matches = [];
1308
+ var total = editor.completers.length;
1309
+ editor.completers.forEach(function(completer, i) {
1310
+ completer.getCompletions(editor, session, pos, prefix, function(err, results) {
1311
+ if (!err && results)
1312
+ matches = matches.concat(results);
1313
+ callback(null, {
1314
+ prefix: util.getCompletionPrefix(editor),
1315
+ matches,
1316
+ finished: --total === 0
1317
+ });
1318
+ });
1319
+ });
1320
+ return true;
1321
+ };
1322
+ this.showPopup = function(editor) {
1323
+ if (this.editor)
1324
+ this.detach();
1325
+ this.activated = true;
1326
+ this.editor = editor;
1327
+ if (editor.completer != this) {
1328
+ if (editor.completer)
1329
+ editor.completer.detach();
1330
+ editor.completer = this;
1331
+ }
1332
+ editor.on("changeSelection", this.changeListener);
1333
+ editor.on("blur", this.blurListener);
1334
+ editor.on("mousedown", this.mousedownListener);
1335
+ editor.on("mousewheel", this.mousewheelListener);
1336
+ this.updateCompletions();
1337
+ };
1338
+ this.updateCompletions = function(keepPopupPosition) {
1339
+ if (keepPopupPosition && this.base && this.completions) {
1340
+ var pos = this.editor.getCursorPosition();
1341
+ var prefix = this.editor.session.getTextRange({ start: this.base, end: pos });
1342
+ if (prefix == this.completions.filterText)
1343
+ return;
1344
+ this.completions.setFilter(prefix);
1345
+ if (!this.completions.filtered.length)
1346
+ return this.detach();
1347
+ if (this.completions.filtered.length == 1 && this.completions.filtered[0].value == prefix && !this.completions.filtered[0].snippet)
1348
+ return this.detach();
1349
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1350
+ return;
1351
+ }
1352
+ var _id = this.gatherCompletionsId;
1353
+ this.gatherCompletions(this.editor, (function(err, results) {
1354
+ var detachIfFinished = (function() {
1355
+ if (!results.finished)
1356
+ return;
1357
+ return this.detach();
1358
+ }).bind(this);
1359
+ var prefix2 = results.prefix;
1360
+ var matches = results && results.matches;
1361
+ if (!matches || !matches.length)
1362
+ return detachIfFinished();
1363
+ if (prefix2.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId)
1364
+ return;
1365
+ this.completions = new FilteredList(matches);
1366
+ if (this.exactMatch)
1367
+ this.completions.exactMatch = true;
1368
+ this.completions.setFilter(prefix2);
1369
+ var filtered = this.completions.filtered;
1370
+ if (!filtered.length)
1371
+ return detachIfFinished();
1372
+ if (filtered.length == 1 && filtered[0].value == prefix2 && !filtered[0].snippet)
1373
+ return detachIfFinished();
1374
+ if (this.autoInsert && filtered.length == 1 && results.finished)
1375
+ return this.insertMatch(filtered[0]);
1376
+ this.openPopup(this.editor, prefix2, keepPopupPosition);
1377
+ }).bind(this));
1378
+ };
1379
+ this.cancelContextMenu = function() {
1380
+ this.editor.$mouseHandler.cancelContextMenu();
1381
+ };
1382
+ this.updateDocTooltip = function() {
1383
+ var popup = this.popup;
1384
+ var all = popup.data;
1385
+ var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
1386
+ var doc = null;
1387
+ if (!selected || !this.editor || !this.popup.isOpen)
1388
+ return this.hideDocTooltip();
1389
+ this.editor.completers.some(function(completer) {
1390
+ if (completer.getDocTooltip)
1391
+ doc = completer.getDocTooltip(selected);
1392
+ return doc;
1393
+ });
1394
+ if (!doc)
1395
+ doc = selected;
1396
+ if (typeof doc == "string")
1397
+ doc = { docText: doc };
1398
+ if (!doc || !(doc.docHTML || doc.docText))
1399
+ return this.hideDocTooltip();
1400
+ this.showDocTooltip(doc);
1401
+ };
1402
+ this.showDocTooltip = function(item) {
1403
+ if (!this.tooltipNode) {
1404
+ this.tooltipNode = dom.createElement("div");
1405
+ this.tooltipNode.className = "ace_tooltip ace_doc-tooltip";
1406
+ this.tooltipNode.style.margin = 0;
1407
+ this.tooltipNode.style.pointerEvents = "auto";
1408
+ this.tooltipNode.tabIndex = -1;
1409
+ this.tooltipNode.onblur = this.blurListener.bind(this);
1410
+ this.tooltipNode.onclick = this.onTooltipClick.bind(this);
1411
+ }
1412
+ var tooltipNode = this.tooltipNode;
1413
+ if (item.docHTML) {
1414
+ tooltipNode.innerHTML = item.docHTML;
1415
+ } else if (item.docText) {
1416
+ tooltipNode.textContent = item.docText;
1417
+ }
1418
+ if (!tooltipNode.parentNode)
1419
+ document.body.appendChild(tooltipNode);
1420
+ var popup = this.popup;
1421
+ var rect = popup.container.getBoundingClientRect();
1422
+ tooltipNode.style.top = popup.container.style.top;
1423
+ tooltipNode.style.bottom = popup.container.style.bottom;
1424
+ if (window.innerWidth - rect.right < 320) {
1425
+ tooltipNode.style.right = window.innerWidth - rect.left + "px";
1426
+ tooltipNode.style.left = "";
1427
+ } else {
1428
+ tooltipNode.style.left = rect.right + 1 + "px";
1429
+ tooltipNode.style.right = "";
1430
+ }
1431
+ tooltipNode.style.display = "block";
1432
+ };
1433
+ this.hideDocTooltip = function() {
1434
+ this.tooltipTimer.cancel();
1435
+ if (!this.tooltipNode)
1436
+ return;
1437
+ var el = this.tooltipNode;
1438
+ if (!this.editor.isFocused() && document.activeElement == el)
1439
+ this.editor.focus();
1440
+ this.tooltipNode = null;
1441
+ if (el.parentNode)
1442
+ el.parentNode.removeChild(el);
1443
+ };
1444
+ this.onTooltipClick = function(e) {
1445
+ var a = e.target;
1446
+ while (a && a != this.tooltipNode) {
1447
+ if (a.nodeName == "A" && a.href) {
1448
+ a.rel = "noreferrer";
1449
+ a.target = "_blank";
1450
+ break;
1451
+ }
1452
+ a = a.parentNode;
1453
+ }
1454
+ };
1455
+ }).call(Autocomplete.prototype);
1456
+ Autocomplete.startCommand = {
1457
+ name: "startAutocomplete",
1458
+ exec: function(editor) {
1459
+ if (!editor.completer)
1460
+ editor.completer = new Autocomplete();
1461
+ editor.completer.autoInsert = false;
1462
+ editor.completer.autoSelect = true;
1463
+ editor.completer.showPopup(editor);
1464
+ editor.completer.cancelContextMenu();
1465
+ },
1466
+ bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
1467
+ };
1468
+ var FilteredList = function(array, filterText) {
1469
+ this.all = array;
1470
+ this.filtered = array;
1471
+ this.filterText = filterText || "";
1472
+ this.exactMatch = false;
1473
+ };
1474
+ (function() {
1475
+ this.setFilter = function(str) {
1476
+ if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0)
1477
+ var matches = this.filtered;
1478
+ else
1479
+ var matches = this.all;
1480
+ this.filterText = str;
1481
+ matches = this.filterCompletions(matches, this.filterText);
1482
+ matches = matches.sort(function(a, b) {
1483
+ return b.exactMatch - a.exactMatch || b.score - a.score;
1484
+ });
1485
+ var prev = null;
1486
+ matches = matches.filter(function(item) {
1487
+ var caption = item.snippet || item.caption || item.value;
1488
+ if (caption === prev)
1489
+ return false;
1490
+ prev = caption;
1491
+ return true;
1492
+ });
1493
+ this.filtered = matches;
1494
+ };
1495
+ this.filterCompletions = function(items, needle) {
1496
+ var results = [];
1497
+ var upper = needle.toUpperCase();
1498
+ var lower = needle.toLowerCase();
1499
+ loop:
1500
+ for (var i = 0, item; item = items[i]; i++) {
1501
+ var caption = item.value || item.caption || item.snippet;
1502
+ if (!caption)
1503
+ continue;
1504
+ var lastIndex = -1;
1505
+ var matchMask = 0;
1506
+ var penalty = 0;
1507
+ var index, distance;
1508
+ if (this.exactMatch) {
1509
+ if (needle !== caption.substr(0, needle.length))
1510
+ continue loop;
1511
+ } else {
1512
+ for (var j = 0; j < needle.length; j++) {
1513
+ var i1 = caption.indexOf(lower[j], lastIndex + 1);
1514
+ var i2 = caption.indexOf(upper[j], lastIndex + 1);
1515
+ index = i1 >= 0 ? i2 < 0 || i1 < i2 ? i1 : i2 : i2;
1516
+ if (index < 0)
1517
+ continue loop;
1518
+ distance = index - lastIndex - 1;
1519
+ if (distance > 0) {
1520
+ if (lastIndex === -1)
1521
+ penalty += 10;
1522
+ penalty += distance;
1523
+ }
1524
+ matchMask = matchMask | 1 << index;
1525
+ lastIndex = index;
1526
+ }
1527
+ }
1528
+ item.matchMask = matchMask;
1529
+ item.exactMatch = penalty ? 0 : 1;
1530
+ item.score = (item.score || 0) - penalty;
1531
+ results.push(item);
1532
+ }
1533
+ return results;
1534
+ };
1535
+ }).call(FilteredList.prototype);
1536
+ exports2.Autocomplete = Autocomplete;
1537
+ exports2.FilteredList = FilteredList;
1538
+ });
1539
+ ace.define("ace/autocomplete/text_completer", ["require", "exports", "module", "ace/range"], function(acequire, exports2, module2) {
1540
+ var Range = acequire("../range").Range;
1541
+ var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;
1542
+ function getWordIndex(doc, pos) {
1543
+ var textBefore = doc.getTextRange(Range.fromPoints({ row: 0, column: 0 }, pos));
1544
+ return textBefore.split(splitRegex).length - 1;
1545
+ }
1546
+ function wordDistance(doc, pos) {
1547
+ var prefixPos = getWordIndex(doc, pos);
1548
+ var words = doc.getValue().split(splitRegex);
1549
+ var wordScores = /* @__PURE__ */ Object.create(null);
1550
+ var currentWord = words[prefixPos];
1551
+ words.forEach(function(word, idx) {
1552
+ if (!word || word === currentWord)
1553
+ return;
1554
+ var distance = Math.abs(prefixPos - idx);
1555
+ var score = words.length - distance;
1556
+ if (wordScores[word]) {
1557
+ wordScores[word] = Math.max(score, wordScores[word]);
1558
+ } else {
1559
+ wordScores[word] = score;
1560
+ }
1561
+ });
1562
+ return wordScores;
1563
+ }
1564
+ exports2.getCompletions = function(editor, session, pos, prefix, callback) {
1565
+ var wordScore = wordDistance(session, pos);
1566
+ var wordList = Object.keys(wordScore);
1567
+ callback(null, wordList.map(function(word) {
1568
+ return {
1569
+ caption: word,
1570
+ value: word,
1571
+ score: wordScore[word],
1572
+ meta: "local"
1573
+ };
1574
+ }));
1575
+ };
1576
+ });
1577
+ ace.define("ace/ext/language_tools", ["require", "exports", "module", "ace/snippets", "ace/autocomplete", "ace/config", "ace/lib/lang", "ace/autocomplete/util", "ace/autocomplete/text_completer", "ace/editor", "ace/config"], function(acequire, exports2, module2) {
1578
+ var snippetManager = acequire("../snippets").snippetManager;
1579
+ var Autocomplete = acequire("../autocomplete").Autocomplete;
1580
+ var config = acequire("../config");
1581
+ var lang = acequire("../lib/lang");
1582
+ var util = acequire("../autocomplete/util");
1583
+ var textCompleter = acequire("../autocomplete/text_completer");
1584
+ var keyWordCompleter = {
1585
+ getCompletions: function(editor, session, pos, prefix, callback) {
1586
+ if (session.$mode.completer) {
1587
+ return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback);
1588
+ }
1589
+ var state = editor.session.getState(pos.row);
1590
+ var completions = session.$mode.getCompletions(state, session, pos, prefix);
1591
+ callback(null, completions);
1592
+ }
1593
+ };
1594
+ var snippetCompleter = {
1595
+ getCompletions: function(editor, session, pos, prefix, callback) {
1596
+ var snippetMap = snippetManager.snippetMap;
1597
+ var completions = [];
1598
+ snippetManager.getActiveScopes(editor).forEach(function(scope) {
1599
+ var snippets = snippetMap[scope] || [];
1600
+ for (var i = snippets.length; i--; ) {
1601
+ var s = snippets[i];
1602
+ var caption = s.name || s.tabTrigger;
1603
+ if (!caption)
1604
+ continue;
1605
+ completions.push({
1606
+ caption,
1607
+ snippet: s.content,
1608
+ meta: s.tabTrigger && !s.name ? s.tabTrigger + "⇥ " : "snippet",
1609
+ type: "snippet"
1610
+ });
1611
+ }
1612
+ }, this);
1613
+ callback(null, completions);
1614
+ },
1615
+ getDocTooltip: function(item) {
1616
+ if (item.type == "snippet" && !item.docHTML) {
1617
+ item.docHTML = [
1618
+ "<b>",
1619
+ lang.escapeHTML(item.caption),
1620
+ "</b>",
1621
+ "<hr></hr>",
1622
+ lang.escapeHTML(item.snippet)
1623
+ ].join("");
1624
+ }
1625
+ }
1626
+ };
1627
+ var completers = [snippetCompleter, textCompleter, keyWordCompleter];
1628
+ exports2.setCompleters = function(val) {
1629
+ completers.length = 0;
1630
+ if (val)
1631
+ completers.push.apply(completers, val);
1632
+ };
1633
+ exports2.addCompleter = function(completer) {
1634
+ completers.push(completer);
1635
+ };
1636
+ exports2.textCompleter = textCompleter;
1637
+ exports2.keyWordCompleter = keyWordCompleter;
1638
+ exports2.snippetCompleter = snippetCompleter;
1639
+ var expandSnippet = {
1640
+ name: "expandSnippet",
1641
+ exec: function(editor) {
1642
+ return snippetManager.expandWithTab(editor);
1643
+ },
1644
+ bindKey: "Tab"
1645
+ };
1646
+ var onChangeMode = function(e, editor) {
1647
+ loadSnippetsForMode(editor.session.$mode);
1648
+ };
1649
+ var loadSnippetsForMode = function(mode) {
1650
+ var id = mode.$id;
1651
+ if (!snippetManager.files)
1652
+ snippetManager.files = {};
1653
+ loadSnippetFile(id);
1654
+ if (mode.modes)
1655
+ mode.modes.forEach(loadSnippetsForMode);
1656
+ };
1657
+ var loadSnippetFile = function(id) {
1658
+ if (!id || snippetManager.files[id])
1659
+ return;
1660
+ var snippetFilePath = id.replace("mode", "snippets");
1661
+ snippetManager.files[id] = {};
1662
+ config.loadModule(snippetFilePath, function(m) {
1663
+ if (m) {
1664
+ snippetManager.files[id] = m;
1665
+ if (!m.snippets && m.snippetText)
1666
+ m.snippets = snippetManager.parseSnippetFile(m.snippetText);
1667
+ snippetManager.register(m.snippets || [], m.scope);
1668
+ if (m.includeScopes) {
1669
+ snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
1670
+ m.includeScopes.forEach(function(x) {
1671
+ loadSnippetFile("ace/mode/" + x);
1672
+ });
1673
+ }
1674
+ }
1675
+ });
1676
+ };
1677
+ var doLiveAutocomplete = function(e) {
1678
+ var editor = e.editor;
1679
+ var hasCompleter = editor.completer && editor.completer.activated;
1680
+ if (e.command.name === "backspace") {
1681
+ if (hasCompleter && !util.getCompletionPrefix(editor))
1682
+ editor.completer.detach();
1683
+ } else if (e.command.name === "insertstring") {
1684
+ var prefix = util.getCompletionPrefix(editor);
1685
+ if (prefix && !hasCompleter) {
1686
+ if (!editor.completer) {
1687
+ editor.completer = new Autocomplete();
1688
+ }
1689
+ editor.completer.autoInsert = false;
1690
+ editor.completer.showPopup(editor);
1691
+ }
1692
+ }
1693
+ };
1694
+ var Editor = acequire("../editor").Editor;
1695
+ acequire("../config").defineOptions(Editor.prototype, "editor", {
1696
+ enableBasicAutocompletion: {
1697
+ set: function(val) {
1698
+ if (val) {
1699
+ if (!this.completers)
1700
+ this.completers = Array.isArray(val) ? val : completers;
1701
+ this.commands.addCommand(Autocomplete.startCommand);
1702
+ } else {
1703
+ this.commands.removeCommand(Autocomplete.startCommand);
1704
+ }
1705
+ },
1706
+ value: false
1707
+ },
1708
+ enableLiveAutocompletion: {
1709
+ set: function(val) {
1710
+ if (val) {
1711
+ if (!this.completers)
1712
+ this.completers = Array.isArray(val) ? val : completers;
1713
+ this.commands.on("afterExec", doLiveAutocomplete);
1714
+ } else {
1715
+ this.commands.removeListener("afterExec", doLiveAutocomplete);
1716
+ }
1717
+ },
1718
+ value: false
1719
+ },
1720
+ enableSnippets: {
1721
+ set: function(val) {
1722
+ if (val) {
1723
+ this.commands.addCommand(expandSnippet);
1724
+ this.on("changeMode", onChangeMode);
1725
+ onChangeMode(null, this);
1726
+ } else {
1727
+ this.commands.removeCommand(expandSnippet);
1728
+ this.off("changeMode", onChangeMode);
1729
+ }
1730
+ },
1731
+ value: false
1732
+ }
1733
+ });
1734
+ });
1735
+ (function() {
1736
+ ace.acequire(["ace/ext/language_tools"], function() {
1737
+ });
1738
+ })();