stackprofiler 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/README.md +1 -1
- data/config.ru +3 -2
- data/lib/stackprofiler.rb +0 -1
- data/lib/stackprofiler/filters/build_tree.rb +3 -4
- data/lib/stackprofiler/filters/gem_removal.rb +3 -0
- data/lib/stackprofiler/web_ui.rb +34 -11
- data/lib/stackprofiler/web_ui/public/css/stackprofiler.css +77 -0
- data/lib/stackprofiler/web_ui/public/js/stackprofiler.js +129 -58
- data/lib/stackprofiler/web_ui/public/vendor/ace/ace.js +18298 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-beautify.js +334 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-chromevox.js +541 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-elastic_tabstops_lite.js +275 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-emmet.js +1190 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-error_marker.js +6 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-keybinding_menu.js +170 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-language_tools.js +1934 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-linking.js +52 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-modelist.js +187 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-old_ie.js +494 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-searchbox.js +409 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-settings_menu.js +637 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-spellcheck.js +71 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-split.js +246 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-static_highlight.js +154 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-statusbar.js +51 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-textarea.js +632 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-themelist.js +58 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-whitespace.js +181 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/keybinding-emacs.js +1182 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/keybinding-vim.js +5320 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-haml.js +525 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-html.js +2427 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-html_ruby.js +2955 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-javascript.js +1025 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-json.js +668 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-ruby.js +839 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-xml.js +637 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-yaml.js +256 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/theme-xcode.js +89 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-coffee.js +7599 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-css.js +8682 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-html.js +11527 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-javascript.js +10429 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-json.js +2319 -0
- data/lib/stackprofiler/web_ui/views/index.erb +1 -1
- data/lib/stackprofiler/web_ui/views/layout.erb +2 -55
- data/stackprofiler.gemspec +2 -4
- metadata +42 -19
- data/lib/stackprofiler/web_ui/views/code.erb +0 -17
@@ -0,0 +1,275 @@
|
|
1
|
+
ace.define("ace/ext/elastic_tabstops_lite",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var ElasticTabstopsLite = function(editor) {
|
5
|
+
this.$editor = editor;
|
6
|
+
var self = this;
|
7
|
+
var changedRows = [];
|
8
|
+
var recordChanges = false;
|
9
|
+
this.onAfterExec = function() {
|
10
|
+
recordChanges = false;
|
11
|
+
self.processRows(changedRows);
|
12
|
+
changedRows = [];
|
13
|
+
};
|
14
|
+
this.onExec = function() {
|
15
|
+
recordChanges = true;
|
16
|
+
};
|
17
|
+
this.onChange = function(e) {
|
18
|
+
var range = e.data.range
|
19
|
+
if (recordChanges) {
|
20
|
+
if (changedRows.indexOf(range.start.row) == -1)
|
21
|
+
changedRows.push(range.start.row);
|
22
|
+
if (range.end.row != range.start.row)
|
23
|
+
changedRows.push(range.end.row);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
};
|
27
|
+
|
28
|
+
(function() {
|
29
|
+
this.processRows = function(rows) {
|
30
|
+
this.$inChange = true;
|
31
|
+
var checkedRows = [];
|
32
|
+
|
33
|
+
for (var r = 0, rowCount = rows.length; r < rowCount; r++) {
|
34
|
+
var row = rows[r];
|
35
|
+
|
36
|
+
if (checkedRows.indexOf(row) > -1)
|
37
|
+
continue;
|
38
|
+
|
39
|
+
var cellWidthObj = this.$findCellWidthsForBlock(row);
|
40
|
+
var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths);
|
41
|
+
var rowIndex = cellWidthObj.firstRow;
|
42
|
+
|
43
|
+
for (var w = 0, l = cellWidths.length; w < l; w++) {
|
44
|
+
var widths = cellWidths[w];
|
45
|
+
checkedRows.push(rowIndex);
|
46
|
+
this.$adjustRow(rowIndex, widths);
|
47
|
+
rowIndex++;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
this.$inChange = false;
|
51
|
+
};
|
52
|
+
|
53
|
+
this.$findCellWidthsForBlock = function(row) {
|
54
|
+
var cellWidths = [], widths;
|
55
|
+
var rowIter = row;
|
56
|
+
while (rowIter >= 0) {
|
57
|
+
widths = this.$cellWidthsForRow(rowIter);
|
58
|
+
if (widths.length == 0)
|
59
|
+
break;
|
60
|
+
|
61
|
+
cellWidths.unshift(widths);
|
62
|
+
rowIter--;
|
63
|
+
}
|
64
|
+
var firstRow = rowIter + 1;
|
65
|
+
rowIter = row;
|
66
|
+
var numRows = this.$editor.session.getLength();
|
67
|
+
|
68
|
+
while (rowIter < numRows - 1) {
|
69
|
+
rowIter++;
|
70
|
+
|
71
|
+
widths = this.$cellWidthsForRow(rowIter);
|
72
|
+
if (widths.length == 0)
|
73
|
+
break;
|
74
|
+
|
75
|
+
cellWidths.push(widths);
|
76
|
+
}
|
77
|
+
|
78
|
+
return { cellWidths: cellWidths, firstRow: firstRow };
|
79
|
+
};
|
80
|
+
|
81
|
+
this.$cellWidthsForRow = function(row) {
|
82
|
+
var selectionColumns = this.$selectionColumnsForRow(row);
|
83
|
+
|
84
|
+
var tabs = [-1].concat(this.$tabsForRow(row));
|
85
|
+
var widths = tabs.map(function(el) { return 0; } ).slice(1);
|
86
|
+
var line = this.$editor.session.getLine(row);
|
87
|
+
|
88
|
+
for (var i = 0, len = tabs.length - 1; i < len; i++) {
|
89
|
+
var leftEdge = tabs[i]+1;
|
90
|
+
var rightEdge = tabs[i+1];
|
91
|
+
|
92
|
+
var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge);
|
93
|
+
var cell = line.substring(leftEdge, rightEdge);
|
94
|
+
widths[i] = Math.max(cell.replace(/\s+$/g,'').length, rightmostSelection - leftEdge);
|
95
|
+
}
|
96
|
+
|
97
|
+
return widths;
|
98
|
+
};
|
99
|
+
|
100
|
+
this.$selectionColumnsForRow = function(row) {
|
101
|
+
var selections = [], cursor = this.$editor.getCursorPosition();
|
102
|
+
if (this.$editor.session.getSelection().isEmpty()) {
|
103
|
+
if (row == cursor.row)
|
104
|
+
selections.push(cursor.column);
|
105
|
+
}
|
106
|
+
|
107
|
+
return selections;
|
108
|
+
};
|
109
|
+
|
110
|
+
this.$setBlockCellWidthsToMax = function(cellWidths) {
|
111
|
+
var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth;
|
112
|
+
var columnInfo = this.$izip_longest(cellWidths);
|
113
|
+
|
114
|
+
for (var c = 0, l = columnInfo.length; c < l; c++) {
|
115
|
+
var column = columnInfo[c];
|
116
|
+
if (!column.push) {
|
117
|
+
console.error(column);
|
118
|
+
continue;
|
119
|
+
}
|
120
|
+
column.push(NaN);
|
121
|
+
|
122
|
+
for (var r = 0, s = column.length; r < s; r++) {
|
123
|
+
var width = column[r];
|
124
|
+
if (startingNewBlock) {
|
125
|
+
blockStartRow = r;
|
126
|
+
maxWidth = 0;
|
127
|
+
startingNewBlock = false;
|
128
|
+
}
|
129
|
+
if (isNaN(width)) {
|
130
|
+
blockEndRow = r;
|
131
|
+
|
132
|
+
for (var j = blockStartRow; j < blockEndRow; j++) {
|
133
|
+
cellWidths[j][c] = maxWidth;
|
134
|
+
}
|
135
|
+
startingNewBlock = true;
|
136
|
+
}
|
137
|
+
|
138
|
+
maxWidth = Math.max(maxWidth, width);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
return cellWidths;
|
143
|
+
};
|
144
|
+
|
145
|
+
this.$rightmostSelectionInCell = function(selectionColumns, cellRightEdge) {
|
146
|
+
var rightmost = 0;
|
147
|
+
|
148
|
+
if (selectionColumns.length) {
|
149
|
+
var lengths = [];
|
150
|
+
for (var s = 0, length = selectionColumns.length; s < length; s++) {
|
151
|
+
if (selectionColumns[s] <= cellRightEdge)
|
152
|
+
lengths.push(s);
|
153
|
+
else
|
154
|
+
lengths.push(0);
|
155
|
+
}
|
156
|
+
rightmost = Math.max.apply(Math, lengths);
|
157
|
+
}
|
158
|
+
|
159
|
+
return rightmost;
|
160
|
+
};
|
161
|
+
|
162
|
+
this.$tabsForRow = function(row) {
|
163
|
+
var rowTabs = [], line = this.$editor.session.getLine(row),
|
164
|
+
re = /\t/g, match;
|
165
|
+
|
166
|
+
while ((match = re.exec(line)) != null) {
|
167
|
+
rowTabs.push(match.index);
|
168
|
+
}
|
169
|
+
|
170
|
+
return rowTabs;
|
171
|
+
};
|
172
|
+
|
173
|
+
this.$adjustRow = function(row, widths) {
|
174
|
+
var rowTabs = this.$tabsForRow(row);
|
175
|
+
|
176
|
+
if (rowTabs.length == 0)
|
177
|
+
return;
|
178
|
+
|
179
|
+
var bias = 0, location = -1;
|
180
|
+
var expandedSet = this.$izip(widths, rowTabs);
|
181
|
+
|
182
|
+
for (var i = 0, l = expandedSet.length; i < l; i++) {
|
183
|
+
var w = expandedSet[i][0], it = expandedSet[i][1];
|
184
|
+
location += 1 + w;
|
185
|
+
it += bias;
|
186
|
+
var difference = location - it;
|
187
|
+
|
188
|
+
if (difference == 0)
|
189
|
+
continue;
|
190
|
+
|
191
|
+
var partialLine = this.$editor.session.getLine(row).substr(0, it );
|
192
|
+
var strippedPartialLine = partialLine.replace(/\s*$/g, "");
|
193
|
+
var ispaces = partialLine.length - strippedPartialLine.length;
|
194
|
+
|
195
|
+
if (difference > 0) {
|
196
|
+
this.$editor.session.getDocument().insertInLine({row: row, column: it + 1}, Array(difference + 1).join(" ") + "\t");
|
197
|
+
this.$editor.session.getDocument().removeInLine(row, it, it + 1);
|
198
|
+
|
199
|
+
bias += difference;
|
200
|
+
}
|
201
|
+
|
202
|
+
if (difference < 0 && ispaces >= -difference) {
|
203
|
+
this.$editor.session.getDocument().removeInLine(row, it + difference, it);
|
204
|
+
bias += difference;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
};
|
208
|
+
this.$izip_longest = function(iterables) {
|
209
|
+
if (!iterables[0])
|
210
|
+
return [];
|
211
|
+
var longest = iterables[0].length;
|
212
|
+
var iterablesLength = iterables.length;
|
213
|
+
|
214
|
+
for (var i = 1; i < iterablesLength; i++) {
|
215
|
+
var iLength = iterables[i].length;
|
216
|
+
if (iLength > longest)
|
217
|
+
longest = iLength;
|
218
|
+
}
|
219
|
+
|
220
|
+
var expandedSet = [];
|
221
|
+
|
222
|
+
for (var l = 0; l < longest; l++) {
|
223
|
+
var set = [];
|
224
|
+
for (var i = 0; i < iterablesLength; i++) {
|
225
|
+
if (iterables[i][l] === "")
|
226
|
+
set.push(NaN);
|
227
|
+
else
|
228
|
+
set.push(iterables[i][l]);
|
229
|
+
}
|
230
|
+
|
231
|
+
expandedSet.push(set);
|
232
|
+
}
|
233
|
+
|
234
|
+
|
235
|
+
return expandedSet;
|
236
|
+
};
|
237
|
+
this.$izip = function(widths, tabs) {
|
238
|
+
var size = widths.length >= tabs.length ? tabs.length : widths.length;
|
239
|
+
|
240
|
+
var expandedSet = [];
|
241
|
+
for (var i = 0; i < size; i++) {
|
242
|
+
var set = [ widths[i], tabs[i] ];
|
243
|
+
expandedSet.push(set);
|
244
|
+
}
|
245
|
+
return expandedSet;
|
246
|
+
};
|
247
|
+
|
248
|
+
}).call(ElasticTabstopsLite.prototype);
|
249
|
+
|
250
|
+
exports.ElasticTabstopsLite = ElasticTabstopsLite;
|
251
|
+
|
252
|
+
var Editor = require("../editor").Editor;
|
253
|
+
require("../config").defineOptions(Editor.prototype, "editor", {
|
254
|
+
useElasticTabstops: {
|
255
|
+
set: function(val) {
|
256
|
+
if (val) {
|
257
|
+
if (!this.elasticTabstops)
|
258
|
+
this.elasticTabstops = new ElasticTabstopsLite(this);
|
259
|
+
this.commands.on("afterExec", this.elasticTabstops.onAfterExec);
|
260
|
+
this.commands.on("exec", this.elasticTabstops.onExec);
|
261
|
+
this.on("change", this.elasticTabstops.onChange);
|
262
|
+
} else if (this.elasticTabstops) {
|
263
|
+
this.commands.removeListener("afterExec", this.elasticTabstops.onAfterExec);
|
264
|
+
this.commands.removeListener("exec", this.elasticTabstops.onExec);
|
265
|
+
this.removeListener("change", this.elasticTabstops.onChange);
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}
|
269
|
+
});
|
270
|
+
|
271
|
+
});
|
272
|
+
(function() {
|
273
|
+
ace.require(["ace/ext/elastic_tabstops_lite"], function() {});
|
274
|
+
})();
|
275
|
+
|
@@ -0,0 +1,1190 @@
|
|
1
|
+
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(require, exports, module) {
|
2
|
+
"use strict";
|
3
|
+
var oop = require("./lib/oop");
|
4
|
+
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
5
|
+
var lang = require("./lib/lang");
|
6
|
+
var Range = require("./range").Range;
|
7
|
+
var Anchor = require("./anchor").Anchor;
|
8
|
+
var HashHandler = require("./keyboard/hash_handler").HashHandler;
|
9
|
+
var Tokenizer = require("./tokenizer").Tokenizer;
|
10
|
+
var comparePoints = Range.comparePoints;
|
11
|
+
|
12
|
+
var SnippetManager = function() {
|
13
|
+
this.snippetMap = {};
|
14
|
+
this.snippetNameMap = {};
|
15
|
+
};
|
16
|
+
|
17
|
+
(function() {
|
18
|
+
oop.implement(this, EventEmitter);
|
19
|
+
|
20
|
+
this.getTokenizer = function() {
|
21
|
+
function TabstopToken(str, _, stack) {
|
22
|
+
str = str.substr(1);
|
23
|
+
if (/^\d+$/.test(str) && !stack.inFormatString)
|
24
|
+
return [{tabstopId: parseInt(str, 10)}];
|
25
|
+
return [{text: str}];
|
26
|
+
}
|
27
|
+
function escape(ch) {
|
28
|
+
return "(?:[^\\\\" + ch + "]|\\\\.)";
|
29
|
+
}
|
30
|
+
SnippetManager.$tokenizer = new Tokenizer({
|
31
|
+
start: [
|
32
|
+
{regex: /:/, onMatch: function(val, state, stack) {
|
33
|
+
if (stack.length && stack[0].expectIf) {
|
34
|
+
stack[0].expectIf = false;
|
35
|
+
stack[0].elseBranch = stack[0];
|
36
|
+
return [stack[0]];
|
37
|
+
}
|
38
|
+
return ":";
|
39
|
+
}},
|
40
|
+
{regex: /\\./, onMatch: function(val, state, stack) {
|
41
|
+
var ch = val[1];
|
42
|
+
if (ch == "}" && stack.length) {
|
43
|
+
val = ch;
|
44
|
+
}else if ("`$\\".indexOf(ch) != -1) {
|
45
|
+
val = ch;
|
46
|
+
} else if (stack.inFormatString) {
|
47
|
+
if (ch == "n")
|
48
|
+
val = "\n";
|
49
|
+
else if (ch == "t")
|
50
|
+
val = "\n";
|
51
|
+
else if ("ulULE".indexOf(ch) != -1) {
|
52
|
+
val = {changeCase: ch, local: ch > "a"};
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
return [val];
|
57
|
+
}},
|
58
|
+
{regex: /}/, onMatch: function(val, state, stack) {
|
59
|
+
return [stack.length ? stack.shift() : val];
|
60
|
+
}},
|
61
|
+
{regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken},
|
62
|
+
{regex: /\$\{[\dA-Z_a-z]+/, onMatch: function(str, state, stack) {
|
63
|
+
var t = TabstopToken(str.substr(1), state, stack);
|
64
|
+
stack.unshift(t[0]);
|
65
|
+
return t;
|
66
|
+
}, next: "snippetVar"},
|
67
|
+
{regex: /\n/, token: "newline", merge: false}
|
68
|
+
],
|
69
|
+
snippetVar: [
|
70
|
+
{regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
|
71
|
+
stack[0].choices = val.slice(1, -1).split(",");
|
72
|
+
}, next: "start"},
|
73
|
+
{regex: "/(" + escape("/") + "+)/(?:(" + escape("/") + "*)/)(\\w*):?",
|
74
|
+
onMatch: function(val, state, stack) {
|
75
|
+
var ts = stack[0];
|
76
|
+
ts.fmtString = val;
|
77
|
+
|
78
|
+
val = this.splitRegex.exec(val);
|
79
|
+
ts.guard = val[1];
|
80
|
+
ts.fmt = val[2];
|
81
|
+
ts.flag = val[3];
|
82
|
+
return "";
|
83
|
+
}, next: "start"},
|
84
|
+
{regex: "`" + escape("`") + "*`", onMatch: function(val, state, stack) {
|
85
|
+
stack[0].code = val.splice(1, -1);
|
86
|
+
return "";
|
87
|
+
}, next: "start"},
|
88
|
+
{regex: "\\?", onMatch: function(val, state, stack) {
|
89
|
+
if (stack[0])
|
90
|
+
stack[0].expectIf = true;
|
91
|
+
}, next: "start"},
|
92
|
+
{regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start"}
|
93
|
+
],
|
94
|
+
formatString: [
|
95
|
+
{regex: "/(" + escape("/") + "+)/", token: "regex"},
|
96
|
+
{regex: "", onMatch: function(val, state, stack) {
|
97
|
+
stack.inFormatString = true;
|
98
|
+
}, next: "start"}
|
99
|
+
]
|
100
|
+
});
|
101
|
+
SnippetManager.prototype.getTokenizer = function() {
|
102
|
+
return SnippetManager.$tokenizer;
|
103
|
+
};
|
104
|
+
return SnippetManager.$tokenizer;
|
105
|
+
};
|
106
|
+
|
107
|
+
this.tokenizeTmSnippet = function(str, startState) {
|
108
|
+
return this.getTokenizer().getLineTokens(str, startState).tokens.map(function(x) {
|
109
|
+
return x.value || x;
|
110
|
+
});
|
111
|
+
};
|
112
|
+
|
113
|
+
this.$getDefaultValue = function(editor, name) {
|
114
|
+
if (/^[A-Z]\d+$/.test(name)) {
|
115
|
+
var i = name.substr(1);
|
116
|
+
return (this.variables[name[0] + "__"] || {})[i];
|
117
|
+
}
|
118
|
+
if (/^\d+$/.test(name)) {
|
119
|
+
return (this.variables.__ || {})[name];
|
120
|
+
}
|
121
|
+
name = name.replace(/^TM_/, "");
|
122
|
+
|
123
|
+
if (!editor)
|
124
|
+
return;
|
125
|
+
var s = editor.session;
|
126
|
+
switch(name) {
|
127
|
+
case "CURRENT_WORD":
|
128
|
+
var r = s.getWordRange();
|
129
|
+
case "SELECTION":
|
130
|
+
case "SELECTED_TEXT":
|
131
|
+
return s.getTextRange(r);
|
132
|
+
case "CURRENT_LINE":
|
133
|
+
return s.getLine(editor.getCursorPosition().row);
|
134
|
+
case "PREV_LINE": // not possible in textmate
|
135
|
+
return s.getLine(editor.getCursorPosition().row - 1);
|
136
|
+
case "LINE_INDEX":
|
137
|
+
return editor.getCursorPosition().column;
|
138
|
+
case "LINE_NUMBER":
|
139
|
+
return editor.getCursorPosition().row + 1;
|
140
|
+
case "SOFT_TABS":
|
141
|
+
return s.getUseSoftTabs() ? "YES" : "NO";
|
142
|
+
case "TAB_SIZE":
|
143
|
+
return s.getTabSize();
|
144
|
+
case "FILENAME":
|
145
|
+
case "FILEPATH":
|
146
|
+
return "";
|
147
|
+
case "FULLNAME":
|
148
|
+
return "Ace";
|
149
|
+
}
|
150
|
+
};
|
151
|
+
this.variables = {};
|
152
|
+
this.getVariableValue = function(editor, varName) {
|
153
|
+
if (this.variables.hasOwnProperty(varName))
|
154
|
+
return this.variables[varName](editor, varName) || "";
|
155
|
+
return this.$getDefaultValue(editor, varName) || "";
|
156
|
+
};
|
157
|
+
this.tmStrFormat = function(str, ch, editor) {
|
158
|
+
var flag = ch.flag || "";
|
159
|
+
var re = ch.guard;
|
160
|
+
re = new RegExp(re, flag.replace(/[^gi]/, ""));
|
161
|
+
var fmtTokens = this.tokenizeTmSnippet(ch.fmt, "formatString");
|
162
|
+
var _self = this;
|
163
|
+
var formatted = str.replace(re, function() {
|
164
|
+
_self.variables.__ = arguments;
|
165
|
+
var fmtParts = _self.resolveVariables(fmtTokens, editor);
|
166
|
+
var gChangeCase = "E";
|
167
|
+
for (var i = 0; i < fmtParts.length; i++) {
|
168
|
+
var ch = fmtParts[i];
|
169
|
+
if (typeof ch == "object") {
|
170
|
+
fmtParts[i] = "";
|
171
|
+
if (ch.changeCase && ch.local) {
|
172
|
+
var next = fmtParts[i + 1];
|
173
|
+
if (next && typeof next == "string") {
|
174
|
+
if (ch.changeCase == "u")
|
175
|
+
fmtParts[i] = next[0].toUpperCase();
|
176
|
+
else
|
177
|
+
fmtParts[i] = next[0].toLowerCase();
|
178
|
+
fmtParts[i + 1] = next.substr(1);
|
179
|
+
}
|
180
|
+
} else if (ch.changeCase) {
|
181
|
+
gChangeCase = ch.changeCase;
|
182
|
+
}
|
183
|
+
} else if (gChangeCase == "U") {
|
184
|
+
fmtParts[i] = ch.toUpperCase();
|
185
|
+
} else if (gChangeCase == "L") {
|
186
|
+
fmtParts[i] = ch.toLowerCase();
|
187
|
+
}
|
188
|
+
}
|
189
|
+
return fmtParts.join("");
|
190
|
+
});
|
191
|
+
this.variables.__ = null;
|
192
|
+
return formatted;
|
193
|
+
};
|
194
|
+
|
195
|
+
this.resolveVariables = function(snippet, editor) {
|
196
|
+
var result = [];
|
197
|
+
for (var i = 0; i < snippet.length; i++) {
|
198
|
+
var ch = snippet[i];
|
199
|
+
if (typeof ch == "string") {
|
200
|
+
result.push(ch);
|
201
|
+
} else if (typeof ch != "object") {
|
202
|
+
continue;
|
203
|
+
} else if (ch.skip) {
|
204
|
+
gotoNext(ch);
|
205
|
+
} else if (ch.processed < i) {
|
206
|
+
continue;
|
207
|
+
} else if (ch.text) {
|
208
|
+
var value = this.getVariableValue(editor, ch.text);
|
209
|
+
if (value && ch.fmtString)
|
210
|
+
value = this.tmStrFormat(value, ch);
|
211
|
+
ch.processed = i;
|
212
|
+
if (ch.expectIf == null) {
|
213
|
+
if (value) {
|
214
|
+
result.push(value);
|
215
|
+
gotoNext(ch);
|
216
|
+
}
|
217
|
+
} else {
|
218
|
+
if (value) {
|
219
|
+
ch.skip = ch.elseBranch;
|
220
|
+
} else
|
221
|
+
gotoNext(ch);
|
222
|
+
}
|
223
|
+
} else if (ch.tabstopId != null) {
|
224
|
+
result.push(ch);
|
225
|
+
} else if (ch.changeCase != null) {
|
226
|
+
result.push(ch);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
function gotoNext(ch) {
|
230
|
+
var i1 = snippet.indexOf(ch, i + 1);
|
231
|
+
if (i1 != -1)
|
232
|
+
i = i1;
|
233
|
+
}
|
234
|
+
return result;
|
235
|
+
};
|
236
|
+
|
237
|
+
this.insertSnippetForSelection = function(editor, snippetText) {
|
238
|
+
var cursor = editor.getCursorPosition();
|
239
|
+
var line = editor.session.getLine(cursor.row);
|
240
|
+
var tabString = editor.session.getTabString();
|
241
|
+
var indentString = line.match(/^\s*/)[0];
|
242
|
+
|
243
|
+
if (cursor.column < indentString.length)
|
244
|
+
indentString = indentString.slice(0, cursor.column);
|
245
|
+
|
246
|
+
var tokens = this.tokenizeTmSnippet(snippetText);
|
247
|
+
tokens = this.resolveVariables(tokens, editor);
|
248
|
+
tokens = tokens.map(function(x) {
|
249
|
+
if (x == "\n")
|
250
|
+
return x + indentString;
|
251
|
+
if (typeof x == "string")
|
252
|
+
return x.replace(/\t/g, tabString);
|
253
|
+
return x;
|
254
|
+
});
|
255
|
+
var tabstops = [];
|
256
|
+
tokens.forEach(function(p, i) {
|
257
|
+
if (typeof p != "object")
|
258
|
+
return;
|
259
|
+
var id = p.tabstopId;
|
260
|
+
var ts = tabstops[id];
|
261
|
+
if (!ts) {
|
262
|
+
ts = tabstops[id] = [];
|
263
|
+
ts.index = id;
|
264
|
+
ts.value = "";
|
265
|
+
}
|
266
|
+
if (ts.indexOf(p) !== -1)
|
267
|
+
return;
|
268
|
+
ts.push(p);
|
269
|
+
var i1 = tokens.indexOf(p, i + 1);
|
270
|
+
if (i1 === -1)
|
271
|
+
return;
|
272
|
+
|
273
|
+
var value = tokens.slice(i + 1, i1);
|
274
|
+
var isNested = value.some(function(t) {return typeof t === "object"});
|
275
|
+
if (isNested && !ts.value) {
|
276
|
+
ts.value = value;
|
277
|
+
} else if (value.length && (!ts.value || typeof ts.value !== "string")) {
|
278
|
+
ts.value = value.join("");
|
279
|
+
}
|
280
|
+
});
|
281
|
+
tabstops.forEach(function(ts) {ts.length = 0});
|
282
|
+
var expanding = {};
|
283
|
+
function copyValue(val) {
|
284
|
+
var copy = [];
|
285
|
+
for (var i = 0; i < val.length; i++) {
|
286
|
+
var p = val[i];
|
287
|
+
if (typeof p == "object") {
|
288
|
+
if (expanding[p.tabstopId])
|
289
|
+
continue;
|
290
|
+
var j = val.lastIndexOf(p, i - 1);
|
291
|
+
p = copy[j] || {tabstopId: p.tabstopId};
|
292
|
+
}
|
293
|
+
copy[i] = p;
|
294
|
+
}
|
295
|
+
return copy;
|
296
|
+
}
|
297
|
+
for (var i = 0; i < tokens.length; i++) {
|
298
|
+
var p = tokens[i];
|
299
|
+
if (typeof p != "object")
|
300
|
+
continue;
|
301
|
+
var id = p.tabstopId;
|
302
|
+
var i1 = tokens.indexOf(p, i + 1);
|
303
|
+
if (expanding[id]) {
|
304
|
+
if (expanding[id] === p)
|
305
|
+
expanding[id] = null;
|
306
|
+
continue;
|
307
|
+
}
|
308
|
+
|
309
|
+
var ts = tabstops[id];
|
310
|
+
var arg = typeof ts.value == "string" ? [ts.value] : copyValue(ts.value);
|
311
|
+
arg.unshift(i + 1, Math.max(0, i1 - i));
|
312
|
+
arg.push(p);
|
313
|
+
expanding[id] = p;
|
314
|
+
tokens.splice.apply(tokens, arg);
|
315
|
+
|
316
|
+
if (ts.indexOf(p) === -1)
|
317
|
+
ts.push(p);
|
318
|
+
}
|
319
|
+
var row = 0, column = 0;
|
320
|
+
var text = "";
|
321
|
+
tokens.forEach(function(t) {
|
322
|
+
if (typeof t === "string") {
|
323
|
+
if (t[0] === "\n"){
|
324
|
+
column = t.length - 1;
|
325
|
+
row ++;
|
326
|
+
} else
|
327
|
+
column += t.length;
|
328
|
+
text += t;
|
329
|
+
} else {
|
330
|
+
if (!t.start)
|
331
|
+
t.start = {row: row, column: column};
|
332
|
+
else
|
333
|
+
t.end = {row: row, column: column};
|
334
|
+
}
|
335
|
+
});
|
336
|
+
var range = editor.getSelectionRange();
|
337
|
+
var end = editor.session.replace(range, text);
|
338
|
+
|
339
|
+
var tabstopManager = new TabstopManager(editor);
|
340
|
+
var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
|
341
|
+
tabstopManager.addTabstops(tabstops, range.start, end, selectionId);
|
342
|
+
};
|
343
|
+
|
344
|
+
this.insertSnippet = function(editor, snippetText) {
|
345
|
+
var self = this;
|
346
|
+
if (editor.inVirtualSelectionMode)
|
347
|
+
return self.insertSnippetForSelection(editor, snippetText);
|
348
|
+
|
349
|
+
editor.forEachSelection(function() {
|
350
|
+
self.insertSnippetForSelection(editor, snippetText);
|
351
|
+
}, null, {keepOrder: true});
|
352
|
+
|
353
|
+
if (editor.tabstopManager)
|
354
|
+
editor.tabstopManager.tabNext();
|
355
|
+
};
|
356
|
+
|
357
|
+
this.$getScope = function(editor) {
|
358
|
+
var scope = editor.session.$mode.$id || "";
|
359
|
+
scope = scope.split("/").pop();
|
360
|
+
if (scope === "html" || scope === "php") {
|
361
|
+
if (scope === "php" && !editor.session.$mode.inlinePhp)
|
362
|
+
scope = "html";
|
363
|
+
var c = editor.getCursorPosition();
|
364
|
+
var state = editor.session.getState(c.row);
|
365
|
+
if (typeof state === "object") {
|
366
|
+
state = state[0];
|
367
|
+
}
|
368
|
+
if (state.substring) {
|
369
|
+
if (state.substring(0, 3) == "js-")
|
370
|
+
scope = "javascript";
|
371
|
+
else if (state.substring(0, 4) == "css-")
|
372
|
+
scope = "css";
|
373
|
+
else if (state.substring(0, 4) == "php-")
|
374
|
+
scope = "php";
|
375
|
+
}
|
376
|
+
}
|
377
|
+
|
378
|
+
return scope;
|
379
|
+
};
|
380
|
+
|
381
|
+
this.getActiveScopes = function(editor) {
|
382
|
+
var scope = this.$getScope(editor);
|
383
|
+
var scopes = [scope];
|
384
|
+
var snippetMap = this.snippetMap;
|
385
|
+
if (snippetMap[scope] && snippetMap[scope].includeScopes) {
|
386
|
+
scopes.push.apply(scopes, snippetMap[scope].includeScopes);
|
387
|
+
}
|
388
|
+
scopes.push("_");
|
389
|
+
return scopes;
|
390
|
+
};
|
391
|
+
|
392
|
+
this.expandWithTab = function(editor, options) {
|
393
|
+
var self = this;
|
394
|
+
var result = editor.forEachSelection(function() {
|
395
|
+
return self.expandSnippetForSelection(editor, options);
|
396
|
+
}, null, {keepOrder: true});
|
397
|
+
if (result && editor.tabstopManager)
|
398
|
+
editor.tabstopManager.tabNext();
|
399
|
+
return result;
|
400
|
+
};
|
401
|
+
|
402
|
+
this.expandSnippetForSelection = function(editor, options) {
|
403
|
+
var cursor = editor.getCursorPosition();
|
404
|
+
var line = editor.session.getLine(cursor.row);
|
405
|
+
var before = line.substring(0, cursor.column);
|
406
|
+
var after = line.substr(cursor.column);
|
407
|
+
|
408
|
+
var snippetMap = this.snippetMap;
|
409
|
+
var snippet;
|
410
|
+
this.getActiveScopes(editor).some(function(scope) {
|
411
|
+
var snippets = snippetMap[scope];
|
412
|
+
if (snippets)
|
413
|
+
snippet = this.findMatchingSnippet(snippets, before, after);
|
414
|
+
return !!snippet;
|
415
|
+
}, this);
|
416
|
+
if (!snippet)
|
417
|
+
return false;
|
418
|
+
if (options && options.dryRun)
|
419
|
+
return true;
|
420
|
+
editor.session.doc.removeInLine(cursor.row,
|
421
|
+
cursor.column - snippet.replaceBefore.length,
|
422
|
+
cursor.column + snippet.replaceAfter.length
|
423
|
+
);
|
424
|
+
|
425
|
+
this.variables.M__ = snippet.matchBefore;
|
426
|
+
this.variables.T__ = snippet.matchAfter;
|
427
|
+
this.insertSnippetForSelection(editor, snippet.content);
|
428
|
+
|
429
|
+
this.variables.M__ = this.variables.T__ = null;
|
430
|
+
return true;
|
431
|
+
};
|
432
|
+
|
433
|
+
this.findMatchingSnippet = function(snippetList, before, after) {
|
434
|
+
for (var i = snippetList.length; i--;) {
|
435
|
+
var s = snippetList[i];
|
436
|
+
if (s.startRe && !s.startRe.test(before))
|
437
|
+
continue;
|
438
|
+
if (s.endRe && !s.endRe.test(after))
|
439
|
+
continue;
|
440
|
+
if (!s.startRe && !s.endRe)
|
441
|
+
continue;
|
442
|
+
|
443
|
+
s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
|
444
|
+
s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
|
445
|
+
s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
|
446
|
+
s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : "";
|
447
|
+
return s;
|
448
|
+
}
|
449
|
+
};
|
450
|
+
|
451
|
+
this.snippetMap = {};
|
452
|
+
this.snippetNameMap = {};
|
453
|
+
this.register = function(snippets, scope) {
|
454
|
+
var snippetMap = this.snippetMap;
|
455
|
+
var snippetNameMap = this.snippetNameMap;
|
456
|
+
var self = this;
|
457
|
+
|
458
|
+
if (!snippets)
|
459
|
+
snippets = [];
|
460
|
+
|
461
|
+
function wrapRegexp(src) {
|
462
|
+
if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
|
463
|
+
src = "(?:" + src + ")";
|
464
|
+
|
465
|
+
return src || "";
|
466
|
+
}
|
467
|
+
function guardedRegexp(re, guard, opening) {
|
468
|
+
re = wrapRegexp(re);
|
469
|
+
guard = wrapRegexp(guard);
|
470
|
+
if (opening) {
|
471
|
+
re = guard + re;
|
472
|
+
if (re && re[re.length - 1] != "$")
|
473
|
+
re = re + "$";
|
474
|
+
} else {
|
475
|
+
re = re + guard;
|
476
|
+
if (re && re[0] != "^")
|
477
|
+
re = "^" + re;
|
478
|
+
}
|
479
|
+
return new RegExp(re);
|
480
|
+
}
|
481
|
+
|
482
|
+
function addSnippet(s) {
|
483
|
+
if (!s.scope)
|
484
|
+
s.scope = scope || "_";
|
485
|
+
scope = s.scope;
|
486
|
+
if (!snippetMap[scope]) {
|
487
|
+
snippetMap[scope] = [];
|
488
|
+
snippetNameMap[scope] = {};
|
489
|
+
}
|
490
|
+
|
491
|
+
var map = snippetNameMap[scope];
|
492
|
+
if (s.name) {
|
493
|
+
var old = map[s.name];
|
494
|
+
if (old)
|
495
|
+
self.unregister(old);
|
496
|
+
map[s.name] = s;
|
497
|
+
}
|
498
|
+
snippetMap[scope].push(s);
|
499
|
+
|
500
|
+
if (s.tabTrigger && !s.trigger) {
|
501
|
+
if (!s.guard && /^\w/.test(s.tabTrigger))
|
502
|
+
s.guard = "\\b";
|
503
|
+
s.trigger = lang.escapeRegExp(s.tabTrigger);
|
504
|
+
}
|
505
|
+
|
506
|
+
s.startRe = guardedRegexp(s.trigger, s.guard, true);
|
507
|
+
s.triggerRe = new RegExp(s.trigger, "", true);
|
508
|
+
|
509
|
+
s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
|
510
|
+
s.endTriggerRe = new RegExp(s.endTrigger, "", true);
|
511
|
+
}
|
512
|
+
|
513
|
+
if (snippets && snippets.content)
|
514
|
+
addSnippet(snippets);
|
515
|
+
else if (Array.isArray(snippets))
|
516
|
+
snippets.forEach(addSnippet);
|
517
|
+
|
518
|
+
this._signal("registerSnippets", {scope: scope});
|
519
|
+
};
|
520
|
+
this.unregister = function(snippets, scope) {
|
521
|
+
var snippetMap = this.snippetMap;
|
522
|
+
var snippetNameMap = this.snippetNameMap;
|
523
|
+
|
524
|
+
function removeSnippet(s) {
|
525
|
+
var nameMap = snippetNameMap[s.scope||scope];
|
526
|
+
if (nameMap && nameMap[s.name]) {
|
527
|
+
delete nameMap[s.name];
|
528
|
+
var map = snippetMap[s.scope||scope];
|
529
|
+
var i = map && map.indexOf(s);
|
530
|
+
if (i >= 0)
|
531
|
+
map.splice(i, 1);
|
532
|
+
}
|
533
|
+
}
|
534
|
+
if (snippets.content)
|
535
|
+
removeSnippet(snippets);
|
536
|
+
else if (Array.isArray(snippets))
|
537
|
+
snippets.forEach(removeSnippet);
|
538
|
+
};
|
539
|
+
this.parseSnippetFile = function(str) {
|
540
|
+
str = str.replace(/\r/g, "");
|
541
|
+
var list = [], snippet = {};
|
542
|
+
var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
|
543
|
+
var m;
|
544
|
+
while (m = re.exec(str)) {
|
545
|
+
if (m[1]) {
|
546
|
+
try {
|
547
|
+
snippet = JSON.parse(m[1]);
|
548
|
+
list.push(snippet);
|
549
|
+
} catch (e) {}
|
550
|
+
} if (m[4]) {
|
551
|
+
snippet.content = m[4].replace(/^\t/gm, "");
|
552
|
+
list.push(snippet);
|
553
|
+
snippet = {};
|
554
|
+
} else {
|
555
|
+
var key = m[2], val = m[3];
|
556
|
+
if (key == "regex") {
|
557
|
+
var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
|
558
|
+
snippet.guard = guardRe.exec(val)[1];
|
559
|
+
snippet.trigger = guardRe.exec(val)[1];
|
560
|
+
snippet.endTrigger = guardRe.exec(val)[1];
|
561
|
+
snippet.endGuard = guardRe.exec(val)[1];
|
562
|
+
} else if (key == "snippet") {
|
563
|
+
snippet.tabTrigger = val.match(/^\S*/)[0];
|
564
|
+
if (!snippet.name)
|
565
|
+
snippet.name = val;
|
566
|
+
} else {
|
567
|
+
snippet[key] = val;
|
568
|
+
}
|
569
|
+
}
|
570
|
+
}
|
571
|
+
return list;
|
572
|
+
};
|
573
|
+
this.getSnippetByName = function(name, editor) {
|
574
|
+
var snippetMap = this.snippetNameMap;
|
575
|
+
var snippet;
|
576
|
+
this.getActiveScopes(editor).some(function(scope) {
|
577
|
+
var snippets = snippetMap[scope];
|
578
|
+
if (snippets)
|
579
|
+
snippet = snippets[name];
|
580
|
+
return !!snippet;
|
581
|
+
}, this);
|
582
|
+
return snippet;
|
583
|
+
};
|
584
|
+
|
585
|
+
}).call(SnippetManager.prototype);
|
586
|
+
|
587
|
+
|
588
|
+
var TabstopManager = function(editor) {
|
589
|
+
if (editor.tabstopManager)
|
590
|
+
return editor.tabstopManager;
|
591
|
+
editor.tabstopManager = this;
|
592
|
+
this.$onChange = this.onChange.bind(this);
|
593
|
+
this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
|
594
|
+
this.$onChangeSession = this.onChangeSession.bind(this);
|
595
|
+
this.$onAfterExec = this.onAfterExec.bind(this);
|
596
|
+
this.attach(editor);
|
597
|
+
};
|
598
|
+
(function() {
|
599
|
+
this.attach = function(editor) {
|
600
|
+
this.index = 0;
|
601
|
+
this.ranges = [];
|
602
|
+
this.tabstops = [];
|
603
|
+
this.$openTabstops = null;
|
604
|
+
this.selectedTabstop = null;
|
605
|
+
|
606
|
+
this.editor = editor;
|
607
|
+
this.editor.on("change", this.$onChange);
|
608
|
+
this.editor.on("changeSelection", this.$onChangeSelection);
|
609
|
+
this.editor.on("changeSession", this.$onChangeSession);
|
610
|
+
this.editor.commands.on("afterExec", this.$onAfterExec);
|
611
|
+
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
612
|
+
};
|
613
|
+
this.detach = function() {
|
614
|
+
this.tabstops.forEach(this.removeTabstopMarkers, this);
|
615
|
+
this.ranges = null;
|
616
|
+
this.tabstops = null;
|
617
|
+
this.selectedTabstop = null;
|
618
|
+
this.editor.removeListener("change", this.$onChange);
|
619
|
+
this.editor.removeListener("changeSelection", this.$onChangeSelection);
|
620
|
+
this.editor.removeListener("changeSession", this.$onChangeSession);
|
621
|
+
this.editor.commands.removeListener("afterExec", this.$onAfterExec);
|
622
|
+
this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
|
623
|
+
this.editor.tabstopManager = null;
|
624
|
+
this.editor = null;
|
625
|
+
};
|
626
|
+
|
627
|
+
this.onChange = function(e) {
|
628
|
+
var changeRange = e.data.range;
|
629
|
+
var isRemove = e.data.action[0] == "r";
|
630
|
+
var start = changeRange.start;
|
631
|
+
var end = changeRange.end;
|
632
|
+
var startRow = start.row;
|
633
|
+
var endRow = end.row;
|
634
|
+
var lineDif = endRow - startRow;
|
635
|
+
var colDiff = end.column - start.column;
|
636
|
+
|
637
|
+
if (isRemove) {
|
638
|
+
lineDif = -lineDif;
|
639
|
+
colDiff = -colDiff;
|
640
|
+
}
|
641
|
+
if (!this.$inChange && isRemove) {
|
642
|
+
var ts = this.selectedTabstop;
|
643
|
+
var changedOutside = ts && !ts.some(function(r) {
|
644
|
+
return comparePoints(r.start, start) <= 0 && comparePoints(r.end, end) >= 0;
|
645
|
+
});
|
646
|
+
if (changedOutside)
|
647
|
+
return this.detach();
|
648
|
+
}
|
649
|
+
var ranges = this.ranges;
|
650
|
+
for (var i = 0; i < ranges.length; i++) {
|
651
|
+
var r = ranges[i];
|
652
|
+
if (r.end.row < start.row)
|
653
|
+
continue;
|
654
|
+
|
655
|
+
if (isRemove && comparePoints(start, r.start) < 0 && comparePoints(end, r.end) > 0) {
|
656
|
+
this.removeRange(r);
|
657
|
+
i--;
|
658
|
+
continue;
|
659
|
+
}
|
660
|
+
|
661
|
+
if (r.start.row == startRow && r.start.column > start.column)
|
662
|
+
r.start.column += colDiff;
|
663
|
+
if (r.end.row == startRow && r.end.column >= start.column)
|
664
|
+
r.end.column += colDiff;
|
665
|
+
if (r.start.row >= startRow)
|
666
|
+
r.start.row += lineDif;
|
667
|
+
if (r.end.row >= startRow)
|
668
|
+
r.end.row += lineDif;
|
669
|
+
|
670
|
+
if (comparePoints(r.start, r.end) > 0)
|
671
|
+
this.removeRange(r);
|
672
|
+
}
|
673
|
+
if (!ranges.length)
|
674
|
+
this.detach();
|
675
|
+
};
|
676
|
+
this.updateLinkedFields = function() {
|
677
|
+
var ts = this.selectedTabstop;
|
678
|
+
if (!ts || !ts.hasLinkedRanges)
|
679
|
+
return;
|
680
|
+
this.$inChange = true;
|
681
|
+
var session = this.editor.session;
|
682
|
+
var text = session.getTextRange(ts.firstNonLinked);
|
683
|
+
for (var i = ts.length; i--;) {
|
684
|
+
var range = ts[i];
|
685
|
+
if (!range.linked)
|
686
|
+
continue;
|
687
|
+
var fmt = exports.snippetManager.tmStrFormat(text, range.original);
|
688
|
+
session.replace(range, fmt);
|
689
|
+
}
|
690
|
+
this.$inChange = false;
|
691
|
+
};
|
692
|
+
this.onAfterExec = function(e) {
|
693
|
+
if (e.command && !e.command.readOnly)
|
694
|
+
this.updateLinkedFields();
|
695
|
+
};
|
696
|
+
this.onChangeSelection = function() {
|
697
|
+
if (!this.editor)
|
698
|
+
return;
|
699
|
+
var lead = this.editor.selection.lead;
|
700
|
+
var anchor = this.editor.selection.anchor;
|
701
|
+
var isEmpty = this.editor.selection.isEmpty();
|
702
|
+
for (var i = this.ranges.length; i--;) {
|
703
|
+
if (this.ranges[i].linked)
|
704
|
+
continue;
|
705
|
+
var containsLead = this.ranges[i].contains(lead.row, lead.column);
|
706
|
+
var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
|
707
|
+
if (containsLead && containsAnchor)
|
708
|
+
return;
|
709
|
+
}
|
710
|
+
this.detach();
|
711
|
+
};
|
712
|
+
this.onChangeSession = function() {
|
713
|
+
this.detach();
|
714
|
+
};
|
715
|
+
this.tabNext = function(dir) {
|
716
|
+
var max = this.tabstops.length;
|
717
|
+
var index = this.index + (dir || 1);
|
718
|
+
index = Math.min(Math.max(index, 1), max);
|
719
|
+
if (index == max)
|
720
|
+
index = 0;
|
721
|
+
this.selectTabstop(index);
|
722
|
+
if (index === 0)
|
723
|
+
this.detach();
|
724
|
+
};
|
725
|
+
this.selectTabstop = function(index) {
|
726
|
+
this.$openTabstops = null;
|
727
|
+
var ts = this.tabstops[this.index];
|
728
|
+
if (ts)
|
729
|
+
this.addTabstopMarkers(ts);
|
730
|
+
this.index = index;
|
731
|
+
ts = this.tabstops[this.index];
|
732
|
+
if (!ts || !ts.length)
|
733
|
+
return;
|
734
|
+
|
735
|
+
this.selectedTabstop = ts;
|
736
|
+
if (!this.editor.inVirtualSelectionMode) {
|
737
|
+
var sel = this.editor.multiSelect;
|
738
|
+
sel.toSingleRange(ts.firstNonLinked.clone());
|
739
|
+
for (var i = ts.length; i--;) {
|
740
|
+
if (ts.hasLinkedRanges && ts[i].linked)
|
741
|
+
continue;
|
742
|
+
sel.addRange(ts[i].clone(), true);
|
743
|
+
}
|
744
|
+
if (sel.ranges[0])
|
745
|
+
sel.addRange(sel.ranges[0].clone());
|
746
|
+
} else {
|
747
|
+
this.editor.selection.setRange(ts.firstNonLinked);
|
748
|
+
}
|
749
|
+
|
750
|
+
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
751
|
+
};
|
752
|
+
this.addTabstops = function(tabstops, start, end) {
|
753
|
+
if (!this.$openTabstops)
|
754
|
+
this.$openTabstops = [];
|
755
|
+
if (!tabstops[0]) {
|
756
|
+
var p = Range.fromPoints(end, end);
|
757
|
+
moveRelative(p.start, start);
|
758
|
+
moveRelative(p.end, start);
|
759
|
+
tabstops[0] = [p];
|
760
|
+
tabstops[0].index = 0;
|
761
|
+
}
|
762
|
+
|
763
|
+
var i = this.index;
|
764
|
+
var arg = [i + 1, 0];
|
765
|
+
var ranges = this.ranges;
|
766
|
+
tabstops.forEach(function(ts, index) {
|
767
|
+
var dest = this.$openTabstops[index] || ts;
|
768
|
+
|
769
|
+
for (var i = ts.length; i--;) {
|
770
|
+
var p = ts[i];
|
771
|
+
var range = Range.fromPoints(p.start, p.end || p.start);
|
772
|
+
movePoint(range.start, start);
|
773
|
+
movePoint(range.end, start);
|
774
|
+
range.original = p;
|
775
|
+
range.tabstop = dest;
|
776
|
+
ranges.push(range);
|
777
|
+
if (dest != ts)
|
778
|
+
dest.unshift(range);
|
779
|
+
else
|
780
|
+
dest[i] = range;
|
781
|
+
if (p.fmtString) {
|
782
|
+
range.linked = true;
|
783
|
+
dest.hasLinkedRanges = true;
|
784
|
+
} else if (!dest.firstNonLinked)
|
785
|
+
dest.firstNonLinked = range;
|
786
|
+
}
|
787
|
+
if (!dest.firstNonLinked)
|
788
|
+
dest.hasLinkedRanges = false;
|
789
|
+
if (dest === ts) {
|
790
|
+
arg.push(dest);
|
791
|
+
this.$openTabstops[index] = dest;
|
792
|
+
}
|
793
|
+
this.addTabstopMarkers(dest);
|
794
|
+
}, this);
|
795
|
+
|
796
|
+
if (arg.length > 2) {
|
797
|
+
if (this.tabstops.length)
|
798
|
+
arg.push(arg.splice(2, 1)[0]);
|
799
|
+
this.tabstops.splice.apply(this.tabstops, arg);
|
800
|
+
}
|
801
|
+
};
|
802
|
+
|
803
|
+
this.addTabstopMarkers = function(ts) {
|
804
|
+
var session = this.editor.session;
|
805
|
+
ts.forEach(function(range) {
|
806
|
+
if (!range.markerId)
|
807
|
+
range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
|
808
|
+
});
|
809
|
+
};
|
810
|
+
this.removeTabstopMarkers = function(ts) {
|
811
|
+
var session = this.editor.session;
|
812
|
+
ts.forEach(function(range) {
|
813
|
+
session.removeMarker(range.markerId);
|
814
|
+
range.markerId = null;
|
815
|
+
});
|
816
|
+
};
|
817
|
+
this.removeRange = function(range) {
|
818
|
+
var i = range.tabstop.indexOf(range);
|
819
|
+
range.tabstop.splice(i, 1);
|
820
|
+
i = this.ranges.indexOf(range);
|
821
|
+
this.ranges.splice(i, 1);
|
822
|
+
this.editor.session.removeMarker(range.markerId);
|
823
|
+
if (!range.tabstop.length) {
|
824
|
+
i = this.tabstops.indexOf(range.tabstop);
|
825
|
+
if (i != -1)
|
826
|
+
this.tabstops.splice(i, 1);
|
827
|
+
if (!this.tabstops.length)
|
828
|
+
this.detach();
|
829
|
+
}
|
830
|
+
};
|
831
|
+
|
832
|
+
this.keyboardHandler = new HashHandler();
|
833
|
+
this.keyboardHandler.bindKeys({
|
834
|
+
"Tab": function(ed) {
|
835
|
+
if (exports.snippetManager && exports.snippetManager.expandWithTab(ed)) {
|
836
|
+
return;
|
837
|
+
}
|
838
|
+
|
839
|
+
ed.tabstopManager.tabNext(1);
|
840
|
+
},
|
841
|
+
"Shift-Tab": function(ed) {
|
842
|
+
ed.tabstopManager.tabNext(-1);
|
843
|
+
},
|
844
|
+
"Esc": function(ed) {
|
845
|
+
ed.tabstopManager.detach();
|
846
|
+
},
|
847
|
+
"Return": function(ed) {
|
848
|
+
return false;
|
849
|
+
}
|
850
|
+
});
|
851
|
+
}).call(TabstopManager.prototype);
|
852
|
+
|
853
|
+
|
854
|
+
|
855
|
+
var changeTracker = {};
|
856
|
+
changeTracker.onChange = Anchor.prototype.onChange;
|
857
|
+
changeTracker.setPosition = function(row, column) {
|
858
|
+
this.pos.row = row;
|
859
|
+
this.pos.column = column;
|
860
|
+
};
|
861
|
+
changeTracker.update = function(pos, delta, $insertRight) {
|
862
|
+
this.$insertRight = $insertRight;
|
863
|
+
this.pos = pos;
|
864
|
+
this.onChange(delta);
|
865
|
+
};
|
866
|
+
|
867
|
+
var movePoint = function(point, diff) {
|
868
|
+
if (point.row == 0)
|
869
|
+
point.column += diff.column;
|
870
|
+
point.row += diff.row;
|
871
|
+
};
|
872
|
+
|
873
|
+
var moveRelative = function(point, start) {
|
874
|
+
if (point.row == start.row)
|
875
|
+
point.column -= start.column;
|
876
|
+
point.row -= start.row;
|
877
|
+
};
|
878
|
+
|
879
|
+
|
880
|
+
require("./lib/dom").importCssString("\
|
881
|
+
.ace_snippet-marker {\
|
882
|
+
-moz-box-sizing: border-box;\
|
883
|
+
box-sizing: border-box;\
|
884
|
+
background: rgba(194, 193, 208, 0.09);\
|
885
|
+
border: 1px dotted rgba(211, 208, 235, 0.62);\
|
886
|
+
position: absolute;\
|
887
|
+
}");
|
888
|
+
|
889
|
+
exports.snippetManager = new SnippetManager();
|
890
|
+
|
891
|
+
|
892
|
+
var Editor = require("./editor").Editor;
|
893
|
+
(function() {
|
894
|
+
this.insertSnippet = function(content, options) {
|
895
|
+
return exports.snippetManager.insertSnippet(this, content, options);
|
896
|
+
};
|
897
|
+
this.expandSnippet = function(options) {
|
898
|
+
return exports.snippetManager.expandWithTab(this, options);
|
899
|
+
};
|
900
|
+
}).call(Editor.prototype);
|
901
|
+
|
902
|
+
});
|
903
|
+
|
904
|
+
ace.define("ace/ext/emmet",["require","exports","module","ace/keyboard/hash_handler","ace/editor","ace/snippets","ace/range","resources","resources","range","tabStops","resources","utils","actions","ace/config","ace/config"], function(require, exports, module) {
|
905
|
+
"use strict";
|
906
|
+
var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
|
907
|
+
var Editor = require("ace/editor").Editor;
|
908
|
+
var snippetManager = require("ace/snippets").snippetManager;
|
909
|
+
var Range = require("ace/range").Range;
|
910
|
+
var emmet, emmetPath;
|
911
|
+
function AceEmmetEditor() {}
|
912
|
+
|
913
|
+
AceEmmetEditor.prototype = {
|
914
|
+
setupContext: function(editor) {
|
915
|
+
this.ace = editor;
|
916
|
+
this.indentation = editor.session.getTabString();
|
917
|
+
if (!emmet)
|
918
|
+
emmet = window.emmet;
|
919
|
+
emmet.require("resources").setVariable("indentation", this.indentation);
|
920
|
+
this.$syntax = null;
|
921
|
+
this.$syntax = this.getSyntax();
|
922
|
+
},
|
923
|
+
getSelectionRange: function() {
|
924
|
+
var range = this.ace.getSelectionRange();
|
925
|
+
var doc = this.ace.session.doc;
|
926
|
+
return {
|
927
|
+
start: doc.positionToIndex(range.start),
|
928
|
+
end: doc.positionToIndex(range.end)
|
929
|
+
};
|
930
|
+
},
|
931
|
+
createSelection: function(start, end) {
|
932
|
+
var doc = this.ace.session.doc;
|
933
|
+
this.ace.selection.setRange({
|
934
|
+
start: doc.indexToPosition(start),
|
935
|
+
end: doc.indexToPosition(end)
|
936
|
+
});
|
937
|
+
},
|
938
|
+
getCurrentLineRange: function() {
|
939
|
+
var ace = this.ace;
|
940
|
+
var row = ace.getCursorPosition().row;
|
941
|
+
var lineLength = ace.session.getLine(row).length;
|
942
|
+
var index = ace.session.doc.positionToIndex({row: row, column: 0});
|
943
|
+
return {
|
944
|
+
start: index,
|
945
|
+
end: index + lineLength
|
946
|
+
};
|
947
|
+
},
|
948
|
+
getCaretPos: function(){
|
949
|
+
var pos = this.ace.getCursorPosition();
|
950
|
+
return this.ace.session.doc.positionToIndex(pos);
|
951
|
+
},
|
952
|
+
setCaretPos: function(index){
|
953
|
+
var pos = this.ace.session.doc.indexToPosition(index);
|
954
|
+
this.ace.selection.moveToPosition(pos);
|
955
|
+
},
|
956
|
+
getCurrentLine: function() {
|
957
|
+
var row = this.ace.getCursorPosition().row;
|
958
|
+
return this.ace.session.getLine(row);
|
959
|
+
},
|
960
|
+
replaceContent: function(value, start, end, noIndent) {
|
961
|
+
if (end == null)
|
962
|
+
end = start == null ? this.getContent().length : start;
|
963
|
+
if (start == null)
|
964
|
+
start = 0;
|
965
|
+
|
966
|
+
var editor = this.ace;
|
967
|
+
var doc = editor.session.doc;
|
968
|
+
var range = Range.fromPoints(doc.indexToPosition(start), doc.indexToPosition(end));
|
969
|
+
editor.session.remove(range);
|
970
|
+
|
971
|
+
range.end = range.start;
|
972
|
+
|
973
|
+
value = this.$updateTabstops(value);
|
974
|
+
snippetManager.insertSnippet(editor, value);
|
975
|
+
},
|
976
|
+
getContent: function(){
|
977
|
+
return this.ace.getValue();
|
978
|
+
},
|
979
|
+
getSyntax: function() {
|
980
|
+
if (this.$syntax)
|
981
|
+
return this.$syntax;
|
982
|
+
var syntax = this.ace.session.$modeId.split("/").pop();
|
983
|
+
if (syntax == "html" || syntax == "php") {
|
984
|
+
var cursor = this.ace.getCursorPosition();
|
985
|
+
var state = this.ace.session.getState(cursor.row);
|
986
|
+
if (typeof state != "string")
|
987
|
+
state = state[0];
|
988
|
+
if (state) {
|
989
|
+
state = state.split("-");
|
990
|
+
if (state.length > 1)
|
991
|
+
syntax = state[0];
|
992
|
+
else if (syntax == "php")
|
993
|
+
syntax = "html";
|
994
|
+
}
|
995
|
+
}
|
996
|
+
return syntax;
|
997
|
+
},
|
998
|
+
getProfileName: function() {
|
999
|
+
switch(this.getSyntax()) {
|
1000
|
+
case "css": return "css";
|
1001
|
+
case "xml":
|
1002
|
+
case "xsl":
|
1003
|
+
return "xml";
|
1004
|
+
case "html":
|
1005
|
+
var profile = emmet.require("resources").getVariable("profile");
|
1006
|
+
if (!profile)
|
1007
|
+
profile = this.ace.session.getLines(0,2).join("").search(/<!DOCTYPE[^>]+XHTML/i) != -1 ? "xhtml": "html";
|
1008
|
+
return profile;
|
1009
|
+
}
|
1010
|
+
return "xhtml";
|
1011
|
+
},
|
1012
|
+
prompt: function(title) {
|
1013
|
+
return prompt(title);
|
1014
|
+
},
|
1015
|
+
getSelection: function() {
|
1016
|
+
return this.ace.session.getTextRange();
|
1017
|
+
},
|
1018
|
+
getFilePath: function() {
|
1019
|
+
return "";
|
1020
|
+
},
|
1021
|
+
$updateTabstops: function(value) {
|
1022
|
+
var base = 1000;
|
1023
|
+
var zeroBase = 0;
|
1024
|
+
var lastZero = null;
|
1025
|
+
var range = emmet.require('range');
|
1026
|
+
var ts = emmet.require('tabStops');
|
1027
|
+
var settings = emmet.require('resources').getVocabulary("user");
|
1028
|
+
var tabstopOptions = {
|
1029
|
+
tabstop: function(data) {
|
1030
|
+
var group = parseInt(data.group, 10);
|
1031
|
+
var isZero = group === 0;
|
1032
|
+
if (isZero)
|
1033
|
+
group = ++zeroBase;
|
1034
|
+
else
|
1035
|
+
group += base;
|
1036
|
+
|
1037
|
+
var placeholder = data.placeholder;
|
1038
|
+
if (placeholder) {
|
1039
|
+
placeholder = ts.processText(placeholder, tabstopOptions);
|
1040
|
+
}
|
1041
|
+
|
1042
|
+
var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}';
|
1043
|
+
|
1044
|
+
if (isZero) {
|
1045
|
+
lastZero = range.create(data.start, result);
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
return result;
|
1049
|
+
},
|
1050
|
+
escape: function(ch) {
|
1051
|
+
if (ch == '$') return '\\$';
|
1052
|
+
if (ch == '\\') return '\\\\';
|
1053
|
+
return ch;
|
1054
|
+
}
|
1055
|
+
};
|
1056
|
+
|
1057
|
+
value = ts.processText(value, tabstopOptions);
|
1058
|
+
|
1059
|
+
if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) {
|
1060
|
+
value += '${0}';
|
1061
|
+
} else if (lastZero) {
|
1062
|
+
value = emmet.require('utils').replaceSubstring(value, '${0}', lastZero);
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
return value;
|
1066
|
+
}
|
1067
|
+
};
|
1068
|
+
|
1069
|
+
|
1070
|
+
var keymap = {
|
1071
|
+
expand_abbreviation: {"mac": "ctrl+alt+e", "win": "alt+e"},
|
1072
|
+
match_pair_outward: {"mac": "ctrl+d", "win": "ctrl+,"},
|
1073
|
+
match_pair_inward: {"mac": "ctrl+j", "win": "ctrl+shift+0"},
|
1074
|
+
matching_pair: {"mac": "ctrl+alt+j", "win": "alt+j"},
|
1075
|
+
next_edit_point: "alt+right",
|
1076
|
+
prev_edit_point: "alt+left",
|
1077
|
+
toggle_comment: {"mac": "command+/", "win": "ctrl+/"},
|
1078
|
+
split_join_tag: {"mac": "shift+command+'", "win": "shift+ctrl+`"},
|
1079
|
+
remove_tag: {"mac": "command+'", "win": "shift+ctrl+;"},
|
1080
|
+
evaluate_math_expression: {"mac": "shift+command+y", "win": "shift+ctrl+y"},
|
1081
|
+
increment_number_by_1: "ctrl+up",
|
1082
|
+
decrement_number_by_1: "ctrl+down",
|
1083
|
+
increment_number_by_01: "alt+up",
|
1084
|
+
decrement_number_by_01: "alt+down",
|
1085
|
+
increment_number_by_10: {"mac": "alt+command+up", "win": "shift+alt+up"},
|
1086
|
+
decrement_number_by_10: {"mac": "alt+command+down", "win": "shift+alt+down"},
|
1087
|
+
select_next_item: {"mac": "shift+command+.", "win": "shift+ctrl+."},
|
1088
|
+
select_previous_item: {"mac": "shift+command+,", "win": "shift+ctrl+,"},
|
1089
|
+
reflect_css_value: {"mac": "shift+command+r", "win": "shift+ctrl+r"},
|
1090
|
+
|
1091
|
+
encode_decode_data_url: {"mac": "shift+ctrl+d", "win": "ctrl+'"},
|
1092
|
+
expand_abbreviation_with_tab: "Tab",
|
1093
|
+
wrap_with_abbreviation: {"mac": "shift+ctrl+a", "win": "shift+ctrl+a"}
|
1094
|
+
};
|
1095
|
+
|
1096
|
+
var editorProxy = new AceEmmetEditor();
|
1097
|
+
exports.commands = new HashHandler();
|
1098
|
+
exports.runEmmetCommand = function(editor) {
|
1099
|
+
try {
|
1100
|
+
editorProxy.setupContext(editor);
|
1101
|
+
if (editorProxy.getSyntax() == "php")
|
1102
|
+
return false;
|
1103
|
+
var actions = emmet.require("actions");
|
1104
|
+
|
1105
|
+
if (this.action == "expand_abbreviation_with_tab") {
|
1106
|
+
if (!editor.selection.isEmpty())
|
1107
|
+
return false;
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
if (this.action == "wrap_with_abbreviation") {
|
1111
|
+
return setTimeout(function() {
|
1112
|
+
actions.run("wrap_with_abbreviation", editorProxy);
|
1113
|
+
}, 0);
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
var pos = editor.selection.lead;
|
1117
|
+
var token = editor.session.getTokenAt(pos.row, pos.column);
|
1118
|
+
if (token && /\btag\b/.test(token.type))
|
1119
|
+
return false;
|
1120
|
+
|
1121
|
+
var result = actions.run(this.action, editorProxy);
|
1122
|
+
} catch(e) {
|
1123
|
+
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
|
1124
|
+
console.log(e);
|
1125
|
+
result = false;
|
1126
|
+
}
|
1127
|
+
return result;
|
1128
|
+
};
|
1129
|
+
|
1130
|
+
for (var command in keymap) {
|
1131
|
+
exports.commands.addCommand({
|
1132
|
+
name: "emmet:" + command,
|
1133
|
+
action: command,
|
1134
|
+
bindKey: keymap[command],
|
1135
|
+
exec: exports.runEmmetCommand,
|
1136
|
+
multiSelectAction: "forEach"
|
1137
|
+
});
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
exports.updateCommands = function(editor, enabled) {
|
1141
|
+
if (enabled) {
|
1142
|
+
editor.keyBinding.addKeyboardHandler(exports.commands);
|
1143
|
+
} else {
|
1144
|
+
editor.keyBinding.removeKeyboardHandler(exports.commands);
|
1145
|
+
}
|
1146
|
+
};
|
1147
|
+
|
1148
|
+
exports.isSupportedMode = function(modeId) {
|
1149
|
+
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs/.test(modeId);
|
1150
|
+
};
|
1151
|
+
|
1152
|
+
var onChangeMode = function(e, target) {
|
1153
|
+
var editor = target;
|
1154
|
+
if (!editor)
|
1155
|
+
return;
|
1156
|
+
var enabled = exports.isSupportedMode(editor.session.$modeId);
|
1157
|
+
if (e.enableEmmet === false)
|
1158
|
+
enabled = false;
|
1159
|
+
if (enabled) {
|
1160
|
+
if (typeof emmetPath == "string") {
|
1161
|
+
require("ace/config").loadModule(emmetPath, function() {
|
1162
|
+
emmetPath = null;
|
1163
|
+
});
|
1164
|
+
}
|
1165
|
+
}
|
1166
|
+
exports.updateCommands(editor, enabled);
|
1167
|
+
};
|
1168
|
+
|
1169
|
+
exports.AceEmmetEditor = AceEmmetEditor;
|
1170
|
+
require("ace/config").defineOptions(Editor.prototype, "editor", {
|
1171
|
+
enableEmmet: {
|
1172
|
+
set: function(val) {
|
1173
|
+
this[val ? "on" : "removeListener"]("changeMode", onChangeMode);
|
1174
|
+
onChangeMode({enableEmmet: !!val}, this);
|
1175
|
+
},
|
1176
|
+
value: true
|
1177
|
+
}
|
1178
|
+
});
|
1179
|
+
|
1180
|
+
exports.setCore = function(e) {
|
1181
|
+
if (typeof e == "string")
|
1182
|
+
emmetPath = e;
|
1183
|
+
else
|
1184
|
+
emmet = e;
|
1185
|
+
};
|
1186
|
+
});
|
1187
|
+
(function() {
|
1188
|
+
ace.require(["ace/ext/emmet"], function() {});
|
1189
|
+
})();
|
1190
|
+
|