1
/* ***** BEGIN LICENSE BLOCK *****
2
* Distributed under the BSD license:
4
* Copyright (c) 2010, Ajax.org B.V.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* * Neither the name of Ajax.org B.V. nor the
15
* names of its contributors may be used to endorse or promote products
16
* derived from this software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
* ***** END LICENSE BLOCK ***** */
31
define('ace/mode/tcl', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/folding/cstyle', 'ace/mode/tcl_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range'], function(require, exports, module) {
34
var oop = require("../lib/oop");
35
var TextMode = require("./text").Mode;
36
var Tokenizer = require("../tokenizer").Tokenizer;
37
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
38
var TclHighlightRules = require("./tcl_highlight_rules").TclHighlightRules;
39
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
40
var Range = require("../range").Range;
42
var Mode = function() {
43
this.$tokenizer = new Tokenizer(new TclHighlightRules().getRules());
44
this.$outdent = new MatchingBraceOutdent();
45
this.foldingRules = new CStyleFoldMode();
47
oop.inherits(Mode, TextMode);
51
this.lineCommentStart = "#";
53
this.getNextLineIndent = function(state, line, tab) {
54
var indent = this.$getIndent(line);
56
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
57
var tokens = tokenizedLine.tokens;
59
if (tokens.length && tokens[tokens.length-1].type == "comment") {
63
if (state == "start") {
64
var match = line.match(/^.*[\{\(\[]\s*$/);
73
this.checkOutdent = function(state, line, input) {
74
return this.$outdent.checkOutdent(line, input);
77
this.autoOutdent = function(state, doc, row) {
78
this.$outdent.autoOutdent(doc, row);
81
}).call(Mode.prototype);
86
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
89
var oop = require("../../lib/oop");
90
var Range = require("../../range").Range;
91
var BaseFoldMode = require("./fold_mode").FoldMode;
93
var FoldMode = exports.FoldMode = function(commentRegex) {
95
this.foldingStartMarker = new RegExp(
96
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
98
this.foldingStopMarker = new RegExp(
99
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
103
oop.inherits(FoldMode, BaseFoldMode);
107
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
108
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
110
this.getFoldWidgetRange = function(session, foldStyle, row) {
111
var line = session.getLine(row);
112
var match = line.match(this.foldingStartMarker);
117
return this.openingBracketBlock(session, match[1], row, i);
119
return session.getCommentFoldRange(row, i + match[0].length, 1);
122
if (foldStyle !== "markbeginend")
125
var match = line.match(this.foldingStopMarker);
127
var i = match.index + match[0].length;
130
return this.closingBracketBlock(session, match[1], row, i);
132
return session.getCommentFoldRange(row, i, -1);
136
}).call(FoldMode.prototype);
140
define('ace/mode/tcl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
143
var oop = require("../lib/oop");
144
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
146
var TclHighlightRules = function() {
153
next : "commentfollow"
158
token : "support.function",
160
next : "splitlineStart"
163
regex : '[\\\\](?:["]|[{]|[}]|[[]|[]]|[$]|[\])'
165
token : "text", // last value before command
166
regex : '^|[^{][;][^}]|[/\r/]',
169
token : "string", // single line
170
regex : '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
172
token : "string", // multi line """ string start
176
token : "variable.instance", // variable xotcl with braces
180
token : "support.function",
181
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::"
183
token : "identifier",
184
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
186
token : "paren.lparen",
190
token : "paren.lparen",
193
token : "paren.rparen",
204
next : "commentfollow"
210
token : "string", // single line
211
regex : '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
213
token : "variable.instance", // variable xotcl with braces
217
token : "support.function",
218
regex : "(?:[:][:])[a-zA-Z0-9_/]+(?:[:][:])",
221
token : "support.function",
222
regex : "[a-zA-Z0-9_/]+(?:[:][:])",
225
token : "support.function",
226
regex : "(?:[:][:])",
229
token : "paren.rparen",
232
token : "support.function",
233
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::"
236
regex : "[a-zA-Z0-9_/]+",
243
next : "commentfollow"
257
token : "variable.instance", // variable xotcl with braces
258
regex : "(?:[:][:])?[a-zA-Z_\\d]+(?:(?:[:][:])?[a-zA-Z_\\d]+)?(?:[(][a-zA-Z_\\d]+[)])?",
261
token : "variable.instance", // variable tcl
262
regex : "[a-zA-Z_\\d]+(?:[(][a-zA-Z_\\d]+[)])?",
265
token : "variable.instance", // variable tcl with braces
266
regex : "{?[a-zA-Z_\\d]+}?",
270
token : "string", // multi line """ string end
271
regex : '(?:[^\\\\]|\\\\.)*?["]',
280
oop.inherits(TclHighlightRules, TextHighlightRules);
282
exports.TclHighlightRules = TclHighlightRules;
285
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
288
var Range = require("../range").Range;
290
var MatchingBraceOutdent = function() {};
294
this.checkOutdent = function(line, input) {
295
if (! /^\s+$/.test(line))
298
return /^\s*\}/.test(input);
301
this.autoOutdent = function(doc, row) {
302
var line = doc.getLine(row);
303
var match = line.match(/^(\s*\})/);
305
if (!match) return 0;
307
var column = match[1].length;
308
var openBracePos = doc.findMatchingBracket({row: row, column: column});
310
if (!openBracePos || openBracePos.row == row) return 0;
312
var indent = this.$getIndent(doc.getLine(openBracePos.row));
313
doc.replace(new Range(row, 0, row, column-1), indent);
316
this.$getIndent = function(line) {
317
return line.match(/^\s*/)[0];
320
}).call(MatchingBraceOutdent.prototype);
322
exports.MatchingBraceOutdent = MatchingBraceOutdent;