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/yaml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/yaml_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/coffee'], 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 YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules; |
|
38 |
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; |
|
39 |
var FoldMode = require("./folding/coffee").FoldMode; |
|
40 |
||
41 |
var Mode = function() { |
|
42 |
this.$tokenizer = new Tokenizer(new YamlHighlightRules().getRules()); |
|
43 |
this.$outdent = new MatchingBraceOutdent(); |
|
44 |
this.foldingRules = new FoldMode(); |
|
45 |
};
|
|
46 |
oop.inherits(Mode, TextMode); |
|
47 |
||
48 |
(function() { |
|
49 |
||
50 |
this.lineCommentStart = "#"; |
|
51 |
|
|
52 |
this.getNextLineIndent = function(state, line, tab) { |
|
53 |
var indent = this.$getIndent(line); |
|
54 |
||
55 |
if (state == "start") { |
|
56 |
var match = line.match(/^.*[\{\(\[]\s*$/); |
|
57 |
if (match) { |
|
58 |
indent += tab; |
|
59 |
} |
|
60 |
} |
|
61 |
||
62 |
return indent; |
|
63 |
}; |
|
64 |
||
65 |
this.checkOutdent = function(state, line, input) { |
|
66 |
return this.$outdent.checkOutdent(line, input); |
|
67 |
}; |
|
68 |
||
69 |
this.autoOutdent = function(state, doc, row) { |
|
70 |
this.$outdent.autoOutdent(doc, row); |
|
71 |
}; |
|
72 |
||
73 |
||
74 |
}).call(Mode.prototype); |
|
75 |
||
76 |
exports.Mode = Mode; |
|
77 |
||
78 |
});
|
|
79 |
||
80 |
define('ace/mode/yaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { |
|
81 |
||
82 |
||
83 |
var oop = require("../lib/oop"); |
|
84 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
|
85 |
||
86 |
var YamlHighlightRules = function() { |
|
87 |
this.$rules = { |
|
88 |
"start" : [ |
|
89 |
{ |
|
90 |
token : "comment", |
|
91 |
regex : "#.*$" |
|
92 |
}, { |
|
93 |
token : "list.markup", |
|
94 |
regex : /^(?:-{3}|\.{3})\s*(?=#|$)/ |
|
95 |
}, { |
|
96 |
token : "list.markup", |
|
97 |
regex : /^\s*[\-?](?:$|\s)/ |
|
98 |
}, { |
|
99 |
token: "constant", |
|
100 |
regex: "!![\\w//]+" |
|
101 |
}, { |
|
102 |
token: "constant.language", |
|
103 |
regex: "[&\\*][a-zA-Z0-9-_]+" |
|
104 |
}, { |
|
105 |
token: ["meta.tag", "keyword"], |
|
106 |
regex: /^(\s*\w.*?)(\:(?:\s+|$))/ |
|
107 |
},{ |
|
108 |
token: ["meta.tag", "keyword"], |
|
109 |
regex: /(\w+?)(\s*\:(?:\s+|$))/ |
|
110 |
}, { |
|
111 |
token : "keyword.operator", |
|
112 |
regex : "<<\\w*:\\w*" |
|
113 |
}, { |
|
114 |
token : "keyword.operator", |
|
115 |
regex : "-\\s*(?=[{])" |
|
116 |
}, { |
|
117 |
token : "string", // single line |
|
118 |
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' |
|
119 |
}, { |
|
120 |
token : "string", // multi line string start |
|
121 |
regex : '[\\|>]\\w*', |
|
122 |
next : "qqstring" |
|
123 |
}, { |
|
124 |
token : "string", // single quoted string |
|
125 |
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" |
|
126 |
}, { |
|
127 |
token : "constant.numeric", // float |
|
128 |
regex : /[+\-]?[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?\b/ |
|
129 |
}, { |
|
130 |
token : "constant.numeric", // other number |
|
131 |
regex : /[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/ |
|
132 |
}, { |
|
133 |
token : "constant.language.boolean", |
|
134 |
regex : "(?:true|false|TRUE|FALSE|True|False|yes|no)\\b" |
|
135 |
}, { |
|
136 |
token : "invalid.illegal", // comments are not allowed |
|
137 |
regex : "\\/\\/.*$" |
|
138 |
}, { |
|
139 |
token : "paren.lparen", |
|
140 |
regex : "[[({]" |
|
141 |
}, { |
|
142 |
token : "paren.rparen", |
|
143 |
regex : "[\\])}]" |
|
144 |
} |
|
145 |
], |
|
146 |
"qqstring" : [ |
|
147 |
{ |
|
148 |
token : "string", |
|
149 |
regex : '(?=(?:(?:\\\\.)|(?:[^:]))*?:)', |
|
150 |
next : "start" |
|
151 |
}, { |
|
152 |
token : "string", |
|
153 |
regex : '.+' |
|
154 |
} |
|
155 |
]}; |
|
156 |
||
157 |
};
|
|
158 |
||
159 |
oop.inherits(YamlHighlightRules, TextHighlightRules); |
|
160 |
||
161 |
exports.YamlHighlightRules = YamlHighlightRules; |
|
162 |
});
|
|
163 |
||
164 |
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { |
|
165 |
||
166 |
||
167 |
var Range = require("../range").Range; |
|
168 |
||
169 |
var MatchingBraceOutdent = function() {}; |
|
170 |
||
171 |
(function() { |
|
172 |
||
173 |
this.checkOutdent = function(line, input) { |
|
174 |
if (! /^\s+$/.test(line)) |
|
175 |
return false; |
|
176 |
||
177 |
return /^\s*\}/.test(input); |
|
178 |
}; |
|
179 |
||
180 |
this.autoOutdent = function(doc, row) { |
|
181 |
var line = doc.getLine(row); |
|
182 |
var match = line.match(/^(\s*\})/); |
|
183 |
||
184 |
if (!match) return 0; |
|
185 |
||
186 |
var column = match[1].length; |
|
187 |
var openBracePos = doc.findMatchingBracket({row: row, column: column}); |
|
188 |
||
189 |
if (!openBracePos || openBracePos.row == row) return 0; |
|
190 |
||
191 |
var indent = this.$getIndent(doc.getLine(openBracePos.row)); |
|
192 |
doc.replace(new Range(row, 0, row, column-1), indent); |
|
193 |
}; |
|
194 |
||
195 |
this.$getIndent = function(line) { |
|
196 |
return line.match(/^\s*/)[0]; |
|
197 |
}; |
|
198 |
||
199 |
}).call(MatchingBraceOutdent.prototype); |
|
200 |
||
201 |
exports.MatchingBraceOutdent = MatchingBraceOutdent; |
|
202 |
});
|
|
203 |
||
204 |
define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) { |
|
205 |
||
206 |
||
207 |
var oop = require("../../lib/oop"); |
|
208 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
|
209 |
var Range = require("../../range").Range; |
|
210 |
||
211 |
var FoldMode = exports.FoldMode = function() {}; |
|
212 |
oop.inherits(FoldMode, BaseFoldMode); |
|
213 |
||
214 |
(function() { |
|
215 |
||
216 |
this.getFoldWidgetRange = function(session, foldStyle, row) { |
|
217 |
var range = this.indentationBlock(session, row); |
|
218 |
if (range) |
|
219 |
return range; |
|
220 |
||
221 |
var re = /\S/; |
|
222 |
var line = session.getLine(row); |
|
223 |
var startLevel = line.search(re); |
|
224 |
if (startLevel == -1 || line[startLevel] != "#") |
|
225 |
return; |
|
226 |
||
227 |
var startColumn = line.length; |
|
228 |
var maxRow = session.getLength(); |
|
229 |
var startRow = row; |
|
230 |
var endRow = row; |
|
231 |
||
232 |
while (++row < maxRow) { |
|
233 |
line = session.getLine(row); |
|
234 |
var level = line.search(re); |
|
235 |
||
236 |
if (level == -1) |
|
237 |
continue; |
|
238 |
||
239 |
if (line[level] != "#") |
|
240 |
break; |
|
241 |
||
242 |
endRow = row; |
|
243 |
} |
|
244 |
||
245 |
if (endRow > startRow) { |
|
246 |
var endColumn = session.getLine(endRow).length; |
|
247 |
return new Range(startRow, startColumn, endRow, endColumn); |
|
248 |
} |
|
249 |
}; |
|
250 |
this.getFoldWidget = function(session, foldStyle, row) { |
|
251 |
var line = session.getLine(row); |
|
252 |
var indent = line.search(/\S/); |
|
253 |
var next = session.getLine(row + 1); |
|
254 |
var prev = session.getLine(row - 1); |
|
255 |
var prevIndent = prev.search(/\S/); |
|
256 |
var nextIndent = next.search(/\S/); |
|
257 |
||
258 |
if (indent == -1) { |
|
259 |
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : ""; |
|
260 |
return ""; |
|
261 |
} |
|
262 |
if (prevIndent == -1) { |
|
263 |
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") { |
|
264 |
session.foldWidgets[row - 1] = ""; |
|
265 |
session.foldWidgets[row + 1] = ""; |
|
266 |
return "start"; |
|
267 |
} |
|
268 |
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") { |
|
269 |
if (session.getLine(row - 2).search(/\S/) == -1) { |
|
270 |
session.foldWidgets[row - 1] = "start"; |
|
271 |
session.foldWidgets[row + 1] = ""; |
|
272 |
return ""; |
|
273 |
} |
|
274 |
} |
|
275 |
||
276 |
if (prevIndent!= -1 && prevIndent < indent) |
|
277 |
session.foldWidgets[row - 1] = "start"; |
|
278 |
else |
|
279 |
session.foldWidgets[row - 1] = ""; |
|
280 |
||
281 |
if (indent < nextIndent) |
|
282 |
return "start"; |
|
283 |
else |
|
284 |
return ""; |
|
285 |
}; |
|
286 |
||
287 |
}).call(FoldMode.prototype); |
|
288 |
||
289 |
});
|