bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
20.1.1
by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff |
1 |
/* ***** BEGIN LICENSE BLOCK *****
|
2 |
* Distributed under the BSD license:
|
|
3 |
*
|
|
4 |
* Copyright (c) 2010, Ajax.org B.V.
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
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.
|
|
17 |
*
|
|
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.
|
|
28 |
*
|
|
29 |
* ***** END LICENSE BLOCK ***** */
|
|
30 |
||
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) { |
|
32 |
||
33 |
||
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; |
|
41 |
||
42 |
var Mode = function() { |
|
43 |
this.$tokenizer = new Tokenizer(new TclHighlightRules().getRules()); |
|
44 |
this.$outdent = new MatchingBraceOutdent(); |
|
45 |
this.foldingRules = new CStyleFoldMode(); |
|
46 |
};
|
|
47 |
oop.inherits(Mode, TextMode); |
|
48 |
||
49 |
(function() { |
|
50 |
||
51 |
this.lineCommentStart = "#"; |
|
52 |
||
53 |
this.getNextLineIndent = function(state, line, tab) { |
|
54 |
var indent = this.$getIndent(line); |
|
55 |
||
56 |
var tokenizedLine = this.$tokenizer.getLineTokens(line, state); |
|
57 |
var tokens = tokenizedLine.tokens; |
|
58 |
||
59 |
if (tokens.length && tokens[tokens.length-1].type == "comment") { |
|
60 |
return indent; |
|
61 |
} |
|
62 |
|
|
63 |
if (state == "start") { |
|
64 |
var match = line.match(/^.*[\{\(\[]\s*$/); |
|
65 |
if (match) { |
|
66 |
indent += tab; |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
return indent; |
|
71 |
}; |
|
72 |
||
73 |
this.checkOutdent = function(state, line, input) { |
|
74 |
return this.$outdent.checkOutdent(line, input); |
|
75 |
}; |
|
76 |
||
77 |
this.autoOutdent = function(state, doc, row) { |
|
78 |
this.$outdent.autoOutdent(doc, row); |
|
79 |
}; |
|
80 |
||
81 |
}).call(Mode.prototype); |
|
82 |
||
83 |
exports.Mode = Mode; |
|
84 |
});
|
|
85 |
||
86 |
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { |
|
87 |
||
88 |
||
89 |
var oop = require("../../lib/oop"); |
|
90 |
var Range = require("../../range").Range; |
|
91 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
|
92 |
||
93 |
var FoldMode = exports.FoldMode = function(commentRegex) { |
|
94 |
if (commentRegex) { |
|
95 |
this.foldingStartMarker = new RegExp( |
|
96 |
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) |
|
97 |
); |
|
98 |
this.foldingStopMarker = new RegExp( |
|
99 |
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) |
|
100 |
); |
|
101 |
} |
|
102 |
};
|
|
103 |
oop.inherits(FoldMode, BaseFoldMode); |
|
104 |
||
105 |
(function() { |
|
106 |
||
107 |
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; |
|
108 |
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; |
|
109 |
||
110 |
this.getFoldWidgetRange = function(session, foldStyle, row) { |
|
111 |
var line = session.getLine(row); |
|
112 |
var match = line.match(this.foldingStartMarker); |
|
113 |
if (match) { |
|
114 |
var i = match.index; |
|
115 |
||
116 |
if (match[1]) |
|
117 |
return this.openingBracketBlock(session, match[1], row, i); |
|
118 |
||
119 |
return session.getCommentFoldRange(row, i + match[0].length, 1); |
|
120 |
} |
|
121 |
||
122 |
if (foldStyle !== "markbeginend") |
|
123 |
return; |
|
124 |
||
125 |
var match = line.match(this.foldingStopMarker); |
|
126 |
if (match) { |
|
127 |
var i = match.index + match[0].length; |
|
128 |
||
129 |
if (match[1]) |
|
130 |
return this.closingBracketBlock(session, match[1], row, i); |
|
131 |
||
132 |
return session.getCommentFoldRange(row, i, -1); |
|
133 |
} |
|
134 |
}; |
|
135 |
||
136 |
}).call(FoldMode.prototype); |
|
137 |
||
138 |
});
|
|
139 |
||
140 |
define('ace/mode/tcl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { |
|
141 |
||
142 |
||
143 |
var oop = require("../lib/oop"); |
|
144 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
|
145 |
||
146 |
var TclHighlightRules = function() { |
|
147 |
||
148 |
this.$rules = { |
|
149 |
"start" : [ |
|
150 |
{ |
|
151 |
token : "comment", |
|
152 |
regex : "#.*\\\\$", |
|
153 |
next : "commentfollow" |
|
154 |
}, { |
|
155 |
token : "comment", |
|
156 |
regex : "#.*$" |
|
157 |
}, { |
|
158 |
token : "support.function", |
|
159 |
regex : '[\\\\]$', |
|
160 |
next : "splitlineStart" |
|
161 |
}, { |
|
162 |
token : "text", |
|
163 |
regex : '[\\\\](?:["]|[{]|[}]|[[]|[]]|[$]|[\])' |
|
164 |
}, { |
|
165 |
token : "text", // last value before command |
|
166 |
regex : '^|[^{][;][^}]|[/\r/]', |
|
167 |
next : "commandItem" |
|
168 |
}, { |
|
169 |
token : "string", // single line |
|
170 |
regex : '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' |
|
171 |
}, { |
|
172 |
token : "string", // multi line """ string start |
|
173 |
regex : '[ ]*["]', |
|
174 |
next : "qqstring" |
|
175 |
}, { |
|
176 |
token : "variable.instance", // variable xotcl with braces |
|
177 |
regex : "[$]", |
|
178 |
next : "variable" |
|
179 |
}, { |
|
180 |
token : "support.function", |
|
181 |
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::" |
|
182 |
}, { |
|
183 |
token : "identifier", |
|
184 |
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" |
|
185 |
}, { |
|
186 |
token : "paren.lparen", |
|
187 |
regex : "[[{]", |
|
188 |
next : "commandItem" |
|
189 |
}, { |
|
190 |
token : "paren.lparen", |
|
191 |
regex : "[(]" |
|
192 |
}, { |
|
193 |
token : "paren.rparen", |
|
194 |
regex : "[\\])}]" |
|
195 |
}, { |
|
196 |
token : "text", |
|
197 |
regex : "\\s+" |
|
198 |
} |
|
199 |
], |
|
200 |
"commandItem" : [ |
|
201 |
{ |
|
202 |
token : "comment", |
|
203 |
regex : "#.*\\\\$", |
|
204 |
next : "commentfollow" |
|
205 |
}, { |
|
206 |
token : "comment", |
|
207 |
regex : "#.*$", |
|
208 |
next : "start" |
|
209 |
}, { |
|
210 |
token : "string", // single line |
|
211 |
regex : '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' |
|
212 |
}, { |
|
213 |
token : "variable.instance", // variable xotcl with braces |
|
214 |
regex : "[$]", |
|
215 |
next : "variable" |
|
216 |
}, { |
|
217 |
token : "support.function", |
|
218 |
regex : "(?:[:][:])[a-zA-Z0-9_/]+(?:[:][:])", |
|
219 |
next : "commandItem" |
|
220 |
}, { |
|
221 |
token : "support.function", |
|
222 |
regex : "[a-zA-Z0-9_/]+(?:[:][:])", |
|
223 |
next : "commandItem" |
|
224 |
}, { |
|
225 |
token : "support.function", |
|
226 |
regex : "(?:[:][:])", |
|
227 |
next : "commandItem" |
|
228 |
}, { |
|
229 |
token : "paren.rparen", |
|
230 |
regex : "[\\])}]" |
|
231 |
}, { |
|
232 |
token : "support.function", |
|
233 |
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::" |
|
234 |
}, { |
|
235 |
token : "keyword", |
|
236 |
regex : "[a-zA-Z0-9_/]+", |
|
237 |
next : "start" |
|
238 |
} ], |
|
239 |
"commentfollow" : [ |
|
240 |
{ |
|
241 |
token : "comment", |
|
242 |
regex : ".*\\\\$", |
|
243 |
next : "commentfollow" |
|
244 |
}, { |
|
245 |
token : "comment", |
|
246 |
regex : '.+', |
|
247 |
next : "start" |
|
248 |
} ], |
|
249 |
"splitlineStart" : [ |
|
250 |
{ |
|
251 |
token : "text", |
|
252 |
regex : "^.", |
|
253 |
next : "start" |
|
254 |
}], |
|
255 |
"variable" : [ |
|
256 |
{ |
|
257 |
token : "variable.instance", // variable xotcl with braces |
|
258 |
regex : "(?:[:][:])?[a-zA-Z_\\d]+(?:(?:[:][:])?[a-zA-Z_\\d]+)?(?:[(][a-zA-Z_\\d]+[)])?", |
|
259 |
next : "start" |
|
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 |
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { |
|
286 |
||
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 |
});
|