/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 js/ace/mode-livescript.js

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-31 06:15:46 UTC
  • mfrom: (90.1.20 lenasys2)
  • Revision ID: gustav.hartvigsson@gmail.com-20130531061546-vj8z28sq375kvghq
Merged Jonsson:s changes:
Fixed the layout on cms index so the arrows and dots marks expanded objects.
Fixed so the course content is sorted by course occasion and not by name

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
define('ace/mode/livescript', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/text'], function(require, exports, module) {
 
2
  var identifier, LiveScriptMode, keywordend, stringfill;
 
3
  identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
 
4
  exports.Mode = LiveScriptMode = (function(superclass){
 
5
    var indenter, prototype = extend$((import$(LiveScriptMode, superclass).displayName = 'LiveScriptMode', LiveScriptMode), superclass).prototype, constructor = LiveScriptMode;
 
6
    function LiveScriptMode(){
 
7
      var that;
 
8
      this.$tokenizer = new (require('ace/tokenizer')).Tokenizer(LiveScriptMode.Rules);
 
9
      if (that = require('ace/mode/matching_brace_outdent')) {
 
10
        this.$outdent = new that.MatchingBraceOutdent;
 
11
      }
 
12
    }
 
13
    indenter = RegExp('(?:[({[=:]|[-~]>|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*' + identifier + ')?))\\s*$');
 
14
    prototype.getNextLineIndent = function(state, line, tab){
 
15
      var indent, tokens;
 
16
      indent = this.$getIndent(line);
 
17
      tokens = this.$tokenizer.getLineTokens(line, state).tokens;
 
18
      if (!(tokens.length && tokens[tokens.length - 1].type === 'comment')) {
 
19
        if (state === 'start' && indenter.test(line)) {
 
20
          indent += tab;
 
21
        }
 
22
      }
 
23
      return indent;
 
24
    };
 
25
    prototype.toggleCommentLines = function(state, doc, startRow, endRow){
 
26
      var comment, range, i$, i, out, line;
 
27
      comment = /^(\s*)#/;
 
28
      range = new (require('ace/range')).Range(0, 0, 0, 0);
 
29
      for (i$ = startRow; i$ <= endRow; ++i$) {
 
30
        i = i$;
 
31
        if (out = comment.test(line = doc.getLine(i))) {
 
32
          line = line.replace(comment, '$1');
 
33
        } else {
 
34
          line = line.replace(/^\s*/, '$&#');
 
35
        }
 
36
        range.end.row = range.start.row = i;
 
37
        range.end.column = line.length + 1;
 
38
        doc.replace(range, line);
 
39
      }
 
40
      return 1 - out * 2;
 
41
    };
 
42
    prototype.checkOutdent = function(state, line, input){
 
43
      var ref$;
 
44
      return (ref$ = this.$outdent) != null ? ref$.checkOutdent(line, input) : void 8;
 
45
    };
 
46
    prototype.autoOutdent = function(state, doc, row){
 
47
      var ref$;
 
48
      return (ref$ = this.$outdent) != null ? ref$.autoOutdent(doc, row) : void 8;
 
49
    };
 
50
    return LiveScriptMode;
 
51
  }(require('ace/mode/text').Mode));
 
52
  keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
 
53
  stringfill = {
 
54
    token: 'string',
 
55
    regex: '.+'
 
56
  };
 
57
  LiveScriptMode.Rules = {
 
58
    start: [
 
59
      {
 
60
        token: 'keyword',
 
61
        regex: '(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)' + keywordend
 
62
      }, {
 
63
        token: 'constant.language',
 
64
        regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
 
65
      }, {
 
66
        token: 'invalid.illegal',
 
67
        regex: '(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)' + keywordend
 
68
      }, {
 
69
        token: 'language.support.class',
 
70
        regex: '(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)' + keywordend
 
71
      }, {
 
72
        token: 'language.support.function',
 
73
        regex: '(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)' + keywordend
 
74
      }, {
 
75
        token: 'variable.language',
 
76
        regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
 
77
      }, {
 
78
        token: 'identifier',
 
79
        regex: identifier + '\\s*:(?![:=])'
 
80
      }, {
 
81
        token: 'variable',
 
82
        regex: identifier
 
83
      }, {
 
84
        token: 'keyword.operator',
 
85
        regex: '(?:\\.{3}|\\s+\\?)'
 
86
      }, {
 
87
        token: 'keyword.variable',
 
88
        regex: '(?:@+|::|\\.\\.)',
 
89
        next: 'key'
 
90
      }, {
 
91
        token: 'keyword.operator',
 
92
        regex: '\\.\\s*',
 
93
        next: 'key'
 
94
      }, {
 
95
        token: 'string',
 
96
        regex: '\\\\\\S[^\\s,;)}\\]]*'
 
97
      }, {
 
98
        token: 'string.doc',
 
99
        regex: '\'\'\'',
 
100
        next: 'qdoc'
 
101
      }, {
 
102
        token: 'string.doc',
 
103
        regex: '"""',
 
104
        next: 'qqdoc'
 
105
      }, {
 
106
        token: 'string',
 
107
        regex: '\'',
 
108
        next: 'qstring'
 
109
      }, {
 
110
        token: 'string',
 
111
        regex: '"',
 
112
        next: 'qqstring'
 
113
      }, {
 
114
        token: 'string',
 
115
        regex: '`',
 
116
        next: 'js'
 
117
      }, {
 
118
        token: 'string',
 
119
        regex: '<\\[',
 
120
        next: 'words'
 
121
      }, {
 
122
        token: 'string.regex',
 
123
        regex: '//',
 
124
        next: 'heregex'
 
125
      }, {
 
126
        token: 'comment.doc',
 
127
        regex: '/\\*',
 
128
        next: 'comment'
 
129
      }, {
 
130
        token: 'comment',
 
131
        regex: '#.*'
 
132
      }, {
 
133
        token: 'string.regex',
 
134
        regex: '\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}',
 
135
        next: 'key'
 
136
      }, {
 
137
        token: 'constant.numeric',
 
138
        regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
 
139
      }, {
 
140
        token: 'lparen',
 
141
        regex: '[({[]'
 
142
      }, {
 
143
        token: 'rparen',
 
144
        regex: '[)}\\]]',
 
145
        next: 'key'
 
146
      }, {
 
147
        token: 'keyword.operator',
 
148
        regex: '\\S+'
 
149
      }, {
 
150
        token: 'text',
 
151
        regex: '\\s+'
 
152
      }
 
153
    ],
 
154
    heregex: [
 
155
      {
 
156
        token: 'string.regex',
 
157
        regex: '.*?//[gimy$?]{0,4}',
 
158
        next: 'start'
 
159
      }, {
 
160
        token: 'string.regex',
 
161
        regex: '\\s*#{'
 
162
      }, {
 
163
        token: 'comment.regex',
 
164
        regex: '\\s+(?:#.*)?'
 
165
      }, {
 
166
        token: 'string.regex',
 
167
        regex: '\\S+'
 
168
      }
 
169
    ],
 
170
    key: [
 
171
      {
 
172
        token: 'keyword.operator',
 
173
        regex: '[.?@!]+'
 
174
      }, {
 
175
        token: 'identifier',
 
176
        regex: identifier,
 
177
        next: 'start'
 
178
      }, {
 
179
        token: 'text',
 
180
        regex: '.',
 
181
        next: 'start'
 
182
      }
 
183
    ],
 
184
    comment: [
 
185
      {
 
186
        token: 'comment.doc',
 
187
        regex: '.*?\\*/',
 
188
        next: 'start'
 
189
      }, {
 
190
        token: 'comment.doc',
 
191
        regex: '.+'
 
192
      }
 
193
    ],
 
194
    qdoc: [
 
195
      {
 
196
        token: 'string',
 
197
        regex: ".*?'''",
 
198
        next: 'key'
 
199
      }, stringfill
 
200
    ],
 
201
    qqdoc: [
 
202
      {
 
203
        token: 'string',
 
204
        regex: '.*?"""',
 
205
        next: 'key'
 
206
      }, stringfill
 
207
    ],
 
208
    qstring: [
 
209
      {
 
210
        token: 'string',
 
211
        regex: '[^\\\\\']*(?:\\\\.[^\\\\\']*)*\'',
 
212
        next: 'key'
 
213
      }, stringfill
 
214
    ],
 
215
    qqstring: [
 
216
      {
 
217
        token: 'string',
 
218
        regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
 
219
        next: 'key'
 
220
      }, stringfill
 
221
    ],
 
222
    js: [
 
223
      {
 
224
        token: 'string',
 
225
        regex: '[^\\\\`]*(?:\\\\.[^\\\\`]*)*`',
 
226
        next: 'key'
 
227
      }, stringfill
 
228
    ],
 
229
    words: [
 
230
      {
 
231
        token: 'string',
 
232
        regex: '.*?\\]>',
 
233
        next: 'key'
 
234
      }, stringfill
 
235
    ]
 
236
  };
 
237
function extend$(sub, sup){
 
238
  function fun(){} fun.prototype = (sub.superclass = sup).prototype;
 
239
  (sub.prototype = new fun).constructor = sub;
 
240
  if (typeof sup.extended == 'function') sup.extended(sub);
 
241
  return sub;
 
242
}
 
243
function import$(obj, src){
 
244
  var own = {}.hasOwnProperty;
 
245
  for (var key in src) if (own.call(src, key)) obj[key] = src[key];
 
246
  return obj;
 
247
}
 
248
});
 
249
 
 
250
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
 
251
 
 
252
 
 
253
var Range = require("../range").Range;
 
254
 
 
255
var MatchingBraceOutdent = function() {};
 
256
 
 
257
(function() {
 
258
 
 
259
    this.checkOutdent = function(line, input) {
 
260
        if (! /^\s+$/.test(line))
 
261
            return false;
 
262
 
 
263
        return /^\s*\}/.test(input);
 
264
    };
 
265
 
 
266
    this.autoOutdent = function(doc, row) {
 
267
        var line = doc.getLine(row);
 
268
        var match = line.match(/^(\s*\})/);
 
269
 
 
270
        if (!match) return 0;
 
271
 
 
272
        var column = match[1].length;
 
273
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
 
274
 
 
275
        if (!openBracePos || openBracePos.row == row) return 0;
 
276
 
 
277
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
 
278
        doc.replace(new Range(row, 0, row, column-1), indent);
 
279
    };
 
280
 
 
281
    this.$getIndent = function(line) {
 
282
        return line.match(/^\s*/)[0];
 
283
    };
 
284
 
 
285
}).call(MatchingBraceOutdent.prototype);
 
286
 
 
287
exports.MatchingBraceOutdent = MatchingBraceOutdent;
 
288
});