Projekt

Obecné

Profil

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

    
4
var oop = require("../lib/oop");
5
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
6

    
7
var YamlHighlightRules = function() {
8
    this.$rules = {
9
        "start" : [
10
            {
11
                token : "comment",
12
                regex : "#.*$"
13
            }, {
14
                token : "list.markup",
15
                regex : /^(?:-{3}|\.{3})\s*(?=#|$)/
16
            },  {
17
                token : "list.markup",
18
                regex : /^\s*[\-?](?:$|\s)/
19
            }, {
20
                token: "constant",
21
                regex: "!![\\w//]+"
22
            }, {
23
                token: "constant.language",
24
                regex: "[&\\*][a-zA-Z0-9-_]+"
25
            }, {
26
                token: ["meta.tag", "keyword"],
27
                regex: /^(\s*\w.*?)(:(?=\s|$))/
28
            },{
29
                token: ["meta.tag", "keyword"],
30
                regex: /(\w+?)(\s*:(?=\s|$))/
31
            }, {
32
                token : "keyword.operator",
33
                regex : "<<\\w*:\\w*"
34
            }, {
35
                token : "keyword.operator",
36
                regex : "-\\s*(?=[{])"
37
            }, {
38
                token : "string", // single line
39
                regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
40
            }, {
41
                token : "string", // multi line string start
42
                regex : /[|>][-+\d]*(?:$|\s+(?:$|#))/,
43
                onMatch: function(val, state, stack, line) {
44
                    line = line.replace(/ #.*/, "");
45
                    var indent = /^ *((:\s*)?-(\s*[^|>])?)?/.exec(line)[0]
46
                        .replace(/\S\s*$/, "").length;
47
                    var indentationIndicator = parseInt(/\d+[\s+-]*$/.exec(line));
48
                    
49
                    if (indentationIndicator) {
50
                        indent += indentationIndicator - 1;
51
                        this.next = "mlString";
52
                    } else {
53
                        this.next = "mlStringPre";
54
                    }
55
                    if (!stack.length) {
56
                        stack.push(this.next);
57
                        stack.push(indent);
58
                    } else {
59
                        stack[0] = this.next;
60
                        stack[1] = indent;
61
                    }
62
                    return this.token;
63
                },
64
                next : "mlString"
65
            }, {
66
                token : "string", // single quoted string
67
                regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
68
            }, {
69
                token : "constant.numeric", // float
70
                regex : /(\b|[+\-\.])[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)(?=[^\d-\w]|$)/
71
            }, {
72
                token : "constant.numeric", // other number
73
                regex : /[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/
74
            }, {
75
                token : "constant.language.boolean",
76
                regex : "\\b(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"
77
            }, {
78
                token : "paren.lparen",
79
                regex : "[[({]"
80
            }, {
81
                token : "paren.rparen",
82
                regex : "[\\])}]"
83
            }, {
84
                token : "text",
85
                regex : /[^\s,:\[\]\{\}]+/
86
            }
87
        ],
88
        "mlStringPre" : [
89
            {
90
                token : "indent",
91
                regex : /^ *$/
92
            }, {
93
                token : "indent",
94
                regex : /^ */,
95
                onMatch: function(val, state, stack) {
96
                    var curIndent = stack[1];
97

    
98
                    if (curIndent >= val.length) {
99
                        this.next = "start";
100
                        stack.shift();
101
                        stack.shift();
102
                    }
103
                    else {
104
                        stack[1] = val.length - 1;
105
                        this.next = stack[0] = "mlString";
106
                    }
107
                    return this.token;
108
                },
109
                next : "mlString"
110
            }, {
111
                defaultToken : "string"
112
            }
113
        ],
114
        "mlString" : [
115
            {
116
                token : "indent",
117
                regex : /^ *$/
118
            }, {
119
                token : "indent",
120
                regex : /^ */,
121
                onMatch: function(val, state, stack) {
122
                    var curIndent = stack[1];
123

    
124
                    if (curIndent >= val.length) {
125
                        this.next = "start";
126
                        stack.splice(0);
127
                    }
128
                    else {
129
                        this.next = "mlString";
130
                    }
131
                    return this.token;
132
                },
133
                next : "mlString"
134
            }, {
135
                token : "string",
136
                regex : '.+'
137
            }
138
        ]};
139
    this.normalizeRules();
140

    
141
};
142

    
143
oop.inherits(YamlHighlightRules, TextHighlightRules);
144

    
145
exports.YamlHighlightRules = YamlHighlightRules;
146
});
147

    
148
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
149
"use strict";
150

    
151
var Range = require("../range").Range;
152

    
153
var MatchingBraceOutdent = function() {};
154

    
155
(function() {
156

    
157
    this.checkOutdent = function(line, input) {
158
        if (! /^\s+$/.test(line))
159
            return false;
160

    
161
        return /^\s*\}/.test(input);
162
    };
163

    
164
    this.autoOutdent = function(doc, row) {
165
        var line = doc.getLine(row);
166
        var match = line.match(/^(\s*\})/);
167

    
168
        if (!match) return 0;
169

    
170
        var column = match[1].length;
171
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
172

    
173
        if (!openBracePos || openBracePos.row == row) return 0;
174

    
175
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
176
        doc.replace(new Range(row, 0, row, column-1), indent);
177
    };
178

    
179
    this.$getIndent = function(line) {
180
        return line.match(/^\s*/)[0];
181
    };
182

    
183
}).call(MatchingBraceOutdent.prototype);
184

    
185
exports.MatchingBraceOutdent = MatchingBraceOutdent;
186
});
187

    
188
ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
189
"use strict";
190

    
191
var oop = require("../../lib/oop");
192
var BaseFoldMode = require("./fold_mode").FoldMode;
193
var Range = require("../../range").Range;
194

    
195
var FoldMode = exports.FoldMode = function() {};
196
oop.inherits(FoldMode, BaseFoldMode);
197

    
198
(function() {
199

    
200
    this.getFoldWidgetRange = function(session, foldStyle, row) {
201
        var range = this.indentationBlock(session, row);
202
        if (range)
203
            return range;
204

    
205
        var re = /\S/;
206
        var line = session.getLine(row);
207
        var startLevel = line.search(re);
208
        if (startLevel == -1 || line[startLevel] != "#")
209
            return;
210

    
211
        var startColumn = line.length;
212
        var maxRow = session.getLength();
213
        var startRow = row;
214
        var endRow = row;
215

    
216
        while (++row < maxRow) {
217
            line = session.getLine(row);
218
            var level = line.search(re);
219

    
220
            if (level == -1)
221
                continue;
222

    
223
            if (line[level] != "#")
224
                break;
225

    
226
            endRow = row;
227
        }
228

    
229
        if (endRow > startRow) {
230
            var endColumn = session.getLine(endRow).length;
231
            return new Range(startRow, startColumn, endRow, endColumn);
232
        }
233
    };
234
    this.getFoldWidget = function(session, foldStyle, row) {
235
        var line = session.getLine(row);
236
        var indent = line.search(/\S/);
237
        var next = session.getLine(row + 1);
238
        var prev = session.getLine(row - 1);
239
        var prevIndent = prev.search(/\S/);
240
        var nextIndent = next.search(/\S/);
241

    
242
        if (indent == -1) {
243
            session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
244
            return "";
245
        }
246
        if (prevIndent == -1) {
247
            if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
248
                session.foldWidgets[row - 1] = "";
249
                session.foldWidgets[row + 1] = "";
250
                return "start";
251
            }
252
        } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
253
            if (session.getLine(row - 2).search(/\S/) == -1) {
254
                session.foldWidgets[row - 1] = "start";
255
                session.foldWidgets[row + 1] = "";
256
                return "";
257
            }
258
        }
259

    
260
        if (prevIndent!= -1 && prevIndent < indent)
261
            session.foldWidgets[row - 1] = "start";
262
        else
263
            session.foldWidgets[row - 1] = "";
264

    
265
        if (indent < nextIndent)
266
            return "start";
267
        else
268
            return "";
269
    };
270

    
271
}).call(FoldMode.prototype);
272

    
273
});
274

    
275
ace.define("ace/mode/yaml",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/yaml_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/coffee"], function(require, exports, module) {
276
"use strict";
277

    
278
var oop = require("../lib/oop");
279
var TextMode = require("./text").Mode;
280
var YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules;
281
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
282
var FoldMode = require("./folding/coffee").FoldMode;
283

    
284
var Mode = function() {
285
    this.HighlightRules = YamlHighlightRules;
286
    this.$outdent = new MatchingBraceOutdent();
287
    this.foldingRules = new FoldMode();
288
    this.$behaviour = this.$defaultBehaviour;
289
};
290
oop.inherits(Mode, TextMode);
291

    
292
(function() {
293

    
294
    this.lineCommentStart = ["#"];
295
    
296
    this.getNextLineIndent = function(state, line, tab) {
297
        var indent = this.$getIndent(line);
298

    
299
        if (state == "start") {
300
            var match = line.match(/^.*[\{\(\[]\s*$/);
301
            if (match) {
302
                indent += tab;
303
            }
304
        }
305

    
306
        return indent;
307
    };
308

    
309
    this.checkOutdent = function(state, line, input) {
310
        return this.$outdent.checkOutdent(line, input);
311
    };
312

    
313
    this.autoOutdent = function(state, doc, row) {
314
        this.$outdent.autoOutdent(doc, row);
315
    };
316

    
317

    
318
    this.$id = "ace/mode/yaml";
319
}).call(Mode.prototype);
320

    
321
exports.Mode = Mode;
322

    
323
});                (function() {
324
                    ace.require(["ace/mode/yaml"], function(m) {
325
                        if (typeof module == "object" && typeof exports == "object" && module) {
326
                            module.exports = m;
327
                        }
328
                    });
329
                })();
330
            
(196-196/244)