/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/js/ace/mode-python.js

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-30 12:02:31 UTC
  • mfrom: (85.1.28 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130530120231-ttqgqjqw2w8enn7g
Merged Ohlsons changes:
added function to get ssn and name for the registrationspages in the user model.
added the registrationpage for students.
edited the registration page for instructors
edited the css for both the registrationpages
minor fix to registration css

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Distributed under the BSD license:
 
3
 *
 
4
 * Copyright (c) 2010, 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
 * ***** END LICENSE BLOCK ***** */
 
30
 
 
31
define('ace/mode/python', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/python_highlight_rules', 'ace/mode/folding/pythonic', 'ace/range'], function(require, exports, module) {
 
32
 
 
33
 
 
34
var oop = require("../lib/oop");
 
35
var TextMode = require("./text").Mode;
 
36
var Tokenizer = require("../tokenizer").Tokenizer;
 
37
var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules;
 
38
var PythonFoldMode = require("./folding/pythonic").FoldMode;
 
39
var Range = require("../range").Range;
 
40
 
 
41
var Mode = function() {
 
42
    this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules());
 
43
    this.foldingRules = new PythonFoldMode("\\:");
 
44
};
 
45
oop.inherits(Mode, TextMode);
 
46
 
 
47
(function() {
 
48
 
 
49
    this.lineCommentStart = "#";
 
50
 
 
51
    this.getNextLineIndent = function(state, line, tab) {
 
52
        var indent = this.$getIndent(line);
 
53
 
 
54
        var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
 
55
        var tokens = tokenizedLine.tokens;
 
56
 
 
57
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
 
58
            return indent;
 
59
        }
 
60
 
 
61
        if (state == "start") {
 
62
            var match = line.match(/^.*[\{\(\[\:]\s*$/);
 
63
            if (match) {
 
64
                indent += tab;
 
65
            }
 
66
        }
 
67
 
 
68
        return indent;
 
69
    };
 
70
 
 
71
    var outdents = {
 
72
        "pass": 1,
 
73
        "return": 1,
 
74
        "raise": 1,
 
75
        "break": 1,
 
76
        "continue": 1
 
77
    };
 
78
    
 
79
    this.checkOutdent = function(state, line, input) {
 
80
        if (input !== "\r\n" && input !== "\r" && input !== "\n")
 
81
            return false;
 
82
 
 
83
        var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens;
 
84
        
 
85
        if (!tokens)
 
86
            return false;
 
87
        do {
 
88
            var last = tokens.pop();
 
89
        } while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/))));
 
90
        
 
91
        if (!last)
 
92
            return false;
 
93
        
 
94
        return (last.type == "keyword" && outdents[last.value]);
 
95
    };
 
96
 
 
97
    this.autoOutdent = function(state, doc, row) {
 
98
        
 
99
        row += 1;
 
100
        var indent = this.$getIndent(doc.getLine(row));
 
101
        var tab = doc.getTabString();
 
102
        if (indent.slice(-tab.length) == tab)
 
103
            doc.remove(new Range(row, indent.length-tab.length, row, indent.length));
 
104
    };
 
105
 
 
106
}).call(Mode.prototype);
 
107
 
 
108
exports.Mode = Mode;
 
109
});
 
110
 
 
111
define('ace/mode/python_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
112
 
 
113
 
 
114
var oop = require("../lib/oop");
 
115
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
116
 
 
117
var PythonHighlightRules = function() {
 
118
 
 
119
    var keywords = (
 
120
        "and|as|assert|break|class|continue|def|del|elif|else|except|exec|" +
 
121
        "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" +
 
122
        "raise|return|try|while|with|yield"
 
123
    );
 
124
 
 
125
    var builtinConstants = (
 
126
        "True|False|None|NotImplemented|Ellipsis|__debug__"
 
127
    );
 
128
 
 
129
    var builtinFunctions = (
 
130
        "abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" +
 
131
        "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" +
 
132
        "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" +
 
133
        "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" +
 
134
        "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" +
 
135
        "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" +
 
136
        "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" +
 
137
        "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern"
 
138
    );
 
139
    var keywordMapper = this.createKeywordMapper({
 
140
        "invalid.deprecated": "debugger",
 
141
        "support.function": builtinFunctions,
 
142
        "constant.language": builtinConstants,
 
143
        "keyword": keywords
 
144
    }, "identifier");
 
145
 
 
146
    var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?";
 
147
 
 
148
    var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
 
149
    var octInteger = "(?:0[oO]?[0-7]+)";
 
150
    var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
 
151
    var binInteger = "(?:0[bB][01]+)";
 
152
    var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")";
 
153
 
 
154
    var exponent = "(?:[eE][+-]?\\d+)";
 
155
    var fraction = "(?:\\.\\d+)";
 
156
    var intPart = "(?:\\d+)";
 
157
    var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
 
158
    var exponentFloat = "(?:(?:" + pointFloat + "|" +  intPart + ")" + exponent + ")";
 
159
    var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
 
160
 
 
161
    this.$rules = {
 
162
        "start" : [ {
 
163
            token : "comment",
 
164
            regex : "#.*$"
 
165
        }, {
 
166
            token : "string",           // """ string
 
167
            regex : strPre + '"{3}(?:[^\\\\]|\\\\.)*?"{3}'
 
168
        }, {
 
169
            token : "string",           // multi line """ string start
 
170
            regex : strPre + '"{3}.*$',
 
171
            next : "qqstring"
 
172
        }, {
 
173
            token : "string",           // " string
 
174
            regex : strPre + '"(?:[^\\\\]|\\\\.)*?"'
 
175
        }, {
 
176
            token : "string",           // ''' string
 
177
            regex : strPre + "'{3}(?:[^\\\\]|\\\\.)*?'{3}"
 
178
        }, {
 
179
            token : "string",           // multi line ''' string start
 
180
            regex : strPre + "'{3}.*$",
 
181
            next : "qstring"
 
182
        }, {
 
183
            token : "string",           // ' string
 
184
            regex : strPre + "'(?:[^\\\\]|\\\\.)*?'"
 
185
        }, {
 
186
            token : "constant.numeric", // imaginary
 
187
            regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b"
 
188
        }, {
 
189
            token : "constant.numeric", // float
 
190
            regex : floatNumber
 
191
        }, {
 
192
            token : "constant.numeric", // long integer
 
193
            regex : integer + "[lL]\\b"
 
194
        }, {
 
195
            token : "constant.numeric", // integer
 
196
            regex : integer + "\\b"
 
197
        }, {
 
198
            token : keywordMapper,
 
199
            regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
 
200
        }, {
 
201
            token : "keyword.operator",
 
202
            regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|="
 
203
        }, {
 
204
            token : "paren.lparen",
 
205
            regex : "[\\[\\(\\{]"
 
206
        }, {
 
207
            token : "paren.rparen",
 
208
            regex : "[\\]\\)\\}]"
 
209
        }, {
 
210
            token : "text",
 
211
            regex : "\\s+"
 
212
        } ],
 
213
        "qqstring" : [ {
 
214
            token : "string", // multi line """ string end
 
215
            regex : '(?:[^\\\\]|\\\\.)*?"{3}',
 
216
            next : "start"
 
217
        }, {
 
218
            token : "string",
 
219
            regex : '.+'
 
220
        } ],
 
221
        "qstring" : [ {
 
222
            token : "string",  // multi line ''' string end
 
223
            regex : "(?:[^\\\\]|\\\\.)*?'{3}",
 
224
            next : "start"
 
225
        }, {
 
226
            token : "string",
 
227
            regex : '.+'
 
228
        } ]
 
229
    };
 
230
};
 
231
 
 
232
oop.inherits(PythonHighlightRules, TextHighlightRules);
 
233
 
 
234
exports.PythonHighlightRules = PythonHighlightRules;
 
235
});
 
236
 
 
237
define('ace/mode/folding/pythonic', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
 
238
 
 
239
 
 
240
var oop = require("../../lib/oop");
 
241
var BaseFoldMode = require("./fold_mode").FoldMode;
 
242
 
 
243
var FoldMode = exports.FoldMode = function(markers) {
 
244
    this.foldingStartMarker = new RegExp("([\\[{])(?:\\s*)$|(" + markers + ")(?:\\s*)(?:#.*)?$");
 
245
};
 
246
oop.inherits(FoldMode, BaseFoldMode);
 
247
 
 
248
(function() {
 
249
 
 
250
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
251
        var line = session.getLine(row);
 
252
        var match = line.match(this.foldingStartMarker);
 
253
        if (match) {
 
254
            if (match[1])
 
255
                return this.openingBracketBlock(session, match[1], row, match.index);
 
256
            if (match[2])
 
257
                return this.indentationBlock(session, row, match.index + match[2].length);
 
258
            return this.indentationBlock(session, row);
 
259
        }
 
260
    }
 
261
 
 
262
}).call(FoldMode.prototype);
 
263
 
 
264
});