Projekt

Obecné

Profil

Stáhnout (13.8 KB) Statistiky
| Větev: | Tag: | Revize:
1
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
2
"use strict";
3

    
4
var Range = require("../range").Range;
5

    
6
var MatchingBraceOutdent = function() {};
7

    
8
(function() {
9

    
10
    this.checkOutdent = function(line, input) {
11
        if (! /^\s+$/.test(line))
12
            return false;
13

    
14
        return /^\s*\}/.test(input);
15
    };
16

    
17
    this.autoOutdent = function(doc, row) {
18
        var line = doc.getLine(row);
19
        var match = line.match(/^(\s*\})/);
20

    
21
        if (!match) return 0;
22

    
23
        var column = match[1].length;
24
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
25

    
26
        if (!openBracePos || openBracePos.row == row) return 0;
27

    
28
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
29
        doc.replace(new Range(row, 0, row, column-1), indent);
30
    };
31

    
32
    this.$getIndent = function(line) {
33
        return line.match(/^\s*/)[0];
34
    };
35

    
36
}).call(MatchingBraceOutdent.prototype);
37

    
38
exports.MatchingBraceOutdent = MatchingBraceOutdent;
39
});
40

    
41
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
42
"use strict";
43

    
44
var oop = require("../lib/oop");
45
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
46

    
47
var DocCommentHighlightRules = function() {
48
    this.$rules = {
49
        "start" : [ {
50
            token : "comment.doc.tag",
51
            regex : "@[\\w\\d_]+" // TODO: fix email addresses
52
        }, 
53
        DocCommentHighlightRules.getTagRule(),
54
        {
55
            defaultToken : "comment.doc",
56
            caseInsensitive: true
57
        }]
58
    };
59
};
60

    
61
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
62

    
63
DocCommentHighlightRules.getTagRule = function(start) {
64
    return {
65
        token : "comment.doc.tag.storage.type",
66
        regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
67
    };
68
};
69

    
70
DocCommentHighlightRules.getStartRule = function(start) {
71
    return {
72
        token : "comment.doc", // doc comment
73
        regex : "\\/\\*(?=\\*)",
74
        next  : start
75
    };
76
};
77

    
78
DocCommentHighlightRules.getEndRule = function (start) {
79
    return {
80
        token : "comment.doc", // closing comment
81
        regex : "\\*\\/",
82
        next  : start
83
    };
84
};
85

    
86

    
87
exports.DocCommentHighlightRules = DocCommentHighlightRules;
88

    
89
});
90

    
91
ace.define("ace/mode/dot_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/doc_comment_highlight_rules"], function(require, exports, module) {
92
"use strict";
93

    
94
var oop = require("../lib/oop");
95
var lang = require("../lib/lang");
96
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
97
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
98

    
99
var DotHighlightRules = function() {
100

    
101
   var keywords = lang.arrayToMap(
102
        ("strict|node|edge|graph|digraph|subgraph").split("|")
103
   );
104

    
105
   var attributes = lang.arrayToMap(
106
        ("damping|k|url|area|arrowhead|arrowsize|arrowtail|aspect|bb|bgcolor|center|charset|clusterrank|color|colorscheme|comment|compound|concentrate|constraint|decorate|defaultdist|dim|dimen|dir|diredgeconstraints|distortion|dpi|edgeurl|edgehref|edgetarget|edgetooltip|epsilon|esep|fillcolor|fixedsize|fontcolor|fontname|fontnames|fontpath|fontsize|forcelabels|gradientangle|group|headurl|head_lp|headclip|headhref|headlabel|headport|headtarget|headtooltip|height|href|id|image|imagepath|imagescale|label|labelurl|label_scheme|labelangle|labeldistance|labelfloat|labelfontcolor|labelfontname|labelfontsize|labelhref|labeljust|labelloc|labeltarget|labeltooltip|landscape|layer|layerlistsep|layers|layerselect|layersep|layout|len|levels|levelsgap|lhead|lheight|lp|ltail|lwidth|margin|maxiter|mclimit|mindist|minlen|mode|model|mosek|nodesep|nojustify|normalize|nslimit|nslimit1|ordering|orientation|outputorder|overlap|overlap_scaling|pack|packmode|pad|page|pagedir|pencolor|penwidth|peripheries|pin|pos|quadtree|quantum|rank|rankdir|ranksep|ratio|rects|regular|remincross|repulsiveforce|resolution|root|rotate|rotation|samehead|sametail|samplepoints|scale|searchsize|sep|shape|shapefile|showboxes|sides|size|skew|smoothing|sortv|splines|start|style|stylesheet|tailurl|tail_lp|tailclip|tailhref|taillabel|tailport|tailtarget|tailtooltip|target|tooltip|truecolor|vertices|viewport|voro_margin|weight|width|xlabel|xlp|z").split("|")
107
   );
108

    
109
   this.$rules = {
110
        "start" : [
111
            {
112
                token : "comment",
113
                regex : /\/\/.*$/
114
            }, {
115
                token : "comment",
116
                regex : /#.*$/
117
            }, {
118
                token : "comment", // multi line comment
119
                merge : true,
120
                regex : /\/\*/,
121
                next : "comment"
122
            }, {
123
                token : "string",
124
                regex : "'(?=.)",
125
                next  : "qstring"
126
            }, {
127
                token : "string",
128
                regex : '"(?=.)',
129
                next  : "qqstring"
130
            }, {
131
                token : "constant.numeric",
132
                regex : /[+\-]?\d+(?:(?:\.\d*)?(?:[eE][+\-]?\d+)?)?\b/
133
            }, {
134
                token : "keyword.operator",
135
                regex : /\+|=|\->/
136
            }, {
137
                token : "punctuation.operator",
138
                regex : /,|;/
139
            }, {
140
                token : "paren.lparen",
141
                regex : /[\[{]/
142
            }, {
143
                token : "paren.rparen",
144
                regex : /[\]}]/
145
            }, {
146
                token: "comment",
147
                regex: /^#!.*$/
148
            }, {
149
                token: function(value) {
150
                    if (keywords.hasOwnProperty(value.toLowerCase())) {
151
                        return "keyword";
152
                    }
153
                    else if (attributes.hasOwnProperty(value.toLowerCase())) {
154
                        return "variable";
155
                    }
156
                    else {
157
                        return "text";
158
                    }
159
                },
160
                regex: "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
161
           }
162
        ],
163
        "comment" : [
164
            {
165
                token : "comment", // closing comment
166
                regex : "\\*\\/",
167
                next : "start"
168
            }, {
169
                defaultToken : "comment"
170
            }
171
        ],
172
        "qqstring" : [
173
            {
174
                token : "string",
175
                regex : '[^"\\\\]+',
176
                merge : true
177
            }, {
178
                token : "string",
179
                regex : "\\\\$",
180
                next  : "qqstring",
181
                merge : true
182
            }, {
183
                token : "string",
184
                regex : '"|$',
185
                next  : "start",
186
                merge : true
187
            }
188
        ],
189
        "qstring" : [
190
            {
191
                token : "string",
192
                regex : "[^'\\\\]+",
193
                merge : true
194
            }, {
195
                token : "string",
196
                regex : "\\\\$",
197
                next  : "qstring",
198
                merge : true
199
            }, {
200
                token : "string",
201
                regex : "'|$",
202
                next  : "start",
203
                merge : true
204
            }
205
        ]
206
   };
207
};
208

    
209
oop.inherits(DotHighlightRules, TextHighlightRules);
210

    
211
exports.DotHighlightRules = DotHighlightRules;
212

    
213
});
214

    
215
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
216
"use strict";
217

    
218
var oop = require("../../lib/oop");
219
var Range = require("../../range").Range;
220
var BaseFoldMode = require("./fold_mode").FoldMode;
221

    
222
var FoldMode = exports.FoldMode = function(commentRegex) {
223
    if (commentRegex) {
224
        this.foldingStartMarker = new RegExp(
225
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
226
        );
227
        this.foldingStopMarker = new RegExp(
228
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
229
        );
230
    }
231
};
232
oop.inherits(FoldMode, BaseFoldMode);
233

    
234
(function() {
235
    
236
    this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
237
    this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
238
    this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
239
    this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
240
    this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
241
    this._getFoldWidgetBase = this.getFoldWidget;
242
    this.getFoldWidget = function(session, foldStyle, row) {
243
        var line = session.getLine(row);
244
    
245
        if (this.singleLineBlockCommentRe.test(line)) {
246
            if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
247
                return "";
248
        }
249
    
250
        var fw = this._getFoldWidgetBase(session, foldStyle, row);
251
    
252
        if (!fw && this.startRegionRe.test(line))
253
            return "start"; // lineCommentRegionStart
254
    
255
        return fw;
256
    };
257

    
258
    this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
259
        var line = session.getLine(row);
260
        
261
        if (this.startRegionRe.test(line))
262
            return this.getCommentRegionBlock(session, line, row);
263
        
264
        var match = line.match(this.foldingStartMarker);
265
        if (match) {
266
            var i = match.index;
267

    
268
            if (match[1])
269
                return this.openingBracketBlock(session, match[1], row, i);
270
                
271
            var range = session.getCommentFoldRange(row, i + match[0].length, 1);
272
            
273
            if (range && !range.isMultiLine()) {
274
                if (forceMultiline) {
275
                    range = this.getSectionRange(session, row);
276
                } else if (foldStyle != "all")
277
                    range = null;
278
            }
279
            
280
            return range;
281
        }
282

    
283
        if (foldStyle === "markbegin")
284
            return;
285

    
286
        var match = line.match(this.foldingStopMarker);
287
        if (match) {
288
            var i = match.index + match[0].length;
289

    
290
            if (match[1])
291
                return this.closingBracketBlock(session, match[1], row, i);
292

    
293
            return session.getCommentFoldRange(row, i, -1);
294
        }
295
    };
296
    
297
    this.getSectionRange = function(session, row) {
298
        var line = session.getLine(row);
299
        var startIndent = line.search(/\S/);
300
        var startRow = row;
301
        var startColumn = line.length;
302
        row = row + 1;
303
        var endRow = row;
304
        var maxRow = session.getLength();
305
        while (++row < maxRow) {
306
            line = session.getLine(row);
307
            var indent = line.search(/\S/);
308
            if (indent === -1)
309
                continue;
310
            if  (startIndent > indent)
311
                break;
312
            var subRange = this.getFoldWidgetRange(session, "all", row);
313
            
314
            if (subRange) {
315
                if (subRange.start.row <= startRow) {
316
                    break;
317
                } else if (subRange.isMultiLine()) {
318
                    row = subRange.end.row;
319
                } else if (startIndent == indent) {
320
                    break;
321
                }
322
            }
323
            endRow = row;
324
        }
325
        
326
        return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
327
    };
328
    this.getCommentRegionBlock = function(session, line, row) {
329
        var startColumn = line.search(/\s*$/);
330
        var maxRow = session.getLength();
331
        var startRow = row;
332
        
333
        var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
334
        var depth = 1;
335
        while (++row < maxRow) {
336
            line = session.getLine(row);
337
            var m = re.exec(line);
338
            if (!m) continue;
339
            if (m[1]) depth--;
340
            else depth++;
341

    
342
            if (!depth) break;
343
        }
344

    
345
        var endRow = row;
346
        if (endRow > startRow) {
347
            return new Range(startRow, startColumn, endRow, line.length);
348
        }
349
    };
350

    
351
}).call(FoldMode.prototype);
352

    
353
});
354

    
355
ace.define("ace/mode/dot",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/matching_brace_outdent","ace/mode/dot_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
356
"use strict";
357

    
358
var oop = require("../lib/oop");
359
var TextMode = require("./text").Mode;
360
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
361
var DotHighlightRules = require("./dot_highlight_rules").DotHighlightRules;
362
var DotFoldMode = require("./folding/cstyle").FoldMode;
363

    
364
var Mode = function() {
365
    this.HighlightRules = DotHighlightRules;
366
    this.$outdent = new MatchingBraceOutdent();
367
    this.foldingRules = new DotFoldMode();
368
    this.$behaviour = this.$defaultBehaviour;
369
};
370
oop.inherits(Mode, TextMode);
371

    
372
(function() {
373

    
374
    this.lineCommentStart = ["//", "#"];
375
    this.blockComment = {start: "/*", end: "*/"};
376

    
377
    this.getNextLineIndent = function(state, line, tab) {
378
        var indent = this.$getIndent(line);
379

    
380
        var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
381
        var tokens = tokenizedLine.tokens;
382
        var endState = tokenizedLine.state;
383

    
384
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
385
            return indent;
386
        }
387

    
388
        if (state == "start") {
389
            var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
390
            if (match) {
391
                indent += tab;
392
            }
393
        }
394

    
395
        return indent;
396
    };
397

    
398
    this.checkOutdent = function(state, line, input) {
399
        return this.$outdent.checkOutdent(line, input);
400
    };
401

    
402
    this.autoOutdent = function(state, doc, row) {
403
        this.$outdent.autoOutdent(doc, row);
404
    };
405

    
406
    this.$id = "ace/mode/dot";
407
}).call(Mode.prototype);
408

    
409
exports.Mode = Mode;
410
});                (function() {
411
                    ace.require(["ace/mode/dot"], function(m) {
412
                        if (typeof module == "object" && typeof exports == "object" && module) {
413
                            module.exports = m;
414
                        }
415
                    });
416
                })();
417
            
(61-61/244)