corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 ace.define("ace/mode/c9search_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) {
2 "use strict";
3  
4 var oop = require("../lib/oop");
5 var lang = require("../lib/lang");
6 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
7  
8 function safeCreateRegexp(source, flag) {
9 try {
10 return new RegExp(source, flag);
11 } catch(e) {}
12 }
13  
14 var C9SearchHighlightRules = function() {
15 this.$rules = {
16 "start" : [
17 {
18 tokenNames : ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text", "c9searchresults.keyword"],
19 regex : /(^\s+[0-9]+)(:)(\d*\s?)([^\r\n]+)/,
20 onMatch : function(val, state, stack) {
21 var values = this.splitRegex.exec(val);
22 var types = this.tokenNames;
23 var tokens = [{
24 type: types[0],
25 value: values[1]
26 }, {
27 type: types[1],
28 value: values[2]
29 }];
30  
31 if (values[3]) {
32 if (values[3] == " ")
33 tokens[1] = { type: types[1], value: values[2] + " " };
34 else
35 tokens.push({ type: types[1], value: values[3] });
36 }
37 var regex = stack[1];
38 var str = values[4];
39  
40 var m;
41 var last = 0;
42 if (regex && regex.exec) {
43 regex.lastIndex = 0;
44 while (m = regex.exec(str)) {
45 var skipped = str.substring(last, m.index);
46 last = regex.lastIndex;
47 if (skipped)
48 tokens.push({type: types[2], value: skipped});
49 if (m[0])
50 tokens.push({type: types[3], value: m[0]});
51 else if (!skipped)
52 break;
53 }
54 }
55 if (last < str.length)
56 tokens.push({type: types[2], value: str.substr(last)});
57 return tokens;
58 }
59 },
60 {
61 regex : "^Searching for [^\\r\\n]*$",
62 onMatch: function(val, state, stack) {
63 var parts = val.split("\x01");
64 if (parts.length < 3)
65 return "text";
66  
67 var options, search, replace;
68  
69 var i = 0;
70 var tokens = [{
71 value: parts[i++] + "'",
72 type: "text"
73 }, {
74 value: search = parts[i++],
75 type: "text" // "c9searchresults.keyword"
76 }, {
77 value: "'" + parts[i++],
78 type: "text"
79 }];
80 if (parts[2] !== " in") {
81 replace = parts[i];
82 tokens.push({
83 value: "'" + parts[i++] + "'",
84 type: "text"
85 }, {
86 value: parts[i++],
87 type: "text"
88 });
89 }
90 tokens.push({
91 value: " " + parts[i++] + " ",
92 type: "text"
93 });
94 if (parts[i+1]) {
95 options = parts[i+1];
96 tokens.push({
97 value: "(" + parts[i+1] + ")",
98 type: "text"
99 });
100 i += 1;
101 } else {
102 i -= 1;
103 }
104 while (i++ < parts.length) {
105 parts[i] && tokens.push({
106 value: parts[i],
107 type: "text"
108 });
109 }
110  
111 if (replace) {
112 search = replace;
113 options = "";
114 }
115  
116 if (search) {
117 if (!/regex/.test(options))
118 search = lang.escapeRegExp(search);
119 if (/whole/.test(options))
120 search = "\\b" + search + "\\b";
121 }
122  
123 var regex = search && safeCreateRegexp(
124 "(" + search + ")",
125 / sensitive/.test(options) ? "g" : "ig"
126 );
127 if (regex) {
128 stack[0] = state;
129 stack[1] = regex;
130 }
131  
132 return tokens;
133 }
134 },
135 {
136 regex : "^(?=Found \\d+ matches)",
137 token : "text",
138 next : "numbers"
139 },
140 {
141 token : "string", // single line
142 regex : "^\\S:?[^:]+",
143 next : "numbers"
144 }
145 ],
146 numbers:[{
147 regex : "\\d+",
148 token : "constant.numeric"
149 }, {
150 regex : "$",
151 token : "text",
152 next : "start"
153 }]
154 };
155 this.normalizeRules();
156 };
157  
158 oop.inherits(C9SearchHighlightRules, TextHighlightRules);
159  
160 exports.C9SearchHighlightRules = C9SearchHighlightRules;
161  
162 });
163  
164 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
165 "use strict";
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 ace.define("ace/mode/folding/c9search",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
205 "use strict";
206  
207 var oop = require("../../lib/oop");
208 var Range = require("../../range").Range;
209 var BaseFoldMode = require("./fold_mode").FoldMode;
210  
211 var FoldMode = exports.FoldMode = function() {};
212 oop.inherits(FoldMode, BaseFoldMode);
213  
214 (function() {
215  
216 this.foldingStartMarker = /^(\S.*:|Searching for.*)$/;
217 this.foldingStopMarker = /^(\s+|Found.*)$/;
218  
219 this.getFoldWidgetRange = function(session, foldStyle, row) {
220 var lines = session.doc.getAllLines(row);
221 var line = lines[row];
222 var level1 = /^(Found.*|Searching for.*)$/;
223 var level2 = /^(\S.*:|\s*)$/;
224 var re = level1.test(line) ? level1 : level2;
225  
226 var startRow = row;
227 var endRow = row;
228  
229 if (this.foldingStartMarker.test(line)) {
230 for (var i = row + 1, l = session.getLength(); i < l; i++) {
231 if (re.test(lines[i]))
232 break;
233 }
234 endRow = i;
235 }
236 else if (this.foldingStopMarker.test(line)) {
237 for (var i = row - 1; i >= 0; i--) {
238 line = lines[i];
239 if (re.test(line))
240 break;
241 }
242 startRow = i;
243 }
244 if (startRow != endRow) {
245 var col = line.length;
246 if (re === level1)
247 col = line.search(/\(Found[^)]+\)$|$/);
248 return new Range(startRow, col, endRow, 0);
249 }
250 };
251  
252 }).call(FoldMode.prototype);
253  
254 });
255  
256 ace.define("ace/mode/c9search",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/c9search_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/c9search"], function(require, exports, module) {
257 "use strict";
258  
259 var oop = require("../lib/oop");
260 var TextMode = require("./text").Mode;
261 var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules;
262 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
263 var C9StyleFoldMode = require("./folding/c9search").FoldMode;
264  
265 var Mode = function() {
266 this.HighlightRules = C9SearchHighlightRules;
267 this.$outdent = new MatchingBraceOutdent();
268 this.foldingRules = new C9StyleFoldMode();
269 };
270 oop.inherits(Mode, TextMode);
271  
272 (function() {
273  
274 this.getNextLineIndent = function(state, line, tab) {
275 var indent = this.$getIndent(line);
276 return indent;
277 };
278  
279 this.checkOutdent = function(state, line, input) {
280 return this.$outdent.checkOutdent(line, input);
281 };
282  
283 this.autoOutdent = function(state, doc, row) {
284 this.$outdent.autoOutdent(doc, row);
285 };
286  
287 this.$id = "ace/mode/c9search";
288 }).call(Mode.prototype);
289  
290 exports.Mode = Mode;
291  
292 });