1
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
2
|
"use strict";
|
3
|
|
4
|
var oop = require("../../lib/oop");
|
5
|
var Range = require("../../range").Range;
|
6
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
7
|
|
8
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
9
|
if (commentRegex) {
|
10
|
this.foldingStartMarker = new RegExp(
|
11
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
12
|
);
|
13
|
this.foldingStopMarker = new RegExp(
|
14
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
15
|
);
|
16
|
}
|
17
|
};
|
18
|
oop.inherits(FoldMode, BaseFoldMode);
|
19
|
|
20
|
(function() {
|
21
|
|
22
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
23
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
24
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
25
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
26
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
27
|
this._getFoldWidgetBase = this.getFoldWidget;
|
28
|
this.getFoldWidget = function(session, foldStyle, row) {
|
29
|
var line = session.getLine(row);
|
30
|
|
31
|
if (this.singleLineBlockCommentRe.test(line)) {
|
32
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
33
|
return "";
|
34
|
}
|
35
|
|
36
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
37
|
|
38
|
if (!fw && this.startRegionRe.test(line))
|
39
|
return "start"; // lineCommentRegionStart
|
40
|
|
41
|
return fw;
|
42
|
};
|
43
|
|
44
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
45
|
var line = session.getLine(row);
|
46
|
|
47
|
if (this.startRegionRe.test(line))
|
48
|
return this.getCommentRegionBlock(session, line, row);
|
49
|
|
50
|
var match = line.match(this.foldingStartMarker);
|
51
|
if (match) {
|
52
|
var i = match.index;
|
53
|
|
54
|
if (match[1])
|
55
|
return this.openingBracketBlock(session, match[1], row, i);
|
56
|
|
57
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
58
|
|
59
|
if (range && !range.isMultiLine()) {
|
60
|
if (forceMultiline) {
|
61
|
range = this.getSectionRange(session, row);
|
62
|
} else if (foldStyle != "all")
|
63
|
range = null;
|
64
|
}
|
65
|
|
66
|
return range;
|
67
|
}
|
68
|
|
69
|
if (foldStyle === "markbegin")
|
70
|
return;
|
71
|
|
72
|
var match = line.match(this.foldingStopMarker);
|
73
|
if (match) {
|
74
|
var i = match.index + match[0].length;
|
75
|
|
76
|
if (match[1])
|
77
|
return this.closingBracketBlock(session, match[1], row, i);
|
78
|
|
79
|
return session.getCommentFoldRange(row, i, -1);
|
80
|
}
|
81
|
};
|
82
|
|
83
|
this.getSectionRange = function(session, row) {
|
84
|
var line = session.getLine(row);
|
85
|
var startIndent = line.search(/\S/);
|
86
|
var startRow = row;
|
87
|
var startColumn = line.length;
|
88
|
row = row + 1;
|
89
|
var endRow = row;
|
90
|
var maxRow = session.getLength();
|
91
|
while (++row < maxRow) {
|
92
|
line = session.getLine(row);
|
93
|
var indent = line.search(/\S/);
|
94
|
if (indent === -1)
|
95
|
continue;
|
96
|
if (startIndent > indent)
|
97
|
break;
|
98
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
99
|
|
100
|
if (subRange) {
|
101
|
if (subRange.start.row <= startRow) {
|
102
|
break;
|
103
|
} else if (subRange.isMultiLine()) {
|
104
|
row = subRange.end.row;
|
105
|
} else if (startIndent == indent) {
|
106
|
break;
|
107
|
}
|
108
|
}
|
109
|
endRow = row;
|
110
|
}
|
111
|
|
112
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
113
|
};
|
114
|
this.getCommentRegionBlock = function(session, line, row) {
|
115
|
var startColumn = line.search(/\s*$/);
|
116
|
var maxRow = session.getLength();
|
117
|
var startRow = row;
|
118
|
|
119
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
120
|
var depth = 1;
|
121
|
while (++row < maxRow) {
|
122
|
line = session.getLine(row);
|
123
|
var m = re.exec(line);
|
124
|
if (!m) continue;
|
125
|
if (m[1]) depth--;
|
126
|
else depth++;
|
127
|
|
128
|
if (!depth) break;
|
129
|
}
|
130
|
|
131
|
var endRow = row;
|
132
|
if (endRow > startRow) {
|
133
|
return new Range(startRow, startColumn, endRow, line.length);
|
134
|
}
|
135
|
};
|
136
|
|
137
|
}).call(FoldMode.prototype);
|
138
|
|
139
|
});
|
140
|
|
141
|
ace.define("ace/mode/tcl_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
142
|
"use strict";
|
143
|
|
144
|
var oop = require("../lib/oop");
|
145
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
146
|
|
147
|
var TclHighlightRules = function() {
|
148
|
|
149
|
this.$rules = {
|
150
|
"start" : [
|
151
|
{
|
152
|
token : "comment",
|
153
|
regex : "#.*\\\\$",
|
154
|
next : "commentfollow"
|
155
|
}, {
|
156
|
token : "comment",
|
157
|
regex : "#.*$"
|
158
|
}, {
|
159
|
token : "support.function",
|
160
|
regex : '[\\\\]$',
|
161
|
next : "splitlineStart"
|
162
|
}, {
|
163
|
token : "text",
|
164
|
regex : /\\(?:["{}\[\]$\\])/
|
165
|
}, {
|
166
|
token : "text", // last value before command
|
167
|
regex : '^|[^{][;][^}]|[/\r/]',
|
168
|
next : "commandItem"
|
169
|
}, {
|
170
|
token : "string", // single line
|
171
|
regex : '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
172
|
}, {
|
173
|
token : "string", // multi line """ string start
|
174
|
regex : '[ ]*["]',
|
175
|
next : "qqstring"
|
176
|
}, {
|
177
|
token : "variable.instance",
|
178
|
regex : "[$]",
|
179
|
next : "variable"
|
180
|
}, {
|
181
|
token : "support.function",
|
182
|
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::"
|
183
|
}, {
|
184
|
token : "identifier",
|
185
|
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
186
|
}, {
|
187
|
token : "paren.lparen",
|
188
|
regex : "[[{]",
|
189
|
next : "commandItem"
|
190
|
}, {
|
191
|
token : "paren.lparen",
|
192
|
regex : "[(]"
|
193
|
}, {
|
194
|
token : "paren.rparen",
|
195
|
regex : "[\\])}]"
|
196
|
}, {
|
197
|
token : "text",
|
198
|
regex : "\\s+"
|
199
|
}
|
200
|
],
|
201
|
"commandItem" : [
|
202
|
{
|
203
|
token : "comment",
|
204
|
regex : "#.*\\\\$",
|
205
|
next : "commentfollow"
|
206
|
}, {
|
207
|
token : "comment",
|
208
|
regex : "#.*$",
|
209
|
next : "start"
|
210
|
}, {
|
211
|
token : "string", // single line
|
212
|
regex : '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
213
|
}, {
|
214
|
token : "variable.instance",
|
215
|
regex : "[$]",
|
216
|
next : "variable"
|
217
|
}, {
|
218
|
token : "support.function",
|
219
|
regex : "(?:[:][:])[a-zA-Z0-9_/]+(?:[:][:])",
|
220
|
next : "commandItem"
|
221
|
}, {
|
222
|
token : "support.function",
|
223
|
regex : "[a-zA-Z0-9_/]+(?:[:][:])",
|
224
|
next : "commandItem"
|
225
|
}, {
|
226
|
token : "support.function",
|
227
|
regex : "(?:[:][:])",
|
228
|
next : "commandItem"
|
229
|
}, {
|
230
|
token : "paren.rparen",
|
231
|
regex : "[\\])}]"
|
232
|
}, {
|
233
|
token : "paren.lparen",
|
234
|
regex : "[[({]"
|
235
|
}, {
|
236
|
token : "support.function",
|
237
|
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::"
|
238
|
}, {
|
239
|
token : "keyword",
|
240
|
regex : "[a-zA-Z0-9_/]+",
|
241
|
next : "start"
|
242
|
} ],
|
243
|
"commentfollow" : [
|
244
|
{
|
245
|
token : "comment",
|
246
|
regex : ".*\\\\$",
|
247
|
next : "commentfollow"
|
248
|
}, {
|
249
|
token : "comment",
|
250
|
regex : '.+',
|
251
|
next : "start"
|
252
|
} ],
|
253
|
"splitlineStart" : [
|
254
|
{
|
255
|
token : "text",
|
256
|
regex : "^.",
|
257
|
next : "start"
|
258
|
}],
|
259
|
"variable" : [
|
260
|
{
|
261
|
token : "variable.instance", // variable tcl
|
262
|
regex : "[a-zA-Z_\\d]+(?:[(][a-zA-Z_\\d]+[)])?",
|
263
|
next : "start"
|
264
|
}, {
|
265
|
token : "variable.instance", // variable tcl with braces
|
266
|
regex : "{?[a-zA-Z_\\d]+}?",
|
267
|
next : "start"
|
268
|
}],
|
269
|
"qqstring" : [ {
|
270
|
token : "string", // multi line """ string end
|
271
|
regex : '(?:[^\\\\]|\\\\.)*?["]',
|
272
|
next : "start"
|
273
|
}, {
|
274
|
token : "string",
|
275
|
regex : '.+'
|
276
|
} ]
|
277
|
};
|
278
|
};
|
279
|
|
280
|
oop.inherits(TclHighlightRules, TextHighlightRules);
|
281
|
|
282
|
exports.TclHighlightRules = TclHighlightRules;
|
283
|
});
|
284
|
|
285
|
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
286
|
"use strict";
|
287
|
|
288
|
var Range = require("../range").Range;
|
289
|
|
290
|
var MatchingBraceOutdent = function() {};
|
291
|
|
292
|
(function() {
|
293
|
|
294
|
this.checkOutdent = function(line, input) {
|
295
|
if (! /^\s+$/.test(line))
|
296
|
return false;
|
297
|
|
298
|
return /^\s*\}/.test(input);
|
299
|
};
|
300
|
|
301
|
this.autoOutdent = function(doc, row) {
|
302
|
var line = doc.getLine(row);
|
303
|
var match = line.match(/^(\s*\})/);
|
304
|
|
305
|
if (!match) return 0;
|
306
|
|
307
|
var column = match[1].length;
|
308
|
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
309
|
|
310
|
if (!openBracePos || openBracePos.row == row) return 0;
|
311
|
|
312
|
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
313
|
doc.replace(new Range(row, 0, row, column-1), indent);
|
314
|
};
|
315
|
|
316
|
this.$getIndent = function(line) {
|
317
|
return line.match(/^\s*/)[0];
|
318
|
};
|
319
|
|
320
|
}).call(MatchingBraceOutdent.prototype);
|
321
|
|
322
|
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
323
|
});
|
324
|
|
325
|
ace.define("ace/mode/tcl",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/folding/cstyle","ace/mode/tcl_highlight_rules","ace/mode/matching_brace_outdent","ace/range"], function(require, exports, module) {
|
326
|
"use strict";
|
327
|
|
328
|
var oop = require("../lib/oop");
|
329
|
var TextMode = require("./text").Mode;
|
330
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
331
|
var TclHighlightRules = require("./tcl_highlight_rules").TclHighlightRules;
|
332
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
333
|
var Range = require("../range").Range;
|
334
|
|
335
|
var Mode = function() {
|
336
|
this.HighlightRules = TclHighlightRules;
|
337
|
this.$outdent = new MatchingBraceOutdent();
|
338
|
this.foldingRules = new CStyleFoldMode();
|
339
|
this.$behaviour = this.$defaultBehaviour;
|
340
|
};
|
341
|
oop.inherits(Mode, TextMode);
|
342
|
|
343
|
(function() {
|
344
|
|
345
|
this.lineCommentStart = "#";
|
346
|
|
347
|
this.getNextLineIndent = function(state, line, tab) {
|
348
|
var indent = this.$getIndent(line);
|
349
|
|
350
|
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
351
|
var tokens = tokenizedLine.tokens;
|
352
|
|
353
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
354
|
return indent;
|
355
|
}
|
356
|
|
357
|
if (state == "start") {
|
358
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
359
|
if (match) {
|
360
|
indent += tab;
|
361
|
}
|
362
|
}
|
363
|
|
364
|
return indent;
|
365
|
};
|
366
|
|
367
|
this.checkOutdent = function(state, line, input) {
|
368
|
return this.$outdent.checkOutdent(line, input);
|
369
|
};
|
370
|
|
371
|
this.autoOutdent = function(state, doc, row) {
|
372
|
this.$outdent.autoOutdent(doc, row);
|
373
|
};
|
374
|
|
375
|
this.$id = "ace/mode/tcl";
|
376
|
this.snippetFileId = "ace/snippets/tcl";
|
377
|
}).call(Mode.prototype);
|
378
|
|
379
|
exports.Mode = Mode;
|
380
|
}); (function() {
|
381
|
ace.require(["ace/mode/tcl"], function(m) {
|
382
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
383
|
module.exports = m;
|
384
|
}
|
385
|
});
|
386
|
})();
|
387
|
|