/lenasys/trunk

To get this branch, use:
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) 2012, 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
 *
30
 * Contributor(s):
31
 * 
32
 *
33
 *
34
 * ***** END LICENSE BLOCK ***** */
35
36
define('ace/mode/pascal', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/pascal_highlight_rules', 'ace/mode/folding/coffee'], function(require, exports, module) {
37
38
39
var oop = require("../lib/oop");
40
var TextMode = require("./text").Mode;
41
var Tokenizer = require("../tokenizer").Tokenizer;
42
var PascalHighlightRules = require("./pascal_highlight_rules").PascalHighlightRules;
43
var FoldMode = require("./folding/coffee").FoldMode;
44
45
var Mode = function() {
46
    var highlighter = new PascalHighlightRules();
47
    this.foldingRules = new FoldMode();
48
    this.$tokenizer = new Tokenizer(highlighter.getRules());
49
};
50
oop.inherits(Mode, TextMode);
51
52
(function() {
53
       
54
    this.lineCommentStart = ["--", "//"];
55
    this.blockComment = [
56
        {start: "(*", end: "*)"},
57
        {start: "{", end: "}"}
58
    ];
59
    
60
}).call(Mode.prototype);
61
62
exports.Mode = Mode;
63
});
64
65
define('ace/mode/pascal_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
66
67
68
var oop = require("../lib/oop");
69
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
70
71
var PascalHighlightRules = function() {
72
73
    this.$rules = { start: 
74
       [ { caseInsensitive: true,
75
           token: 'keyword.control.pascal',
76
           regex: '\\b(?:(absolute|abstract|all|and|and_then|array|as|asm|attribute|begin|bindable|case|class|const|constructor|destructor|div|do|do|else|end|except|export|exports|external|far|file|finalization|finally|for|forward|goto|if|implementation|import|in|inherited|initialization|interface|interrupt|is|label|library|mod|module|name|near|nil|not|object|of|only|operator|or|or_else|otherwise|packed|pow|private|program|property|protected|public|published|qualified|record|repeat|resident|restricted|segment|set|shl|shr|then|to|try|type|unit|until|uses|value|var|view|virtual|while|with|xor))\\b' },
77
         { caseInsensitive: true,           
78
           token: 
79
            [ 'variable.pascal', "text",
80
              'storage.type.prototype.pascal',
81
              'entity.name.function.prototype.pascal' ],
82
           regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?(?=(?:\\(.*?\\))?;\\s*(?:attribute|forward|external))' },
83
         { caseInsensitive: true,
84
           token: 
85
            [ 'variable.pascal', "text",
86
              'storage.type.function.pascal',
87
              'entity.name.function.pascal' ],
88
           regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?' },
89
         { token: 'constant.numeric.pascal',
90
           regex: '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b' },
91
         { token: 'punctuation.definition.comment.pascal',
92
           regex: '--',
93
           push: 
94
            [ { token: 'comment.line.double-dash.pascal.one',
95
                regex: '$',
96
                next: 'pop' },
97
              { defaultToken: 'comment.line.double-dash.pascal.one' } ] },
98
         { token: 'punctuation.definition.comment.pascal',
99
           regex: '//',
100
           push: 
101
            [ { token: 'comment.line.double-slash.pascal.two',
102
                regex: '$',
103
                next: 'pop' },
104
              { defaultToken: 'comment.line.double-slash.pascal.two' } ] },
105
         { token: 'punctuation.definition.comment.pascal',
106
           regex: '\\(\\*',
107
           push: 
108
            [ { token: 'punctuation.definition.comment.pascal',
109
                regex: '\\*\\)',
110
                next: 'pop' },
111
              { defaultToken: 'comment.block.pascal.one' } ] },
112
         { token: 'punctuation.definition.comment.pascal',
113
           regex: '\\{',
114
           push: 
115
            [ { token: 'punctuation.definition.comment.pascal',
116
                regex: '\\}',
117
                next: 'pop' },
118
              { defaultToken: 'comment.block.pascal.two' } ] },
119
         { token: 'punctuation.definition.string.begin.pascal',
120
           regex: '"',
121
           push: 
122
            [ { token: 'constant.character.escape.pascal', regex: '\\\\.' },
123
              { token: 'punctuation.definition.string.end.pascal',
124
                regex: '"',
125
                next: 'pop' },
126
              { defaultToken: 'string.quoted.double.pascal' } ],
127
            },
128
         { token: 'punctuation.definition.string.begin.pascal',
129
           regex: '\'',
130
           push: 
131
            [ { token: 'constant.character.escape.apostrophe.pascal',
132
                regex: '\'\'' },
133
              { token: 'punctuation.definition.string.end.pascal',
134
                regex: '\'',
135
                next: 'pop' },
136
              { defaultToken: 'string.quoted.single.pascal' } ] },
137
          { token: 'keyword.operator',
138
           regex: '[+\\-;,/*%]|:=|=' } ] }
139
    
140
    this.normalizeRules();
141
};
142
143
oop.inherits(PascalHighlightRules, TextHighlightRules);
144
145
exports.PascalHighlightRules = PascalHighlightRules;
146
});
147
148
define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
149
150
151
var oop = require("../../lib/oop");
152
var BaseFoldMode = require("./fold_mode").FoldMode;
153
var Range = require("../../range").Range;
154
155
var FoldMode = exports.FoldMode = function() {};
156
oop.inherits(FoldMode, BaseFoldMode);
157
158
(function() {
159
160
    this.getFoldWidgetRange = function(session, foldStyle, row) {
161
        var range = this.indentationBlock(session, row);
162
        if (range)
163
            return range;
164
165
        var re = /\S/;
166
        var line = session.getLine(row);
167
        var startLevel = line.search(re);
168
        if (startLevel == -1 || line[startLevel] != "#")
169
            return;
170
171
        var startColumn = line.length;
172
        var maxRow = session.getLength();
173
        var startRow = row;
174
        var endRow = row;
175
176
        while (++row < maxRow) {
177
            line = session.getLine(row);
178
            var level = line.search(re);
179
180
            if (level == -1)
181
                continue;
182
183
            if (line[level] != "#")
184
                break;
185
186
            endRow = row;
187
        }
188
189
        if (endRow > startRow) {
190
            var endColumn = session.getLine(endRow).length;
191
            return new Range(startRow, startColumn, endRow, endColumn);
192
        }
193
    };
194
    this.getFoldWidget = function(session, foldStyle, row) {
195
        var line = session.getLine(row);
196
        var indent = line.search(/\S/);
197
        var next = session.getLine(row + 1);
198
        var prev = session.getLine(row - 1);
199
        var prevIndent = prev.search(/\S/);
200
        var nextIndent = next.search(/\S/);
201
202
        if (indent == -1) {
203
            session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
204
            return "";
205
        }
206
        if (prevIndent == -1) {
207
            if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
208
                session.foldWidgets[row - 1] = "";
209
                session.foldWidgets[row + 1] = "";
210
                return "start";
211
            }
212
        } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
213
            if (session.getLine(row - 2).search(/\S/) == -1) {
214
                session.foldWidgets[row - 1] = "start";
215
                session.foldWidgets[row + 1] = "";
216
                return "";
217
            }
218
        }
219
220
        if (prevIndent!= -1 && prevIndent < indent)
221
            session.foldWidgets[row - 1] = "start";
222
        else
223
            session.foldWidgets[row - 1] = "";
224
225
        if (indent < nextIndent)
226
            return "start";
227
        else
228
            return "";
229
    };
230
231
}).call(FoldMode.prototype);
232
233
});