1
/* ***** BEGIN LICENSE BLOCK *****
2
* Distributed under the BSD license:
4
* Copyright (c) 2010, Ajax.org B.V.
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.
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.
29
* ***** END LICENSE BLOCK ***** */
31
define('ace/mode/glsl', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/c_cpp', 'ace/tokenizer', 'ace/mode/glsl_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
34
var oop = require("../lib/oop");
35
var CMode = require("./c_cpp").Mode;
36
var Tokenizer = require("../tokenizer").Tokenizer;
37
var glslHighlightRules = require("./glsl_highlight_rules").glslHighlightRules;
38
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
39
var Range = require("../range").Range;
40
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
41
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
43
var Mode = function() {
44
this.$tokenizer = new Tokenizer(new glslHighlightRules().getRules());
45
this.$outdent = new MatchingBraceOutdent();
46
this.$behaviour = new CstyleBehaviour();
47
this.foldingRules = new CStyleFoldMode();
49
oop.inherits(Mode, CMode);
54
define('ace/mode/c_cpp', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/c_cpp_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
57
var oop = require("../lib/oop");
58
var TextMode = require("./text").Mode;
59
var Tokenizer = require("../tokenizer").Tokenizer;
60
var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
61
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
62
var Range = require("../range").Range;
63
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
64
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
66
var Mode = function() {
67
this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
68
this.$outdent = new MatchingBraceOutdent();
69
this.$behaviour = new CstyleBehaviour();
70
this.foldingRules = new CStyleFoldMode();
72
oop.inherits(Mode, TextMode);
76
this.lineCommentStart = "//";
77
this.blockComment = {start: "/*", end: "*/"};
79
this.getNextLineIndent = function(state, line, tab) {
80
var indent = this.$getIndent(line);
82
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
83
var tokens = tokenizedLine.tokens;
84
var endState = tokenizedLine.state;
86
if (tokens.length && tokens[tokens.length-1].type == "comment") {
90
if (state == "start") {
91
var match = line.match(/^.*[\{\(\[]\s*$/);
95
} else if (state == "doc-start") {
96
if (endState == "start") {
99
var match = line.match(/^\s*(\/?)\*/);
111
this.checkOutdent = function(state, line, input) {
112
return this.$outdent.checkOutdent(line, input);
115
this.autoOutdent = function(state, doc, row) {
116
this.$outdent.autoOutdent(doc, row);
119
}).call(Mode.prototype);
123
define('ace/mode/c_cpp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
126
var oop = require("../lib/oop");
127
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
128
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
129
var cFunctions = exports.cFunctions = "\\s*\\bhypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len)))\\b"
131
var c_cppHighlightRules = function() {
133
var keywordControls = (
134
"break|case|continue|default|do|else|for|goto|if|_Pragma|" +
135
"return|switch|while|catch|operator|try|throw|using"
139
"asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
140
"_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
141
"class|wchar_t|template"
144
var storageModifiers = (
145
"const|extern|register|restrict|static|volatile|inline|private:|" +
146
"protected:|public:|friend|explicit|virtual|export|mutable|typename"
149
var keywordOperators = (
150
"and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq" +
151
"const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace"
154
var builtinConstants = (
155
"NULL|true|false|TRUE|FALSE"
158
var keywordMapper = this.$keywords = this.createKeywordMapper({
159
"keyword.control" : keywordControls,
160
"storage.type" : storageType,
161
"storage.modifier" : storageModifiers,
162
"keyword.operator" : keywordOperators,
163
"variable.language": "this",
164
"constant.language": builtinConstants
167
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\d\\$_\u00a1-\uffff]*\\b";
175
DocCommentHighlightRules.getStartRule("doc-start"),
177
token : "comment", // multi line comment
181
token : "string", // single line
182
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
184
token : "string", // multi line string start
185
regex : '["].*\\\\$',
188
token : "string", // single line
189
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
191
token : "string", // multi line string start
192
regex : "['].*\\\\$",
195
token : "constant.numeric", // hex
196
regex : "0[xX][0-9a-fA-F]+\\b"
198
token : "constant.numeric", // float
199
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
201
token : "keyword", // pre-compiler directives
202
regex : "(?:#include|#import|#pragma|#line|#define|#undef|#if|#ifdef|#else|#elif|#ifndef)\\b",
205
token : "keyword", // special case pre-compiler directive
206
regex : "(?:#endif)\\b"
208
token : "support.function.C99.c",
211
token : keywordMapper,
212
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
214
token : "keyword.operator",
215
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
217
token : "punctuation.operator",
218
regex : "\\?|\\:|\\,|\\;|\\."
220
token : "paren.lparen",
223
token : "paren.rparen",
232
token : "comment", // closing comment
236
token : "comment", // comment spanning whole line
243
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
253
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
262
token : "constant.other.multiline",
266
token : "constant.other.multiline",
270
token : "constant.other",
275
token : "constant.other", // single line
276
regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
280
token : "constant.other", // single line
281
regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
285
token : "constant.other",
292
this.embedRules(DocCommentHighlightRules, "doc-",
293
[ DocCommentHighlightRules.getEndRule("start") ]);
296
oop.inherits(c_cppHighlightRules, TextHighlightRules);
298
exports.c_cppHighlightRules = c_cppHighlightRules;
301
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
304
var oop = require("../lib/oop");
305
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
307
var DocCommentHighlightRules = function() {
311
token : "comment.doc.tag",
312
regex : "@[\\w\\d_]+" // TODO: fix email addresses
314
token : "comment.doc.tag",
317
defaultToken : "comment.doc"
322
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
324
DocCommentHighlightRules.getStartRule = function(start) {
326
token : "comment.doc", // doc comment
327
regex : "\\/\\*(?=\\*)",
332
DocCommentHighlightRules.getEndRule = function (start) {
334
token : "comment.doc", // closing comment
341
exports.DocCommentHighlightRules = DocCommentHighlightRules;
345
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
348
var Range = require("../range").Range;
350
var MatchingBraceOutdent = function() {};
354
this.checkOutdent = function(line, input) {
355
if (! /^\s+$/.test(line))
358
return /^\s*\}/.test(input);
361
this.autoOutdent = function(doc, row) {
362
var line = doc.getLine(row);
363
var match = line.match(/^(\s*\})/);
365
if (!match) return 0;
367
var column = match[1].length;
368
var openBracePos = doc.findMatchingBracket({row: row, column: column});
370
if (!openBracePos || openBracePos.row == row) return 0;
372
var indent = this.$getIndent(doc.getLine(openBracePos.row));
373
doc.replace(new Range(row, 0, row, column-1), indent);
376
this.$getIndent = function(line) {
377
return line.match(/^\s*/)[0];
380
}).call(MatchingBraceOutdent.prototype);
382
exports.MatchingBraceOutdent = MatchingBraceOutdent;
385
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
388
var oop = require("../../lib/oop");
389
var Behaviour = require("../behaviour").Behaviour;
390
var TokenIterator = require("../../token_iterator").TokenIterator;
391
var lang = require("../../lib/lang");
393
var SAFE_INSERT_IN_TOKENS =
394
["text", "paren.rparen", "punctuation.operator"];
395
var SAFE_INSERT_BEFORE_TOKENS =
396
["text", "paren.rparen", "punctuation.operator", "comment"];
399
var autoInsertedBrackets = 0;
400
var autoInsertedRow = -1;
401
var autoInsertedLineEnd = "";
402
var maybeInsertedBrackets = 0;
403
var maybeInsertedRow = -1;
404
var maybeInsertedLineStart = "";
405
var maybeInsertedLineEnd = "";
407
var CstyleBehaviour = function () {
409
CstyleBehaviour.isSaneInsertion = function(editor, session) {
410
var cursor = editor.getCursorPosition();
411
var iterator = new TokenIterator(session, cursor.row, cursor.column);
412
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
413
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
414
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
417
iterator.stepForward();
418
return iterator.getCurrentTokenRow() !== cursor.row ||
419
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
422
CstyleBehaviour.$matchTokenType = function(token, types) {
423
return types.indexOf(token.type || token) > -1;
426
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
427
var cursor = editor.getCursorPosition();
428
var line = session.doc.getLine(cursor.row);
429
if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
430
autoInsertedBrackets = 0;
431
autoInsertedRow = cursor.row;
432
autoInsertedLineEnd = bracket + line.substr(cursor.column);
433
autoInsertedBrackets++;
436
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
437
var cursor = editor.getCursorPosition();
438
var line = session.doc.getLine(cursor.row);
439
if (!this.isMaybeInsertedClosing(cursor, line))
440
maybeInsertedBrackets = 0;
441
maybeInsertedRow = cursor.row;
442
maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
443
maybeInsertedLineEnd = line.substr(cursor.column);
444
maybeInsertedBrackets++;
447
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
448
return autoInsertedBrackets > 0 &&
449
cursor.row === autoInsertedRow &&
450
bracket === autoInsertedLineEnd[0] &&
451
line.substr(cursor.column) === autoInsertedLineEnd;
454
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
455
return maybeInsertedBrackets > 0 &&
456
cursor.row === maybeInsertedRow &&
457
line.substr(cursor.column) === maybeInsertedLineEnd &&
458
line.substr(0, cursor.column) == maybeInsertedLineStart;
461
CstyleBehaviour.popAutoInsertedClosing = function() {
462
autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
463
autoInsertedBrackets--;
466
CstyleBehaviour.clearMaybeInsertedClosing = function() {
467
maybeInsertedBrackets = 0;
468
maybeInsertedRow = -1;
471
this.add("braces", "insertion", function (state, action, editor, session, text) {
472
var cursor = editor.getCursorPosition();
473
var line = session.doc.getLine(cursor.row);
475
var selection = editor.getSelectionRange();
476
var selected = session.doc.getTextRange(selection);
477
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
479
text: '{' + selected + '}',
482
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
483
if (/[\]\}\)]/.test(line[cursor.column])) {
484
CstyleBehaviour.recordAutoInsert(editor, session, "}");
490
CstyleBehaviour.recordMaybeInsert(editor, session, "{");
497
} else if (text == '}') {
498
var rightChar = line.substring(cursor.column, cursor.column + 1);
499
if (rightChar == '}') {
500
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
501
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
502
CstyleBehaviour.popAutoInsertedClosing();
509
} else if (text == "\n" || text == "\r\n") {
511
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
512
closing = lang.stringRepeat("}", maybeInsertedBrackets);
513
CstyleBehaviour.clearMaybeInsertedClosing();
515
var rightChar = line.substring(cursor.column, cursor.column + 1);
516
if (rightChar == '}' || closing !== "") {
517
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
521
var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
522
var next_indent = this.$getIndent(line);
525
text: '\n' + indent + '\n' + next_indent + closing,
526
selection: [1, indent.length, 1, indent.length]
532
this.add("braces", "deletion", function (state, action, editor, session, range) {
533
var selected = session.doc.getTextRange(range);
534
if (!range.isMultiLine() && selected == '{') {
535
var line = session.doc.getLine(range.start.row);
536
var rightChar = line.substring(range.end.column, range.end.column + 1);
537
if (rightChar == '}') {
541
maybeInsertedBrackets--;
546
this.add("parens", "insertion", function (state, action, editor, session, text) {
548
var selection = editor.getSelectionRange();
549
var selected = session.doc.getTextRange(selection);
550
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
552
text: '(' + selected + ')',
555
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
556
CstyleBehaviour.recordAutoInsert(editor, session, ")");
562
} else if (text == ')') {
563
var cursor = editor.getCursorPosition();
564
var line = session.doc.getLine(cursor.row);
565
var rightChar = line.substring(cursor.column, cursor.column + 1);
566
if (rightChar == ')') {
567
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
568
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
569
CstyleBehaviour.popAutoInsertedClosing();
579
this.add("parens", "deletion", function (state, action, editor, session, range) {
580
var selected = session.doc.getTextRange(range);
581
if (!range.isMultiLine() && selected == '(') {
582
var line = session.doc.getLine(range.start.row);
583
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
584
if (rightChar == ')') {
591
this.add("brackets", "insertion", function (state, action, editor, session, text) {
593
var selection = editor.getSelectionRange();
594
var selected = session.doc.getTextRange(selection);
595
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
597
text: '[' + selected + ']',
600
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
601
CstyleBehaviour.recordAutoInsert(editor, session, "]");
607
} else if (text == ']') {
608
var cursor = editor.getCursorPosition();
609
var line = session.doc.getLine(cursor.row);
610
var rightChar = line.substring(cursor.column, cursor.column + 1);
611
if (rightChar == ']') {
612
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
613
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
614
CstyleBehaviour.popAutoInsertedClosing();
624
this.add("brackets", "deletion", function (state, action, editor, session, range) {
625
var selected = session.doc.getTextRange(range);
626
if (!range.isMultiLine() && selected == '[') {
627
var line = session.doc.getLine(range.start.row);
628
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
629
if (rightChar == ']') {
636
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
637
if (text == '"' || text == "'") {
639
var selection = editor.getSelectionRange();
640
var selected = session.doc.getTextRange(selection);
641
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
643
text: quote + selected + quote,
647
var cursor = editor.getCursorPosition();
648
var line = session.doc.getLine(cursor.row);
649
var leftChar = line.substring(cursor.column-1, cursor.column);
650
if (leftChar == '\\') {
653
var tokens = session.getTokens(selection.start.row);
655
var quotepos = -1; // Track whether we're inside an open quote.
657
for (var x = 0; x < tokens.length; x++) {
659
if (token.type == "string") {
661
} else if (quotepos < 0) {
662
quotepos = token.value.indexOf(quote);
664
if ((token.value.length + col) > selection.start.column) {
667
col += tokens[x].value.length;
669
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)))) {
670
if (!CstyleBehaviour.isSaneInsertion(editor, session))
676
} else if (token && token.type === "string") {
677
var rightChar = line.substring(cursor.column, cursor.column + 1);
678
if (rightChar == quote) {
689
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
690
var selected = session.doc.getTextRange(range);
691
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
692
var line = session.doc.getLine(range.start.row);
693
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
694
if (rightChar == selected) {
703
oop.inherits(CstyleBehaviour, Behaviour);
705
exports.CstyleBehaviour = CstyleBehaviour;
708
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
711
var oop = require("../../lib/oop");
712
var Range = require("../../range").Range;
713
var BaseFoldMode = require("./fold_mode").FoldMode;
715
var FoldMode = exports.FoldMode = function(commentRegex) {
717
this.foldingStartMarker = new RegExp(
718
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
720
this.foldingStopMarker = new RegExp(
721
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
725
oop.inherits(FoldMode, BaseFoldMode);
729
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
730
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
732
this.getFoldWidgetRange = function(session, foldStyle, row) {
733
var line = session.getLine(row);
734
var match = line.match(this.foldingStartMarker);
739
return this.openingBracketBlock(session, match[1], row, i);
741
return session.getCommentFoldRange(row, i + match[0].length, 1);
744
if (foldStyle !== "markbeginend")
747
var match = line.match(this.foldingStopMarker);
749
var i = match.index + match[0].length;
752
return this.closingBracketBlock(session, match[1], row, i);
754
return session.getCommentFoldRange(row, i, -1);
758
}).call(FoldMode.prototype);
762
define('ace/mode/glsl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/c_cpp_highlight_rules'], function(require, exports, module) {
765
var oop = require("../lib/oop");
766
var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
768
var glslHighlightRules = function() {
771
"attribute|const|uniform|varying|break|continue|do|for|while|" +
772
"if|else|in|out|inout|float|int|void|bool|true|false|" +
773
"lowp|mediump|highp|precision|invariant|discard|return|mat2|mat3|" +
774
"mat4|vec2|vec3|vec4|ivec2|ivec3|ivec4|bvec2|bvec3|bvec4|sampler2D|" +
778
var buildinConstants = (
779
"radians|degrees|sin|cos|tan|asin|acos|atan|pow|" +
780
"exp|log|exp2|log2|sqrt|inversesqrt|abs|sign|floor|ceil|fract|mod|" +
781
"min|max|clamp|mix|step|smoothstep|length|distance|dot|cross|" +
782
"normalize|faceforward|reflect|refract|matrixCompMult|lessThan|" +
783
"lessThanEqual|greaterThan|greaterThanEqual|equal|notEqual|any|all|" +
784
"not|dFdx|dFdy|fwidth|texture2D|texture2DProj|texture2DLod|" +
785
"texture2DProjLod|textureCube|textureCubeLod|" +
786
"gl_MaxVertexAttribs|gl_MaxVertexUniformVectors|gl_MaxVaryingVectors|" +
787
"gl_MaxVertexTextureImageUnits|gl_MaxCombinedTextureImageUnits|" +
788
"gl_MaxTextureImageUnits|gl_MaxFragmentUniformVectors|gl_MaxDrawBuffers|" +
789
"gl_DepthRangeParameters|gl_DepthRange|" +
790
"gl_Position|gl_PointSize|" +
791
"gl_FragCoord|gl_FrontFacing|gl_PointCoord|gl_FragColor|gl_FragData"
794
var keywordMapper = this.createKeywordMapper({
795
"variable.language": "this",
797
"constant.language": buildinConstants
800
this.$rules = new c_cppHighlightRules().$rules;
801
this.$rules.start.forEach(function(rule) {
802
if (typeof rule.token == "function")
803
rule.token = keywordMapper;
807
oop.inherits(glslHighlightRules, c_cppHighlightRules);
809
exports.glslHighlightRules = glslHighlightRules;