Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Irakli Gozalishvili 2011-02-10 11:39:51 +01:00
commit b2fc509f60
57 changed files with 1698 additions and 443 deletions

2
.gitignore vendored
View file

@ -7,7 +7,7 @@
.project .project
.settings/ .settings/
.settings.xml .settings.xml
.c9settiongs.xml .c9settings.xml
.settings.xml.old .settings.xml.old
.*.gz .*.gz

22
ChangeLog.txt Normal file
View file

@ -0,0 +1,22 @@
2011.02.08, Version 0.1.5
* Add Coffeescript Mode (Satoshi Murakami)
* Fix word wrap bug (Julian Viereck)
* Fix packaged version of the Eclipse mode
* Loading of workers is more robust
* Fix "click selection"
* Allow tokizing empty lines (Daniel Krech)
* Make PageUp/Down behavior more consistent with native OS (Joe Cheng)
2011.02.04, Version 0.1.4
* Add C/C++ mode contributed by Gastón Kleiman
* Fix exception in key input
2011.02.04, Version 0.1.3
* Let the packaged version play nice with requireJS
* Add Ruby mode contributed by Shlomo Zalman Heigh
* Add Java mode contributed by Tom Tasche
* Fix annotation bug
* Changing a document added a new empty line at the end

View file

@ -54,6 +54,12 @@ copy({
}); });
var ace = copy.createDataObject(); var ace = copy.createDataObject();
copy({
source: [
'build_support/mini_require.js'
],
dest: ace
});
copy({ copy({
source: [ source: [
copy.source.commonjs({ copy.source.commonjs({
@ -96,7 +102,6 @@ copy({
}); });
copy({ copy({
source: [ source: [
'build_support/mini_require.js',
'build_support/boot.js' 'build_support/boot.js'
], ],
dest: ace dest: ace
@ -116,7 +121,7 @@ copy({
console.log('# cockpit ---------'); console.log('# cockpit ---------');
project.assmeAllFilesLoaded(); project.assumeAllFilesLoaded();
project.addRoot(aceHome + '/support/cockpit/lib'); project.addRoot(aceHome + '/support/cockpit/lib');
var cockpit = copy.createDataObject(); var cockpit = copy.createDataObject();
@ -125,7 +130,7 @@ copy({
copy.source.commonjs({ copy.source.commonjs({
project: project, project: project,
require: [ 'cockpit/index' ] require: [ 'cockpit/index' ]
}), })
], ],
filter: [ copy.filter.moduleDefines ], filter: [ copy.filter.moduleDefines ],
dest: cockpit dest: cockpit
@ -162,17 +167,17 @@ copy({
// create modes // create modes
project.assmeAllFilesLoaded(); project.assumeAllFilesLoaded();
["css", "html", "javascript", "php", "python", "xml", "ruby", "java", "c_cpp", "coffee"].forEach(function(mode) {
["css", "html", "javascript", "php", "python", "xml"].forEach(function(mode) { console.log("mode " + mode);
copy({ copy({
source: [ source: [
copy.source.commonjs({ copy.source.commonjs({
project: project, project: project.clone(),
require: [ 'ace/mode/' + mode ] require: [ 'ace/mode/' + mode ]
}), })
], ],
filter: [ copy.filter.moduleDefines, copy.filter.uglifyjs ], filter: [ copy.filter.debug, copy.filter.moduleDefines, copy.filter.uglifyjs ],
dest: "build/src/mode-" + mode + ".js" dest: "build/src/mode-" + mode + ".js"
}); });
}); });
@ -195,9 +200,9 @@ copy({
'pilot/oop', 'pilot/oop',
'ace/mode/javascript_worker' 'ace/mode/javascript_worker'
] ]
}), })
], ],
filter: [ copy.filter.moduleDefines, copy.filter.uglifyjs ], filter: [ copy.filter.moduleDefines],
dest: jsWorker dest: jsWorker
}); });
copy({ copy({
@ -205,6 +210,7 @@ copy({
aceHome + "/lib/ace/worker/worker.js", aceHome + "/lib/ace/worker/worker.js",
jsWorker jsWorker
], ],
filter: [ copy.filter.uglifyjs ],
dest: "build/src/worker-javascript.js" dest: "build/src/worker-javascript.js"
}); });
@ -215,7 +221,7 @@ copy({
root: aceHome + '/lib', root: aceHome + '/lib',
include: "ace/theme/eclipse.js" include: "ace/theme/eclipse.js"
}], }],
filter: [ copy.filter.moduleDefines, copy.filter.uglifyjs ], filter: [ copy.filter.moduleDefines ],
dest: eclipseTheme dest: eclipseTheme
}); });
copy({ copy({
@ -223,11 +229,12 @@ copy({
root: aceHome + '/lib', root: aceHome + '/lib',
include: "ace/theme/eclipse.css" include: "ace/theme/eclipse.css"
}], }],
filter: [ copy.filter.addDefines, copy.filter.uglifyjs ], filter: [ copy.filter.addDefines ],
dest: eclipseTheme dest: eclipseTheme
}); });
copy({ copy({
source: eclipseTheme, source: eclipseTheme,
filter: [ copy.filter.uglifyjs ],
dest: 'build/src/theme-eclipse.js' dest: 'build/src/theme-eclipse.js'
}); });
@ -246,14 +253,14 @@ copy({
}); });
// copy key bindings // copy key bindings
project.assumeAllFilesLoaded();
["vim", "emacs"].forEach(function(keybinding) { ["vim", "emacs"].forEach(function(keybinding) {
project.assmeAllFilesLoaded();
copy({ copy({
source: [ source: [
copy.source.commonjs({ copy.source.commonjs({
project: project, project: project.clone(),
require: [ 'ace/keyboard/keybinding/' + keybinding ] require: [ 'ace/keyboard/keybinding/' + keybinding ]
}), })
], ],
filter: [ copy.filter.moduleDefines, copy.filter.uglifyjs ], filter: [ copy.filter.moduleDefines, copy.filter.uglifyjs ],
dest: "build/src/keybinding-" + keybinding + ".js" dest: "build/src/keybinding-" + keybinding + ".js"
@ -270,6 +277,10 @@ copy({
source: aceHome + "/Readme.md", source: aceHome + "/Readme.md",
dest: 'build/Readme.md' dest: 'build/Readme.md'
}); });
copy({
source: aceHome + "/ChangeLog.txt",
dest: 'build/ChangeLog.txt'
});
// copy complex demo // copy complex demo
//copy({ //copy({
@ -309,4 +320,4 @@ copy({
//copy({ //copy({
// source: aceHome + '/demo/logo.png', // source: aceHome + '/demo/logo.png',
// dest: "build/demo/logo.png" // dest: "build/demo/logo.png"
//}); //});

22
build/ChangeLog.txt Normal file
View file

@ -0,0 +1,22 @@
2011.02.08, Version 0.1.5
* Add Coffeescript Mode (Satoshi Murakami)
* Fix word wrap bug (Julian Viereck)
* Fix packaged version of the Eclipse mode
* Loading of workers is more robust
* Fix "click selection"
* Allow tokizing empty lines (Daniel Krech)
* Make PageUp/Down behavior more consistent with native OS (Joe Cheng)
2011.02.04, Version 0.1.4
* Add C/C++ mode contributed by Gastón Kleiman
* Fix exception in key input
2011.02.04, Version 0.1.3
* Let the packaged version play nice with requireJS
* Add Ruby mode contributed by Shlomo Zalman Heigh
* Add Java mode contributed by Tom Tasche
* Fix annotation bug
* Changing a document added a new empty line at the end

View file

@ -22,7 +22,8 @@
<body> <body>
<pre id="editor">function foo(items) { <pre id="editor">function foo(items) {
for (var i = 0; i &lt; items.length; i++) { var i;
for (i = 0; i &lt; items.length; i++) {
alert("Ace Rocks " + items[i]); alert("Ace Rocks " + items[i]);
} }
}</pre> }</pre>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
define("ace/keyboard/keybinding/emacs",function(a,b,c){var d=a("ace/keyboard/state_handler").StateHandler,e=a("ace/keyboard/state_handler").matchCharacterOnly,f={start:[{key:"ctrl-x",then:"c-x"},{regex:["(?:command-([0-9]*))*","(down|ctrl-n)"],exec:"golinedown",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(right|ctrl-f)"],exec:"gotoright",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(up|ctrl-p)"],exec:"golineup",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(left|ctrl-b)"],exec:"gotoleft",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{comment:"This binding matches all printable characters except numbers as long as they are no numbers and print them n times.",regex:["(?:command-([0-9]*))","([^0-9]+)*"],match:e,exec:"inserttext",params:[{name:"times",match:1,type:"number",defaultValue:"1"},{name:"text",match:2}]},{comment:"This binding matches numbers as long as there is no meta_number in the buffer.",regex:["(command-[0-9]*)*","([0-9]+)"],match:e,disallowMatches:[1],exec:"inserttext",params:[{name:"text",match:2,type:"text"}]},{regex:["command-([0-9]*)","(command-[0-9]|[0-9])"],comment:"Stops execution if the regex /meta_[0-9]+/ matches to avoid resetting the buffer."}],"c-x":[{key:"ctrl-g",then:"start"},{key:"ctrl-s",exec:"save",then:"start"}]};b.Emacs=new d(f)}) define("ace/keyboard/keybinding/emacs",function(a,b,c){var d=a("ace/keyboard/state_handler").StateHandler,e=a("ace/keyboard/state_handler").matchCharacterOnly,f={start:[{key:"ctrl-x",then:"c-x"},{regex:["(?:command-([0-9]*))*","(down|ctrl-n)"],exec:"golinedown",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(right|ctrl-f)"],exec:"gotoright",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(up|ctrl-p)"],exec:"golineup",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(left|ctrl-b)"],exec:"gotoleft",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{comment:"This binding matches all printable characters except numbers as long as they are no numbers and print them n times.",regex:["(?:command-([0-9]*))","([^0-9]+)*"],match:e,exec:"inserttext",params:[{name:"times",match:1,type:"number",defaultValue:"1"},{name:"text",match:2}]},{comment:"This binding matches numbers as long as there is no meta_number in the buffer.",regex:["(command-[0-9]*)*","([0-9]+)"],match:e,disallowMatches:[1],exec:"inserttext",params:[{name:"text",match:2,type:"text"}]},{regex:["command-([0-9]*)","(command-[0-9]|[0-9])"],comment:"Stops execution if the regex /meta_[0-9]+/ matches to avoid resetting the buffer."}],"c-x":[{key:"ctrl-g",then:"start"},{key:"ctrl-s",exec:"save",then:"start"}]};b.Emacs=new d(f)}),define("ace/keyboard/state_handler",function(a,b,c){function e(a){this.keymapping=this.$buildKeymappingRegex(a)}var d=!1;e.prototype={$buildKeymappingRegex:function(a){for(state in a)this.$buildBindingsRegex(a[state]);return a},$buildBindingsRegex:function(a){a.forEach(function(a){a.key?a.key=new RegExp("^"+a.key+"$"):Array.isArray(a.regex)?(a.key=new RegExp("^"+a.regex[1]+"$"),a.regex=new RegExp(a.regex.join("")+"$")):a.regex&&(a.regex=new RegExp(a.regex+"$"))})},$composeBuffer:function(a,b,c){if(a.state==null||a.buffer==null)a.state="start",a.buffer="";var d=[];b&1&&d.push("ctrl"),b&8&&d.push("command"),b&2&&d.push("option"),b&4&&d.push("shift"),c&&d.push(c);var e=d.join("-"),f=a.buffer+e;b!=2&&(a.buffer=f);return{bufferToUse:f,symbolicName:e}},$find:function(a,b,c,e,f){var g={};this.keymapping[a.state].some(function(h){var i;if(h.key&&!h.key.test(c))return!1;if(h.regex&&!(i=h.regex.exec(b)))return!1;if(h.match&&!h.match(b,e,f,c))return!1;if(h.disallowMatches)for(var j=0;j<h.disallowMatches.length;j++)if(!!i[h.disallowMatches[j]])return!1;if(h.exec){g.command=h.exec;if(h.params){var k;g.args={},h.params.forEach(function(a){a.match!=null&&i!=null?k=i[a.match]||a.defaultValue:k=a.defaultValue,a.type==="number"&&(k=parseInt(k)),g.args[a.name]=k})}a.buffer=""}h.then&&(a.state=h.then,a.buffer=""),g.command==null&&(g.command="null"),d&&console.log("KeyboardStateMapper#find",h);return!0});if(g.command)return g;a.buffer="";return!1},handleKeyboard:function(a,b,c){if(b!=0&&(c==""||c==String.fromCharCode(0)))return null;var e=this.$composeBuffer(a,b,c),f=e.bufferToUse,g=e.symbolicName;e=this.$find(a,f,g,b,c),d&&console.log("KeyboardStateMapper#match",f,g,e);return e}},b.matchCharacterOnly=function(a,b,c,d){return b==0?!0:b==4&&c.length==1?!0:!1},b.StateHandler=e})

1
build/src/mode-c_cpp.js Normal file
View file

@ -0,0 +1 @@
define("ace/mode/c_cpp",function(a,b,c){var d=a("pilot/oop"),e=a("ace/mode/text").Mode,f=a("ace/tokenizer").Tokenizer,g=a("ace/mode/c_cpp_highlight_rules").c_cppHighlightRules,h=a("ace/mode/matching_brace_outdent").MatchingBraceOutdent,i=a("ace/range").Range,j=function(){this.$tokenizer=new f((new g).getRules()),this.$outdent=new h};d.inherits(j,e),function(){this.toggleCommentLines=function(a,b,c,d){var e=!0,f=[],g=/^(\s*)\/\//;for(var h=c;h<=d;h++)if(!g.test(b.getLine(h))){e=!1;break}if(e){var j=new i(0,0,0,0);for(var h=c;h<=d;h++){var k=b.getLine(h).replace(g,"$1");j.start.row=h,j.end.row=h,j.end.column=k.length+2,b.replace(j,k)}return-2}return b.indentRows(c,d,"//")},this.getNextLineIndent=function(a,b,c){var d=this.$getIndent(b),e=this.$tokenizer.getLineTokens(b,a),f=e.tokens,g=e.state;if(f.length&&f[f.length-1].type=="comment")return d;if(a=="start"){var h=b.match(/^.*[\{\(\[]\s*$/);h&&(d+=c)}else if(a=="doc-start"){if(g=="start")return"";var h=b.match(/^\s*(\/?)\*/);h&&(h[1]&&(d+=" "),d+="* ")}return d},this.checkOutdent=function(a,b,c){return this.$outdent.checkOutdent(b,c)},this.autoOutdent=function(a,b,c){return this.$outdent.autoOutdent(b,c)}}.call(j.prototype),b.Mode=j}),define("ace/mode/c_cpp_highlight_rules",function(a,b,c){var d=a("pilot/oop"),e=a("pilot/lang"),f=a("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules,g=a("ace/mode/text_highlight_rules").TextHighlightRules;c_cppHighlightRules=function(){var a=new f,b=e.arrayToMap("and|double|not_eq|throw|and_eq|dynamic_cast|operator|true|asm|else|or|try|auto|enum|or_eq|typedef|bitand|explicit|private|typeid|bitor|extern|protected|typename|bool|false|public|union|break|float|register|unsigned|case|fro|reinterpret-cast|using|catch|friend|return|virtual|char|goto|short|void|class|if|signed|volatile|compl|inline|sizeof|wchar_t|const|int|static|while|const-cast|long|static_cast|xor|continue|mutable|struct|xor_eq|default|namespace|switch|delete|new|template|do|not|this|for".split("|")),c=e.arrayToMap("NULL".split("|"));this.$rules={start:[{token:"comment",regex:"\\/\\/.*$"},a.getStartRule("doc-start"),{token:"comment",regex:"\\/\\*",next:"comment"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",regex:'["].*\\\\$',next:"qqstring"},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"string",regex:"['].*\\\\$",next:"qstring"},{token:"constant.numeric",regex:"0[xX][0-9a-fA-F]+\\b"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:"constant",regex:"<[a-zA-Z0-9.]+>"},{token:"keyword",regex:"(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"},{token:function(a){return a=="this"?"variable.language":b.hasOwnProperty(a)?"keyword":c.hasOwnProperty(a)?"constant.language":"identifier"},regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"},{token:"lparen",regex:"[[({]"},{token:"rparen",regex:"[\\])}]"},{token:"text",regex:"\\s+"}],comment:[{token:"comment",regex:".*?\\*\\/",next:"start"},{token:"comment",regex:".+"}],qqstring:[{token:"string",regex:'(?:(?:\\\\.)|(?:[^"\\\\]))*?"',next:"start"},{token:"string",regex:".+"}],qstring:[{token:"string",regex:"(?:(?:\\\\.)|(?:[^'\\\\]))*?'",next:"start"},{token:"string",regex:".+"}]},this.addRules(a.getRules(),"doc-"),this.$rules["doc-start"][0].next="start"},d.inherits(c_cppHighlightRules,g),b.c_cppHighlightRules=c_cppHighlightRules}),define("ace/mode/doc_comment_highlight_rules",function(a,b,c){var d=a("pilot/oop"),e=a("ace/mode/text_highlight_rules").TextHighlightRules,f=function(){this.$rules={start:[{token:"comment.doc",regex:"\\*\\/",next:"start"},{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},{token:"comment.doc",regex:"s+"},{token:"comment.doc",regex:"TODO"},{token:"comment.doc",regex:"[^@\\*]+"},{token:"comment.doc",regex:"."}]}};d.inherits(f,e),function(){this.getStartRule=function(a){return{token:"comment.doc",regex:"\\/\\*(?=\\*)",next:a}}}.call(f.prototype),b.DocCommentHighlightRules=f})

1
build/src/mode-coffee.js Normal file
View file

@ -0,0 +1 @@
define("ace/mode/coffee",function(a,b,c){function h(){this.$tokenizer=new d((new e).getRules()),this.$outdent=new f}var d=a("ace/tokenizer").Tokenizer,e=a("ace/mode/coffee_highlight_rules").CoffeeHighlightRules,f=a("ace/mode/matching_brace_outdent").MatchingBraceOutdent,g=a("ace/range").Range;a("pilot/oop").inherits(h,a("ace/mode/text").Mode);var i=h.prototype,j=/(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/,k=/^(\s*)#/,l=/^\s*###(?!#)/,m=/^\s*/;i.getNextLineIndent=function(a,b,c){var d=this.$getIndent(b),e=this.$tokenizer.getLineTokens(b,a).tokens;(!e.length||e[e.length-1].type!=="comment")&&a==="start"&&j.test(b)&&(d+=c);return d},i.toggleCommentLines=function(a,b,c,d){var e,f=new g(0,0,0,0);for(var h=c;h<=d;++h){var i=b.getLine(h);if(l.test(i))continue;i=(e=k.test(i))?i.replace(k,"$1"):i.replace(m,"$&#"),f.end.row=f.start.row=h,f.end.column=i.length+1,b.replace(f,i)}return 1-e*2},i.checkOutdent=function(a,b,c){return this.$outdent.checkOutdent(b,c)},i.autoOutdent=function(a,b,c){return this.$outdent.autoOutdent(b,c)},b.Mode=h}),define("ace/mode/coffee_highlight_rules",function(a,b,c){function d(){var a="[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*",b="(?![$\\w]|\\s*:)",c={token:"string",regex:".+"};this.$rules={start:[{token:"identifier",regex:"(?:@|(?:\\.|::)\\s*)"+a},{token:"keyword",regex:"(?:t(?:h(?:is|row|en)|ry|ypeof)|s(?:uper|witch)|return|b(?:reak|y)|c(?:ontinue|atch|lass)|i(?:n(?:stanceof)?|s(?:nt)?|f)|e(?:lse|xtends)|f(?:or (?:own)?|inally|unction)|wh(?:ile|en)|n(?:ew|ot?)|d(?:e(?:lete|bugger)|o)|loop|o(?:ff?|[rn])|un(?:less|til)|and|yes)"+b},{token:"constant.language",regex:"(?:true|false|null|undefined)"+b},{token:"invalid.illegal",regex:"(?:c(?:ase|onst)|default|function|v(?:ar|oid)|with|e(?:num|xport)|i(?:mplements|nterface)|let|p(?:ackage|r(?:ivate|otected)|ublic)|static|yield|__(?:hasProp|extends|slice|bind|indexOf))"+b},{token:"language.support.class",regex:"(?:Array|Boolean|Date|Function|Number|Object|R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|TypeError|URIError)"+b},{token:"language.support.function",regex:"(?:Math|JSON|is(?:NaN|Finite)|parse(?:Int|Float)|encodeURI(?:Component)?|decodeURI(?:Component)?)"+b},{token:"identifier",regex:a},{token:"constant.numeric",regex:"(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"},{token:"string",regex:"'''",next:"qdoc"},{token:"string",regex:'"""',next:"qqdoc"},{token:"string",regex:"'",next:"qstring"},{token:"string",regex:'"',next:"qqstring"},{token:"string",regex:"`",next:"js"},{token:"string.regex",regex:"///",next:"heregex"},{token:"string.regex",regex:"/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)"},{token:"comment",regex:"###(?!#)",next:"comment"},{token:"comment",regex:"#.*"},{token:"lparen",regex:"[({[]"},{token:"rparen",regex:"[\\]})]"},{token:"keyword.operator",regex:"\\S+"},{token:"text",regex:"\\s+"}],qdoc:[{token:"string",regex:".*?'''",next:"start"},c],qqdoc:[{token:"string",regex:'.*?"""',next:"start"},c],qstring:[{token:"string",regex:"[^\\\\']*(?:\\\\.[^\\\\']*)*'",next:"start"},c],qqstring:[{token:"string",regex:'[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',next:"start"},c],js:[{token:"string",regex:"[^\\\\`]*(?:\\\\.[^\\\\`]*)*`",next:"start"},c],heregex:[{token:"string.regex",regex:".*?///[imgy]{0,4}",next:"start"},{token:"comment.regex",regex:"\\s+(?:#.*)?"},{token:"string.regex",regex:"\\S+"}],comment:[{token:"comment",regex:".*?###",next:"start"},{token:"comment",regex:".+"}]}}a("pilot/oop").inherits(d,a("ace/mode/text_highlight_rules").TextHighlightRules),b.CoffeeHighlightRules=d})

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
build/src/mode-java.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
build/src/mode-ruby.js Normal file
View file

@ -0,0 +1 @@
define("ace/mode/ruby",function(a,b,c){var d=a("pilot/oop"),e=a("ace/mode/text").Mode,f=a("ace/tokenizer").Tokenizer,g=a("ace/mode/ruby_highlight_rules").RubyHighlightRules,h=a("ace/mode/matching_brace_outdent").MatchingBraceOutdent,i=a("ace/range").Range,j=function(){this.$tokenizer=new f((new g).getRules()),this.$outdent=new h};d.inherits(j,e),function(){this.toggleCommentLines=function(a,b,c,d){var e=!0,f=[],g=/^(\s*)#/;for(var h=c;h<=d;h++)if(!g.test(b.getLine(h))){e=!1;break}if(e){var j=new i(0,0,0,0);for(var h=c;h<=d;h++){var k=b.getLine(h).replace(g,"$1");j.start.row=h,j.end.row=h,j.end.column=k.length+2,b.replace(j,k)}return-2}return b.indentRows(c,d,"#")},this.getNextLineIndent=function(a,b,c){var d=this.$getIndent(b),e=this.$tokenizer.getLineTokens(b,a),f=e.tokens,g=e.state;if(f.length&&f[f.length-1].type=="comment")return d;if(a=="start"){var h=b.match(/^.*[\{\(\[]\s*$/);h&&(d+=c)}return d},this.checkOutdent=function(a,b,c){return this.$outdent.checkOutdent(b,c)},this.autoOutdent=function(a,b,c){return this.$outdent.autoOutdent(b,c)}}.call(j.prototype),b.Mode=j}),define("ace/mode/ruby_highlight_rules",function(a,b,c){var d=a("pilot/oop"),e=a("pilot/lang"),f=a("ace/mode/text_highlight_rules").TextHighlightRules;RubyHighlightRules=function(){var a=e.arrayToMap("abort|Array|at_exit|autoload|binding|block_given?|callcc|caller|catch|chomp|chomp!|chop|chop!|eval|exec|exit|exit!fail|Float|fork|format|gets|global_variables|gsub|gsub!|Integer|lambda|load|local_variables|loop|open|p|print|printf|proc|putc|puts|raise|rand|readline|readlines|require|scan|select|set_trace_func|sleep|split|sprintf|srand|String|syscall|system|sub|sub!|test|throw|trace_var|trap|untrace_var|atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan".split("|")),b=e.arrayToMap("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|__FILE__|finally|for|if|in|__LINE__|module|next|not|or|redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield".split("|")),c=e.arrayToMap("true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING".split("|")),d=e.arrayToMap("$DEBUG|$defout|$FILENAME|$LOAD_PATH|$SAFE|$stdin|$stdout|$stderr|$VERBOSE".split("|"));this.$rules={start:[{token:"comment",regex:"#.*$"},{token:"comment",regex:"^=begin$",next:"comment"},{token:"string.regexp",regex:"[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"constant.numeric",regex:"0[xX][0-9a-fA-F]+\\b"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:"constant.language.boolean",regex:"(?:true|false)\\b"},{token:function(e){return e=="self"?"variable.language":b.hasOwnProperty(e)?"keyword":c.hasOwnProperty(e)?"constant.language":d.hasOwnProperty(e)?"variable.language":a.hasOwnProperty(e)?"support.function":e=="debugger"?"invalid.deprecated":"identifier"},regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"},{token:"lparen",regex:"[[({]"},{token:"rparen",regex:"[\\])}]"},{token:"text",regex:"\\s+"}],comment:[{token:"comment",regex:"^=end$",next:"start"},{token:"comment",regex:".+"}]}},d.inherits(RubyHighlightRules,f),b.RubyHighlightRules=RubyHighlightRules})

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
define("ace/theme/eclipse",function(a,b,c){var d=a("pilot/dom"),e=a("text!ace/theme/eclipse.css");d.importCssString(e),b.cssClass="ace-eclipse"})define("text!ace/theme/eclipse.css",".ace-eclipse .ace_editor { border: 2px solid rgb(159, 159, 159);}.ace-eclipse .ace_editor.ace_focus { border: 2px solid #327fbd;}.ace-eclipse .ace_gutter { width: 40px; background: rgb(227, 227, 227); border-right: 1px solid rgb(159, 159, 159);\t color: rgb(136, 136, 136);}.ace-eclipse .ace_gutter-layer { right: 10px; text-align: right;}.ace-eclipse .ace_text-layer { cursor: text;}.ace-eclipse .ace_cursor { border-left: 1px solid black;}.ace-eclipse .ace_line .ace_keyword, .ace-eclipse .ace_line .ace_variable { color: rgb(127, 0, 85);}.ace-eclipse .ace_line .ace_constant.ace_buildin { color: rgb(88, 72, 246);}.ace-eclipse .ace_line .ace_constant.ace_library { color: rgb(6, 150, 14);}.ace-eclipse .ace_line .ace_function { color: rgb(60, 76, 114);}.ace-eclipse .ace_line .ace_string { color: rgb(42, 0, 255);}.ace-eclipse .ace_line .ace_comment { color: rgb(63, 127, 95);}.ace-eclipse .ace_line .ace_comment.ace_doc { color: rgb(63, 95, 191);}.ace-eclipse .ace_line .ace_comment.ace_doc.ace_tag { color: rgb(127, 159, 191);}.ace-eclipse .ace_line .ace_constant.ace_numeric {}.ace-eclipse .ace_line .ace_tag {\tcolor: rgb(63, 127, 127);}.ace-eclipse .ace_line .ace_xml_pe { color: rgb(104, 104, 91);}.ace-eclipse .ace_marker-layer .ace_selection { background: rgb(181, 213, 255);}.ace-eclipse .ace_marker-layer .ace_bracket { margin: -1px 0 0 -1px; border: 1px solid rgb(192, 192, 192);}.ace-eclipse .ace_marker-layer .ace_active_line { background: rgb(232, 242, 254);}") define("ace/theme/eclipse",function(a,b,c){var d=a("pilot/dom"),e=a("text!ace/theme/eclipse.css");d.importCssString(e),b.cssClass="ace-eclipse"}),define("text!ace/theme/eclipse.css",".ace-eclipse .ace_editor { border: 2px solid rgb(159, 159, 159);}.ace-eclipse .ace_editor.ace_focus { border: 2px solid #327fbd;}.ace-eclipse .ace_gutter { width: 40px; background: rgb(227, 227, 227); border-right: 1px solid rgb(159, 159, 159);\t color: rgb(136, 136, 136);}.ace-eclipse .ace_gutter-layer { right: 10px; text-align: right;}.ace-eclipse .ace_text-layer { cursor: text;}.ace-eclipse .ace_cursor { border-left: 1px solid black;}.ace-eclipse .ace_line .ace_keyword, .ace-eclipse .ace_line .ace_variable { color: rgb(127, 0, 85);}.ace-eclipse .ace_line .ace_constant.ace_buildin { color: rgb(88, 72, 246);}.ace-eclipse .ace_line .ace_constant.ace_library { color: rgb(6, 150, 14);}.ace-eclipse .ace_line .ace_function { color: rgb(60, 76, 114);}.ace-eclipse .ace_line .ace_string { color: rgb(42, 0, 255);}.ace-eclipse .ace_line .ace_comment { color: rgb(63, 127, 95);}.ace-eclipse .ace_line .ace_comment.ace_doc { color: rgb(63, 95, 191);}.ace-eclipse .ace_line .ace_comment.ace_doc.ace_tag { color: rgb(127, 159, 191);}.ace-eclipse .ace_line .ace_constant.ace_numeric {}.ace-eclipse .ace_line .ace_tag {\tcolor: rgb(63, 127, 127);}.ace-eclipse .ace_line .ace_xml_pe { color: rgb(104, 104, 91);}.ace-eclipse .ace_marker-layer .ace_selection { background: rgb(181, 213, 255);}.ace-eclipse .ace_marker-layer .ace_bracket { margin: -1px 0 0 -1px; border: 1px solid rgb(192, 192, 192);}.ace-eclipse .ace_marker-layer .ace_active_line { background: rgb(232, 242, 254);}")

File diff suppressed because one or more lines are too long

View file

@ -22,12 +22,13 @@
<body> <body>
<pre id="editor">function foo(items) { <pre id="editor">function foo(items) {
for (var i = 0; i &lt; items.length; i++) { var i;
for (i = 0; i &lt; items.length; i++) {
alert("Ace Rocks " + items[i]); alert("Ace Rocks " + items[i]);
} }
}</pre> }</pre>
<script src="src/ace-uncompressed.js" type="text/javascript" charset="utf-8"></script> <script src="src/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script> <script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script>
<script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script> <script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
<script> <script>

View file

@ -40,10 +40,17 @@
* @param module a name for the payload * @param module a name for the payload
* @param payload a function to call with (require, exports, module) params * @param payload a function to call with (require, exports, module) params
*/ */
function define(module, payload) {
(function() {
var _define = function(module, payload) {
if (typeof module !== 'string') { if (typeof module !== 'string') {
console.error('dropping module because define wasn\'t a string.'); if (_define.original)
console.trace(); _define.original.apply(window, arguments);
else {
console.error('dropping module because define wasn\'t a string.');
console.trace();
}
return; return;
} }
@ -51,16 +58,24 @@ function define(module, payload) {
define.modules = {}; define.modules = {};
define.modules[module] = payload; define.modules[module] = payload;
} };
if (window.define)
_define.original = window.define;
window.define = _define;
/** /**
* Get at functionality define()ed using the function above * Get at functionality define()ed using the function above
*/ */
function require(module, callback) { var _require = function(module, callback) {
if (Object.prototype.toString.call(module) === "[object Array]") { if (Object.prototype.toString.call(module) === "[object Array]") {
var params = []; var params = [];
for (var i = 0, l = module.length; i < l; ++i) { for (var i = 0, l = module.length; i < l; ++i) {
params.push(define.lookup(module[i])); var dep = lookup(module[i]);
if (!dep && _require.original)
return _require.original.apply(window, arguments);
params.push(dep);
}; };
if (callback) { if (callback) {
callback.apply(null, params); callback.apply(null, params);
@ -68,7 +83,10 @@ function require(module, callback) {
} }
if (typeof module === 'string') { if (typeof module === 'string') {
var payload = define.lookup(module); var payload = lookup(module);
if (!payload && _require.original)
return _require.original.apply(window, arguments);
if (callback) { if (callback) {
callback(); callback();
} }
@ -77,13 +95,17 @@ function require(module, callback) {
}; };
} }
if (window.require)
_require.original = window.require;
window.require = _require;
require.packaged = true; require.packaged = true;
/** /**
* Internal function to lookup moduleNames and resolve them by calling the * Internal function to lookup moduleNames and resolve them by calling the
* definition function if needed. * definition function if needed.
*/ */
define.lookup = function(moduleName) { var lookup = function(moduleName) {
var module = define.modules[moduleName]; var module = define.modules[moduleName];
if (module == null) { if (module == null) {
console.error('Missing module: ' + moduleName); console.error('Missing module: ' + moduleName);
@ -100,3 +122,5 @@ define.lookup = function(moduleName) {
return module; return module;
}; };
})();

View file

@ -46,12 +46,17 @@ exports.launch = function(env) {
var Renderer = require("ace/virtual_renderer").VirtualRenderer; var Renderer = require("ace/virtual_renderer").VirtualRenderer;
var theme = require("ace/theme/textmate"); var theme = require("ace/theme/textmate");
var EditSession = require("ace/edit_session").EditSession; var EditSession = require("ace/edit_session").EditSession;
var JavaScriptMode = require("ace/mode/javascript").Mode; var JavaScriptMode = require("ace/mode/javascript").Mode;
var CssMode = require("ace/mode/css").Mode; var CssMode = require("ace/mode/css").Mode;
var HtmlMode = require("ace/mode/html").Mode; var HtmlMode = require("ace/mode/html").Mode;
var XmlMode = require("ace/mode/xml").Mode; var XmlMode = require("ace/mode/xml").Mode;
var PythonMode = require("ace/mode/python").Mode; var PythonMode = require("ace/mode/python").Mode;
var PhpMode = require("ace/mode/php").Mode; var PhpMode = require("ace/mode/php").Mode;
var JavaMode = require("ace/mode/java").Mode;
var RubyMode = require("ace/mode/ruby").Mode;
var CCPPMode = require("ace/mode/c_cpp").Mode;
var CoffeeMode = require("ace/mode/coffee").Mode;
var TextMode = require("ace/mode/text").Mode; var TextMode = require("ace/mode/text").Mode;
var UndoManager = require("ace/undomanager").UndoManager; var UndoManager = require("ace/undomanager").UndoManager;
@ -102,6 +107,21 @@ exports.launch = function(env) {
docs.php.setMode(new PhpMode()); docs.php.setMode(new PhpMode());
docs.php.setUndoManager(new UndoManager()); docs.php.setUndoManager(new UndoManager());
docs.java = new EditSession(document.getElementById("javatext").innerHTML);
docs.java.setMode(new JavaMode());
docs.java.setUndoManager(new UndoManager());
docs.ruby = new EditSession(document.getElementById("rubytext").innerHTML);
docs.ruby.setMode(new RubyMode());
docs.ruby.setUndoManager(new UndoManager());
docs.c_cpp = new EditSession(document.getElementById("cpptext").innerHTML);
docs.c_cpp.setMode(new CCPPMode());
docs.c_cpp.setUndoManager(new UndoManager());
docs.coffee = new EditSession(document.getElementById("coffeetext").innerHTML);
docs.coffee.setMode(new CoffeeMode());
docs.coffee.setUndoManager(new UndoManager());
var container = document.getElementById("editor"); var container = document.getElementById("editor");
env.editor = new Editor(new Renderer(container, theme)); env.editor = new Editor(new Renderer(container, theme));
@ -113,7 +133,11 @@ exports.launch = function(env) {
css: new CssMode(), css: new CssMode(),
javascript: new JavaScriptMode(), javascript: new JavaScriptMode(),
python: new PythonMode(), python: new PythonMode(),
php: new PhpMode() php: new PhpMode(),
java: new JavaMode(),
ruby: new RubyMode(),
c_cpp: new CCPPMode(),
coffee: new CoffeeMode()
}; };
function getMode() { function getMode() {
@ -146,6 +170,18 @@ exports.launch = function(env) {
else if (mode instanceof PhpMode) { else if (mode instanceof PhpMode) {
modeEl.value = "php"; modeEl.value = "php";
} }
else if (mode instanceof JavaMode) {
modeEl.value = "java";
}
else if (mode instanceof RubyMode) {
modeEl.value = "ruby";
}
else if (mode instanceof CCPPMode) {
modeEl.value = "c_cpp";
}
else if (mode instanceof CoffeeMode) {
modeEl.value = "coffee";
}
else { else {
modeEl.value = "text"; modeEl.value = "text";
} }
@ -271,6 +307,14 @@ exports.launch = function(env) {
mode = "python"; mode = "python";
} else if (/^.*\.php$/i.test(file.name)) { } else if (/^.*\.php$/i.test(file.name)) {
mode = "php"; mode = "php";
} else if (/^.*\.java$/i.test(file.name)) {
mode = "java";
} else if (/^.*\.rb$/i.test(file.name)) {
mode = "ruby";
} else if (/^.*\.(c|cpp|h|hpp|cxx)$/i.test(file.name)) {
mode = "c_cpp";
} else if (/^.*\.coffee$/i.test(file.name)) {
mode = "coffee";
} }
env.editor.onTextInput(reader.result); env.editor.onTextInput(reader.result);

View file

@ -19,6 +19,10 @@
<option value="css">CSS Document</option> <option value="css">CSS Document</option>
<option value="python">Python Document</option> <option value="python">Python Document</option>
<option value="php">PHP Document</option> <option value="php">PHP Document</option>
<option value="java">Java Document</option>
<option value="ruby">Ruby Document</option>
<option value="c_cpp">C++ Document</option>
<option value="coffee">CoffeeScript Document</option>
<option value="plain">Text Document</option> <option value="plain">Text Document</option>
</select> </select>
</td> </td>
@ -72,6 +76,10 @@
<option value="css">CSS</option> <option value="css">CSS</option>
<option value="python">Python</option> <option value="python">Python</option>
<option value="php">PHP</option> <option value="php">PHP</option>
<option value="java">Java</option>
<option value="ruby">Ruby</option>
<option value="c_cpp">C/C++</option>
<option value="coffee">CoffeeScript</option>
</select> </select>
</td> </td>
<td align="right"> <td align="right">
@ -136,6 +144,22 @@
</body> </body>
</html></script> </html></script>
<script type="text/editor" id="javatext">public class InfiniteLoop {
/*
* This will cause the program to hang...
*
* Taken from:
* http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
*/
public static void main(String[] args) {
double d = Double.parseDouble("2.2250738585072012e-308");
// unreachable code
System.out.println("Value: " + d);
}
}</script>
<script type="text/editor" id="pythontext">#!/usr/local/bin/python <script type="text/editor" id="pythontext">#!/usr/local/bin/python
import string, sys import string, sys
@ -176,7 +200,7 @@ echo $output;
?></script> ?></script>
<script type="text/editor" id="plaintext">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. <script type="text/editor" id="plaintext">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
@ -188,9 +212,62 @@ Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie co
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
</script> </script>
<script type="text/editor" id="rubytext">#!/usr/bin/ruby
# Program to find the factorial of a number
def fact(n)
if n == 0
1
else
n * fact(n-1)
end
end
puts fact(ARGV[0].to_i)
</script>
<script type="text/editor" id="cpptext">// compound assignment operators
#include <iostream>
using namespace std;
int main ()
{
int a, b=3; /* foobar */
a = b;
a+=2; // equivalent to a=a+2
cout << a;
return 0;
}
</script>
<script type="text/editor" id="coffeetext">#!/usr/bin/env coffee
try
throw URIError decodeURI(0xC0ffee * 123456.7e-8 / .9)
catch e
console.log 'qstring' + "qqstring" + '''
qdoc
''' + """
qqdoc
"""
do ->
###
herecomment
###
re = /regex/imgy.test ///
heregex # comment
///imgy
this isnt: `just JavaScript`
undefined
var illegal</script>
<input id="cockpitInput" type="text"/> <input id="cockpitInput" type="text"/>
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script> <script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
<script src="demo/boot.js" type="text/javascript"></script> <script src="demo/boot.js" type="text/javascript"></script>
</body> </body>
</html> </html>

View file

@ -46,6 +46,11 @@ var Document = function(text) {
if (Array.isArray(text)) { if (Array.isArray(text)) {
this.insertLines(0, text); this.insertLines(0, text);
}
// There has to be one line at least in the document. If you pass an empty
// string to the insert function, nothing will happen. Workaround.
else if (text.length == 0) {
this.$lines = [""];
} else { } else {
this.insert({row: 0, column:0}, text); this.insert({row: 0, column:0}, text);
} }
@ -57,7 +62,7 @@ var Document = function(text) {
this.setValue = function(text) { this.setValue = function(text) {
var len = this.getLength(); var len = this.getLength();
this.remove(new Range(0, 0, len, this.getLine(len-1).length)); this.remove(new Range(0, 0, len, this.getLine(len-1).length));
this.insert({row: 0, column:0}, text); this.insert({row: 0, column:0}, text);
}; };
@ -262,16 +267,16 @@ var Document = function(text) {
var firstRow = range.start.row; var firstRow = range.start.row;
var lastRow = range.end.row; var lastRow = range.end.row;
if (range.isMultiLine()) { if (range.isMultiLine()) {
var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1; var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
var lastFullRow = lastRow - 1; var lastFullRow = lastRow - 1;
if (range.end.column > 0) if (range.end.column > 0)
this.removeInLine(lastRow, 0, range.end.column); this.removeInLine(lastRow, 0, range.end.column);
if (lastFullRow >= firstFullRow) if (lastFullRow >= firstFullRow)
this.removeLines(firstFullRow, lastFullRow); this.removeLines(firstFullRow, lastFullRow);
if (firstFullRow != firstRow) { if (firstFullRow != firstRow) {
this.removeInLine(firstRow, range.start.column, this.$lines[firstRow].length); this.removeInLine(firstRow, range.start.column, this.$lines[firstRow].length);
this.removeNewLine(range.start.row); this.removeNewLine(range.start.row);

View file

@ -214,7 +214,7 @@ var EditSession = function(text, mode) {
* } * }
*/ */
this.setAnnotations = function(annotations) { this.setAnnotations = function(annotations) {
this.$annotations = []; this.$annotations = {};
for (var i=0; i<annotations.length; i++) { for (var i=0; i<annotations.length; i++) {
var annotation = annotations[i]; var annotation = annotations[i];
var row = annotation.row; var row = annotation.row;
@ -231,7 +231,7 @@ var EditSession = function(text, mode) {
}; };
this.clearAnnotations = function() { this.clearAnnotations = function() {
this.$annotations = []; this.$annotations = {};
this._dispatchEvent("changeAnnotation", {}); this._dispatchEvent("changeAnnotation", {});
}; };
@ -295,7 +295,7 @@ var EditSession = function(text, mode) {
if (window.Worker) if (window.Worker)
this.$worker = mode.createWorker(this); this.$worker = mode.createWorker(this);
else else
this.$worker = null; this.$worker = null;
this.$mode = mode; this.$mode = mode;
@ -646,8 +646,18 @@ var EditSession = function(text, mode) {
this.setUseWrapMode = function(useWrapMode) { this.setUseWrapMode = function(useWrapMode) {
if (useWrapMode != this.$useWrapMode) { if (useWrapMode != this.$useWrapMode) {
this.$useWrapMode = useWrapMode; this.$useWrapMode = useWrapMode;
this.$updateWrapData(0, this.getLength() - 1);
this.$modified = true; this.$modified = true;
// If wrapMode is activaed, the wrapData array has to be initialized.
if (useWrapMode) {
var len = this.getLength();
this.$wrapMode = [];
for (i = 0; i < len; i++) {
this.$wrapData.push([]);
}
this.$updateWrapData(0, len - 1);
}
this._dispatchEvent("changeWrapMode"); this._dispatchEvent("changeWrapMode");
} }
}; };
@ -659,7 +669,10 @@ var EditSession = function(text, mode) {
this.setWrapLimit = function(wrapLimit) { this.setWrapLimit = function(wrapLimit) {
if (wrapLimit != this.$wrapLimit) { if (wrapLimit != this.$wrapLimit) {
this.$wrapLimit = wrapLimit; this.$wrapLimit = wrapLimit;
this.$updateWrapData(0, this.getLength() - 1); this.$modified = true;
if (this.$useWrapMode) {
this.$updateWrapData(0, this.getLength() - 1);
}
this._dispatchEvent("changeWrapMode"); this._dispatchEvent("changeWrapMode");
} }
}; };
@ -673,20 +686,23 @@ var EditSession = function(text, mode) {
return; return;
} }
var len;
var action = e.data.action; var action = e.data.action;
var firstRow = e.data.range.start.row, var firstRow = e.data.range.start.row,
lastRow = e.data.range.end.row; lastRow = e.data.range.end.row;
if (action.indexOf("Lines") != -1) { if (action.indexOf("Lines") != -1) {
if (action == "insertLines") { if (action == "insertLines") {
lastRow = firstRow + e.data.lines.length; lastRow = firstRow + (e.data.lines.length);
} else { } else {
firstRow = lastRow - e.data.lines.length; lastRow = firstRow;
} }
len = e.data.lines.length;
} else {
len = lastRow - firstRow;
} }
if (firstRow != lastRow) { if (len != 0) {
var len = lastRow - firstRow;
if (action.indexOf("remove") != -1) { if (action.indexOf("remove") != -1) {
this.$wrapData.splice(firstRow, len); this.$wrapData.splice(firstRow, len);
lastRow = firstRow; lastRow = firstRow;
@ -697,6 +713,10 @@ var EditSession = function(text, mode) {
} }
} }
if (this.$wrapData.length != this.doc.$lines.length) {
console.error("The length of doc.$lines and $wrapData have to be the same!");
}
this.$updateWrapData(firstRow, lastRow); this.$updateWrapData(firstRow, lastRow);
}; };
@ -706,9 +726,6 @@ var EditSession = function(text, mode) {
var wrapData = this.$wrapData; var wrapData = this.$wrapData;
var wrapLimit = this.$wrapLimit; var wrapLimit = this.$wrapLimit;
// Remove lines that are no longer there.
wrapData.splice(lines.length, wrapData.length - lines.length);
for (var row = firstRow; row <= lastRow; row++) { for (var row = firstRow; row <= lastRow; row++) {
wrapData[row] = wrapData[row] =
this.$computeWrapSplits(lines[row], wrapLimit, tabSize); this.$computeWrapSplits(lines[row], wrapLimit, tabSize);
@ -856,7 +873,7 @@ var EditSession = function(text, mode) {
this.getRowHeight = function(config, row) { this.getRowHeight = function(config, row) {
var rows; var rows;
if (!this.$useWrapMode) { if (!this.$useWrapMode || !this.$wrapData[row]) {
rows = 1; rows = 1;
} else { } else {
rows = this.$wrapData[row].length + 1; rows = this.$wrapData[row].length + 1;
@ -1055,7 +1072,7 @@ var EditSession = function(text, mode) {
if (docRow > wrapData.length - 1) { if (docRow > wrapData.length - 1) {
return [ return [
this.getScreenLength(), this.getScreenLength(),
wrapData[wrapData.length - 1].length - 1 wrapData.length == 0 ? 0 : (wrapData[wrapData.length - 1].length - 1)
]; ];
} }

View file

@ -149,7 +149,7 @@ var Editor =function(renderer, session) {
this.$onDocumentChangeTabSize = this.renderer.updateText.bind(this.renderer); this.$onDocumentChangeTabSize = this.renderer.updateText.bind(this.renderer);
session.addEventListener("changeTabSize", this.$onDocumentChangeTabSize); session.addEventListener("changeTabSize", this.$onDocumentChangeTabSize);
this.$onDocumentChangeWrapMode = this.renderer.updateFull.bind(this.renderer); this.$onDocumentChangeWrapMode = this.onDocumentChangeWrapMode.bind(this);
session.addEventListener("changeWrapMode", this.$onDocumentChangeWrapMode); session.addEventListener("changeWrapMode", this.$onDocumentChangeWrapMode);
this.$onDocumentChangeBreakpoint = this.onDocumentChangeBreakpoint.bind(this); this.$onDocumentChangeBreakpoint = this.onDocumentChangeBreakpoint.bind(this);
@ -348,6 +348,11 @@ var Editor =function(renderer, session) {
this.renderer.setTokenizer(this.bgTokenizer); this.renderer.setTokenizer(this.bgTokenizer);
}; };
this.onDocumentChangeWrapMode = function() {
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
this.renderer.updateFull();
};
this.getCopyText = function() { this.getCopyText = function() {
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
return this.session.getTextRange(this.getSelectionRange()); return this.session.getTextRange(this.getSelectionRange());
@ -818,12 +823,14 @@ var Editor =function(renderer, session) {
this.navigateUp = function(times) { this.navigateUp = function(times) {
this.selection.clearSelection(); this.selection.clearSelection();
this.selection.moveCursorBy(-1, 0); times = times || 1;
this.selection.moveCursorBy(-times, 0);
}; };
this.navigateDown = function(times) { this.navigateDown = function(times) {
this.selection.clearSelection(); this.selection.clearSelection();
this.selection.moveCursorBy(1, 0); times = times || 1;
this.selection.moveCursorBy(times, 0);
}; };
this.navigateLeft = function(times) { this.navigateLeft = function(times) {

View file

@ -75,12 +75,14 @@ exports.bindings = {
"gotoright": "Right", "gotoright": "Right",
"selectpagedown": "Shift-PageDown", "selectpagedown": "Shift-PageDown",
"pagedown": "PageDown", "pagedown": "PageDown",
"gotopagedown": "Option-PageDown",
"selectpageup": "Shift-PageUp", "selectpageup": "Shift-PageUp",
"pageup": "PageUp", "pageup": "PageUp",
"gotopageup": "Option-PageUp",
"selectlinestart": "Shift-Home", "selectlinestart": "Shift-Home",
"selectlineend": "Shift-End", "selectlineend": "Shift-End",
"del": "Delete", "del": "Delete",
"backspace": "Ctrl-Backspace|Command-Backspace|Option-Backspace|Backspace", "backspace": "Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
"outdent": "Shift-Tab", "outdent": "Shift-Tab",
"indent": "Tab" "indent": "Tab"
}; };

View file

@ -74,13 +74,13 @@ exports.bindings = {
"selectright": "Shift-Right", "selectright": "Shift-Right",
"gotoright": "Right", "gotoright": "Right",
"selectpagedown": "Shift-PageDown", "selectpagedown": "Shift-PageDown",
"pagedown": "PageDown", "gotopagedown": "PageDown",
"selectpageup": "Shift-PageUp", "selectpageup": "Shift-PageUp",
"pageup": "PageUp", "gotopageup": "PageUp",
"selectlinestart": "Shift-Home", "selectlinestart": "Shift-Home",
"selectlineend": "Shift-End", "selectlineend": "Shift-End",
"del": "Delete", "del": "Delete",
"backspace": "Backspace", "backspace": "Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
"outdent": "Shift-Tab", "outdent": "Shift-Tab",
"indent": "Tab" "indent": "Tab"
}; };

View file

@ -111,7 +111,10 @@ var TextInput = function(parentNode, host) {
else else
e.preventDefault(); e.preventDefault();
text.select(); text.select();
setTimeout(sendText, 0); setTimeout(function () {
sendText();
}, 0);
}; };
var onCut = function(e) { var onCut = function(e) {
@ -123,7 +126,10 @@ var TextInput = function(parentNode, host) {
} else } else
e.preventDefault(); e.preventDefault();
text.select(); text.select();
setTimeout(sendText, 0); setTimeout(function () {
sendText();
}, 0);
}; };
event.addCommandKeyListener(text, host.onCommandKey.bind(host)); event.addCommandKeyListener(text, host.onCommandKey.bind(host));
@ -131,7 +137,8 @@ var TextInput = function(parentNode, host) {
if (useragent.isIE) { if (useragent.isIE) {
var keytable = { 13:1, 27:1 }; var keytable = { 13:1, 27:1 };
event.addListener(text, "keyup", function (e) { event.addListener(text, "keyup", function (e) {
if (inCompostion && (!text.value || keytable[e.keyCode])) setTimeout(onCompositionEnd, 0); if (inCompostion && (!text.value || keytable[e.keyCode]))
setTimeout(onCompositionEnd, 0);
if ((text.value.charCodeAt(0)|0) < 129) { if ((text.value.charCodeAt(0)|0) < 129) {
return; return;
}; };

View file

@ -72,12 +72,15 @@ var Gutter = function(parentEl) {
this.setAnnotations = function(annotations) { this.setAnnotations = function(annotations) {
// iterate over sparse array // iterate over sparse array
this.$annotations = []; this.$annotations = [];
for (var row in annotations) { for (var row in annotations) if (annotations.hasOwnProperty(row)) {
var rowAnnotations = annotations[row];
if (!rowAnnotations)
continue;
var rowInfo = this.$annotations[row] = { var rowInfo = this.$annotations[row] = {
text: [] text: []
}; };
var rowAnnotations = annotations[row];
for (var i=0; i<rowAnnotations.length; i++) { for (var i=0; i<rowAnnotations.length; i++) {
var annotation = rowAnnotations[i]; var annotation = rowAnnotations[i];
rowInfo.text.push(annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&rsquo;").replace(/</, "&lt;")); rowInfo.text.push(annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&rsquo;").replace(/</, "&lt;"));

View file

@ -227,7 +227,8 @@ var Text = function(parentEl) {
style.width = config.width + "px"; style.width = config.width + "px";
var html = []; var html = [];
this.$renderLine(html, row, tokens[row-firstRow].tokens); if (tokens.length > row-firstRow)
this.$renderLine(html, row, tokens[row-firstRow].tokens);
// don't use setInnerHtml since we are working with an empty DIV // don't use setInnerHtml since we are working with an empty DIV
lineEl.innerHTML = html.join(""); lineEl.innerHTML = html.join("");
fragment.appendChild(lineEl); fragment.appendChild(lineEl);

128
lib/ace/mode/c_cpp.js Normal file
View file

@ -0,0 +1,128 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Gastón Kleiman <gaston.kleiman AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var c_cppHighlightRules = require("ace/mode/c_cpp_highlight_rules").c_cppHighlightRules;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Range = require("ace/range").Range;
var Mode = function() {
this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, TextMode);
(function() {
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var outentedRows = [];
var re = /^(\s*)\/\//;
for (var i=startRow; i<= endRow; i++) {
if (!re.test(doc.getLine(i))) {
outdent = false;
break;
}
}
if (outdent) {
var deleteRange = new Range(0, 0, 0, 0);
for (var i=startRow; i<= endRow; i++)
{
var line = doc.getLine(i).replace(re, "$1");
deleteRange.start.row = i;
deleteRange.end.row = i;
deleteRange.end.column = line.length + 2;
doc.replace(deleteRange, line);
}
return -2;
}
else {
return doc.indentRows(startRow, endRow, "//");
}
};
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {
indent += tab;
}
} else if (state == "doc-start") {
if (endState == "start") {
return "";
}
var match = line.match(/^\s*(\/?)\*/);
if (match) {
if (match[1]) {
indent += " ";
}
indent += "* ";
}
}
return indent;
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,172 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Gastón Kleiman <gaston.kleiman AT gmail DOT com>
*
* Based on Bespin's C/C++ Syntax Plugin by Marc McIntyre.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var lang = require("pilot/lang");
var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
c_cppHighlightRules = function() {
var docComment = new DocCommentHighlightRules();
var keywords = lang.arrayToMap(
("and|double|not_eq|throw|and_eq|dynamic_cast|operator|true|" +
"asm|else|or|try|auto|enum|or_eq|typedef|bitand|explicit|private|" +
"typeid|bitor|extern|protected|typename|bool|false|public|union|" +
"break|float|register|unsigned|case|fro|reinterpret-cast|using|catch|" +
"friend|return|virtual|char|goto|short|void|class|if|signed|volatile|" +
"compl|inline|sizeof|wchar_t|const|int|static|while|const-cast|long|" +
"static_cast|xor|continue|mutable|struct|xor_eq|default|namespace|" +
"switch|delete|new|template|do|not|this|for").split("|")
);
var buildinConstants = lang.arrayToMap(
("NULL").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
docComment.getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
regex : '["].*\\\\$',
next : "qqstring"
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
regex : "['].*\\\\$",
next : "qstring"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant", // <CONSTANT>
regex : "<[a-zA-Z0-9.]+>"
}, {
token : "keyword", // pre-compiler directivs
regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
]
};
this.addRules(docComment.getRules(), "doc-");
this.$rules["doc-start"][0].next = "start";
};
oop.inherits(c_cppHighlightRules, TextHighlightRules);
exports.c_cppHighlightRules = c_cppHighlightRules;
});

88
lib/ace/mode/coffee.js Normal file
View file

@ -0,0 +1,88 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Satoshi Murakami <murky.satyr AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var Tokenizer = require("ace/tokenizer").Tokenizer
, Rules = require("ace/mode/coffee_highlight_rules").CoffeeHighlightRules
, Outdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent
, Range = require("ace/range").Range
;
require("pilot/oop").inherits(CoffeeMode, require("ace/mode/text").Mode);
function CoffeeMode() {
this.$tokenizer = new Tokenizer(new Rules().getRules());
this.$outdent = new Outdent();
}
var proto = CoffeeMode.prototype
, indenter = /(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/
, commentLine = /^(\s*)#/
, hereComment = /^\s*###(?!#)/
, indentation = /^\s*/
;
proto.getNextLineIndent = function(state, line, tab){
var indent = this.$getIndent(line)
, tokens = this.$tokenizer.getLineTokens(line, state).tokens
;
if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') &&
state === 'start' && indenter.test(line))
indent += tab;
return indent;
};
proto.toggleCommentLines = function(state, doc, startRow, endRow){
var out, range = new Range(0, 0, 0, 0);
for (var i = startRow; i <= endRow; ++i) {
var line = doc.getLine(i);
if (hereComment.test(line)) continue;
line = (out = commentLine.test(line))
? line.replace(commentLine, '$1')
: line.replace(indentation, '$&#');
range.end.row = range.start.row = i;
range.end.column = line.length + 1;
doc.replace(range, line);
}
return 1 - out * 2;
};
proto.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
proto.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
};
exports.Mode = CoffeeMode;
});

View file

@ -0,0 +1,182 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Satoshi Murakami <murky.satyr AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
require("pilot/oop").inherits(
CoffeeHighlightRules,
require("ace/mode/text_highlight_rules").TextHighlightRules);
function CoffeeHighlightRules() {
var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*"
, keywordend = "(?![$\\w]|\\s*:)"
, stringfill = {token: "string", regex: ".+"}
;
this.$rules =
{ start:
[ { token: "identifier"
, regex: "(?:@|(?:\\.|::)\\s*)" + identifier
}
, { token: "keyword"
, regex: "(?:t(?:h(?:is|row|en)|ry|ypeof)|s(?:uper|witch)|return|b(?:reak|y)|c(?:ontinue|atch|lass)|i(?:n(?:stanceof)?|s(?:nt)?|f)|e(?:lse|xtends)|f(?:or (?:own)?|inally|unction)|wh(?:ile|en)|n(?:ew|ot?)|d(?:e(?:lete|bugger)|o)|loop|o(?:ff?|[rn])|un(?:less|til)|and|yes)" + keywordend
}
, { token: "constant.language"
, regex: "(?:true|false|null|undefined)" + keywordend
}
, { token: "invalid.illegal"
, regex: "(?:c(?:ase|onst)|default|function|v(?:ar|oid)|with|e(?:num|xport)|i(?:mplements|nterface)|let|p(?:ackage|r(?:ivate|otected)|ublic)|static|yield|__(?:hasProp|extends|slice|bind|indexOf))" + keywordend
}
, { token: "language.support.class"
, regex: "(?:Array|Boolean|Date|Function|Number|Object|R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|TypeError|URIError)" + keywordend
}
, { token: "language.support.function"
, regex: "(?:Math|JSON|is(?:NaN|Finite)|parse(?:Int|Float)|encodeURI(?:Component)?|decodeURI(?:Component)?)" + keywordend
}
, { token: "identifier"
, regex: identifier
}
, { token: "constant.numeric"
, regex: "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"
}
, { token: "string"
, regex: "'''"
, next : "qdoc"
}
, { token: "string"
, regex: '"""'
, next : "qqdoc"
}
, { token: "string"
, regex: "'"
, next : "qstring"
}
, { token: "string"
, regex: '"'
, next : "qqstring"
}
, { token: "string"
, regex: "`"
, next : "js"
}
, { token: "string.regex"
, regex: "///"
, next : "heregex"
}
, { token: "string.regex"
, regex: "/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)"
}
, { token: "comment"
, regex: "###(?!#)"
, next : "comment"
}
, { token: "comment"
, regex: "#.*"
}
, { token: "lparen"
, regex: "[({[]"
}
, { token: "rparen"
, regex: "[\\]})]"
}
, { token: "keyword.operator"
, regex: "\\S+"
}
, { token: "text"
, regex: "\\s+"
}
]
, qdoc:
[ { token: "string"
, regex: ".*?'''"
, next : "start"
}
, stringfill
]
, qqdoc:
[ { token: "string"
, regex: '.*?"""'
, next : "start"
}
, stringfill
]
, qstring:
[ { token: "string"
, regex: "[^\\\\']*(?:\\\\.[^\\\\']*)*'"
, next : "start"
}
, stringfill
]
, qqstring:
[ { token: "string"
, regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"'
, next : "start"
}
, stringfill
]
, js:
[ { token: "string"
, regex: "[^\\\\`]*(?:\\\\.[^\\\\`]*)*`"
, next : "start"
}
, stringfill
]
, heregex:
[ { token: "string.regex"
, regex: '.*?///[imgy]{0,4}'
, next : "start"
}
, { token: "comment.regex"
, regex: "\\s+(?:#.*)?"
}
, { token: "string.regex"
, regex: "\\S+"
}
]
, comment:
[ { token: "comment"
, regex: '.*?###'
, next : "start"
}
, { token: "comment"
, regex: ".+"
}
]
};
}
exports.CoffeeHighlightRules = CoffeeHighlightRules;
});

View file

@ -198,16 +198,16 @@ var CssHighlightRules = function() {
regex : "\}" regex : "\}"
}, { }, {
token : function(value) { token : function(value) {
if (properties[value.toLowerCase()]) { if (properties.hasOwnProperty(value.toLowerCase())) {
return "support.type"; return "support.type";
} }
else if (functions[value.toLowerCase()]) { else if (functions.hasOwnProperty(value.toLowerCase())) {
return "support.function"; return "support.function";
} }
else if (constants[value.toLowerCase()]) { else if (constants.hasOwnProperty(value.toLowerCase())) {
return "support.constant"; return "support.constant";
} }
else if (colors[value.toLowerCase()]) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else { else {

24
lib/ace/mode/java.js Normal file
View file

@ -0,0 +1,24 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var JavaScriptMode = require("ace/mode/javascript").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var JavaHighlightRules = require("ace/mode/java_highlight_rules").JavaHighlightRules;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Mode = function() {
this.$tokenizer = new Tokenizer(new JavaHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, JavaScriptMode);
(function() {
this.createWorker = function(session) {
return null;
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,134 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var lang = require("pilot/lang");
var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
JavaHighlightRules = function() {
var docComment = new DocCommentHighlightRules();
// taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
var keywords = lang.arrayToMap(
("abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized" +
"boolean|do|if|private|this" +
"break|double|implements|protected|throw" +
"byte|else|import|public|throws" +
"case|enum|instanceof|return|transient" +
"catch|extends|int|short|try" +
"char|final|interface|static|void" +
"class|finally|long|strictfp|volatile|" +
"const|float|native|super|while").split("|")
);
var buildinConstants = lang.arrayToMap(
("null|Infinity|NaN|undefined").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
docComment.getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "comment", // multi line comment
regex : "\\/\\*\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
]
};
this.addRules(docComment.getRules(), "doc-");
this.$rules["doc-start"][0].next = "start";
};
oop.inherits(JavaHighlightRules, TextHighlightRules);
exports.JavaHighlightRules = JavaHighlightRules;
});

View file

@ -124,7 +124,7 @@ oop.inherits(Mode, TextMode);
this.createWorker = function(session) { this.createWorker = function(session) {
var doc = session.getDocument(); var doc = session.getDocument();
var worker = new WorkerClient("../..", ["ace", "pilot"], "worker-javascript.js", "ace/mode/javascript_worker", "JavaScriptWorker"); var worker = new WorkerClient(["ace", "pilot"], "worker-javascript.js", "ace/mode/javascript_worker", "JavaScriptWorker");
worker.call("setValue", [doc.getValue()]); worker.call("setValue", [doc.getValue()]);
doc.on("change", function(e) { doc.on("change", function(e) {

View file

@ -104,11 +104,11 @@ JavaScriptHighlightRules = function() {
token : function(value) { token : function(value) {
if (value == "this") if (value == "this")
return "variable.language"; return "variable.language";
else if (keywords[value]) else if (keywords.hasOwnProperty(value))
return "keyword"; return "keyword";
else if (buildinConstants[value]) else if (buildinConstants.hasOwnProperty(value))
return "constant.language"; return "constant.language";
else if (futureReserved[value]) else if (futureReserved.hasOwnProperty(value))
return "invalid.illegal"; return "invalid.illegal";
else if (value == "debugger") else if (value == "debugger")
return "invalid.deprecated"; return "invalid.deprecated";

View file

@ -16,6 +16,7 @@ oop.inherits(JavaScriptWorker, Mirror);
this.onUpdate = function() { this.onUpdate = function() {
var value = this.doc.getValue(); var value = this.doc.getValue();
value = value.replace(/^#!.*\n/, "\n");
// var start = new Date(); // var start = new Date();
var parser = require("ace/narcissus/jsparse"); var parser = require("ace/narcissus/jsparse");

View file

@ -527,15 +527,15 @@ PhpHighlightRules = function() {
"T(?:HOUS(?:ANDS_SEP|EP)|_FMT(?:_AMPM|))|YES(?:EXPR|STR)|STD(?:IN|OUT|ERR))\\b" "T(?:HOUS(?:ANDS_SEP|EP)|_FMT(?:_AMPM|))|YES(?:EXPR|STR)|STD(?:IN|OUT|ERR))\\b"
}, { }, {
token : function(value) { token : function(value) {
if (keywords[value]) if (keywords.hasOwnProperty(value))
return "keyword"; return "keyword";
else if (builtinConstants[value]) else if (builtinConstants.hasOwnProperty(value))
return "constant.language"; return "constant.language";
else if (builtinVariables[value]) else if (builtinVariables.hasOwnProperty(value))
return "variable.language"; return "variable.language";
else if (futureReserved[value]) else if (futureReserved.hasOwnProperty(value))
return "invalid.illegal"; return "invalid.illegal";
else if (builtinFunctions[value]) else if (builtinFunctions.hasOwnProperty(value))
return "support.function"; return "support.function";
else if (value == "debugger") else if (value == "debugger")
return "invalid.deprecated"; return "invalid.deprecated";

View file

@ -20,6 +20,7 @@
* *
* Contributor(s): * Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org> * Fabian Jakobs <fabian AT ajax DOT org>
* Colin Gourlay <colin DOT j DOT gourlay AT gmail DOT com>
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or

View file

@ -20,6 +20,7 @@
* *
* Contributor(s): * Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org> * Fabian Jakobs <fabian AT ajax DOT org>
* Colin Gourlay <colin DOT j DOT gourlay AT gmail DOT com>
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -124,13 +125,13 @@ PythonHighlightRules = function() {
regex : integer + "\\b" regex : integer + "\\b"
}, { }, {
token : function(value) { token : function(value) {
if (keywords[value]) if (keywords.hasOwnProperty(value))
return "keyword"; return "keyword";
else if (builtinConstants[value]) else if (builtinConstants.hasOwnProperty(value))
return "constant.language"; return "constant.language";
else if (futureReserved[value]) else if (futureReserved.hasOwnProperty(value))
return "invalid.illegal"; return "invalid.illegal";
else if (builtinFunctions[value]) else if (builtinFunctions.hasOwnProperty(value))
return "support.function"; return "support.function";
else if (value == "debugger") else if (value == "debugger")
return "invalid.deprecated"; return "invalid.deprecated";

117
lib/ace/mode/ruby.js Normal file
View file

@ -0,0 +1,117 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Shlomo Zalman Heigh <shlomozalmanheigh AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var RubyHighlightRules = require("ace/mode/ruby_highlight_rules").RubyHighlightRules;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Range = require("ace/range").Range;
var Mode = function() {
this.$tokenizer = new Tokenizer(new RubyHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, TextMode);
(function() {
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var outentedRows = [];
var re = /^(\s*)#/;
for (var i=startRow; i<= endRow; i++) {
if (!re.test(doc.getLine(i))) {
outdent = false;
break;
}
}
if (outdent) {
var deleteRange = new Range(0, 0, 0, 0);
for (var i=startRow; i<= endRow; i++)
{
var line = doc.getLine(i).replace(re, "$1");
deleteRange.start.row = i;
deleteRange.end.row = i;
deleteRange.end.column = line.length + 2;
doc.replace(deleteRange, line);
}
return -2;
}
else {
return doc.indentRows(startRow, endRow, "#");
}
};
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {
indent += tab;
}
}
return indent;
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,148 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Shlomo Zalman Heigh <shlomozalmanheigh AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var lang = require("pilot/lang");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
RubyHighlightRules = function() {
var builtinFunctions = lang.arrayToMap(
("abort|Array|at_exit|autoload|binding|block_given?|callcc|caller|catch|chomp|chomp!|chop|chop!|eval|exec|exit|exit!" +
"fail|Float|fork|format|gets|global_variables|gsub|gsub!|Integer|lambda|load|local_variables|loop|open|p|print|" +
"printf|proc|putc|puts|raise|rand|readline|readlines|require|scan|select|set_trace_func|sleep|split|sprintf|srand|" +
"String|syscall|system|sub|sub!|test|throw|trace_var|trap|untrace_var|" +
"atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan").split("|")
);
var keywords = lang.arrayToMap(
("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|__FILE__|finally|for|" +
"if|in|__LINE__|module|next|not|or|redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield").split("|")
);
var buildinConstants = lang.arrayToMap(
("true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING").split("|")
);
var builtinVariables = lang.arrayToMap(
("\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
token : "comment",
regex : "#.*$"
}, {
token : "comment", // multi line comment
regex : "^\=begin$",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "self")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else if (builtinVariables.hasOwnProperty(value))
return "variable.language";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else if (value == "debugger")
return "invalid.deprecated";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : "^\=end$",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
]
};
};
oop.inherits(RubyHighlightRules, TextHighlightRules);
exports.RubyHighlightRules = RubyHighlightRules;
});

View file

@ -44,6 +44,9 @@ var TextHighlightRules = function() {
this.$rules = { this.$rules = {
"start" : [ { "start" : [ {
token : "empty_line",
regex : '^$',
}, {
token : "text", token : "text",
regex : ".+" regex : ".+"
} ] } ]

View file

@ -120,7 +120,7 @@ var MouseHandler = function(editor) {
if (self.$clickSelection) { if (self.$clickSelection) {
if (self.$clickSelection.contains(cursor.row, cursor.column)) { if (self.$clickSelection.contains(cursor.row, cursor.column)) {
self.selection.setSelectionRange(self.$clickSelection); editor.selection.setSelectionRange(self.$clickSelection);
} else { } else {
if (self.$clickSelection.compare(cursor.row, cursor.column) == -1) { if (self.$clickSelection.compare(cursor.row, cursor.column) == -1) {
var anchor = self.$clickSelection.end; var anchor = self.$clickSelection.end;

View file

@ -279,19 +279,24 @@ var Test = {
doc.replace(new Range(0, 0, 2, 1), ["4", "5", "6"].join("\n")); doc.replace(new Range(0, 0, 2, 1), ["4", "5", "6"].join("\n"));
assert.equal(["4", "5", "6"].join("\n"), doc.getValue()); assert.equal(["4", "5", "6"].join("\n"), doc.getValue());
}, },
"test: set value": function() { "test: set value": function() {
var doc = new Document("1"); var doc = new Document("1");
assert.equal("1", doc.getValue()); assert.equal("1", doc.getValue());
doc.setValue(doc.getValue()); doc.setValue(doc.getValue());
assert.equal("1", doc.getValue()); assert.equal("1", doc.getValue());
var doc = new Document("1\n2"); var doc = new Document("1\n2");
assert.equal("1\n2", doc.getValue()); assert.equal("1\n2", doc.getValue());
doc.setValue(doc.getValue()); doc.setValue(doc.getValue());
assert.equal("1\n2", doc.getValue()); assert.equal("1\n2", doc.getValue());
},
"test: empty document has to contain one line": function() {
var doc = new Document("");
assert.equal(doc.$lines.length, 1);
} }
}; };

View file

@ -38,6 +38,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var EditSession = require("ace/edit_session").EditSession, var EditSession = require("ace/edit_session").EditSession,
Editor = require("../editor").Editor,
UndoManager = require("ace/undomanager").UndoManager, UndoManager = require("ace/undomanager").UndoManager,
MockRenderer = require("./mockrenderer"), MockRenderer = require("./mockrenderer"),
Range = require("ace/range").Range, Range = require("ace/range").Range,
@ -162,17 +163,17 @@ var Test = {
assert.equal(session.documentToScreenColumn(0, 2), 8); assert.equal(session.documentToScreenColumn(0, 2), 8);
assert.equal(session.documentToScreenColumn(0, 3), 9); assert.equal(session.documentToScreenColumn(0, 3), 9);
}, },
"test: documentToScreen with soft wrap and multibyte characters": function() { "test: documentToScreen with soft wrap and multibyte characters": function() {
var tabSize = 4; var tabSize = 4;
var wrapLimit = 12; var wrapLimit = 12;
var session = new EditSession(["foo bar foo bar"]); var session = new EditSession(["foo bar foo bar"]);
session.setUseWrapMode(true); session.setUseWrapMode(true);
session.setWrapLimit(12); session.setWrapLimit(12);
assert.position(session.documentToScreenPosition(0, 11), 0, 11); assert.position(session.documentToScreenPosition(0, 11), 0, 11);
assert.position(session.documentToScreenPosition(0, 12), 1, 0); assert.position(session.documentToScreenPosition(0, 12), 1, 0);
session = new EditSession(["ぁぁa"]); session = new EditSession(["ぁぁa"]);
session.setUseWrapMode(true); session.setUseWrapMode(true);
session.setWrapLimit(2); session.setWrapLimit(2);
@ -195,20 +196,20 @@ var Test = {
assert.equal(session.screenToDocumentColumn(0, 15), 12); assert.equal(session.screenToDocumentColumn(0, 15), 12);
assert.equal(session.screenToDocumentColumn(0, 19), 13); assert.equal(session.screenToDocumentColumn(0, 19), 13);
}, },
"test: screenToDocument with soft wrap and multi byte characters": function() { "test: screenToDocument with soft wrap and multi byte characters": function() {
var tabSize = 4; var tabSize = 4;
var wrapLimit = 12; var wrapLimit = 12;
var session = new EditSession(["foo bar foo bar"]); var session = new EditSession(["foo bar foo bar"]);
session.setUseWrapMode(true); session.setUseWrapMode(true);
session.setWrapLimit(12); session.setWrapLimit(12);
assert.position(session.screenToDocumentPosition(1, 0), 0, 12); assert.position(session.screenToDocumentPosition(1, 0), 0, 12);
assert.position(session.screenToDocumentPosition(0, 11), 0, 11); assert.position(session.screenToDocumentPosition(0, 11), 0, 11);
// Check if the position is clamped the right way. // Check if the position is clamped the right way.
assert.position(session.screenToDocumentPosition(0, 12), 0, 11); assert.position(session.screenToDocumentPosition(0, 12), 0, 11);
assert.position(session.screenToDocumentPosition(0, 20), 0, 11); assert.position(session.screenToDocumentPosition(0, 20), 0, 11);
session = new EditSession(["ぁ a"]); session = new EditSession(["ぁ a"]);
session.setUseWrapMode(true); session.setUseWrapMode(true);
assert.position(session.screenToDocumentPosition(0, 1), 0, 0); assert.position(session.screenToDocumentPosition(0, 1), 0, 0);
@ -217,12 +218,12 @@ var Test = {
assert.position(session.screenToDocumentPosition(0, 4), 0, 3); assert.position(session.screenToDocumentPosition(0, 4), 0, 3);
assert.position(session.screenToDocumentPosition(0, 5), 0, 3); assert.position(session.screenToDocumentPosition(0, 5), 0, 3);
}, },
"test: wrapLine split function" : function() { "test: wrapLine split function" : function() {
var splits; var splits;
var computeWrapSplits = EditSession.prototype.$computeWrapSplits; var computeWrapSplits = EditSession.prototype.$computeWrapSplits;
var c = 0; var c = 0;
function computeAndAssert(line, assertEqual, wrapLimit, tabSize) { function computeAndAssert(line, assertEqual, wrapLimit, tabSize) {
wrapLimit = wrapLimit || 12; wrapLimit = wrapLimit || 12;
tabSize = tabSize || 4; tabSize = tabSize || 4;
@ -233,28 +234,28 @@ var Test = {
assert.ok(splits[i] == assertEqual[i]); assert.ok(splits[i] == assertEqual[i]);
} }
} }
// Basic splitting. // Basic splitting.
computeAndAssert("foo bar foo bar", [ 12 ]); computeAndAssert("foo bar foo bar", [ 12 ]);
computeAndAssert("foo bar f bar", [ 12 ]); computeAndAssert("foo bar f bar", [ 12 ]);
computeAndAssert("foo bar f r", [ 14 ]); computeAndAssert("foo bar f r", [ 14 ]);
computeAndAssert("foo bar foo bar foo bara foo", [12, 25]); computeAndAssert("foo bar foo bar foo bara foo", [12, 25]);
// Don't split if there is only whitespaces/tabs at the end of the line. // Don't split if there is only whitespaces/tabs at the end of the line.
computeAndAssert("foo foo foo \t \t", [ ]); computeAndAssert("foo foo foo \t \t", [ ]);
// If there is no space to split, force split. // If there is no space to split, force split.
computeAndAssert("foooooooooooooo", [ 12 ]); computeAndAssert("foooooooooooooo", [ 12 ]);
computeAndAssert("fooooooooooooooooooooooooooo", [12, 24]); computeAndAssert("fooooooooooooooooooooooooooo", [12, 24]);
computeAndAssert("foo bar fooooooooooobooooooo", [8, 20]); computeAndAssert("foo bar fooooooooooobooooooo", [8, 20]);
// Basic splitting + tabs. // Basic splitting + tabs.
computeAndAssert("foo \t\tbar", [ 6 ]); computeAndAssert("foo \t\tbar", [ 6 ]);
computeAndAssert("foo \t \tbar", [ 7 ]); computeAndAssert("foo \t \tbar", [ 7 ]);
// Ignore spaces/tabs at beginning of split. // Ignore spaces/tabs at beginning of split.
computeAndAssert("foo \t \t \t \t bar", [ 14 ]); computeAndAssert("foo \t \t \t \t bar", [ 14 ]);
// Test wrapping for asian characters. // Test wrapping for asian characters.
computeAndAssert("ぁぁ", [1], 2); computeAndAssert("ぁぁ", [1], 2);
computeAndAssert(" ぁぁ", [1, 2], 2); computeAndAssert(" ぁぁ", [1, 2], 2);
@ -357,6 +358,32 @@ var Test = {
assert.equal(session.$getDisplayTokens("\t").length, 4); assert.equal(session.$getDisplayTokens("\t").length, 4);
assert.equal(session.$getDisplayTokens("abc").length, 3); assert.equal(session.$getDisplayTokens("abc").length, 3);
assert.equal(session.$getDisplayTokens("abc\t").length, 7); assert.equal(session.$getDisplayTokens("abc\t").length, 7);
},
"test issue 83": function() {
var session = new EditSession("");
var editor = new Editor(new MockRenderer(), session);
var document = session.getDocument();
session.setUseWrapMode(true);
document.insertLines(0, ["a", "b"]);
document.insertLines(2, ["c", "d"]);
document.removeLines(1, 2);
},
"test wrapMode init has to create wrapData array": function() {
var session = new EditSession("foo bar\nfoo bar");
var editor = new Editor(new MockRenderer(), session);
var document = session.getDocument();
session.setUseWrapMode(true);
session.setWrapLimit(3);
// Test if wrapData is there and was computed.
assert.equal(session.$wrapData.length, 2);
assert.equal(session.$wrapData[0].length, 1);
assert.equal(session.$wrapData[1].length, 1);
} }
}; };

View file

@ -40,7 +40,7 @@ define(function(require, exports, module) {
require("./mockdom"); require("./mockdom");
var EditSession = require("ace/edit_session").EditSession, var EditSession = require("ace/edit_session").EditSession,
Editor = require("../Editor").Editor, Editor = require("../editor").Editor,
MockRenderer = require("./mockrenderer"), MockRenderer = require("./mockrenderer"),
assert = require("./assertions"); assert = require("./assertions");

View file

@ -74,11 +74,8 @@ var Tokenizer = function(rules) {
var type = "text"; var type = "text";
var value = match[0]; var value = match[0];
if (re.lastIndex == lastIndex) { throw new Error("tokenizer error"); }
lastIndex = re.lastIndex;
for ( var i = 0; i < state.length; i++) { for ( var i = 0; i < state.length; i++) {
if (match[i + 1]) { if (match[i + 1] !== undefined) {
if (typeof state[i].token == "function") { if (typeof state[i].token == "function") {
type = state[i].token(match[0]); type = state[i].token(match[0]);
} }
@ -110,6 +107,12 @@ var Tokenizer = function(rules) {
} else { } else {
token.value += value; token.value += value;
} }
if (lastIndex == line.length) {
break;
}
lastIndex = re.lastIndex;
}; };
if (token.type) { if (token.type) {

View file

@ -19,23 +19,23 @@ var require = function(id) {
var chunks = id.split("/"); var chunks = id.split("/");
chunks[0] = require.tlns[chunks[0]] || chunks[0]; chunks[0] = require.tlns[chunks[0]] || chunks[0];
path = require.baseUrl + "/" + chunks.join("/") + ".js" path = chunks.join("/") + ".js";
require.id = id; require.id = id;
// console.log("require " + path + " " + id)
importScripts(path); importScripts(path);
return require(id); return require(id);
}; };
require.modules = {}; require.modules = {};
require.tlns = {}; require.tlns = {};
require.baseUrl;
var define = function(id, factory) { var define = function(id, factory) {
if (!factory) { if (!factory) {
factory = id; factory = id;
id = require.id; id = require.id;
} }
if (id.indexOf("text!") == 0) if (id.indexOf("text!") === 0)
return; return;
require.modules[id] = { require.modules[id] = {
@ -51,8 +51,7 @@ var define = function(id, factory) {
}; };
}; };
function initBaseUrls(baseUrl, topLevelNamespaces) { function initBaseUrls(topLevelNamespaces) {
require.baseUrl = baseUrl;
require.tlns = topLevelNamespaces; require.tlns = topLevelNamespaces;
} }
@ -73,7 +72,7 @@ function initSender() {
id: callbackId, id: callbackId,
data: data data: data
}); });
}, };
this.emit = function(name, data) { this.emit = function(name, data) {
postMessage({ postMessage({
@ -81,7 +80,8 @@ function initSender() {
name: name, name: name,
data: data data: data
}); });
} };
}).call(Sender.prototype); }).call(Sender.prototype);
return new Sender(); return new Sender();
@ -92,15 +92,17 @@ var sender;
onmessage = function(e) { onmessage = function(e) {
var msg = e.data; var msg = e.data;
if (msg.command) if (msg.command) {
main[msg.command].apply(main, msg.args); main[msg.command].apply(main, msg.args);
}
else if (msg.init) { else if (msg.init) {
initBaseUrls(msg.base, msg.tlns); initBaseUrls(msg.tlns);
require("pilot/fixoldbrowsers"); require("pilot/fixoldbrowsers");
sender = initSender(); sender = initSender();
var clazz = require(msg.module)[msg.classname]; var clazz = require(msg.module)[msg.classname];
main = new clazz(sender); main = new clazz(sender);
} else if (msg.event) { }
else if (msg.event) {
sender._dispatchEvent(msg.event, msg.data); sender._dispatchEvent(msg.event, msg.data);
} }
}; };

View file

@ -11,12 +11,13 @@ define(function(require, exports, module) {
var oop = require("pilot/oop"); var oop = require("pilot/oop");
var EventEmitter = require("pilot/event_emitter").EventEmitter; var EventEmitter = require("pilot/event_emitter").EventEmitter;
var WorkerClient = function(baseUrl, topLevelNamespaces, packagedJs, module, classname) { var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
this.callbacks = []; this.callbacks = [];
if (require.packaged) { if (require.packaged) {
var worker = this.$worker = new Worker(packagedJs); var base = this.$guessBasePath();
var worker = this.$worker = new Worker(base + packagedJs);
} }
else { else {
var workerUrl = require.nameToUrl("ace/worker/worker", null, "_"); var workerUrl = require.nameToUrl("ace/worker/worker", null, "_");
@ -25,14 +26,13 @@ var WorkerClient = function(baseUrl, topLevelNamespaces, packagedJs, module, cla
var tlns = {}; var tlns = {};
for (var i=0; i<topLevelNamespaces.length; i++) { for (var i=0; i<topLevelNamespaces.length; i++) {
var ns = topLevelNamespaces[i]; var ns = topLevelNamespaces[i];
tlns[ns] = require.nameToUrl(ns, null, "_").replace(/.js$/, "").replace(require.config.baseUrl, ""); tlns[ns] = require.nameToUrl(ns, null, "_").replace(/.js$/, "");
} }
} }
this.$worker.postMessage({ this.$worker.postMessage({
init : true, init : true,
tlns: tlns, tlns: tlns,
base: baseUrl,
module: module, module: module,
classname: classname classname: classname
}); });
@ -42,13 +42,14 @@ var WorkerClient = function(baseUrl, topLevelNamespaces, packagedJs, module, cla
var _self = this; var _self = this;
this.$worker.onerror = function(e) { this.$worker.onerror = function(e) {
console.log(e);
throw e; throw e;
}; };
this.$worker.onmessage = function(e) { this.$worker.onmessage = function(e) {
var msg = e.data; var msg = e.data;
switch(msg.type) { switch(msg.type) {
case "log": case "log":
console.log(msg.data); window.console && console.log && console.log(msg.data);
break; break;
case "event": case "event":
@ -70,6 +71,16 @@ var WorkerClient = function(baseUrl, topLevelNamespaces, packagedJs, module, cla
oop.implement(this, EventEmitter); oop.implement(this, EventEmitter);
this.$guessBasePath = function() {
var scripts = document.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) {
var m = scripts[i].src.match(/^(.*\/)ace\.js$/);
if (m)
return m[1];
}
return "";
};
this.terminate = function() { this.terminate = function() {
this._dispatchEvent("terminate", {}); this._dispatchEvent("terminate", {});
this.$worker.terminate(); this.$worker.terminate();

View file

@ -1,7 +1,7 @@
{ {
"name": "ace", "name": "ace",
"description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE", "description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE",
"version": "0.1.2", "version": "0.1.5",
"homepage" : "http://github.com/ajaxorg/ace", "homepage" : "http://github.com/ajaxorg/ace",
"engines": {"node": ">= 0.2.0"}, "engines": {"node": ">= 0.2.0"},
"author": "Fabian Jakobs <fabian@ajax.org>", "author": "Fabian Jakobs <fabian@ajax.org>",
@ -28,7 +28,7 @@
"asyncjs": ">=0.0.2", "asyncjs": ">=0.0.2",
"jsdom": ">=0.1.23", "jsdom": ">=0.1.23",
"htmlparser": ">=1.7.2", "htmlparser": ">=1.7.2",
"dryice": ">=0.2.1" "dryice": ">=0.2.2"
}, },
"licenses": [{ "licenses": [{
"type": "MPL", "type": "MPL",

@ -1 +1 @@
Subproject commit 67a380309e5b139a9603334ad9d9f917659f04bc Subproject commit c0cab19cbb5d44df98bae0060c782a6f30464afe