/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-csharp.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
define('ace/mode/csharp', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/csharp_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
 
2
 
 
3
 
 
4
var oop = require("../lib/oop");
 
5
var TextMode = require("./text").Mode;
 
6
var Tokenizer = require("../tokenizer").Tokenizer;
 
7
var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
 
8
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
 
9
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
 
10
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
 
11
 
 
12
var Mode = function() {
 
13
    this.$tokenizer = new Tokenizer(new CSharpHighlightRules().getRules());
 
14
    this.$outdent = new MatchingBraceOutdent();
 
15
    this.$behaviour = new CstyleBehaviour();
 
16
    this.foldingRules = new CStyleFoldMode();
 
17
};
 
18
oop.inherits(Mode, TextMode);
 
19
 
 
20
(function() {
 
21
    
 
22
    this.lineCommentStart = "//";
 
23
    this.blockComment = {start: "/*", end: "*/"};
 
24
    
 
25
    this.getNextLineIndent = function(state, line, tab) {
 
26
        var indent = this.$getIndent(line);
 
27
  
 
28
        var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
 
29
        var tokens = tokenizedLine.tokens;
 
30
  
 
31
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
 
32
            return indent;
 
33
        }
 
34
    
 
35
        if (state == "start") {
 
36
            var match = line.match(/^.*[\{\(\[]\s*$/);
 
37
            if (match) {
 
38
                indent += tab;
 
39
            }
 
40
        }
 
41
  
 
42
        return indent;
 
43
    };
 
44
 
 
45
    this.checkOutdent = function(state, line, input) {
 
46
        return this.$outdent.checkOutdent(line, input);
 
47
    };
 
48
  
 
49
    this.autoOutdent = function(state, doc, row) {
 
50
        this.$outdent.autoOutdent(doc, row);
 
51
    };
 
52
 
 
53
 
 
54
    this.createWorker = function(session) {
 
55
        return null;
 
56
    };
 
57
 
 
58
}).call(Mode.prototype);
 
59
 
 
60
exports.Mode = Mode;
 
61
});
 
62
define('ace/mode/csharp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
63
 
 
64
 
 
65
var oop = require("../lib/oop");
 
66
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
 
67
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
68
 
 
69
var CSharpHighlightRules = function() {
 
70
    var keywordMapper = this.createKeywordMapper({
 
71
        "variable.language": "this",
 
72
        "keyword": "abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic",
 
73
        "constant.language": "null|true|false"
 
74
    }, "identifier");
 
75
 
 
76
    this.$rules = {
 
77
        "start" : [
 
78
            {
 
79
                token : "comment",
 
80
                regex : "\\/\\/.*$"
 
81
            },
 
82
            DocCommentHighlightRules.getStartRule("doc-start"),
 
83
            {
 
84
                token : "comment", // multi line comment
 
85
                regex : "\\/\\*",
 
86
                next : "comment"
 
87
            }, {
 
88
                token : "string.regexp",
 
89
                regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
 
90
            }, {
 
91
                token : "string", // character
 
92
                regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/
 
93
            }, {
 
94
                token : "string", start : '"', end : '"|$', next: [
 
95
                    {token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/},
 
96
                    {token: "invalid", regex: /\\./}
 
97
                ]
 
98
            }, {
 
99
                token : "string", start : '@"', end : '"', next:[
 
100
                    {token: "constant.language.escape", regex: '""'}
 
101
                ]
 
102
            }, {
 
103
                token : "constant.numeric", // hex
 
104
                regex : "0[xX][0-9a-fA-F]+\\b"
 
105
            }, {
 
106
                token : "constant.numeric", // float
 
107
                regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
 
108
            }, {
 
109
                token : "constant.language.boolean",
 
110
                regex : "(?:true|false)\\b"
 
111
            }, {
 
112
                token : keywordMapper,
 
113
                regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
 
114
            }, {
 
115
                token : "keyword.operator",
 
116
                regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
 
117
            }, {
 
118
                token : "punctuation.operator",
 
119
                regex : "\\?|\\:|\\,|\\;|\\."
 
120
            }, {
 
121
                token : "paren.lparen",
 
122
                regex : "[[({]"
 
123
            }, {
 
124
                token : "paren.rparen",
 
125
                regex : "[\\])}]"
 
126
            }, {
 
127
                token : "text",
 
128
                regex : "\\s+"
 
129
            }
 
130
        ],
 
131
        "comment" : [
 
132
            {
 
133
                token : "comment", // closing comment
 
134
                regex : ".*?\\*\\/",
 
135
                next : "start"
 
136
            }, {
 
137
                token : "comment", // comment spanning whole line
 
138
                regex : ".+"
 
139
            }
 
140
        ]
 
141
    };
 
142
 
 
143
    this.embedRules(DocCommentHighlightRules, "doc-",
 
144
        [ DocCommentHighlightRules.getEndRule("start") ]);
 
145
    this.normalizeRules();
 
146
};
 
147
 
 
148
oop.inherits(CSharpHighlightRules, TextHighlightRules);
 
149
 
 
150
exports.CSharpHighlightRules = CSharpHighlightRules;
 
151
});
 
152
 
 
153
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
154
 
 
155
 
 
156
var oop = require("../lib/oop");
 
157
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
158
 
 
159
var DocCommentHighlightRules = function() {
 
160
 
 
161
    this.$rules = {
 
162
        "start" : [ {
 
163
            token : "comment.doc.tag",
 
164
            regex : "@[\\w\\d_]+" // TODO: fix email addresses
 
165
        }, {
 
166
            token : "comment.doc.tag",
 
167
            regex : "\\bTODO\\b"
 
168
        }, {
 
169
            defaultToken : "comment.doc"
 
170
        }]
 
171
    };
 
172
};
 
173
 
 
174
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
 
175
 
 
176
DocCommentHighlightRules.getStartRule = function(start) {
 
177
    return {
 
178
        token : "comment.doc", // doc comment
 
179
        regex : "\\/\\*(?=\\*)",
 
180
        next  : start
 
181
    };
 
182
};
 
183
 
 
184
DocCommentHighlightRules.getEndRule = function (start) {
 
185
    return {
 
186
        token : "comment.doc", // closing comment
 
187
        regex : "\\*\\/",
 
188
        next  : start
 
189
    };
 
190
};
 
191
 
 
192
 
 
193
exports.DocCommentHighlightRules = DocCommentHighlightRules;
 
194
 
 
195
});
 
196
 
 
197
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
 
198
 
 
199
 
 
200
var Range = require("../range").Range;
 
201
 
 
202
var MatchingBraceOutdent = function() {};
 
203
 
 
204
(function() {
 
205
 
 
206
    this.checkOutdent = function(line, input) {
 
207
        if (! /^\s+$/.test(line))
 
208
            return false;
 
209
 
 
210
        return /^\s*\}/.test(input);
 
211
    };
 
212
 
 
213
    this.autoOutdent = function(doc, row) {
 
214
        var line = doc.getLine(row);
 
215
        var match = line.match(/^(\s*\})/);
 
216
 
 
217
        if (!match) return 0;
 
218
 
 
219
        var column = match[1].length;
 
220
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
 
221
 
 
222
        if (!openBracePos || openBracePos.row == row) return 0;
 
223
 
 
224
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
 
225
        doc.replace(new Range(row, 0, row, column-1), indent);
 
226
    };
 
227
 
 
228
    this.$getIndent = function(line) {
 
229
        return line.match(/^\s*/)[0];
 
230
    };
 
231
 
 
232
}).call(MatchingBraceOutdent.prototype);
 
233
 
 
234
exports.MatchingBraceOutdent = MatchingBraceOutdent;
 
235
});
 
236
 
 
237
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
 
238
 
 
239
 
 
240
var oop = require("../../lib/oop");
 
241
var Behaviour = require("../behaviour").Behaviour;
 
242
var TokenIterator = require("../../token_iterator").TokenIterator;
 
243
var lang = require("../../lib/lang");
 
244
 
 
245
var SAFE_INSERT_IN_TOKENS =
 
246
    ["text", "paren.rparen", "punctuation.operator"];
 
247
var SAFE_INSERT_BEFORE_TOKENS =
 
248
    ["text", "paren.rparen", "punctuation.operator", "comment"];
 
249
 
 
250
 
 
251
var autoInsertedBrackets = 0;
 
252
var autoInsertedRow = -1;
 
253
var autoInsertedLineEnd = "";
 
254
var maybeInsertedBrackets = 0;
 
255
var maybeInsertedRow = -1;
 
256
var maybeInsertedLineStart = "";
 
257
var maybeInsertedLineEnd = "";
 
258
 
 
259
var CstyleBehaviour = function () {
 
260
    
 
261
    CstyleBehaviour.isSaneInsertion = function(editor, session) {
 
262
        var cursor = editor.getCursorPosition();
 
263
        var iterator = new TokenIterator(session, cursor.row, cursor.column);
 
264
        if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
 
265
            var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
 
266
            if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
 
267
                return false;
 
268
        }
 
269
        iterator.stepForward();
 
270
        return iterator.getCurrentTokenRow() !== cursor.row ||
 
271
            this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
 
272
    };
 
273
    
 
274
    CstyleBehaviour.$matchTokenType = function(token, types) {
 
275
        return types.indexOf(token.type || token) > -1;
 
276
    };
 
277
    
 
278
    CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
 
279
        var cursor = editor.getCursorPosition();
 
280
        var line = session.doc.getLine(cursor.row);
 
281
        if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
 
282
            autoInsertedBrackets = 0;
 
283
        autoInsertedRow = cursor.row;
 
284
        autoInsertedLineEnd = bracket + line.substr(cursor.column);
 
285
        autoInsertedBrackets++;
 
286
    };
 
287
    
 
288
    CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
 
289
        var cursor = editor.getCursorPosition();
 
290
        var line = session.doc.getLine(cursor.row);
 
291
        if (!this.isMaybeInsertedClosing(cursor, line))
 
292
            maybeInsertedBrackets = 0;
 
293
        maybeInsertedRow = cursor.row;
 
294
        maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
 
295
        maybeInsertedLineEnd = line.substr(cursor.column);
 
296
        maybeInsertedBrackets++;
 
297
    };
 
298
    
 
299
    CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
 
300
        return autoInsertedBrackets > 0 &&
 
301
            cursor.row === autoInsertedRow &&
 
302
            bracket === autoInsertedLineEnd[0] &&
 
303
            line.substr(cursor.column) === autoInsertedLineEnd;
 
304
    };
 
305
    
 
306
    CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
 
307
        return maybeInsertedBrackets > 0 &&
 
308
            cursor.row === maybeInsertedRow &&
 
309
            line.substr(cursor.column) === maybeInsertedLineEnd &&
 
310
            line.substr(0, cursor.column) == maybeInsertedLineStart;
 
311
    };
 
312
    
 
313
    CstyleBehaviour.popAutoInsertedClosing = function() {
 
314
        autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
 
315
        autoInsertedBrackets--;
 
316
    };
 
317
    
 
318
    CstyleBehaviour.clearMaybeInsertedClosing = function() {
 
319
        maybeInsertedBrackets = 0;
 
320
        maybeInsertedRow = -1;
 
321
    };
 
322
 
 
323
    this.add("braces", "insertion", function (state, action, editor, session, text) {
 
324
        var cursor = editor.getCursorPosition();
 
325
        var line = session.doc.getLine(cursor.row);
 
326
        if (text == '{') {
 
327
            var selection = editor.getSelectionRange();
 
328
            var selected = session.doc.getTextRange(selection);
 
329
            if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
 
330
                return {
 
331
                    text: '{' + selected + '}',
 
332
                    selection: false
 
333
                };
 
334
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
 
335
                if (/[\]\}\)]/.test(line[cursor.column])) {
 
336
                    CstyleBehaviour.recordAutoInsert(editor, session, "}");
 
337
                    return {
 
338
                        text: '{}',
 
339
                        selection: [1, 1]
 
340
                    };
 
341
                } else {
 
342
                    CstyleBehaviour.recordMaybeInsert(editor, session, "{");
 
343
                    return {
 
344
                        text: '{',
 
345
                        selection: [1, 1]
 
346
                    };
 
347
                }
 
348
            }
 
349
        } else if (text == '}') {
 
350
            var rightChar = line.substring(cursor.column, cursor.column + 1);
 
351
            if (rightChar == '}') {
 
352
                var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
 
353
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
 
354
                    CstyleBehaviour.popAutoInsertedClosing();
 
355
                    return {
 
356
                        text: '',
 
357
                        selection: [1, 1]
 
358
                    };
 
359
                }
 
360
            }
 
361
        } else if (text == "\n" || text == "\r\n") {
 
362
            var closing = "";
 
363
            if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
 
364
                closing = lang.stringRepeat("}", maybeInsertedBrackets);
 
365
                CstyleBehaviour.clearMaybeInsertedClosing();
 
366
            }
 
367
            var rightChar = line.substring(cursor.column, cursor.column + 1);
 
368
            if (rightChar == '}' || closing !== "") {
 
369
                var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
 
370
                if (!openBracePos)
 
371
                     return null;
 
372
 
 
373
                var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
 
374
                var next_indent = this.$getIndent(line);
 
375
 
 
376
                return {
 
377
                    text: '\n' + indent + '\n' + next_indent + closing,
 
378
                    selection: [1, indent.length, 1, indent.length]
 
379
                };
 
380
            }
 
381
        }
 
382
    });
 
383
 
 
384
    this.add("braces", "deletion", function (state, action, editor, session, range) {
 
385
        var selected = session.doc.getTextRange(range);
 
386
        if (!range.isMultiLine() && selected == '{') {
 
387
            var line = session.doc.getLine(range.start.row);
 
388
            var rightChar = line.substring(range.end.column, range.end.column + 1);
 
389
            if (rightChar == '}') {
 
390
                range.end.column++;
 
391
                return range;
 
392
            } else {
 
393
                maybeInsertedBrackets--;
 
394
            }
 
395
        }
 
396
    });
 
397
 
 
398
    this.add("parens", "insertion", function (state, action, editor, session, text) {
 
399
        if (text == '(') {
 
400
            var selection = editor.getSelectionRange();
 
401
            var selected = session.doc.getTextRange(selection);
 
402
            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
 
403
                return {
 
404
                    text: '(' + selected + ')',
 
405
                    selection: false
 
406
                };
 
407
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
 
408
                CstyleBehaviour.recordAutoInsert(editor, session, ")");
 
409
                return {
 
410
                    text: '()',
 
411
                    selection: [1, 1]
 
412
                };
 
413
            }
 
414
        } else if (text == ')') {
 
415
            var cursor = editor.getCursorPosition();
 
416
            var line = session.doc.getLine(cursor.row);
 
417
            var rightChar = line.substring(cursor.column, cursor.column + 1);
 
418
            if (rightChar == ')') {
 
419
                var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
 
420
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
 
421
                    CstyleBehaviour.popAutoInsertedClosing();
 
422
                    return {
 
423
                        text: '',
 
424
                        selection: [1, 1]
 
425
                    };
 
426
                }
 
427
            }
 
428
        }
 
429
    });
 
430
 
 
431
    this.add("parens", "deletion", function (state, action, editor, session, range) {
 
432
        var selected = session.doc.getTextRange(range);
 
433
        if (!range.isMultiLine() && selected == '(') {
 
434
            var line = session.doc.getLine(range.start.row);
 
435
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
 
436
            if (rightChar == ')') {
 
437
                range.end.column++;
 
438
                return range;
 
439
            }
 
440
        }
 
441
    });
 
442
 
 
443
    this.add("brackets", "insertion", function (state, action, editor, session, text) {
 
444
        if (text == '[') {
 
445
            var selection = editor.getSelectionRange();
 
446
            var selected = session.doc.getTextRange(selection);
 
447
            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
 
448
                return {
 
449
                    text: '[' + selected + ']',
 
450
                    selection: false
 
451
                };
 
452
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
 
453
                CstyleBehaviour.recordAutoInsert(editor, session, "]");
 
454
                return {
 
455
                    text: '[]',
 
456
                    selection: [1, 1]
 
457
                };
 
458
            }
 
459
        } else if (text == ']') {
 
460
            var cursor = editor.getCursorPosition();
 
461
            var line = session.doc.getLine(cursor.row);
 
462
            var rightChar = line.substring(cursor.column, cursor.column + 1);
 
463
            if (rightChar == ']') {
 
464
                var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
 
465
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
 
466
                    CstyleBehaviour.popAutoInsertedClosing();
 
467
                    return {
 
468
                        text: '',
 
469
                        selection: [1, 1]
 
470
                    };
 
471
                }
 
472
            }
 
473
        }
 
474
    });
 
475
 
 
476
    this.add("brackets", "deletion", function (state, action, editor, session, range) {
 
477
        var selected = session.doc.getTextRange(range);
 
478
        if (!range.isMultiLine() && selected == '[') {
 
479
            var line = session.doc.getLine(range.start.row);
 
480
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
 
481
            if (rightChar == ']') {
 
482
                range.end.column++;
 
483
                return range;
 
484
            }
 
485
        }
 
486
    });
 
487
 
 
488
    this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
 
489
        if (text == '"' || text == "'") {
 
490
            var quote = text;
 
491
            var selection = editor.getSelectionRange();
 
492
            var selected = session.doc.getTextRange(selection);
 
493
            if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
 
494
                return {
 
495
                    text: quote + selected + quote,
 
496
                    selection: false
 
497
                };
 
498
            } else {
 
499
                var cursor = editor.getCursorPosition();
 
500
                var line = session.doc.getLine(cursor.row);
 
501
                var leftChar = line.substring(cursor.column-1, cursor.column);
 
502
                if (leftChar == '\\') {
 
503
                    return null;
 
504
                }
 
505
                var tokens = session.getTokens(selection.start.row);
 
506
                var col = 0, token;
 
507
                var quotepos = -1; // Track whether we're inside an open quote.
 
508
 
 
509
                for (var x = 0; x < tokens.length; x++) {
 
510
                    token = tokens[x];
 
511
                    if (token.type == "string") {
 
512
                      quotepos = -1;
 
513
                    } else if (quotepos < 0) {
 
514
                      quotepos = token.value.indexOf(quote);
 
515
                    }
 
516
                    if ((token.value.length + col) > selection.start.column) {
 
517
                        break;
 
518
                    }
 
519
                    col += tokens[x].value.length;
 
520
                }
 
521
                if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
 
522
                    if (!CstyleBehaviour.isSaneInsertion(editor, session))
 
523
                        return;
 
524
                    return {
 
525
                        text: quote + quote,
 
526
                        selection: [1,1]
 
527
                    };
 
528
                } else if (token && token.type === "string") {
 
529
                    var rightChar = line.substring(cursor.column, cursor.column + 1);
 
530
                    if (rightChar == quote) {
 
531
                        return {
 
532
                            text: '',
 
533
                            selection: [1, 1]
 
534
                        };
 
535
                    }
 
536
                }
 
537
            }
 
538
        }
 
539
    });
 
540
 
 
541
    this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
 
542
        var selected = session.doc.getTextRange(range);
 
543
        if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
 
544
            var line = session.doc.getLine(range.start.row);
 
545
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
 
546
            if (rightChar == selected) {
 
547
                range.end.column++;
 
548
                return range;
 
549
            }
 
550
        }
 
551
    });
 
552
 
 
553
};
 
554
 
 
555
oop.inherits(CstyleBehaviour, Behaviour);
 
556
 
 
557
exports.CstyleBehaviour = CstyleBehaviour;
 
558
});
 
559
 
 
560
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
 
561
 
 
562
 
 
563
var oop = require("../../lib/oop");
 
564
var Range = require("../../range").Range;
 
565
var BaseFoldMode = require("./fold_mode").FoldMode;
 
566
 
 
567
var FoldMode = exports.FoldMode = function(commentRegex) {
 
568
    if (commentRegex) {
 
569
        this.foldingStartMarker = new RegExp(
 
570
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
 
571
        );
 
572
        this.foldingStopMarker = new RegExp(
 
573
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
 
574
        );
 
575
    }
 
576
};
 
577
oop.inherits(FoldMode, BaseFoldMode);
 
578
 
 
579
(function() {
 
580
 
 
581
    this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
 
582
    this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
 
583
 
 
584
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
585
        var line = session.getLine(row);
 
586
        var match = line.match(this.foldingStartMarker);
 
587
        if (match) {
 
588
            var i = match.index;
 
589
 
 
590
            if (match[1])
 
591
                return this.openingBracketBlock(session, match[1], row, i);
 
592
 
 
593
            return session.getCommentFoldRange(row, i + match[0].length, 1);
 
594
        }
 
595
 
 
596
        if (foldStyle !== "markbeginend")
 
597
            return;
 
598
 
 
599
        var match = line.match(this.foldingStopMarker);
 
600
        if (match) {
 
601
            var i = match.index + match[0].length;
 
602
 
 
603
            if (match[1])
 
604
                return this.closingBracketBlock(session, match[1], row, i);
 
605
 
 
606
            return session.getCommentFoldRange(row, i, -1);
 
607
        }
 
608
    };
 
609
 
 
610
}).call(FoldMode.prototype);
 
611
 
 
612
});