Projekt

Obecné

Profil

Stáhnout (5.18 KB) Statistiky
| Větev: | Tag: | Revize:
1
ace.define("ace/mode/tex_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
var TexHighlightRules = function(textClass) {
9

    
10
    if (!textClass)
11
        textClass = "text";
12

    
13
    this.$rules = {
14
        "start" : [
15
            {
16
                token : "comment",
17
                regex : "%.*$"
18
            }, {
19
                token : textClass, // non-command
20
                regex : "\\\\[$&%#\\{\\}]"
21
            }, {
22
                token : "keyword", // command
23
                regex : "\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem)\\b",
24
               next : "nospell"
25
            }, {
26
                token : "keyword", // command
27
                regex : "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])"
28
            }, {
29
               token : "paren.keyword.operator",
30
                regex : "[[({]"
31
            }, {
32
               token : "paren.keyword.operator",
33
                regex : "[\\])}]"
34
            }, {
35
                token : textClass,
36
                regex : "\\s+"
37
            }
38
        ],
39
        "nospell" : [
40
           {
41
               token : "comment",
42
               regex : "%.*$",
43
               next : "start"
44
           }, {
45
               token : "nospell." + textClass, // non-command
46
               regex : "\\\\[$&%#\\{\\}]"
47
           }, {
48
               token : "keyword", // command
49
               regex : "\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem)\\b"
50
           }, {
51
               token : "keyword", // command
52
               regex : "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])",
53
               next : "start"
54
           }, {
55
               token : "paren.keyword.operator",
56
               regex : "[[({]"
57
           }, {
58
               token : "paren.keyword.operator",
59
               regex : "[\\])]"
60
           }, {
61
               token : "paren.keyword.operator",
62
               regex : "}",
63
               next : "start"
64
           }, {
65
               token : "nospell." + textClass,
66
               regex : "\\s+"
67
           }, {
68
               token : "nospell." + textClass,
69
               regex : "\\w+"
70
           }
71
        ]
72
    };
73
};
74

    
75
oop.inherits(TexHighlightRules, TextHighlightRules);
76

    
77
exports.TexHighlightRules = TexHighlightRules;
78
});
79

    
80
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
81
"use strict";
82

    
83
var Range = require("../range").Range;
84

    
85
var MatchingBraceOutdent = function() {};
86

    
87
(function() {
88

    
89
    this.checkOutdent = function(line, input) {
90
        if (! /^\s+$/.test(line))
91
            return false;
92

    
93
        return /^\s*\}/.test(input);
94
    };
95

    
96
    this.autoOutdent = function(doc, row) {
97
        var line = doc.getLine(row);
98
        var match = line.match(/^(\s*\})/);
99

    
100
        if (!match) return 0;
101

    
102
        var column = match[1].length;
103
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
104

    
105
        if (!openBracePos || openBracePos.row == row) return 0;
106

    
107
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
108
        doc.replace(new Range(row, 0, row, column-1), indent);
109
    };
110

    
111
    this.$getIndent = function(line) {
112
        return line.match(/^\s*/)[0];
113
    };
114

    
115
}).call(MatchingBraceOutdent.prototype);
116

    
117
exports.MatchingBraceOutdent = MatchingBraceOutdent;
118
});
119

    
120
ace.define("ace/mode/tex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/text_highlight_rules","ace/mode/tex_highlight_rules","ace/mode/matching_brace_outdent"], function(require, exports, module) {
121
"use strict";
122

    
123
var oop = require("../lib/oop");
124
var TextMode = require("./text").Mode;
125
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
126
var TexHighlightRules = require("./tex_highlight_rules").TexHighlightRules;
127
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
128

    
129
var Mode = function(suppressHighlighting) {
130
    if (suppressHighlighting)
131
        this.HighlightRules = TextHighlightRules;
132
    else
133
        this.HighlightRules = TexHighlightRules;
134
    this.$outdent = new MatchingBraceOutdent();
135
    this.$behaviour = this.$defaultBehaviour;
136
};
137
oop.inherits(Mode, TextMode);
138

    
139
(function() {
140
   this.lineCommentStart = "%";
141
   this.getNextLineIndent = function(state, line, tab) {
142
      return this.$getIndent(line);
143
   };
144

    
145
   this.allowAutoInsert = function() {
146
      return false;
147
   };
148
    this.$id = "ace/mode/tex";
149
    this.snippetFileId = "ace/snippets/tex";
150
}).call(Mode.prototype);
151

    
152
exports.Mode = Mode;
153
});                (function() {
154
                    ace.require(["ace/mode/tex"], function(m) {
155
                        if (typeof module == "object" && typeof exports == "object" && module) {
156
                            module.exports = m;
157
                        }
158
                    });
159
                })();
160
            
(179-179/244)