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