├── demo ├── logo.png ├── icons │ ├── error_obj.gif │ ├── warning_obj.gif │ └── Readme.txt ├── styles.css └── boot.js ├── experiments ├── worker.js ├── worker.html ├── triple_click.html ├── capture.html └── cut_copy.html ├── .gitmodules ├── doc ├── Contributor_License_Agreement-v2.pdf └── Corporate_Contributor_License_Agreement-v2.pdf ├── version.js ├── lib └── ace │ ├── test │ ├── asyncjs │ │ ├── index.js │ │ └── utils.js │ ├── mockdom.js │ ├── tests.html │ ├── all.js │ ├── assertions.js │ ├── all_browser.js │ └── event_emitter_test.js │ ├── mode │ ├── java.js │ ├── javascript_worker.js │ ├── csharp.js │ ├── xml.js │ ├── xml_tokenizer_test.js │ ├── text_test.js │ ├── textile.js │ ├── text_highlight_rules.js │ ├── matching_brace_outdent.js │ ├── html_test.js │ ├── doc_comment_highlight_rules.js │ ├── css.js │ ├── svg_highlight_rules.js │ ├── xml_test.js │ ├── css_test.js │ ├── svg.js │ ├── css_tokenizer_test.js │ ├── textile_highlight_rules.js │ ├── html_tokenizer_test.js │ ├── coffee.js │ ├── html.js │ ├── php.js │ ├── perl.js │ ├── python.js │ ├── ruby.js │ ├── javascript_tokenizer_test.js │ ├── xml_highlight_rules.js │ ├── csharp_highlight_rules.js │ └── c_cpp.js │ ├── worker │ ├── mirror.js │ ├── worker.js │ └── worker_client.js │ ├── environment.js │ ├── index.js │ ├── undomanager.js │ ├── scrollbar.js │ ├── settings │ └── default-settings.js │ ├── renderloop.js │ ├── virtual_renderer_test.js │ ├── keyboard │ ├── keybinding │ │ └── vim.js │ └── hash_handler.js │ ├── theme │ ├── eclipse.js │ └── clouds.js │ ├── keys.js │ ├── tokenizer.js │ ├── commands │ └── settings.js │ ├── css │ └── editor.css │ └── layer │ ├── gutter.js │ └── cursor.js ├── support ├── paths.js └── requireJS-node.js ├── Makefile ├── .gitignore ├── tool ├── tmthemes │ └── LICENSE ├── theme.tmpl.js └── Theme.tmpl.css ├── static.js ├── package.json └── ChangeLog.txt /demo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mozilla/ace/HEAD/demo/logo.png -------------------------------------------------------------------------------- /demo/icons/error_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mozilla/ace/HEAD/demo/icons/error_obj.gif -------------------------------------------------------------------------------- /demo/icons/warning_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mozilla/ace/HEAD/demo/icons/warning_obj.gif -------------------------------------------------------------------------------- /experiments/worker.js: -------------------------------------------------------------------------------- 1 | onmessage = function(e) { 2 | onmessage = new Function("e", e.data); 3 | }; -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "support/gcli"] 2 | path = support/gcli 3 | url = git://github.com/joewalker/gcli.git 4 | -------------------------------------------------------------------------------- /doc/Contributor_License_Agreement-v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mozilla/ace/HEAD/doc/Contributor_License_Agreement-v2.pdf -------------------------------------------------------------------------------- /demo/icons/Readme.txt: -------------------------------------------------------------------------------- 1 | The icons in this folder are from the Eclipse project and licensed under the Eclipse public license version 1.0 (EPL). -------------------------------------------------------------------------------- /version.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var x; 3 | eval("x= " + require("fs").readFileSync(__dirname + "/package.json")) 4 | console.log(x.version) -------------------------------------------------------------------------------- /doc/Corporate_Contributor_License_Agreement-v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mozilla/ace/HEAD/doc/Corporate_Contributor_License_Agreement-v2.pdf -------------------------------------------------------------------------------- /lib/ace/test/asyncjs/index.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * async.js 3 | * Copyright(c) 2010 Fabian Jakobs 4 | * MIT Licensed 5 | */ 6 | 7 | define(function(require, exports, module) { 8 | 9 | module.exports = require("./async") 10 | require("./utils") 11 | 12 | }) -------------------------------------------------------------------------------- /lib/ace/test/mockdom.js: -------------------------------------------------------------------------------- 1 | var dom = require('jsdom/level2/html').dom.level2.html; 2 | var browser = require('jsdom/browser/index').windowAugmentation(dom); 3 | 4 | global.document = browser.document; 5 | global.window = browser.window; 6 | global.self = browser.self; 7 | global.navigator = browser.navigator; 8 | global.location = browser.location; -------------------------------------------------------------------------------- /support/paths.js: -------------------------------------------------------------------------------- 1 | require("./requireJS-node"); 2 | require.paths.unshift(__dirname + "/../lib"); 3 | require.paths.unshift(__dirname + "/../support/gcli/support/pilot/lib"); 4 | require.paths.unshift(__dirname + "/../support/gcli/lib"); 5 | require.paths.unshift(__dirname + "/../node_modules/async/lib"); 6 | require.paths.unshift(__dirname + "/../node_modules/jsdom/lib"); 7 | require.paths.unshift(__dirname); 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | mkdir -p build/src 3 | mkdir -p build/textarea/src 4 | ./Makefile.dryice.js 5 | ./Makefile.dryice.textarea.js 6 | 7 | clean: 8 | rm -rf build 9 | rm -rf ace-* 10 | rm -f ace-*.tgz 11 | 12 | ace.tgz: build 13 | mv build ace-`./version.js`/ 14 | cp Readme.md ace-`./version.js`/ 15 | cp LICENSE ace-`./version.js`/ 16 | tar cvfz ace-`./version.js`.tgz ace-`./version.js`/ 17 | 18 | dist: clean build ace.tgz 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Junk that could exist anywhere: 2 | .DS_Store 3 | *.swp 4 | *.tmp 5 | 6 | # Project files that should not be in the repo 7 | .project 8 | .settings/ 9 | .settings.xml 10 | .c9settings.xml 11 | .settings.xml.old 12 | .*.gz 13 | 14 | # A handy place to put stuff that git should ignore: 15 | /ignore/ 16 | 17 | support/async/ 18 | support/dryice/ 19 | support/jsdom/ 20 | support/node-htmlparser/ 21 | support/node-o3-xml/ 22 | support/requirejs/ 23 | 24 | build/ace-uncompressed.js 25 | build/ace.js 26 | build/cockpit-uncompressed.js 27 | build/cockpit.js 28 | build/editor2.html 29 | 30 | node_modules/ 31 | 32 | -------------------------------------------------------------------------------- /tool/tmthemes/LICENSE: -------------------------------------------------------------------------------- 1 | If not otherwise specified (see below), files in this directory fall under the following license: 2 | 3 | Permission to copy, use, modify, sell and distribute this 4 | software is granted. This software is provided "as is" without 5 | express or implied warranty, and with no claim as to its 6 | suitability for any purpose. 7 | 8 | An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”. -------------------------------------------------------------------------------- /lib/ace/mode/java.js: -------------------------------------------------------------------------------- 1 | define(function(require, exports, module) { 2 | 3 | var oop = require("pilot/oop"); 4 | var JavaScriptMode = require("ace/mode/javascript").Mode; 5 | var Tokenizer = require("ace/tokenizer").Tokenizer; 6 | var JavaHighlightRules = require("ace/mode/java_highlight_rules").JavaHighlightRules; 7 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 8 | 9 | var Mode = function() { 10 | this.$tokenizer = new Tokenizer(new JavaHighlightRules().getRules()); 11 | this.$outdent = new MatchingBraceOutdent(); 12 | }; 13 | oop.inherits(Mode, JavaScriptMode); 14 | 15 | (function() { 16 | 17 | this.createWorker = function(session) { 18 | return null; 19 | }; 20 | 21 | }).call(Mode.prototype); 22 | 23 | exports.Mode = Mode; 24 | }); 25 | -------------------------------------------------------------------------------- /experiments/worker.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | worker 8 | 9 | 10 | 11 | 12 | 13 | 14 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /experiments/triple_click.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | triple_click 8 | 9 | 10 | 11 | 12 | 13 |
14 | Juhu Kinners 15 |
16 | 17 | 18 | 19 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /demo/styles.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | overflow: hidden; 4 | } 5 | 6 | body { 7 | overflow: hidden; 8 | margin: 0; 9 | padding: 0; 10 | height: 100%; 11 | width: 100%; 12 | font-family: Arial, Helvetica, sans-serif, Tahoma, Verdana, sans-serif; 13 | font-size: 12px; 14 | background: rgb(14, 98, 165); 15 | color: white; 16 | } 17 | 18 | #editor { 19 | position: absolute; 20 | top: 60px; 21 | left: 0px; 22 | background: white; 23 | } 24 | 25 | #controls { 26 | width: 100%; 27 | } 28 | 29 | #gcliInput { 30 | position: absolute; 31 | width: 100%; 32 | bottom: 0; 33 | 34 | border: none; outline: none; 35 | font-family: consolas, courier, monospace; 36 | font-size: 120%; 37 | } 38 | 39 | #gcliOutput { 40 | margin: 0 15px; 41 | border: 1px solid #AAA; 42 | -moz-border-radius-topleft: 10px; 43 | -moz-border-radius-topright: 10px; 44 | border-top-left-radius: 4px; border-top-right-radius: 4px; 45 | background: #DDD; color: #000; 46 | } 47 | -------------------------------------------------------------------------------- /experiments/capture.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | 18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /lib/ace/worker/mirror.js: -------------------------------------------------------------------------------- 1 | 2 | define(function(require, exports, module) { 3 | 4 | var Document = require("ace/document").Document; 5 | var lang = require("pilot/lang"); 6 | 7 | var Mirror = exports.Mirror = function(sender) { 8 | this.sender = sender; 9 | var doc = this.doc = new Document(""); 10 | 11 | var deferredUpdate = this.deferredUpdate = lang.deferredCall(this.onUpdate.bind(this)); 12 | 13 | var _self = this; 14 | sender.on("change", function(e) { 15 | doc.applyDeltas([e.data]); 16 | deferredUpdate.schedule(_self.$timeout); 17 | }); 18 | }; 19 | 20 | (function() { 21 | 22 | this.$timeout = 500; 23 | 24 | this.setTimeout = function(timeout) { 25 | this.$timeout = timeout; 26 | }; 27 | 28 | this.setValue = function(value) { 29 | this.doc.setValue(value); 30 | this.deferredUpdate.schedule(this.$timeout); 31 | }; 32 | 33 | this.getValue = function(callbackId) { 34 | this.sender.callback(this.doc.getValue(), callbackId); 35 | }; 36 | 37 | this.onUpdate = function() { 38 | // abstract method 39 | }; 40 | 41 | }).call(Mirror.prototype); 42 | 43 | }); -------------------------------------------------------------------------------- /lib/ace/test/tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ace Unit Tests 7 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /static.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var http = require("http"), 4 | url = require("url"), 5 | path = require("path"), 6 | fs = require("fs"), 7 | mime = require("mime"), 8 | port = process.env.C9_PORT || 8888; 9 | 10 | http.createServer(function(request, response) { 11 | 12 | var uri = url.parse(request.url).pathname 13 | , filename = path.join(process.cwd(), uri); 14 | 15 | path.exists(filename, function(exists) { 16 | if(!exists) { 17 | response.writeHead(404, {"Content-Type": "text/plain"}); 18 | response.write("404 Not Found\n"); 19 | response.end(); 20 | return; 21 | } 22 | 23 | if (fs.statSync(filename).isDirectory()) filename += '/index.html'; 24 | 25 | fs.readFile(filename, "binary", function(err, file) { 26 | if(err) { 27 | response.writeHead(500, {"Content-Type": "text/plain"}); 28 | response.write(err + "\n"); 29 | response.end(); 30 | return; 31 | } 32 | 33 | var contentType = mime.lookup(filename) || "text/plain"; 34 | response.writeHead(200, {"Content-Type": contentType}); 35 | response.write(file, "binary"); 36 | response.end(); 37 | }); 38 | }); 39 | }).listen(port, "0.0.0.0"); 40 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ace", 3 | "description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE", 4 | "version": "0.1.6", 5 | "homepage" : "http://github.com/ajaxorg/ace", 6 | "engines": {"node": ">= 0.2.0"}, 7 | "author": "Fabian Jakobs ", 8 | "main": "lib/ace", 9 | "repository" : { 10 | "type" : "git", 11 | "url" : "http://github.com/ajaxorg/ace.git" 12 | }, 13 | "overlay": { 14 | "teleport": { 15 | "directories": { 16 | "lib": "lib/ace", 17 | "dependencies": { 18 | "gcli": ">=0.1.1", 19 | "pilot": ">=0.1.1" 20 | } 21 | } 22 | } 23 | }, 24 | "dependencies": { 25 | /* "pilot": ">=0.1.1", */ 26 | /* "gcli": ">=0.1.1", */ 27 | "teleport": ">=0.2.6", 28 | "asyncjs": ">=0.0.2", 29 | "jsdom": ">=0.1.23", 30 | "htmlparser": ">=1.7.2", 31 | "dryice": ">=0.2.2", 32 | "mime": ">=1.2.1" 33 | }, 34 | "licenses": [{ 35 | "type": "MPL", 36 | "url": "http://www.mozilla.org/MPL/" 37 | }, 38 | { 39 | "type": "GPL", 40 | "url": "http://www.gnu.org/licenses/gpl.html" 41 | }, 42 | { 43 | "type": "LGPL", 44 | "url": "http://www.gnu.org/licenses/lgpl.html" 45 | }] 46 | } 47 | -------------------------------------------------------------------------------- /lib/ace/mode/javascript_worker.js: -------------------------------------------------------------------------------- 1 | 2 | define(function(require, exports, module) { 3 | 4 | var oop = require("pilot/oop"); 5 | var Mirror = require("ace/worker/mirror").Mirror; 6 | //var lint = require("ace/worker/jslint").JSLINT; 7 | var lint = require("ace/worker/jshint").JSHINT; 8 | 9 | var JavaScriptWorker = exports.JavaScriptWorker = function(sender) { 10 | Mirror.call(this, sender); 11 | this.setTimeout(500); 12 | }; 13 | 14 | oop.inherits(JavaScriptWorker, Mirror); 15 | 16 | (function() { 17 | 18 | this.onUpdate = function() { 19 | var value = this.doc.getValue(); 20 | value = value.replace(/^#!.*\n/, "\n"); 21 | 22 | // var start = new Date(); 23 | var parser = require("ace/narcissus/jsparse"); 24 | try { 25 | parser.parse(value); 26 | } catch(e) { 27 | // console.log("narcissus") 28 | // console.log(e); 29 | sender.emit("narcissus", { 30 | row: e.lineno-1, 31 | column: null, // TODO convert e.cursor 32 | text: e.message, 33 | type: "error" 34 | }); 35 | return; 36 | } finally { 37 | // console.log("parse time: " + (new Date() - start)); 38 | } 39 | 40 | // var start = new Date(); 41 | // console.log("jslint") 42 | lint(value, {undef: false, onevar: false, passfail: false}); 43 | this.sender.emit("jslint", lint.errors); 44 | // console.log("lint time: " + (new Date() - start)); 45 | } 46 | 47 | }).call(JavaScriptWorker.prototype); 48 | 49 | }); -------------------------------------------------------------------------------- /lib/ace/mode/csharp.js: -------------------------------------------------------------------------------- 1 | define(function(require, exports, module) { 2 | 3 | var oop = require("pilot/oop"); 4 | var TextMode = require("ace/mode/text").Mode; 5 | var Tokenizer = require("ace/tokenizer").Tokenizer; 6 | var CSharpHighlightRules = require("ace/mode/csharp_highlight_rules").CSharpHighlightRules; 7 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 8 | 9 | var Mode = function() { 10 | this.$tokenizer = new Tokenizer(new CSharpHighlightRules().getRules()); 11 | this.$outdent = new MatchingBraceOutdent(); 12 | }; 13 | oop.inherits(Mode, TextMode); 14 | 15 | (function() { 16 | 17 | this.getNextLineIndent = function(state, line, tab) { 18 | var indent = this.$getIndent(line); 19 | 20 | var tokenizedLine = this.$tokenizer.getLineTokens(line, state); 21 | var tokens = tokenizedLine.tokens; 22 | var endState = tokenizedLine.state; 23 | 24 | if (tokens.length && tokens[tokens.length-1].type == "comment") { 25 | return indent; 26 | } 27 | 28 | if (state == "start") { 29 | var match = line.match(/^.*[\{\(\[]\s*$/); 30 | if (match) { 31 | indent += tab; 32 | } 33 | } 34 | 35 | return indent; 36 | }; 37 | 38 | this.checkOutdent = function(state, line, input) { 39 | return this.$outdent.checkOutdent(line, input); 40 | }; 41 | 42 | this.autoOutdent = function(state, doc, row) { 43 | this.$outdent.autoOutdent(doc, row); 44 | }; 45 | 46 | 47 | this.createWorker = function(session) { 48 | return null; 49 | }; 50 | 51 | }).call(Mode.prototype); 52 | 53 | exports.Mode = Mode; 54 | }); 55 | -------------------------------------------------------------------------------- /lib/ace/test/asyncjs/utils.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * async.js 3 | * Copyright(c) 2010 Fabian Jakobs 4 | * MIT Licensed 5 | */ 6 | 7 | define(function(require, exports, module) { 8 | 9 | var async = require("asyncjs/async") 10 | 11 | async.plugin({ 12 | delay: function(delay) { 13 | return this.each(function(item, next) { 14 | setTimeout(next, delay) 15 | }) 16 | }, 17 | 18 | timeout: function(timeout) { 19 | timeout = timeout || 0 20 | var source = this.source 21 | 22 | this.next = function(callback) { 23 | var called 24 | var id = setTimeout(function() { 25 | called = true 26 | callback("Source did not respond after " + timeout + "ms!") 27 | }, timeout) 28 | 29 | source.next(function(err, value) { 30 | if (called) 31 | return 32 | 33 | called = true 34 | clearTimeout(id) 35 | 36 | callback(err, value) 37 | }) 38 | } 39 | return new this.constructor(this) 40 | }, 41 | 42 | get: function(key) { 43 | return this.map(function(value, next) { 44 | next(null, value[key]) 45 | }) 46 | }, 47 | 48 | inspect: function() { 49 | return this.each(function(item, next) { 50 | console.log(JSON.stringify(item)) 51 | next() 52 | }) 53 | }, 54 | 55 | print: function() { 56 | return this.each(function(item, next) { 57 | console.log(item) 58 | next() 59 | }) 60 | } 61 | }) 62 | 63 | }) -------------------------------------------------------------------------------- /tool/theme.tmpl.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var dom = require("pilot/dom"); 41 | 42 | var cssText = %css%; 43 | 44 | // import CSS once 45 | dom.importCssString(cssText); 46 | 47 | exports.cssClass = "%cssClass%"; 48 | }); -------------------------------------------------------------------------------- /lib/ace/test/all.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | require("ace/test/mockdom"); 41 | } 42 | 43 | require("gcli/index").startup(); 44 | 45 | var test = require("asyncjs").test; 46 | test.walkTestCases(__dirname + "/..").exec(); 47 | -------------------------------------------------------------------------------- /lib/ace/environment.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is DomTemplate. 15 | * 16 | * The Initial Developer of the Original Code is Mozilla. 17 | * Portions created by the Initial Developer are Copyright (C) 2009 18 | * the Initial Developer. All Rights Reserved. 19 | * 20 | * Contributor(s): 21 | * Joe Walker (jwalker@mozilla.com) (original author) 22 | * 23 | * Alternatively, the contents of this file may be used under the terms of 24 | * either the GNU General Public License Version 2 or later (the "GPL"), or 25 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 26 | * in which case the provisions of the GPL or the LGPL are applicable instead 27 | * of those above. If you wish to allow use of your version of this file only 28 | * under the terms of either the GPL or the LGPL, and not to allow others to 29 | * use your version of this file under the terms of the MPL, indicate your 30 | * decision by deleting the provisions above and replace them with the notice 31 | * and other provisions required by the GPL or the LGPL. If you do not delete 32 | * the provisions above, a recipient may use your version of this file under 33 | * the terms of any one of the MPL, the GPL or the LGPL. 34 | * 35 | * ***** END LICENSE BLOCK ***** */ 36 | 37 | define(function(require, exports, module) { 38 | 39 | 40 | var settings = require("ace/settings").settings; 41 | 42 | /** 43 | * Create an environment object 44 | */ 45 | function create() { 46 | return { 47 | settings: settings 48 | }; 49 | }; 50 | 51 | exports.create = create; 52 | 53 | 54 | }); 55 | -------------------------------------------------------------------------------- /ChangeLog.txt: -------------------------------------------------------------------------------- 1 | 2011.02.14, Version 0.1.6 2 | 3 | * Floating Anchors 4 | - An Anchor is a floating pointer in the document. 5 | - Whenever text is inserted or deleted before the cursor, the position of the cursor is updated 6 | - Usesd for the cursor and selection 7 | - Basis for bookmarks, multiple cursors and snippets in the future 8 | * Extensive support for Cocoa style keybindings on the Mac 9 | * New commands: 10 | - center selection in viewport 11 | - remove to end/start of line 12 | - split line 13 | - transpose letters 14 | * Refator markers 15 | - Custom code can be used to render markers 16 | - Markers can be in front or behind the text 17 | - Markers are now stored in the session (was in the renderer) 18 | * Lots of IE8 fixes including copy, cut and selections 19 | * Unit tests can also be run in the browser 20 | * Soft wrap can adapt to the width of the editor (Mike Ratcliffe, Joe Cheng) 21 | * Add minimal node server server.js to run the Ace demo in Chrome 22 | * The top level editor.html demo has been renamed to index.html 23 | * Bug fixes 24 | - Fixed gotoLine to consider wrapped lines when calculating where to scroll to (James Allen) 25 | - Fixed isues when the editor was scrolled in the web page (Eric Allam) 26 | - Highlighting of Python string literals 27 | - Syntax rule for PHP comments 28 | 29 | 2011.02.08, Version 0.1.5 30 | 31 | * Add Coffeescript Mode (Satoshi Murakami) 32 | * Fix word wrap bug (Julian Viereck) 33 | * Fix packaged version of the Eclipse mode 34 | * Loading of workers is more robust 35 | * Fix "click selection" 36 | * Allow tokizing empty lines (Daniel Krech) 37 | * Make PageUp/Down behavior more consistent with native OS (Joe Cheng) 38 | 39 | 2011.02.04, Version 0.1.4 40 | 41 | * Add C/C++ mode contributed by Gastón Kleiman 42 | * Fix exception in key input 43 | 44 | 2011.02.04, Version 0.1.3 45 | 46 | * Let the packaged version play nice with requireJS 47 | * Add Ruby mode contributed by Shlomo Zalman Heigh 48 | * Add Java mode contributed by Tom Tasche 49 | * Fix annotation bug 50 | * Changing a document added a new empty line at the end -------------------------------------------------------------------------------- /lib/ace/mode/xml.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextMode = require("ace/mode/text").Mode; 42 | var Tokenizer = require("ace/tokenizer").Tokenizer; 43 | var XmlHighlightRules = require("ace/mode/xml_highlight_rules").XmlHighlightRules; 44 | 45 | var Mode = function() { 46 | this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules()); 47 | }; 48 | 49 | oop.inherits(Mode, TextMode); 50 | 51 | (function() { 52 | 53 | this.getNextLineIndent = function(state, line, tab) { 54 | return this.$getIndent(line); 55 | }; 56 | 57 | }).call(Mode.prototype); 58 | 59 | exports.Mode = Mode; 60 | }); 61 | -------------------------------------------------------------------------------- /lib/ace/test/assertions.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var assert = require("assert"); 41 | 42 | assert.position = function(cursor, row, column) { 43 | assert.equal(cursor.row, row); 44 | assert.equal(cursor.column, column); 45 | }; 46 | 47 | assert.range = function(range, startRow, startColumn, endRow, endColumn) { 48 | assert.position(range.start, startRow, startColumn); 49 | assert.position(range.end, endRow, endColumn); 50 | }; 51 | 52 | assert.notOk = function(value) { 53 | assert.equal(value, false); 54 | } 55 | 56 | exports.jsonEquals = function(foundJson, expectedJson) { 57 | assert.equal(JSON.stringify(foundJson), JSON.stringify(expectedJson)); 58 | }; 59 | 60 | module.exports = assert; 61 | 62 | }); -------------------------------------------------------------------------------- /lib/ace/index.js: -------------------------------------------------------------------------------- 1 | /* vim:ts=4:sts=4:sw=4: 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is Ajax.org Code Editor (ACE). 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Ajax.org B.V. 19 | * Portions created by the Initial Developer are Copyright (C) 2010 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * Joe Walker (jwalker@mozilla.com) 24 | * Irakli Gozalishvili (http://jeditoolkit.com) 25 | * 26 | * Alternatively, the contents of this file may be used under the terms of 27 | * either the GNU General Public License Version 2 or later (the "GPL"), or 28 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 29 | * in which case the provisions of the GPL or the LGPL are applicable instead 30 | * of those above. If you wish to allow use of your version of this file only 31 | * under the terms of either the GPL or the LGPL, and not to allow others to 32 | * use your version of this file under the terms of the MPL, indicate your 33 | * decision by deleting the provisions above and replace them with the notice 34 | * and other provisions required by the GPL or the LGPL. If you do not delete 35 | * the provisions above, a recipient may use your version of this file under 36 | * the terms of any one of the MPL, the GPL or the LGPL. 37 | * 38 | * ***** END LICENSE BLOCK ***** */ 39 | 40 | define(function(require, exports, module) { 41 | 42 | 43 | exports.startup = function startup(data) { 44 | require("ace/settings").startup(data); 45 | require("ace/commands/settings").startup(data); 46 | require('ace/commands/default_commands').startup(data); 47 | require("ace/settings/default-settings").startup(data); 48 | }; 49 | 50 | exports.shutdown = function shutdown(data) { 51 | require("ace/settings/default-settings").shutdown(data); 52 | require('ace/commands/default_commands').shutdown(data); 53 | require("ace/commands/settings").shutdown(data); 54 | require("ace/settings").shutdown(data); 55 | }; 56 | 57 | 58 | }); 59 | -------------------------------------------------------------------------------- /demo/boot.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Mozilla Skywriter. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Mozilla. 18 | * Portions created by the Initial Developer are Copyright (C) 2009 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Kevin Dangoor (kdangoor@mozilla.com) 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | require({ 39 | paths: { 40 | demo: "../demo", 41 | ace: "../lib/ace", 42 | gcli: "../support/gcli/lib/gcli", 43 | pilot: "../support/gcli/support/pilot/lib/pilot" 44 | } 45 | }); 46 | 47 | var deps = [ 48 | "pilot/fixoldbrowsers", 49 | "ace/plugin_manager", 50 | "ace/environment", 51 | "demo/demo" 52 | ]; 53 | 54 | require(deps, function() { 55 | var catalog = require("ace/plugin_manager").catalog; 56 | 57 | var plugins = [ "gcli/index", "ace/index" ]; 58 | catalog.registerPlugins(plugins).then(function() { 59 | var env = require("ace/environment").create(); 60 | catalog.startupPlugins({ env: env }).then(function() { 61 | require("demo/demo").launch(env); 62 | 63 | var gcli = require("gcli/index"); 64 | gcli.createView({ env: env }); 65 | }); 66 | }); 67 | }); 68 | -------------------------------------------------------------------------------- /lib/ace/test/all_browser.js: -------------------------------------------------------------------------------- 1 | define(function(require, exports, module) { 2 | 3 | require("pilot/fixoldbrowsers"); 4 | var AsyncTest = require("asyncjs/test"); 5 | var async = require("asyncjs"); 6 | var dom = require("pilot/dom"); 7 | 8 | var passed = 0 9 | var failed = 0 10 | var log = document.getElementById("log") 11 | 12 | var tests = [ 13 | require("ace/editor_change_document_test"), 14 | require("ace/editor_navigation_test"), 15 | require("ace/editor_highlight_selected_word_test"), 16 | require("ace/editor_text_edit_test"), 17 | require("ace/document_test"), 18 | require("ace/edit_session_test"), 19 | require("ace/test/event_emitter_test"), 20 | require("ace/range_test"), 21 | require("ace/search_test"), 22 | require("ace/selection_test"), 23 | require("ace/virtual_renderer_test"), 24 | require("ace/anchor_test"), 25 | require("ace/mode/css_test"), 26 | require("ace/mode/css_tokenizer_test"), 27 | require("ace/mode/html_test"), 28 | require("ace/mode/html_tokenizer_test"), 29 | require("ace/mode/javascript_test"), 30 | require("ace/mode/javascript_tokenizer_test"), 31 | require("ace/mode/text_test"), 32 | require("ace/mode/xml_test"), 33 | require("ace/mode/xml_tokenizer_test") 34 | ] 35 | 36 | async.list(tests) 37 | .expand(function(test) { 38 | return AsyncTest.testcase(test) 39 | }, AsyncTest.TestGenerator) 40 | .run() 41 | .each(function(test, next) { 42 | var node = document.createElement("div"); 43 | node.className = test.passed ? "passed" : "failed"; 44 | 45 | var name = test.name 46 | if (test.suiteName) 47 | name = test.suiteName + ": " + test.name 48 | 49 | var msg = "[" + test.count + "/" + test.index + "] " + name + " " + (test.passed ? "OK" : "FAIL") 50 | if (!test.passed) { 51 | if (test.err.stack) 52 | var err = test.err.stack 53 | else 54 | var err = test.err 55 | 56 | msg += "
" + err + "
"; 57 | } 58 | 59 | node.innerHTML = msg; 60 | log.appendChild(node); 61 | 62 | next() 63 | }) 64 | .each(function(test) { 65 | if (test.passed) 66 | passed += 1 67 | else 68 | failed += 1 69 | }) 70 | .end(function() { 71 | log.innerHTML += [ 72 | "
", 73 | "
", 74 | "Summary:
", 75 | "
", 76 | "Total number of tests: " + (passed + failed) + "
", 77 | (passed ? "Passed tests: " + passed + "
" : ""), 78 | (failed ? "Failed tests: " + failed + "
" : "") 79 | ].join("") 80 | }) 81 | 82 | }); 83 | -------------------------------------------------------------------------------- /lib/ace/mode/xml_tokenizer_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var XmlMode = require("ace/mode/xml").Mode; 45 | var assert = require("ace/test/assertions"); 46 | 47 | module.exports = { 48 | setUp : function() { 49 | this.tokenizer = new XmlMode().getTokenizer(); 50 | }, 51 | 52 | "test: tokenize1" : function() { 53 | 54 | var line = "//Juhu Kinners"; 55 | var tokens = this.tokenizer.getLineTokens(line, "start").tokens; 56 | 57 | assert.equal(5, tokens.length); 58 | assert.equal("text", tokens[0].type); 59 | assert.equal("keyword", tokens[1].type); 60 | assert.equal("text", tokens[2].type); 61 | assert.equal("keyword", tokens[3].type); 62 | assert.equal("text", tokens[4].type); 63 | } 64 | }; 65 | 66 | }); 67 | 68 | if (typeof module !== "undefined" && module === require.main) { 69 | require("asyncjs/test").testcase(module.exports).exec() 70 | } -------------------------------------------------------------------------------- /lib/ace/mode/text_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var EditSession = require("ace/edit_session").EditSession; 45 | var TextMode = require("ace/mode/text").Mode; 46 | var assert = require("ace/test/assertions"); 47 | 48 | module.exports = { 49 | setUp : function() { 50 | this.mode = new TextMode(); 51 | }, 52 | 53 | "test: toggle comment lines should not do anything" : function() { 54 | var session = new EditSession([" abc", "cde", "fg"]); 55 | 56 | var comment = this.mode.toggleCommentLines("start", session, 0, 1); 57 | assert.equal([" abc", "cde", "fg"].join("\n"), session.toString()); 58 | }, 59 | 60 | 61 | "text: lines should not be indented" : function() { 62 | assert.equal("", this.mode.getNextLineIndent("start", " abc", " ")); 63 | } 64 | }; 65 | 66 | }); 67 | 68 | if (typeof module !== "undefined" && module === require.main) { 69 | require("asyncjs/test").testcase(module.exports).exec() 70 | } -------------------------------------------------------------------------------- /experiments/cut_copy.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Text Events 8 | 9 | 10 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
32 |
33 | 34 | 35 |
36 | 37 |
38 | 39 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /lib/ace/mode/textile.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Kelley van Evert 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextMode = require("ace/mode/text").Mode; 42 | var Tokenizer = require("ace/tokenizer").Tokenizer; 43 | var TextileHighlightRules = require("ace/mode/textile_highlight_rules").TextileHighlightRules; 44 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 45 | var Range = require("ace/range").Range; 46 | 47 | var Mode = function() 48 | { 49 | this.$tokenizer = new Tokenizer(new TextileHighlightRules().getRules()); 50 | this.$outdent = new MatchingBraceOutdent(); 51 | }; 52 | oop.inherits(Mode, TextMode); 53 | 54 | (function() 55 | { 56 | this.getNextLineIndent = function(state, line, tab) 57 | { 58 | if (state == "intag") 59 | return tab; 60 | 61 | return ""; 62 | }; 63 | 64 | this.checkOutdent = function(state, line, input) { 65 | return this.$outdent.checkOutdent(line, input); 66 | }; 67 | 68 | this.autoOutdent = function(state, doc, row) { 69 | this.$outdent.autoOutdent(doc, row); 70 | }; 71 | 72 | }).call(Mode.prototype); 73 | 74 | exports.Mode = Mode; 75 | 76 | }); 77 | -------------------------------------------------------------------------------- /lib/ace/mode/text_highlight_rules.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var TextHighlightRules = function() { 41 | 42 | // regexp must not have capturing parentheses 43 | // regexps are ordered -> the first match is used 44 | 45 | this.$rules = { 46 | "start" : [ { 47 | token : "empty_line", 48 | regex : '^$' 49 | }, { 50 | token : "text", 51 | regex : ".+" 52 | } ] 53 | }; 54 | }; 55 | 56 | (function() { 57 | 58 | this.addRules = function(rules, prefix) { 59 | for (var key in rules) { 60 | var state = rules[key]; 61 | for (var i=0; i 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var Range = require("ace/range").Range; 41 | 42 | var MatchingBraceOutdent = function() {}; 43 | 44 | (function() { 45 | 46 | this.checkOutdent = function(line, input) { 47 | if (! /^\s+$/.test(line)) 48 | return false; 49 | 50 | return /^\s*\}/.test(input); 51 | }; 52 | 53 | this.autoOutdent = function(doc, row) { 54 | var line = doc.getLine(row); 55 | var match = line.match(/^(\s*\})/); 56 | 57 | if (!match) return 0; 58 | 59 | var column = match[1].length; 60 | var openBracePos = doc.findMatchingBracket({row: row, column: column}); 61 | 62 | if (!openBracePos || openBracePos.row == row) return 0; 63 | 64 | var indent = this.$getIndent(doc.getLine(openBracePos.row)); 65 | doc.replace(new Range(row, 0, row, column-1), indent); 66 | }; 67 | 68 | this.$getIndent = function(line) { 69 | var match = line.match(/^(\s+)/); 70 | if (match) { 71 | return match[1]; 72 | } 73 | 74 | return ""; 75 | }; 76 | 77 | }).call(MatchingBraceOutdent.prototype); 78 | 79 | exports.MatchingBraceOutdent = MatchingBraceOutdent; 80 | }); 81 | -------------------------------------------------------------------------------- /tool/Theme.tmpl.css: -------------------------------------------------------------------------------- 1 | .%cssClass% .ace_editor { 2 | border: 2px solid rgb(159, 159, 159); 3 | } 4 | 5 | .%cssClass% .ace_editor.ace_focus { 6 | border: 2px solid #327fbd; 7 | } 8 | 9 | .%cssClass% .ace_gutter { 10 | width: 50px; 11 | background: #e8e8e8; 12 | color: #333; 13 | overflow : hidden; 14 | } 15 | 16 | .%cssClass% .ace_gutter-layer { 17 | width: 100%; 18 | text-align: right; 19 | } 20 | 21 | .%cssClass% .ace_gutter-layer .ace_gutter-cell { 22 | padding-right: 6px; 23 | } 24 | 25 | .%cssClass% .ace_print_margin { 26 | width: 1px; 27 | background: %printMargin%; 28 | } 29 | 30 | .%cssClass% .ace_scroller { 31 | background-color: %background%; 32 | } 33 | 34 | .%cssClass% .ace_text-layer { 35 | cursor: text; 36 | color: %foreground%; 37 | } 38 | 39 | .%cssClass% .ace_cursor { 40 | border-left: 2px solid %cursor%; 41 | } 42 | 43 | .%cssClass% .ace_cursor.ace_overwrite { 44 | border-left: 0px; 45 | border-bottom: 1px solid %overwrite%; 46 | } 47 | 48 | .%cssClass% .ace_marker-layer .ace_selection { 49 | background: %selection%; 50 | } 51 | 52 | .%cssClass% .ace_marker-layer .ace_step { 53 | background: %step%; 54 | } 55 | 56 | .%cssClass% .ace_marker-layer .ace_bracket { 57 | margin: -1px 0 0 -1px; 58 | border: 1px solid %bracket%; 59 | } 60 | 61 | .%cssClass% .ace_marker-layer .ace_active_line { 62 | background: %active_line%; 63 | } 64 | 65 | 66 | .%cssClass% .ace_invisible { 67 | %invisible% 68 | } 69 | 70 | .%cssClass% .ace_keyword { 71 | %keyword% 72 | } 73 | 74 | .%cssClass% .ace_keyword.ace_operator { 75 | %keyword.operator% 76 | } 77 | 78 | .%cssClass% .ace_constant { 79 | %constant% 80 | } 81 | 82 | .%cssClass% .ace_constant.ace_language { 83 | %constant.language% 84 | } 85 | 86 | .%cssClass% .ace_constant.ace_library { 87 | %constant.library% 88 | } 89 | 90 | .%cssClass% .ace_constant.ace_numeric { 91 | %constant.numeric% 92 | } 93 | 94 | .%cssClass% .ace_invalid { 95 | %invalid% 96 | } 97 | 98 | .%cssClass% .ace_invalid.ace_illegal { 99 | %invalid.illegal% 100 | } 101 | 102 | .%cssClass% .ace_invalid.ace_deprecated { 103 | %invalid.deprecated% 104 | } 105 | 106 | .%cssClass% .ace_support { 107 | %support% 108 | } 109 | 110 | .%cssClass% .ace_support.ace_function { 111 | %support.function% 112 | } 113 | 114 | .%cssClass% .ace_function.ace_buildin { 115 | %function.buildin% 116 | } 117 | 118 | .%cssClass% .ace_string { 119 | %string% 120 | } 121 | 122 | .%cssClass% .ace_string.ace_regexp { 123 | %string.regexp% 124 | } 125 | 126 | .%cssClass% .ace_comment { 127 | %comment% 128 | } 129 | 130 | .%cssClass% .ace_comment.ace_doc { 131 | %comment.doc% 132 | } 133 | 134 | .%cssClass% .ace_comment.ace_doc.ace_tag { 135 | %comment.doc.tag% 136 | } 137 | 138 | .%cssClass% .ace_variable { 139 | %variable% 140 | } 141 | 142 | .%cssClass% .ace_variable.ace_language { 143 | %variable.language% 144 | } 145 | 146 | .%cssClass% .ace_xml_pe { 147 | %xml_pe% 148 | } 149 | 150 | .%cssClass% .ace_collab.ace_user1 { 151 | %collab.user1% 152 | } -------------------------------------------------------------------------------- /lib/ace/worker/worker.js: -------------------------------------------------------------------------------- 1 | var console = { 2 | log: function(msg) { 3 | postMessage({type: "log", data: msg}); 4 | } 5 | }; 6 | var window = { 7 | console: console 8 | }; 9 | 10 | var require = function(id) { 11 | var module = require.modules[id]; 12 | if (module) { 13 | if (!module.initialized) { 14 | module.exports = module.factory().exports; 15 | module.initialized = true; 16 | } 17 | return module.exports; 18 | } 19 | 20 | var chunks = id.split("/"); 21 | chunks[0] = require.tlns[chunks[0]] || chunks[0]; 22 | path = chunks.join("/") + ".js"; 23 | 24 | require.id = id; 25 | // console.log("require " + path + " " + id) 26 | importScripts(path); 27 | return require(id); 28 | }; 29 | 30 | require.modules = {}; 31 | require.tlns = {}; 32 | 33 | var define = function(id, deps, factory) { 34 | if (arguments.length == 2) { 35 | factory = deps; 36 | } else if (arguments.length == 1) { 37 | factory = id; 38 | id = require.id; 39 | } 40 | 41 | if (id.indexOf("text!") === 0) 42 | return; 43 | 44 | require.modules[id] = { 45 | factory: function() { 46 | var module = { 47 | exports: {} 48 | }; 49 | var returnExports = factory(require, module.exports, module); 50 | if (returnExports) 51 | module.exports = exports; 52 | return module; 53 | } 54 | }; 55 | }; 56 | 57 | function initBaseUrls(topLevelNamespaces) { 58 | require.tlns = topLevelNamespaces; 59 | } 60 | 61 | function initSender() { 62 | 63 | var EventEmitter = require("pilot/event_emitter").EventEmitter; 64 | var oop = require("pilot/oop"); 65 | 66 | var Sender = function() {}; 67 | 68 | (function() { 69 | 70 | oop.implement(this, EventEmitter); 71 | 72 | this.callback = function(data, callbackId) { 73 | postMessage({ 74 | type: "call", 75 | id: callbackId, 76 | data: data 77 | }); 78 | }; 79 | 80 | this.emit = function(name, data) { 81 | postMessage({ 82 | type: "event", 83 | name: name, 84 | data: data 85 | }); 86 | }; 87 | 88 | }).call(Sender.prototype); 89 | 90 | return new Sender(); 91 | } 92 | 93 | var main; 94 | var sender; 95 | 96 | onmessage = function(e) { 97 | var msg = e.data; 98 | if (msg.command) { 99 | main[msg.command].apply(main, msg.args); 100 | } 101 | else if (msg.init) { 102 | initBaseUrls(msg.tlns); 103 | require("pilot/fixoldbrowsers"); 104 | sender = initSender(); 105 | var clazz = require(msg.module)[msg.classname]; 106 | main = new clazz(sender); 107 | } 108 | else if (msg.event && sender) { 109 | sender._dispatchEvent(msg.event, msg.data); 110 | } 111 | }; -------------------------------------------------------------------------------- /lib/ace/undomanager.js: -------------------------------------------------------------------------------- 1 | /* vim:ts=4:sts=4:sw=4: 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is Ajax.org Code Editor (ACE). 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Ajax.org B.V. 19 | * Portions created by the Initial Developer are Copyright (C) 2010 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * Fabian Jakobs 24 | * Mihai Sucan 25 | * 26 | * Alternatively, the contents of this file may be used under the terms of 27 | * either the GNU General Public License Version 2 or later (the "GPL"), or 28 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 29 | * in which case the provisions of the GPL or the LGPL are applicable instead 30 | * of those above. If you wish to allow use of your version of this file only 31 | * under the terms of either the GPL or the LGPL, and not to allow others to 32 | * use your version of this file under the terms of the MPL, indicate your 33 | * decision by deleting the provisions above and replace them with the notice 34 | * and other provisions required by the GPL or the LGPL. If you do not delete 35 | * the provisions above, a recipient may use your version of this file under 36 | * the terms of any one of the MPL, the GPL or the LGPL. 37 | * 38 | * ***** END LICENSE BLOCK ***** */ 39 | 40 | define(function(require, exports, module) { 41 | 42 | var UndoManager = function() { 43 | this.reset(); 44 | }; 45 | 46 | (function() { 47 | 48 | this.execute = function(options) { 49 | var deltas = options.args[0]; 50 | this.$doc = options.args[1]; 51 | this.$undoStack.push(deltas); 52 | }; 53 | 54 | this.undo = function() { 55 | var deltas = this.$undoStack.pop(); 56 | if (deltas) { 57 | this.$doc.undoChanges(deltas); 58 | this.$redoStack.push(deltas); 59 | } 60 | }; 61 | 62 | this.redo = function() { 63 | var deltas = this.$redoStack.pop(); 64 | if (deltas) { 65 | this.$doc.redoChanges(deltas); 66 | this.$undoStack.push(deltas); 67 | } 68 | }; 69 | 70 | this.reset = function() { 71 | this.$undoStack = []; 72 | this.$redoStack = []; 73 | }; 74 | 75 | this.hasUndo = function() { 76 | return this.$undoStack.length > 0; 77 | }; 78 | 79 | this.hasRedo = function() { 80 | return this.$redoStack.length > 0; 81 | }; 82 | 83 | }).call(UndoManager.prototype); 84 | 85 | exports.UndoManager = UndoManager; 86 | }); 87 | -------------------------------------------------------------------------------- /lib/ace/mode/html_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var EditSession = require("ace/edit_session").EditSession; 45 | var Range = require("ace/range").Range; 46 | var HtmlMode = require("ace/mode/html").Mode; 47 | var assert = require("ace/test/assertions"); 48 | 49 | module.exports = { 50 | setUp : function() { 51 | this.mode = new HtmlMode(); 52 | }, 53 | 54 | "test: toggle comment lines should not do anything" : function() { 55 | var session = new EditSession([" abc", "cde", "fg"]); 56 | 57 | var range = new Range(0, 3, 1, 1); 58 | var comment = this.mode.toggleCommentLines("start", session, 0, 1); 59 | assert.equal([" abc", "cde", "fg"].join("\n"), session.toString()); 60 | }, 61 | 62 | "test: next line indent should be the same as the current line indent" : function() { 63 | assert.equal(" ", this.mode.getNextLineIndent("start", " abc")); 64 | assert.equal("", this.mode.getNextLineIndent("start", "abc")); 65 | assert.equal("\t", this.mode.getNextLineIndent("start", "\tabc")); 66 | } 67 | }; 68 | 69 | }); 70 | 71 | if (typeof module !== "undefined" && module === require.main) { 72 | require("asyncjs/test").testcase(module.exports).exec() 73 | } -------------------------------------------------------------------------------- /lib/ace/mode/doc_comment_highlight_rules.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; 42 | 43 | var DocCommentHighlightRules = function() { 44 | 45 | this.$rules = { 46 | "start" : [ { 47 | token : "comment.doc", // closing comment 48 | regex : "\\*\\/", 49 | next : "start" 50 | }, { 51 | token : "comment.doc.tag", 52 | regex : "@[\\w\\d_]+" // TODO: fix email addresses 53 | }, { 54 | token : "comment.doc", 55 | regex : "\s+" 56 | }, { 57 | token : "comment.doc", 58 | regex : "TODO" 59 | }, { 60 | token : "comment.doc", 61 | regex : "[^@\\*]+" 62 | }, { 63 | token : "comment.doc", 64 | regex : "." 65 | }] 66 | }; 67 | }; 68 | 69 | oop.inherits(DocCommentHighlightRules, TextHighlightRules); 70 | 71 | (function() { 72 | 73 | this.getStartRule = function(start) { 74 | return { 75 | token : "comment.doc", // doc comment 76 | regex : "\\/\\*(?=\\*)", 77 | next: start 78 | }; 79 | }; 80 | 81 | }).call(DocCommentHighlightRules.prototype); 82 | 83 | exports.DocCommentHighlightRules = DocCommentHighlightRules; 84 | 85 | }); 86 | -------------------------------------------------------------------------------- /lib/ace/scrollbar.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var dom = require("pilot/dom"); 42 | var event = require("pilot/event"); 43 | var EventEmitter = require("pilot/event_emitter").EventEmitter; 44 | 45 | var ScrollBar = function(parent) { 46 | this.element = dom.createElement("div"); 47 | this.element.className = "ace_sb"; 48 | 49 | this.inner = dom.createElement("div"); 50 | this.element.appendChild(this.inner); 51 | 52 | parent.appendChild(this.element); 53 | 54 | this.width = dom.scrollbarWidth(); 55 | this.element.style.width = this.width + "px"; 56 | 57 | event.addListener(this.element, "scroll", this.onScroll.bind(this)); 58 | }; 59 | 60 | (function() { 61 | oop.implement(this, EventEmitter); 62 | 63 | this.onScroll = function() { 64 | this._dispatchEvent("scroll", {data: this.element.scrollTop}); 65 | }; 66 | 67 | this.getWidth = function() { 68 | return this.width; 69 | }; 70 | 71 | this.setHeight = function(height) { 72 | this.element.style.height = height + "px"; 73 | }; 74 | 75 | this.setInnerHeight = function(height) { 76 | this.inner.style.height = height + "px"; 77 | }; 78 | 79 | this.setScrollTop = function(scrollTop) { 80 | this.element.scrollTop = scrollTop; 81 | }; 82 | 83 | }).call(ScrollBar.prototype); 84 | 85 | exports.ScrollBar = ScrollBar; 86 | }); 87 | -------------------------------------------------------------------------------- /lib/ace/test/event_emitter_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var oop = require("pilot/oop"); 45 | var EventEmitter = require("pilot/event_emitter").EventEmitter; 46 | var assert = require("ace/test/assertions"); 47 | 48 | var Emitter = function() {}; 49 | 50 | oop.implement(Emitter.prototype, EventEmitter); 51 | 52 | module.exports = { 53 | "test: dispatch event with no data" : function() { 54 | var emitter = new Emitter(); 55 | 56 | var called = false; 57 | emitter.addEventListener("juhu", function(e) { 58 | called = true; 59 | assert.equal(e.type, "juhu"); 60 | }); 61 | 62 | emitter._dispatchEvent("juhu"); 63 | assert.ok(called); 64 | }, 65 | 66 | "test: single dispatch" : function() { 67 | var real = new Emitter(); 68 | var ignored = new Emitter(); 69 | 70 | var calls = 0; 71 | real.addEventListener("juhu", function(e) { 72 | calls++; 73 | assert.equal(e.type, "juhu"); 74 | }); 75 | 76 | real._dispatchEvent("juhu"); 77 | real._dispatchEvent("juhu"); 78 | 79 | assert.equal(2, calls); 80 | } 81 | }; 82 | 83 | if (typeof module !== "undefined" && module === require.main) { 84 | require("asyncjs/test").testcase(module.exports).exec() 85 | } 86 | 87 | }); 88 | 89 | -------------------------------------------------------------------------------- /lib/ace/mode/css.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextMode = require("ace/mode/text").Mode; 42 | var Tokenizer = require("ace/tokenizer").Tokenizer; 43 | var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules; 44 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 45 | 46 | var Mode = function() { 47 | this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules()); 48 | this.$outdent = new MatchingBraceOutdent(); 49 | }; 50 | oop.inherits(Mode, TextMode); 51 | 52 | (function() { 53 | 54 | this.getNextLineIndent = function(state, line, tab) { 55 | var indent = this.$getIndent(line); 56 | 57 | // ignore braces in comments 58 | var tokens = this.$tokenizer.getLineTokens(line, state).tokens; 59 | if (tokens.length && tokens[tokens.length-1].type == "comment") { 60 | return indent; 61 | } 62 | 63 | var match = line.match(/^.*\{\s*$/); 64 | if (match) { 65 | indent += tab; 66 | } 67 | 68 | return indent; 69 | }; 70 | 71 | this.checkOutdent = function(state, line, input) { 72 | return this.$outdent.checkOutdent(line, input); 73 | }; 74 | 75 | this.autoOutdent = function(state, doc, row) { 76 | this.$outdent.autoOutdent(doc, row); 77 | }; 78 | 79 | }).call(Mode.prototype); 80 | 81 | exports.Mode = Mode; 82 | 83 | }); 84 | -------------------------------------------------------------------------------- /lib/ace/mode/svg_highlight_rules.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules; 42 | var XmlHighlightRules = require("ace/mode/xml_highlight_rules").XmlHighlightRules; 43 | 44 | var SvgHighlightRules = function() { 45 | XmlHighlightRules.call(this); 46 | 47 | this.$rules.start.splice(3, 0, { 48 | token : "text", 49 | regex : "<(?=\s*script)", 50 | next : "script" 51 | }); 52 | this.$rules.script = [{ 53 | token : "text", 54 | regex : ">", 55 | next : "js-start" 56 | }, { 57 | token : "keyword", 58 | regex : "[-_a-zA-Z0-9:]+" 59 | }, { 60 | token : "text", 61 | regex : "\\s+" 62 | }, { 63 | token : "string", 64 | regex : '".*?"' 65 | }, { 66 | token : "string", 67 | regex : "'.*?'" 68 | }]; 69 | 70 | var jsRules = new JavaScriptHighlightRules().getRules(); 71 | this.addRules(jsRules, "js-"); 72 | this.$rules["js-start"].unshift({ 73 | token: "comment", 74 | regex: "\\/\\/.*(?=<\\/script>)", 75 | next: "tag" 76 | }, { 77 | token: "text", 78 | regex: "<\\/(?=script)", 79 | next: "tag" 80 | }); 81 | 82 | }; 83 | 84 | oop.inherits(SvgHighlightRules, XmlHighlightRules); 85 | 86 | exports.SvgHighlightRules = SvgHighlightRules; 87 | }); 88 | -------------------------------------------------------------------------------- /lib/ace/mode/xml_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var EditSession = require("ace/edit_session").EditSession; 45 | var Tokenizer = require("ace/tokenizer").Tokenizer; 46 | var XmlMode = require("ace/mode/xml").Mode; 47 | var assert = require("ace/test/assertions"); 48 | 49 | module.exports = { 50 | setUp : function() { 51 | this.mode = new XmlMode(); 52 | }, 53 | 54 | "test: getTokenizer() (smoke test)" : function() { 55 | var tokenizer = this.mode.getTokenizer(); 56 | 57 | assert.ok(tokenizer instanceof Tokenizer); 58 | 59 | var tokens = tokenizer.getLineTokens("", "start").tokens; 60 | assert.equal("keyword", tokens[1].type); 61 | }, 62 | 63 | "test: toggle comment lines should not do anything" : function() { 64 | var session = new EditSession([" abc", "cde", "fg"]); 65 | 66 | var comment = this.mode.toggleCommentLines("start", session, 0, 1); 67 | assert.equal([" abc", "cde", "fg"].join("\n"), session.toString()); 68 | }, 69 | 70 | "test: next line indent should be the same as the current line indent" : function() { 71 | assert.equal(" ", this.mode.getNextLineIndent("start", " abc")); 72 | assert.equal("", this.mode.getNextLineIndent("start", "abc")); 73 | assert.equal("\t", this.mode.getNextLineIndent("start", "\tabc")); 74 | } 75 | }; 76 | 77 | }); 78 | 79 | if (typeof module !== "undefined" && module === require.main) { 80 | require("asyncjs/test").testcase(module.exports).exec() 81 | } -------------------------------------------------------------------------------- /lib/ace/settings/default-settings.js: -------------------------------------------------------------------------------- 1 | /* vim:ts=4:sts=4:sw=4: 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is Ajax.org Code Editor (ACE). 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Ajax.org B.V. 19 | * Portions created by the Initial Developer are Copyright (C) 2010 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * Irakli Gozalishvili (http://jeditoolkit.com) 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * either the GNU General Public License Version 2 or later (the "GPL"), or 27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 | * in which case the provisions of the GPL or the LGPL are applicable instead 29 | * of those above. If you wish to allow use of your version of this file only 30 | * under the terms of either the GPL or the LGPL, and not to allow others to 31 | * use your version of this file under the terms of the MPL, indicate your 32 | * decision by deleting the provisions above and replace them with the notice 33 | * and other provisions required by the GPL or the LGPL. If you do not delete 34 | * the provisions above, a recipient may use your version of this file under 35 | * the terms of any one of the MPL, the GPL or the LGPL. 36 | * 37 | * ***** END LICENSE BLOCK ***** */ 38 | 39 | define(function(require, exports, module) { 40 | 41 | 42 | var env; 43 | 44 | var settings = { 45 | printMargin: { 46 | description: 'Position of the print margin column.', 47 | type: 'number', 48 | defaultValue: 80, 49 | onChange: function onChange(event) { 50 | if (env.editor) env.editor.setPrintMarginColumn(event.value); 51 | } 52 | }, 53 | showIvisibles: { 54 | description: 'Whether or not to show invisible characters.', 55 | type: 'boolean', 56 | defaultValue: false, 57 | onChange: function onChange(event) { 58 | if (env.editor) env.editor.setShowInvisibles(event.value); 59 | } 60 | }, 61 | highlightActiveLine: { 62 | description: 'Whether or not highlight active line.', 63 | type: 'boolean', 64 | defaultValue: true, 65 | onChange: function onChange(event) { 66 | if (env.editor) env.editor.setHighlightActiveLine(event.value); 67 | } 68 | }, 69 | selectionStyle: { 70 | description: 'Type of text selection.', 71 | type: { name: 'selection', data: [ 'line', 'text' ] }, 72 | defaultValue: 'line', 73 | onChange: function onChange(event) { 74 | if (env.editor) env.editor.setSelectionStyle(event.value); 75 | } 76 | } 77 | }; 78 | 79 | exports.startup = function startup(data) { 80 | env = data.env; 81 | data.env.settings.addSettings(settings); 82 | }; 83 | 84 | exports.shutdown = function shutdown(data) { 85 | data.env.settings.removeSettings(settings); 86 | }; 87 | 88 | }); 89 | -------------------------------------------------------------------------------- /lib/ace/mode/css_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var EditSession = require("ace/edit_session").EditSession; 45 | var CssMode = require("ace/mode/css").Mode; 46 | var assert = require("ace/test/assertions"); 47 | 48 | module.exports = { 49 | setUp : function() { 50 | this.mode = new CssMode(); 51 | }, 52 | 53 | "test: toggle comment lines should not do anything" : function() { 54 | var session = new EditSession([" abc", "cde", "fg"].join("\n")); 55 | 56 | var comment = this.mode.toggleCommentLines("start", session, 0, 1); 57 | assert.equal([" abc", "cde", "fg"].join("\n"), session.toString()); 58 | }, 59 | 60 | 61 | "test: lines should keep indentation" : function() { 62 | assert.equal(" ", this.mode.getNextLineIndent("start", " abc", " ")); 63 | assert.equal("\t", this.mode.getNextLineIndent("start", "\tabc", " ")); 64 | }, 65 | 66 | "test: new line after { should increase indent" : function() { 67 | assert.equal(" ", this.mode.getNextLineIndent("start", " abc{", " ")); 68 | assert.equal("\t ", this.mode.getNextLineIndent("start", "\tabc { ", " ")); 69 | }, 70 | 71 | "test: no indent increase after { in a comment" : function() { 72 | assert.equal(" ", this.mode.getNextLineIndent("start", " /*{", " ")); 73 | assert.equal(" ", this.mode.getNextLineIndent("start", " /*{ ", " ")); 74 | } 75 | }; 76 | 77 | }); 78 | 79 | if (typeof module !== "undefined" && module === require.main) { 80 | require("asyncjs/test").testcase(module.exports).exec() 81 | } -------------------------------------------------------------------------------- /lib/ace/renderloop.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var event = require("pilot/event"); 41 | 42 | var RenderLoop = function(onRender) { 43 | this.onRender = onRender; 44 | this.pending = false; 45 | this.changes = 0; 46 | }; 47 | 48 | (function() { 49 | 50 | this.schedule = function(change) { 51 | //this.onRender(change); 52 | //return; 53 | this.changes = this.changes | change; 54 | if (!this.pending) { 55 | this.pending = true; 56 | var _self = this; 57 | this.setTimeoutZero(function() { 58 | _self.pending = false; 59 | var changes = _self.changes; 60 | _self.changes = 0; 61 | _self.onRender(changes); 62 | }) 63 | } 64 | }; 65 | 66 | if (window.postMessage) { 67 | 68 | this.messageName = "zero-timeout-message"; 69 | 70 | this.setTimeoutZero = function(callback) { 71 | if (!this.attached) { 72 | var _self = this; 73 | event.addListener(window, "message", function(e) { 74 | if (_self.callback && e.data == _self.messageName) { 75 | event.stopPropagation(e); 76 | _self.callback(); 77 | } 78 | }); 79 | this.attached = true; 80 | } 81 | this.callback = callback; 82 | window.postMessage(this.messageName, "*"); 83 | } 84 | 85 | } else { 86 | 87 | this.setTimeoutZero = function(callback) { 88 | setTimeout(callback, 0); 89 | } 90 | } 91 | 92 | }).call(RenderLoop.prototype); 93 | 94 | exports.RenderLoop = RenderLoop; 95 | }); 96 | -------------------------------------------------------------------------------- /lib/ace/mode/svg.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var XmlMode = require("ace/mode/text").Mode; 42 | var JavaScriptMode = require("ace/mode/javascript").Mode; 43 | var Tokenizer = require("ace/tokenizer").Tokenizer; 44 | var SvgHighlightRules = require("ace/mode/svg_highlight_rules").SvgHighlightRules; 45 | 46 | var Mode = function() { 47 | this.$tokenizer = new Tokenizer(new SvgHighlightRules().getRules()); 48 | this.$js = new JavaScriptMode(); 49 | }; 50 | 51 | oop.inherits(Mode, XmlMode); 52 | 53 | (function() { 54 | 55 | this.toggleCommentLines = function(state, doc, startRow, endRow) { 56 | this.$delegate("toggleCommentLines", arguments, function() { 57 | return 0; 58 | }); 59 | }; 60 | 61 | this.getNextLineIndent = function(state, line, tab) { 62 | var self = this; 63 | return this.$delegate("getNextLineIndent", arguments, function() { 64 | return self.$getIndent(line); 65 | }); 66 | }; 67 | 68 | this.checkOutdent = function(state, line, input) { 69 | return this.$delegate("checkOutdent", arguments, function() { 70 | return false; 71 | }); 72 | }; 73 | 74 | this.autoOutdent = function(state, doc, row) { 75 | this.$delegate("autoOutdent", arguments); 76 | }; 77 | 78 | this.$delegate = function(method, args, defaultHandler) { 79 | var state = args[0]; 80 | var split = state.split("js-"); 81 | 82 | if (!split[0] && split[1]) { 83 | args[0] = split[1]; 84 | return this.$js[method].apply(this.$js, args); 85 | } 86 | 87 | return defaultHandler ? defaultHandler() : undefined; 88 | }; 89 | 90 | }).call(Mode.prototype); 91 | 92 | exports.Mode = Mode; 93 | }); 94 | -------------------------------------------------------------------------------- /lib/ace/worker/worker_client.js: -------------------------------------------------------------------------------- 1 | /* vim:ts=4:sts=4:sw=4: 2 | * 3 | * Ajax.org Code Editor (ACE) 4 | * 5 | * @copyright 2010, Ajax.org Services B.V. 6 | * @license LGPLv3 7 | * @author Fabian Jakobs 8 | */ 9 | 10 | define(function(require, exports, module) { 11 | 12 | var oop = require("pilot/oop"); 13 | var EventEmitter = require("pilot/event_emitter").EventEmitter; 14 | 15 | var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) { 16 | 17 | this.callbacks = []; 18 | 19 | if (require.packaged) { 20 | var base = this.$guessBasePath(); 21 | var worker = this.$worker = new Worker(base + packagedJs); 22 | } 23 | else { 24 | var workerUrl = require.nameToUrl("ace/worker/worker", null, "_"); 25 | var worker = this.$worker = new Worker(workerUrl); 26 | 27 | var tlns = {}; 28 | for (var i=0; i 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var CssMode = require("ace/mode/css").Mode; 45 | var assert = require("ace/test/assertions"); 46 | 47 | module.exports = { 48 | setUp : function() { 49 | this.tokenizer = new CssMode().getTokenizer(); 50 | }, 51 | 52 | "test: tokenize pixel number" : function() { 53 | var line = "-12px"; 54 | var tokens = this.tokenizer.getLineTokens(line, "start").tokens; 55 | 56 | assert.equal(1, tokens.length); 57 | assert.equal("constant.numeric", tokens[0].type); 58 | }, 59 | 60 | "test: tokenize hex3 color" : function() { 61 | var tokens = this.tokenizer.getLineTokens("#abc", "start").tokens; 62 | 63 | assert.equal(1, tokens.length); 64 | assert.equal("constant.numeric", tokens[0].type); 65 | }, 66 | 67 | "test: tokenize hex6 color" : function() { 68 | var tokens = this.tokenizer.getLineTokens("#abc012", "start").tokens; 69 | 70 | assert.equal(1, tokens.length); 71 | assert.equal("constant.numeric", tokens[0].type); 72 | }, 73 | 74 | "test: tokenize parens" : function() { 75 | var tokens = this.tokenizer.getLineTokens("{()}", "start").tokens; 76 | 77 | assert.equal(3, tokens.length); 78 | assert.equal("lparen", tokens[0].type); 79 | assert.equal("text", tokens[1].type); 80 | assert.equal("rparen", tokens[2].type); 81 | }, 82 | 83 | "test for last rule in ruleset to catch capturing group bugs" : function() { 84 | var tokens = this.tokenizer.getLineTokens("top", "start").tokens; 85 | 86 | assert.equal(1, tokens.length); 87 | assert.equal("support.type", tokens[0].type); 88 | } 89 | }; 90 | 91 | }); 92 | 93 | if (typeof module !== "undefined" && module === require.main) { 94 | require("asyncjs/test").testcase(module.exports).exec() 95 | } -------------------------------------------------------------------------------- /lib/ace/virtual_renderer_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../support/paths"); 40 | require("ace/test/mockdom"); 41 | } 42 | 43 | define(function(require, exports, module) { 44 | 45 | var EditSession = require("ace/edit_session").EditSession; 46 | var VirtualRenderer = require("ace/virtual_renderer").VirtualRenderer; 47 | var assert = require("ace/test/assertions"); 48 | 49 | module.exports = { 50 | "test: screen2text the column should be rounded to the next character edge" : function() { 51 | var el = document.createElement("div"); 52 | 53 | if (!el.getBoundingClientRect) { 54 | console.log("Skipping test: This test only runs in the browser"); 55 | return; 56 | } 57 | 58 | el.style.left = "0px"; 59 | el.style.top = "0px"; 60 | el.style.width = "100px"; 61 | el.style.height = "100px"; 62 | document.body.style.margin = "0px"; 63 | document.body.style.padding = "0px"; 64 | document.body.appendChild(el); 65 | 66 | var renderer = new VirtualRenderer(el); 67 | renderer.setPadding(0); 68 | renderer.setSession(new EditSession("1234")); 69 | 70 | renderer.characterWidth = 10; 71 | renderer.lineHeight = 15; 72 | 73 | assert.position(renderer.screenToTextCoordinates(0, 0), 0, 0); 74 | assert.position(renderer.screenToTextCoordinates(4, 0), 0, 0); 75 | assert.position(renderer.screenToTextCoordinates(5, 0), 0, 1); 76 | assert.position(renderer.screenToTextCoordinates(9, 0), 0, 1); 77 | assert.position(renderer.screenToTextCoordinates(10, 0), 0, 1); 78 | assert.position(renderer.screenToTextCoordinates(14, 0), 0, 1); 79 | assert.position(renderer.screenToTextCoordinates(15, 0), 0, 2); 80 | document.body.removeChild(el); 81 | } 82 | 83 | // change tab size after setDocument (for text layer) 84 | }; 85 | 86 | }); 87 | 88 | if (typeof module !== "undefined" && module === require.main) { 89 | require("asyncjs/test").testcase(module.exports).exec() 90 | } -------------------------------------------------------------------------------- /lib/ace/mode/textile_highlight_rules.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Kelley van Evert 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; 42 | 43 | var TextileHighlightRules = function() 44 | { 45 | /* 46 | var phraseModifiers = lang.arrayToMap( 47 | ("_|*|__|**|??|-|+|^|%|@").split("|") 48 | ); 49 | 50 | var blockModifiers = lang.arrayToMap( 51 | ("h1|h2|h3|h4|h5|h6|bq|p|bc|pre").split("|") 52 | ); 53 | */ 54 | /* 55 | var punctuation = lang.arrayToMap( 56 | ("-|--|(tm)|(r)|(c)").split("|") 57 | ); 58 | */ 59 | 60 | this.$rules = { 61 | "start" : [ 62 | { 63 | token : "keyword", // start of block 64 | regex : "h1|h2|h3|h4|h5|h6|bq|p|bc|pre", 65 | next : "blocktag" 66 | }, 67 | { 68 | token : "keyword", 69 | regex : "[\\*]+|[#]+" 70 | }, 71 | { 72 | token : "text", 73 | regex : ".+" 74 | } 75 | ], 76 | "blocktag" : [ 77 | { 78 | token : "keyword", 79 | regex : "\\. ", 80 | next : "start" 81 | }, 82 | { 83 | token : "keyword", 84 | regex : "\\(", 85 | next : "blocktagproperties" 86 | }, 87 | ], 88 | "blocktagproperties" : [ 89 | { 90 | token : "keyword", 91 | regex : "\\)", 92 | next : "blocktag" 93 | }, 94 | { 95 | token : "string", 96 | regex : "[a-zA-Z0-9\\-_]+" 97 | }, 98 | { 99 | token : "keyword", 100 | regex : "#" 101 | }, 102 | ] 103 | }; 104 | }; 105 | 106 | oop.inherits(TextileHighlightRules, TextHighlightRules); 107 | 108 | exports.TextileHighlightRules = TextileHighlightRules; 109 | 110 | }); 111 | -------------------------------------------------------------------------------- /lib/ace/mode/html_tokenizer_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var HtmlMode = require("ace/mode/html").Mode; 45 | var assert = require("ace/test/assertions"); 46 | 47 | module.exports = { 48 | setUp : function() { 49 | this.tokenizer = new HtmlMode().getTokenizer(); 50 | }, 51 | 52 | "test: tokenize embedded script" : function() { 53 | 54 | var line = "'123'"; 55 | var tokens = this.tokenizer.getLineTokens(line, "start").tokens; 56 | 57 | //assert.equal(10, tokens.length); 58 | assert.equal("text", tokens[0].type); 59 | assert.equal("keyword", tokens[1].type); 60 | assert.equal("text", tokens[2].type); 61 | assert.equal("keyword", tokens[3].type); 62 | assert.equal("text", tokens[4].type); 63 | assert.equal("string", tokens[5].type); 64 | assert.equal("text", tokens[6].type); 65 | assert.equal("keyword", tokens[7].type); 66 | assert.equal("text", tokens[8].type); 67 | assert.equal("keyword", tokens[9].type); 68 | assert.equal("text", tokens[10].type); 69 | }, 70 | 71 | "test: tokenize multiline attribute value with double quotes": function() { 72 | var line1 = this.tokenizer.getLineTokens('', line1.state).tokens; 75 | assert.equal(t1[t1.length-1].type, "string"); 76 | assert.equal(t2[0].type, "string"); 77 | }, 78 | 79 | "test: tokenize multiline attribute value with single quotes": function() { 80 | var line1 = this.tokenizer.getLineTokens('', line1.state).tokens; 83 | assert.equal(t1[t1.length-1].type, "string"); 84 | assert.equal(t2[0].type, "string"); 85 | } 86 | }; 87 | 88 | }); 89 | 90 | if (typeof module !== "undefined" && module === require.main) { 91 | require("asyncjs/test").testcase(module.exports).exec() 92 | } -------------------------------------------------------------------------------- /lib/ace/mode/coffee.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Satoshi Murakami 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var Tokenizer = require("ace/tokenizer").Tokenizer; 41 | var Rules = require("ace/mode/coffee_highlight_rules").CoffeeHighlightRules; 42 | var Outdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 43 | var Range = require("ace/range").Range; 44 | var TextMode = require("ace/mode/text").Mode; 45 | var oop = require("pilot/oop") 46 | 47 | function CoffeeMode() { 48 | this.$tokenizer = new Tokenizer(new Rules().getRules()); 49 | this.$outdent = new Outdent(); 50 | }; 51 | 52 | oop.inherits(CoffeeMode, TextMode); 53 | 54 | var proto = CoffeeMode.prototype; 55 | var indenter = /(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/; 56 | var commentLine = /^(\s*)#/; 57 | var hereComment = /^\s*###(?!#)/; 58 | var indentation = /^\s*/; 59 | 60 | proto.getNextLineIndent = function(state, line, tab) { 61 | var indent = this.$getIndent(line); 62 | var tokens = this.$tokenizer.getLineTokens(line, state).tokens; 63 | 64 | if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') && 65 | state === 'start' && indenter.test(line)) 66 | indent += tab; 67 | return indent; 68 | }; 69 | 70 | proto.toggleCommentLines = function(state, doc, startRow, endRow){ 71 | console.log("toggle"); 72 | var range = new Range(0, 0, 0, 0); 73 | for (var i = startRow; i <= endRow; ++i) { 74 | var line = doc.getLine(i); 75 | if (hereComment.test(line)) 76 | continue; 77 | 78 | if (commentLine.test(line)) 79 | line = line.replace(commentLine, '$1'); 80 | else 81 | line = line.replace(indentation, '$&#'); 82 | 83 | range.end.row = range.start.row = i; 84 | range.end.column = line.length + 1; 85 | doc.replace(range, line); 86 | } 87 | }; 88 | 89 | proto.checkOutdent = function(state, line, input) { 90 | return this.$outdent.checkOutdent(line, input); 91 | }; 92 | 93 | proto.autoOutdent = function(state, doc, row) { 94 | this.$outdent.autoOutdent(doc, row); 95 | }; 96 | 97 | exports.Mode = CoffeeMode; 98 | 99 | }); -------------------------------------------------------------------------------- /lib/ace/mode/html.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextMode = require("ace/mode/text").Mode; 42 | var JavaScriptMode = require("ace/mode/javascript").Mode; 43 | var CssMode = require("ace/mode/css").Mode; 44 | var Tokenizer = require("ace/tokenizer").Tokenizer; 45 | var HtmlHighlightRules = require("ace/mode/html_highlight_rules").HtmlHighlightRules; 46 | 47 | var Mode = function() { 48 | this.$tokenizer = new Tokenizer(new HtmlHighlightRules().getRules()); 49 | 50 | this.$js = new JavaScriptMode(); 51 | this.$css = new CssMode(); 52 | }; 53 | oop.inherits(Mode, TextMode); 54 | 55 | (function() { 56 | 57 | this.toggleCommentLines = function(state, doc, startRow, endRow) { 58 | this.$delegate("toggleCommentLines", arguments, function() { 59 | return 0; 60 | }); 61 | }; 62 | 63 | this.getNextLineIndent = function(state, line, tab) { 64 | var self = this; 65 | return this.$delegate("getNextLineIndent", arguments, function() { 66 | return self.$getIndent(line); 67 | }); 68 | }; 69 | 70 | this.checkOutdent = function(state, line, input) { 71 | return this.$delegate("checkOutdent", arguments, function() { 72 | return false; 73 | }); 74 | }; 75 | 76 | this.autoOutdent = function(state, doc, row) { 77 | this.$delegate("autoOutdent", arguments); 78 | }; 79 | 80 | this.$delegate = function(method, args, defaultHandler) { 81 | var state = args[0]; 82 | var split = state.split("js-"); 83 | 84 | if (!split[0] && split[1]) { 85 | args[0] = split[1]; 86 | return this.$js[method].apply(this.$js, args); 87 | } 88 | 89 | var split = state.split("css-"); 90 | if (!split[0] && split[1]) { 91 | args[0] = split[1]; 92 | return this.$css[method].apply(this.$css, args); 93 | } 94 | 95 | return defaultHandler ? defaultHandler() : undefined; 96 | }; 97 | 98 | }).call(Mode.prototype); 99 | 100 | exports.Mode = Mode; 101 | }); 102 | -------------------------------------------------------------------------------- /lib/ace/keyboard/keybinding/vim.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Mozilla Skywriter. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Mozilla. 18 | * Portions created by the Initial Developer are Copyright (C) 2009 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Julian Viereck (julian.viereck@gmail.com) 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var StateHandler = require("ace/keyboard/state_handler").StateHandler; 41 | var matchCharacterOnly = require("ace/keyboard/state_handler").matchCharacterOnly; 42 | 43 | var vimStates = { 44 | start: [ 45 | { 46 | key: "i", 47 | then: "insertMode" 48 | }, 49 | { 50 | regex: [ "([0-9]*)", "(k|up)" ], 51 | exec: "golineup", 52 | params: [ 53 | { 54 | name: "times", 55 | match: 1, 56 | type: "number", 57 | defaultValue: 1 58 | } 59 | ] 60 | }, 61 | { 62 | regex: [ "([0-9]*)", "(j|down|enter)" ], 63 | exec: "golinedown", 64 | params: [ 65 | { 66 | name: "times", 67 | match: 1, 68 | type: "number", 69 | defaultValue: 1 70 | } 71 | ] 72 | }, 73 | { 74 | regex: [ "([0-9]*)", "(l|right)" ], 75 | exec: "gotoright", 76 | params: [ 77 | { 78 | name: "times", 79 | match: 1, 80 | type: "number", 81 | defaultValue: 1 82 | } 83 | ] 84 | }, 85 | { 86 | regex: [ "([0-9]*)", "(h|left)" ], 87 | exec: "gotoleft", 88 | params: [ 89 | { 90 | name: "times", 91 | match: 1, 92 | type: "number", 93 | defaultValue: 1 94 | } 95 | ] 96 | }, 97 | { 98 | comment: "Catch some keyboard input to stop it here", 99 | match: matchCharacterOnly 100 | } 101 | ], 102 | insertMode: [ 103 | { 104 | key: "esc", 105 | then: "start" 106 | } 107 | ] 108 | }; 109 | 110 | exports.Vim = new StateHandler(vimStates); 111 | 112 | }); 113 | -------------------------------------------------------------------------------- /lib/ace/theme/eclipse.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var dom = require("pilot/dom"); 41 | 42 | var cssText = ".ace-eclipse .ace_editor {\ 43 | border: 2px solid rgb(159, 159, 159);\ 44 | }\ 45 | \ 46 | .ace-eclipse .ace_editor.ace_focus {\ 47 | border: 2px solid #327fbd;\ 48 | }\ 49 | \ 50 | .ace-eclipse .ace_gutter {\ 51 | width: 50px;\ 52 | background: rgb(227, 227, 227);\ 53 | border-right: 1px solid rgb(159, 159, 159); \ 54 | color: rgb(136, 136, 136);\ 55 | }\ 56 | \ 57 | .ace-eclipse .ace_gutter-layer {\ 58 | width: 100%;\ 59 | text-align: right;\ 60 | }\ 61 | \ 62 | .ace-eclipse .ace_gutter-layer .ace_gutter-cell {\ 63 | padding-right: 6px;\ 64 | }\ 65 | \ 66 | .ace-eclipse .ace_text-layer {\ 67 | cursor: text;\ 68 | }\ 69 | \ 70 | .ace-eclipse .ace_cursor {\ 71 | border-left: 1px solid black;\ 72 | }\ 73 | \ 74 | .ace-eclipse .ace_line .ace_keyword, .ace-eclipse .ace_line .ace_variable {\ 75 | color: rgb(127, 0, 85);\ 76 | }\ 77 | \ 78 | .ace-eclipse .ace_line .ace_constant.ace_buildin {\ 79 | color: rgb(88, 72, 246);\ 80 | }\ 81 | \ 82 | .ace-eclipse .ace_line .ace_constant.ace_library {\ 83 | color: rgb(6, 150, 14);\ 84 | }\ 85 | \ 86 | .ace-eclipse .ace_line .ace_function {\ 87 | color: rgb(60, 76, 114);\ 88 | }\ 89 | \ 90 | .ace-eclipse .ace_line .ace_string {\ 91 | color: rgb(42, 0, 255);\ 92 | }\ 93 | \ 94 | .ace-eclipse .ace_line .ace_comment {\ 95 | color: rgb(63, 127, 95);\ 96 | }\ 97 | \ 98 | .ace-eclipse .ace_line .ace_comment.ace_doc {\ 99 | color: rgb(63, 95, 191);\ 100 | }\ 101 | \ 102 | .ace-eclipse .ace_line .ace_comment.ace_doc.ace_tag {\ 103 | color: rgb(127, 159, 191);\ 104 | }\ 105 | \ 106 | .ace-eclipse .ace_line .ace_constant.ace_numeric {\ 107 | }\ 108 | \ 109 | .ace-eclipse .ace_line .ace_tag {\ 110 | color: rgb(63, 127, 127);\ 111 | }\ 112 | \ 113 | .ace-eclipse .ace_line .ace_xml_pe {\ 114 | color: rgb(104, 104, 91);\ 115 | }\ 116 | \ 117 | .ace-eclipse .ace_marker-layer .ace_selection {\ 118 | background: rgb(181, 213, 255);\ 119 | }\ 120 | \ 121 | .ace-eclipse .ace_marker-layer .ace_bracket {\ 122 | margin: -1px 0 0 -1px;\ 123 | border: 1px solid rgb(192, 192, 192);\ 124 | }\ 125 | \ 126 | .ace-eclipse .ace_marker-layer .ace_active_line {\ 127 | background: rgb(232, 242, 254);\ 128 | }"; 129 | 130 | // import CSS once 131 | dom.importCssString(cssText); 132 | 133 | exports.cssClass = "ace-eclipse"; 134 | }); 135 | -------------------------------------------------------------------------------- /lib/ace/keys.js: -------------------------------------------------------------------------------- 1 | /*! @license 2 | ========================================================================== 3 | SproutCore -- JavaScript Application Framework 4 | copyright 2006-2009, Sprout Systems Inc., Apple Inc. and contributors. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the "Software"), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | DEALINGS IN THE SOFTWARE. 23 | 24 | SproutCore and the SproutCore logo are trademarks of Sprout Systems, Inc. 25 | 26 | For more information about SproutCore, visit http://www.sproutcore.com 27 | 28 | 29 | ========================================================================== 30 | @license */ 31 | 32 | // Most of the following code is taken from SproutCore with a few changes. 33 | 34 | define(function(require, exports, module) { 35 | 36 | var oop = require("pilot/oop"); 37 | 38 | /** 39 | * Helper functions and hashes for key handling. 40 | */ 41 | var Keys = (function() { 42 | var ret = { 43 | MODIFIER_KEYS: { 44 | 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta' 45 | }, 46 | 47 | KEY_MODS: { 48 | "ctrl": 1, "alt": 2, "option" : 2, 49 | "shift": 4, "meta": 8, "command": 8 50 | }, 51 | 52 | FUNCTION_KEYS : { 53 | 8 : "Backspace", 54 | 9 : "Tab", 55 | 13 : "Return", 56 | 19 : "Pause", 57 | 27 : "Esc", 58 | 32 : "Space", 59 | 33 : "PageUp", 60 | 34 : "PageDown", 61 | 35 : "End", 62 | 36 : "Home", 63 | 37 : "Left", 64 | 38 : "Up", 65 | 39 : "Right", 66 | 40 : "Down", 67 | 44 : "Print", 68 | 45 : "Insert", 69 | 46 : "Delete", 70 | 112: "F1", 71 | 113: "F2", 72 | 114: "F3", 73 | 115: "F4", 74 | 116: "F5", 75 | 117: "F6", 76 | 118: "F7", 77 | 119: "F8", 78 | 120: "F9", 79 | 121: "F10", 80 | 122: "F11", 81 | 123: "F12", 82 | 144: "Numlock", 83 | 145: "Scrolllock" 84 | }, 85 | 86 | PRINTABLE_KEYS: { 87 | 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', 88 | 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a', 89 | 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h', 90 | 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o', 91 | 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v', 92 | 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.', 93 | 188: ',', 190: '.', 191: '/', 192: '`', 219: '[', 220: '\\', 94 | 221: ']', 222: '\"' 95 | } 96 | }; 97 | 98 | // A reverse map of FUNCTION_KEYS 99 | for (i in ret.FUNCTION_KEYS) { 100 | var name = ret.FUNCTION_KEYS[i].toUpperCase(); 101 | ret[name] = parseInt(i, 10); 102 | } 103 | 104 | // Add the MODIFIER_KEYS, FUNCTION_KEYS and PRINTABLE_KEYS to the KEY 105 | // variables as well. 106 | oop.mixin(ret, ret.MODIFIER_KEYS); 107 | oop.mixin(ret, ret.PRINTABLE_KEYS); 108 | oop.mixin(ret, ret.FUNCTION_KEYS); 109 | 110 | return ret; 111 | })(); 112 | oop.mixin(exports, Keys); 113 | 114 | exports.keyCodeToString = function(keyCode) { 115 | return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase(); 116 | }; 117 | 118 | }); 119 | -------------------------------------------------------------------------------- /lib/ace/mode/php.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * André Fiedler 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextMode = require("ace/mode/text").Mode; 42 | var Tokenizer = require("ace/tokenizer").Tokenizer; 43 | var PhpHighlightRules = require("ace/mode/php_highlight_rules").PhpHighlightRules; 44 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 45 | var Range = require("ace/range").Range; 46 | 47 | var Mode = function() { 48 | this.$tokenizer = new Tokenizer(new PhpHighlightRules().getRules()); 49 | this.$outdent = new MatchingBraceOutdent(); 50 | }; 51 | oop.inherits(Mode, TextMode); 52 | 53 | (function() { 54 | 55 | this.toggleCommentLines = function(state, doc, startRow, endRow) { 56 | var outdent = true; 57 | var outentedRows = []; 58 | var re = /^(\s*)#/; 59 | 60 | for (var i=startRow; i<= endRow; i++) { 61 | if (!re.test(doc.getLine(i))) { 62 | outdent = false; 63 | break; 64 | } 65 | } 66 | 67 | if (outdent) { 68 | var deleteRange = new Range(0, 0, 0, 0); 69 | for (var i=startRow; i<= endRow; i++) 70 | { 71 | var line = doc.getLine(i); 72 | var m = line.match(re); 73 | deleteRange.start.row = i; 74 | deleteRange.end.row = i; 75 | deleteRange.end.column = m[0].length; 76 | doc.replace(deleteRange, m[1]); 77 | } 78 | } 79 | else { 80 | doc.indentRows(startRow, endRow, "#"); 81 | } 82 | }; 83 | 84 | this.getNextLineIndent = function(state, line, tab) { 85 | var indent = this.$getIndent(line); 86 | 87 | var tokenizedLine = this.$tokenizer.getLineTokens(line, state); 88 | var tokens = tokenizedLine.tokens; 89 | var endState = tokenizedLine.state; 90 | 91 | if (tokens.length && tokens[tokens.length-1].type == "comment") { 92 | return indent; 93 | } 94 | 95 | if (state == "start") { 96 | var match = line.match(/^.*[\{\(\[\:]\s*$/); 97 | if (match) { 98 | indent += tab; 99 | } 100 | } 101 | 102 | return indent; 103 | }; 104 | 105 | this.checkOutdent = function(state, line, input) { 106 | return this.$outdent.checkOutdent(line, input); 107 | }; 108 | 109 | this.autoOutdent = function(state, doc, row) { 110 | this.$outdent.autoOutdent(doc, row); 111 | }; 112 | 113 | }).call(Mode.prototype); 114 | 115 | exports.Mode = Mode; 116 | }); 117 | -------------------------------------------------------------------------------- /lib/ace/mode/perl.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Panagiotis Astithas 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextMode = require("ace/mode/text").Mode; 42 | var Tokenizer = require("ace/tokenizer").Tokenizer; 43 | var PerlHighlightRules = require("ace/mode/perl_highlight_rules").PerlHighlightRules; 44 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 45 | var Range = require("ace/range").Range; 46 | 47 | var Mode = function() { 48 | this.$tokenizer = new Tokenizer(new PerlHighlightRules().getRules()); 49 | this.$outdent = new MatchingBraceOutdent(); 50 | }; 51 | oop.inherits(Mode, TextMode); 52 | 53 | (function() { 54 | 55 | this.toggleCommentLines = function(state, doc, startRow, endRow) { 56 | var outdent = true; 57 | var outentedRows = []; 58 | var re = /^(\s*)#/; 59 | 60 | for (var i=startRow; i<= endRow; i++) { 61 | if (!re.test(doc.getLine(i))) { 62 | outdent = false; 63 | break; 64 | } 65 | } 66 | 67 | if (outdent) { 68 | var deleteRange = new Range(0, 0, 0, 0); 69 | for (var i=startRow; i<= endRow; i++) 70 | { 71 | var line = doc.getLine(i); 72 | var m = line.match(re); 73 | deleteRange.start.row = i; 74 | deleteRange.end.row = i; 75 | deleteRange.end.column = m[0].length; 76 | doc.replace(deleteRange, m[1]); 77 | } 78 | } 79 | else { 80 | doc.indentRows(startRow, endRow, "#"); 81 | } 82 | }; 83 | 84 | this.getNextLineIndent = function(state, line, tab) { 85 | var indent = this.$getIndent(line); 86 | 87 | var tokenizedLine = this.$tokenizer.getLineTokens(line, state); 88 | var tokens = tokenizedLine.tokens; 89 | var endState = tokenizedLine.state; 90 | 91 | if (tokens.length && tokens[tokens.length-1].type == "comment") { 92 | return indent; 93 | } 94 | 95 | if (state == "start") { 96 | var match = line.match(/^.*[\{\(\[\:]\s*$/); 97 | if (match) { 98 | indent += tab; 99 | } 100 | } 101 | 102 | return indent; 103 | }; 104 | 105 | this.checkOutdent = function(state, line, input) { 106 | return this.$outdent.checkOutdent(line, input); 107 | }; 108 | 109 | this.autoOutdent = function(state, doc, row) { 110 | this.$outdent.autoOutdent(doc, row); 111 | }; 112 | 113 | }).call(Mode.prototype); 114 | 115 | exports.Mode = Mode; 116 | }); 117 | -------------------------------------------------------------------------------- /lib/ace/keyboard/hash_handler.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Mozilla Skywriter. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Mozilla. 18 | * Portions created by the Initial Developer are Copyright (C) 2009 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * Julian Viereck (julian.viereck@gmail.com) 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * either the GNU General Public License Version 2 or later (the "GPL"), or 27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 | * in which case the provisions of the GPL or the LGPL are applicable instead 29 | * of those above. If you wish to allow use of your version of this file only 30 | * under the terms of either the GPL or the LGPL, and not to allow others to 31 | * use your version of this file under the terms of the MPL, indicate your 32 | * decision by deleting the provisions above and replace them with the notice 33 | * and other provisions required by the GPL or the LGPL. If you do not delete 34 | * the provisions above, a recipient may use your version of this file under 35 | * the terms of any one of the MPL, the GPL or the LGPL. 36 | * 37 | * ***** END LICENSE BLOCK ***** */ 38 | 39 | define(function(require, exports, module) { 40 | 41 | var keyUtil = require("ace/keys"); 42 | 43 | function HashHandler(config) { 44 | this.setConfig(config); 45 | } 46 | 47 | (function() { 48 | function splitSafe(s, separator, limit, bLowerCase) { 49 | return (bLowerCase && s.toLowerCase() || s) 50 | .replace(/(?:^\s+|\n|\s+$)/g, "") 51 | .split(new RegExp("[\\s ]*" + separator + "[\\s ]*", "g"), limit || 999); 52 | } 53 | 54 | function parseKeys(keys, val, ret) { 55 | var key, 56 | hashId = 0, 57 | parts = splitSafe(keys, "\\-", null, true), 58 | i = 0, 59 | l = parts.length; 60 | 61 | for (; i < l; ++i) { 62 | if (keyUtil.KEY_MODS[parts[i]]) 63 | hashId = hashId | keyUtil.KEY_MODS[parts[i]]; 64 | else 65 | key = parts[i] || "-"; //when empty, the splitSafe removed a '-' 66 | } 67 | 68 | (ret[hashId] || (ret[hashId] = {}))[key] = val; 69 | return ret; 70 | } 71 | 72 | function objectReverse(obj, keySplit) { 73 | var i, j, l, key, 74 | ret = {}; 75 | for (i in obj) { 76 | key = obj[i]; 77 | if (keySplit && typeof key == "string") { 78 | key = key.split(keySplit); 79 | for (j = 0, l = key.length; j < l; ++j) 80 | parseKeys.call(this, key[j], i, ret); 81 | } 82 | else { 83 | parseKeys.call(this, key, i, ret); 84 | } 85 | } 86 | return ret; 87 | } 88 | 89 | this.setConfig = function(config) { 90 | this.$config = config; 91 | if (typeof this.$config.reverse == "undefined") 92 | this.$config.reverse = objectReverse.call(this, this.$config, "|"); 93 | }; 94 | 95 | /** 96 | * This function is called by keyBinding. 97 | */ 98 | this.handleKeyboard = function(data, hashId, textOrKey, keyCode) { 99 | // Figure out if a commandKey was pressed or just some text was insert. 100 | if (hashId != 0 || keyCode != 0) { 101 | return { 102 | command: (this.$config.reverse[hashId] || {})[textOrKey] 103 | }; 104 | } else { 105 | return { 106 | command: "inserttext", 107 | args: { 108 | text: textOrKey 109 | } 110 | }; 111 | } 112 | }; 113 | }).call(HashHandler.prototype); 114 | 115 | exports.HashHandler = HashHandler; 116 | }); 117 | -------------------------------------------------------------------------------- /lib/ace/mode/python.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * Colin Gourlay 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * either the GNU General Public License Version 2 or later (the "GPL"), or 27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 | * in which case the provisions of the GPL or the LGPL are applicable instead 29 | * of those above. If you wish to allow use of your version of this file only 30 | * under the terms of either the GPL or the LGPL, and not to allow others to 31 | * use your version of this file under the terms of the MPL, indicate your 32 | * decision by deleting the provisions above and replace them with the notice 33 | * and other provisions required by the GPL or the LGPL. If you do not delete 34 | * the provisions above, a recipient may use your version of this file under 35 | * the terms of any one of the MPL, the GPL or the LGPL. 36 | * 37 | * ***** END LICENSE BLOCK ***** */ 38 | 39 | define(function(require, exports, module) { 40 | 41 | var oop = require("pilot/oop"); 42 | var TextMode = require("ace/mode/text").Mode; 43 | var Tokenizer = require("ace/tokenizer").Tokenizer; 44 | var PythonHighlightRules = require("ace/mode/python_highlight_rules").PythonHighlightRules; 45 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 46 | var Range = require("ace/range").Range; 47 | 48 | var Mode = function() { 49 | this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules()); 50 | this.$outdent = new MatchingBraceOutdent(); 51 | }; 52 | oop.inherits(Mode, TextMode); 53 | 54 | (function() { 55 | 56 | this.toggleCommentLines = function(state, doc, startRow, endRow) { 57 | var outdent = true; 58 | var outentedRows = []; 59 | var re = /^(\s*)#/; 60 | 61 | for (var i=startRow; i<= endRow; i++) { 62 | if (!re.test(doc.getLine(i))) { 63 | outdent = false; 64 | break; 65 | } 66 | } 67 | 68 | if (outdent) { 69 | var deleteRange = new Range(0, 0, 0, 0); 70 | for (var i=startRow; i<= endRow; i++) 71 | { 72 | var line = doc.getLine(i); 73 | var m = line.match(re); 74 | deleteRange.start.row = i; 75 | deleteRange.end.row = i; 76 | deleteRange.end.column = m[0].length; 77 | doc.replace(deleteRange, m[1]); 78 | } 79 | } 80 | else { 81 | doc.indentRows(startRow, endRow, "#"); 82 | } 83 | }; 84 | 85 | this.getNextLineIndent = function(state, line, tab) { 86 | var indent = this.$getIndent(line); 87 | 88 | var tokenizedLine = this.$tokenizer.getLineTokens(line, state); 89 | var tokens = tokenizedLine.tokens; 90 | var endState = tokenizedLine.state; 91 | 92 | if (tokens.length && tokens[tokens.length-1].type == "comment") { 93 | return indent; 94 | } 95 | 96 | if (state == "start") { 97 | var match = line.match(/^.*[\{\(\[\:]\s*$/); 98 | if (match) { 99 | indent += tab; 100 | } 101 | } 102 | 103 | return indent; 104 | }; 105 | 106 | this.checkOutdent = function(state, line, input) { 107 | return this.$outdent.checkOutdent(line, input); 108 | }; 109 | 110 | this.autoOutdent = function(state, doc, row) { 111 | this.$outdent.autoOutdent(doc, row); 112 | }; 113 | 114 | }).call(Mode.prototype); 115 | 116 | exports.Mode = Mode; 117 | }); 118 | -------------------------------------------------------------------------------- /lib/ace/mode/ruby.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * Shlomo Zalman Heigh 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * either the GNU General Public License Version 2 or later (the "GPL"), or 27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 | * in which case the provisions of the GPL or the LGPL are applicable instead 29 | * of those above. If you wish to allow use of your version of this file only 30 | * under the terms of either the GPL or the LGPL, and not to allow others to 31 | * use your version of this file under the terms of the MPL, indicate your 32 | * decision by deleting the provisions above and replace them with the notice 33 | * and other provisions required by the GPL or the LGPL. If you do not delete 34 | * the provisions above, a recipient may use your version of this file under 35 | * the terms of any one of the MPL, the GPL or the LGPL. 36 | * 37 | * ***** END LICENSE BLOCK ***** */ 38 | 39 | define(function(require, exports, module) { 40 | 41 | var oop = require("pilot/oop"); 42 | var TextMode = require("ace/mode/text").Mode; 43 | var Tokenizer = require("ace/tokenizer").Tokenizer; 44 | var RubyHighlightRules = require("ace/mode/ruby_highlight_rules").RubyHighlightRules; 45 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 46 | var Range = require("ace/range").Range; 47 | 48 | var Mode = function() { 49 | this.$tokenizer = new Tokenizer(new RubyHighlightRules().getRules()); 50 | this.$outdent = new MatchingBraceOutdent(); 51 | }; 52 | oop.inherits(Mode, TextMode); 53 | 54 | (function() { 55 | 56 | this.toggleCommentLines = function(state, doc, startRow, endRow) { 57 | var outdent = true; 58 | var outentedRows = []; 59 | var re = /^(\s*)#/; 60 | 61 | for (var i=startRow; i<= endRow; i++) { 62 | if (!re.test(doc.getLine(i))) { 63 | outdent = false; 64 | break; 65 | } 66 | } 67 | 68 | if (outdent) { 69 | var deleteRange = new Range(0, 0, 0, 0); 70 | for (var i=startRow; i<= endRow; i++) 71 | { 72 | var line = doc.getLine(i); 73 | var m = line.match(re); 74 | deleteRange.start.row = i; 75 | deleteRange.end.row = i; 76 | deleteRange.end.column = m[0].length; 77 | doc.replace(deleteRange, m[1]); 78 | } 79 | } 80 | else { 81 | doc.indentRows(startRow, endRow, "#"); 82 | } 83 | }; 84 | 85 | this.getNextLineIndent = function(state, line, tab) { 86 | var indent = this.$getIndent(line); 87 | 88 | var tokenizedLine = this.$tokenizer.getLineTokens(line, state); 89 | var tokens = tokenizedLine.tokens; 90 | var endState = tokenizedLine.state; 91 | 92 | if (tokens.length && tokens[tokens.length-1].type == "comment") { 93 | return indent; 94 | } 95 | 96 | if (state == "start") { 97 | var match = line.match(/^.*[\{\(\[]\s*$/); 98 | if (match) { 99 | indent += tab; 100 | } 101 | } 102 | 103 | return indent; 104 | }; 105 | 106 | this.checkOutdent = function(state, line, input) { 107 | return this.$outdent.checkOutdent(line, input); 108 | }; 109 | 110 | this.autoOutdent = function(state, doc, row) { 111 | this.$outdent.autoOutdent(doc, row); 112 | }; 113 | 114 | }).call(Mode.prototype); 115 | 116 | exports.Mode = Mode; 117 | }); 118 | -------------------------------------------------------------------------------- /lib/ace/tokenizer.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var Tokenizer = function(rules) { 41 | this.rules = rules; 42 | 43 | this.regExps = {}; 44 | for ( var key in this.rules) { 45 | var rule = this.rules[key]; 46 | var state = rule; 47 | var ruleRegExps = []; 48 | 49 | for ( var i = 0; i < state.length; i++) 50 | ruleRegExps.push(state[i].regex); 51 | 52 | this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(") + ")|(.))", "g"); 53 | 54 | } 55 | }; 56 | 57 | (function() { 58 | 59 | this.getLineTokens = function(line, startState) { 60 | var currentState = startState; 61 | var state = this.rules[currentState]; 62 | var re = this.regExps[currentState]; 63 | re.lastIndex = 0; 64 | 65 | var match, tokens = []; 66 | 67 | var lastIndex = 0; 68 | 69 | var token = { 70 | type: null, 71 | value: "" 72 | }; 73 | 74 | while (match = re.exec(line)) { 75 | var type = "text"; 76 | var value = match[0]; 77 | 78 | for ( var i = 0; i < state.length; i++) { 79 | if (match[i + 1]) { 80 | var rule = state[i]; 81 | 82 | if (typeof rule.token == "function") 83 | type = rule.token(match[0]); 84 | else 85 | type = rule.token; 86 | 87 | if (rule.next && rule.next !== currentState) { 88 | currentState = rule.next; 89 | state = this.rules[currentState]; 90 | lastIndex = re.lastIndex; 91 | 92 | re = this.regExps[currentState]; 93 | re.lastIndex = lastIndex; 94 | } 95 | break; 96 | } 97 | }; 98 | 99 | 100 | if (token.type !== type) { 101 | if (token.type) 102 | tokens.push(token); 103 | 104 | token = { 105 | type: type, 106 | value: value 107 | }; 108 | } else { 109 | token.value += value; 110 | } 111 | 112 | if (lastIndex == line.length) 113 | break; 114 | 115 | lastIndex = re.lastIndex; 116 | }; 117 | 118 | if (token.type) 119 | tokens.push(token); 120 | 121 | return { 122 | tokens : tokens, 123 | state : currentState 124 | }; 125 | }; 126 | 127 | }).call(Tokenizer.prototype); 128 | 129 | exports.Tokenizer = Tokenizer; 130 | }); 131 | -------------------------------------------------------------------------------- /lib/ace/mode/javascript_tokenizer_test.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | if (typeof process !== "undefined") { 39 | require("../../../support/paths"); 40 | } 41 | 42 | define(function(require, exports, module) { 43 | 44 | var JavaScriptMode = require("ace/mode/javascript").Mode; 45 | var assert = require("ace/test/assertions"); 46 | 47 | module.exports = { 48 | setUp : function() { 49 | this.tokenizer = new JavaScriptMode().getTokenizer(); 50 | }, 51 | 52 | "test: tokenize1" : function() { 53 | var line = "foo = function"; 54 | 55 | var tokens = this.tokenizer.getLineTokens(line, "start").tokens; 56 | 57 | assert.equal(5, tokens.length); 58 | assert.equal("identifier", tokens[0].type); 59 | assert.equal("text", tokens[1].type); 60 | assert.equal("keyword.operator", tokens[2].type); 61 | assert.equal("text", tokens[3].type); 62 | assert.equal("keyword", tokens[4].type); 63 | }, 64 | 65 | "test: tokenize doc comment" : function() { 66 | var line = "abc /** de */ fg"; 67 | 68 | var tokens = this.tokenizer.getLineTokens(line, "start").tokens; 69 | 70 | assert.equal(5, tokens.length); 71 | assert.equal("identifier", tokens[0].type); 72 | assert.equal("text", tokens[1].type); 73 | assert.equal("comment.doc", tokens[2].type); 74 | assert.equal("text", tokens[3].type); 75 | assert.equal("identifier", tokens[4].type); 76 | }, 77 | 78 | "test: tokenize doc comment with tag" : function() { 79 | var line = "/** @param {} */"; 80 | 81 | var tokens = this.tokenizer.getLineTokens(line, "start").tokens; 82 | 83 | assert.equal(3, tokens.length); 84 | assert.equal("comment.doc", tokens[0].type); 85 | assert.equal("comment.doc.tag", tokens[1].type); 86 | assert.equal("comment.doc", tokens[2].type); 87 | }, 88 | 89 | "test: tokenize parens" : function() { 90 | var line = "[{( )}]"; 91 | 92 | var tokens = this.tokenizer.getLineTokens(line, "start").tokens; 93 | 94 | assert.equal(3, tokens.length); 95 | assert.equal("lparen", tokens[0].type); 96 | assert.equal("text", tokens[1].type); 97 | assert.equal("rparen", tokens[2].type); 98 | }, 99 | 100 | "test for last rule in ruleset to catch capturing group bugs" : function() { 101 | var tokens = this.tokenizer.getLineTokens("}", "start").tokens; 102 | 103 | assert.equal(1, tokens.length); 104 | assert.equal("rparen", tokens[0].type); 105 | }, 106 | 107 | "test tokenize regular expressions": function() { 108 | var tokens = this.tokenizer.getLineTokens("a/b/c", "start").tokens; 109 | assert.equal(5, tokens.length); 110 | } 111 | }; 112 | 113 | }); 114 | 115 | if (typeof module !== "undefined" && module === require.main) { 116 | require("asyncjs/test").testcase(module.exports).exec() 117 | } -------------------------------------------------------------------------------- /lib/ace/mode/xml_highlight_rules.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var oop = require("pilot/oop"); 41 | var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; 42 | 43 | var XmlHighlightRules = function() { 44 | 45 | // regexp must not have capturing parentheses 46 | // regexps are ordered -> the first match is used 47 | 48 | this.$rules = { 49 | start : [ { 50 | token : "text", 51 | regex : "<\\!\\[CDATA\\[", 52 | next : "cdata" 53 | }, { 54 | token : "xml_pe", 55 | regex : "<\\?.*?\\?>" 56 | }, { 57 | token : "comment", 58 | regex : "<\\!--", 59 | next : "comment" 60 | }, { 61 | token : "text", // opening tag 62 | regex : "<\\/?", 63 | next : "tag" 64 | }, { 65 | token : "text", 66 | regex : "\\s+" 67 | }, { 68 | token : "text", 69 | regex : "[^<]+" 70 | } ], 71 | 72 | tag : [ { 73 | token : "text", 74 | regex : ">", 75 | next : "start" 76 | }, { 77 | token : "keyword", 78 | regex : "[-_a-zA-Z0-9:]+" 79 | }, { 80 | token : "text", 81 | regex : "\\s+" 82 | }, { 83 | token : "string", 84 | regex : '".*?"' 85 | }, { 86 | token : "string", // multi line string start 87 | regex : '["].*$', 88 | next : "qqstring" 89 | }, { 90 | token : "string", 91 | regex : "'.*?'" 92 | }, { 93 | token : "string", // multi line string start 94 | regex : "['].*$", 95 | next : "qstring" 96 | }], 97 | 98 | qstring: [{ 99 | token : "string", 100 | regex : ".*'", 101 | next : "tag" 102 | }, { 103 | token : "string", 104 | regex : '.+' 105 | }], 106 | 107 | qqstring: [{ 108 | token : "string", 109 | regex : ".*\"", 110 | next : "tag" 111 | }, { 112 | token : "string", 113 | regex : '.+' 114 | }], 115 | 116 | cdata : [ { 117 | token : "text", 118 | regex : "\\]\\]>", 119 | next : "start" 120 | }, { 121 | token : "text", 122 | regex : "\\s+" 123 | }, { 124 | token : "text", 125 | regex : "(?:[^\\]]|\\](?!\\]>))+" 126 | } ], 127 | 128 | comment : [ { 129 | token : "comment", 130 | regex : ".*?-->", 131 | next : "start" 132 | }, { 133 | token : "comment", 134 | regex : ".+" 135 | } ] 136 | }; 137 | }; 138 | 139 | oop.inherits(XmlHighlightRules, TextHighlightRules); 140 | 141 | exports.XmlHighlightRules = XmlHighlightRules; 142 | }); 143 | -------------------------------------------------------------------------------- /lib/ace/mode/csharp_highlight_rules.js: -------------------------------------------------------------------------------- 1 | define(function(require, exports, module) { 2 | 3 | var oop = require("pilot/oop"); 4 | var lang = require("pilot/lang"); 5 | var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules; 6 | var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; 7 | 8 | var CSharpHighlightRules = function() { 9 | 10 | var docComment = new DocCommentHighlightRules(); 11 | var keywords = lang.arrayToMap( 12 | ("abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic").split("|") 13 | ); 14 | 15 | var buildinConstants = lang.arrayToMap( 16 | ("null|true|false").split("|") 17 | ); 18 | 19 | 20 | // regexp must not have capturing parentheses. Use (?:) instead. 21 | // regexps are ordered -> the first match is used 22 | 23 | this.$rules = { 24 | "start" : [ 25 | { 26 | token : "comment", 27 | regex : "\\/\\/.*$" 28 | }, 29 | docComment.getStartRule("doc-start"), 30 | { 31 | token : "comment", // multi line comment 32 | regex : "\\/\\*", 33 | next : "comment" 34 | }, { 35 | token : "comment", // multi line comment 36 | regex : "\\/\\*\\*", 37 | next : "comment" 38 | }, { 39 | token : "string.regexp", 40 | regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" 41 | }, { 42 | token : "string", // single line 43 | regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' 44 | }, { 45 | token : "string", // single line 46 | regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" 47 | }, { 48 | token : "constant.numeric", // hex 49 | regex : "0[xX][0-9a-fA-F]+\\b" 50 | }, { 51 | token : "constant.numeric", // float 52 | regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" 53 | }, { 54 | token : "constant.language.boolean", 55 | regex : "(?:true|false)\\b" 56 | }, { 57 | token : function(value) { 58 | if (value == "this") 59 | return "variable.language"; 60 | else if (keywords.hasOwnProperty(value)) 61 | return "keyword"; 62 | else if (buildinConstants.hasOwnProperty(value)) 63 | return "constant.language"; 64 | else 65 | return "identifier"; 66 | }, 67 | // TODO: Unicode escape sequences 68 | // TODO: Unicode identifiers 69 | regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" 70 | }, { 71 | token : "keyword.operator", 72 | regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" 73 | }, { 74 | token : "lparen", 75 | regex : "[[({]" 76 | }, { 77 | token : "rparen", 78 | regex : "[\\])}]" 79 | }, { 80 | token : "text", 81 | regex : "\\s+" 82 | } 83 | ], 84 | "comment" : [ 85 | { 86 | token : "comment", // closing comment 87 | regex : ".*?\\*\\/", 88 | next : "start" 89 | }, { 90 | token : "comment", // comment spanning whole line 91 | regex : ".+" 92 | } 93 | ], 94 | "qqstring" : [ 95 | { 96 | token : "string", 97 | regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', 98 | next : "start" 99 | }, { 100 | token : "string", 101 | regex : '.+' 102 | } 103 | ], 104 | "qstring" : [ 105 | { 106 | token : "string", 107 | regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", 108 | next : "start" 109 | }, { 110 | token : "string", 111 | regex : '.+' 112 | } 113 | ] 114 | }; 115 | 116 | this.addRules(docComment.getRules(), "doc-"); 117 | this.$rules["doc-start"][0].next = "start"; 118 | }; 119 | 120 | oop.inherits(CSharpHighlightRules, TextHighlightRules); 121 | 122 | exports.CSharpHighlightRules = CSharpHighlightRules; 123 | }); 124 | -------------------------------------------------------------------------------- /lib/ace/mode/c_cpp.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * Gastón Kleiman 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * either the GNU General Public License Version 2 or later (the "GPL"), or 27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 | * in which case the provisions of the GPL or the LGPL are applicable instead 29 | * of those above. If you wish to allow use of your version of this file only 30 | * under the terms of either the GPL or the LGPL, and not to allow others to 31 | * use your version of this file under the terms of the MPL, indicate your 32 | * decision by deleting the provisions above and replace them with the notice 33 | * and other provisions required by the GPL or the LGPL. If you do not delete 34 | * the provisions above, a recipient may use your version of this file under 35 | * the terms of any one of the MPL, the GPL or the LGPL. 36 | * 37 | * ***** END LICENSE BLOCK ***** */ 38 | 39 | define(function(require, exports, module) { 40 | 41 | var oop = require("pilot/oop"); 42 | var TextMode = require("ace/mode/text").Mode; 43 | var Tokenizer = require("ace/tokenizer").Tokenizer; 44 | var c_cppHighlightRules = require("ace/mode/c_cpp_highlight_rules").c_cppHighlightRules; 45 | var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; 46 | var Range = require("ace/range").Range; 47 | 48 | var Mode = function() { 49 | this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules()); 50 | this.$outdent = new MatchingBraceOutdent(); 51 | }; 52 | oop.inherits(Mode, TextMode); 53 | 54 | (function() { 55 | 56 | this.toggleCommentLines = function(state, doc, startRow, endRow) { 57 | var outdent = true; 58 | var outentedRows = []; 59 | var re = /^(\s*)\/\//; 60 | 61 | for (var i=startRow; i<= endRow; i++) { 62 | if (!re.test(doc.getLine(i))) { 63 | outdent = false; 64 | break; 65 | } 66 | } 67 | 68 | if (outdent) { 69 | var deleteRange = new Range(0, 0, 0, 0); 70 | for (var i=startRow; i<= endRow; i++) 71 | { 72 | var line = doc.getLine(i); 73 | var m = line.match(re); 74 | deleteRange.start.row = i; 75 | deleteRange.end.row = i; 76 | deleteRange.end.column = m[0].length; 77 | doc.replace(deleteRange, m[1]); 78 | } 79 | } 80 | else { 81 | doc.indentRows(startRow, endRow, "//"); 82 | } 83 | }; 84 | 85 | this.getNextLineIndent = function(state, line, tab) { 86 | var indent = this.$getIndent(line); 87 | 88 | var tokenizedLine = this.$tokenizer.getLineTokens(line, state); 89 | var tokens = tokenizedLine.tokens; 90 | var endState = tokenizedLine.state; 91 | 92 | if (tokens.length && tokens[tokens.length-1].type == "comment") { 93 | return indent; 94 | } 95 | 96 | if (state == "start") { 97 | var match = line.match(/^.*[\{\(\[]\s*$/); 98 | if (match) { 99 | indent += tab; 100 | } 101 | } else if (state == "doc-start") { 102 | if (endState == "start") { 103 | return ""; 104 | } 105 | var match = line.match(/^\s*(\/?)\*/); 106 | if (match) { 107 | if (match[1]) { 108 | indent += " "; 109 | } 110 | indent += "* "; 111 | } 112 | } 113 | 114 | return indent; 115 | }; 116 | 117 | this.checkOutdent = function(state, line, input) { 118 | return this.$outdent.checkOutdent(line, input); 119 | }; 120 | 121 | this.autoOutdent = function(state, doc, row) { 122 | this.$outdent.autoOutdent(doc, row); 123 | }; 124 | 125 | }).call(Mode.prototype); 126 | 127 | exports.Mode = Mode; 128 | }); 129 | -------------------------------------------------------------------------------- /lib/ace/commands/settings.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Skywriter. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Mozilla. 18 | * Portions created by the Initial Developer are Copyright (C) 2009 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Skywriter Team (skywriter@mozilla.com) 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | 41 | var gcli = require('gcli/index'); 42 | 43 | var pref = { 44 | metadata: { 45 | description: 'Commands for managing preferences' 46 | }, 47 | 48 | showMetadata: { 49 | description: 'Show preferences', 50 | params: [ 51 | { 52 | name: 'filter', 53 | type: 'string', 54 | description: 'Regex filter to show only some settings', 55 | defaultValue: null 56 | } 57 | ] 58 | }, 59 | show: function(filter) { 60 | var names = gcli.getEnvironment().settings.getSettingNames(); 61 | // first sort the settingsList based on the name 62 | names.sort(function(name1, name2) { 63 | return name1.localeCompare(name2); 64 | }); 65 | 66 | if (filter) { 67 | filter = new RegExp(filter); 68 | } 69 | 70 | var html = ''; 71 | names.forEach(function(name) { 72 | if (!filter || filter.test(name)) { 73 | var setting = gcli.getEnvironment().settings.getSetting(name); 74 | var url = 'https://wiki.mozilla.org/Labs/Skywriter/Settings#' + 75 | setting.name; 76 | html += '' + 80 | setting.name + 81 | ' = ' + 82 | setting.value + 83 | '
'; 84 | } 85 | }); 86 | 87 | return html; 88 | }, 89 | 90 | setMetadata: { 91 | description: 'Alter current settings', 92 | params: [ 93 | { 94 | name: 'setting', 95 | type: 'setting', 96 | description: 'The name of the setting to display or alter' 97 | }, 98 | { 99 | name: 'value', 100 | type: 'settingValue', 101 | description: 'The new value for the chosen setting' 102 | } 103 | ] 104 | }, 105 | set: function(setting, value) { 106 | setting.set(value); 107 | return 'Setting: ' + setting.name + ' = ' + setting.get(); 108 | }, 109 | 110 | resetMetadata: { 111 | description: 'Reset a preference to it\'s default values', 112 | params: [ 113 | { 114 | name: 'setting', 115 | type: 'setting', 116 | description: 'The name of the setting to return to defaults' 117 | } 118 | ] 119 | }, 120 | reset: function(setting) { 121 | setting.reset(); 122 | return 'Reset ' + setting.name + ' to default: ' + setting.value; 123 | } 124 | }; 125 | 126 | 127 | exports.startup = function() { 128 | gcli.addCommands(pref, 'pref'); 129 | }; 130 | 131 | exports.shutdown = function() { 132 | gcli.removeCommands(pref, 'pref'); 133 | }; 134 | 135 | 136 | }); 137 | -------------------------------------------------------------------------------- /lib/ace/theme/clouds.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | define(function(require, exports, module) { 39 | 40 | var dom = require("pilot/dom"); 41 | 42 | var cssText = ".ace-clouds .ace_editor {\ 43 | border: 2px solid rgb(159, 159, 159);\ 44 | }\ 45 | \ 46 | .ace-clouds .ace_editor.ace_focus {\ 47 | border: 2px solid #327fbd;\ 48 | }\ 49 | \ 50 | .ace-clouds .ace_gutter {\ 51 | width: 50px;\ 52 | background: #e8e8e8;\ 53 | color: #333;\ 54 | overflow : hidden;\ 55 | }\ 56 | \ 57 | .ace-clouds .ace_gutter-layer {\ 58 | width: 100%;\ 59 | text-align: right;\ 60 | }\ 61 | \ 62 | .ace-clouds .ace_gutter-layer .ace_gutter-cell {\ 63 | padding-right: 6px;\ 64 | }\ 65 | \ 66 | .ace-clouds .ace_print_margin {\ 67 | width: 1px;\ 68 | background: #e8e8e8;\ 69 | }\ 70 | \ 71 | .ace-clouds .ace_scroller {\ 72 | background-color: #FFFFFF;\ 73 | }\ 74 | \ 75 | .ace-clouds .ace_text-layer {\ 76 | cursor: text;\ 77 | color: #000000;\ 78 | }\ 79 | \ 80 | .ace-clouds .ace_cursor {\ 81 | border-left: 2px solid #000000;\ 82 | }\ 83 | \ 84 | .ace-clouds .ace_cursor.ace_overwrite {\ 85 | border-left: 0px;\ 86 | border-bottom: 1px solid #000000;\ 87 | }\ 88 | \ 89 | .ace-clouds .ace_marker-layer .ace_selection {\ 90 | background: #BDD5FC;\ 91 | }\ 92 | \ 93 | .ace-clouds .ace_marker-layer .ace_step {\ 94 | background: rgb(198, 219, 174);\ 95 | }\ 96 | \ 97 | .ace-clouds .ace_marker-layer .ace_bracket {\ 98 | margin: -1px 0 0 -1px;\ 99 | border: 1px solid #BFBFBF;\ 100 | }\ 101 | \ 102 | .ace-clouds .ace_marker-layer .ace_active_line {\ 103 | background: #FFFBD1;\ 104 | }\ 105 | \ 106 | \ 107 | .ace-clouds .ace_invisible {\ 108 | color: #BFBFBF;\ 109 | }\ 110 | \ 111 | .ace-clouds .ace_keyword {\ 112 | color:#AF956F;\ 113 | }\ 114 | \ 115 | .ace-clouds .ace_keyword.ace_operator {\ 116 | color:#484848;\ 117 | }\ 118 | \ 119 | .ace-clouds .ace_constant {\ 120 | \ 121 | }\ 122 | \ 123 | .ace-clouds .ace_constant.ace_language {\ 124 | color:#39946A;\ 125 | }\ 126 | \ 127 | .ace-clouds .ace_constant.ace_library {\ 128 | \ 129 | }\ 130 | \ 131 | .ace-clouds .ace_constant.ace_numeric {\ 132 | color:#46A609;\ 133 | }\ 134 | \ 135 | .ace-clouds .ace_invalid {\ 136 | background-color:#FF002A;\ 137 | }\ 138 | \ 139 | .ace-clouds .ace_invalid.ace_illegal {\ 140 | \ 141 | }\ 142 | \ 143 | .ace-clouds .ace_invalid.ace_deprecated {\ 144 | \ 145 | }\ 146 | \ 147 | .ace-clouds .ace_support {\ 148 | \ 149 | }\ 150 | \ 151 | .ace-clouds .ace_support.ace_function {\ 152 | color:#C52727;\ 153 | }\ 154 | \ 155 | .ace-clouds .ace_function.ace_buildin {\ 156 | \ 157 | }\ 158 | \ 159 | .ace-clouds .ace_string {\ 160 | color:#5D90CD;\ 161 | }\ 162 | \ 163 | .ace-clouds .ace_string.ace_regexp {\ 164 | \ 165 | }\ 166 | \ 167 | .ace-clouds .ace_comment {\ 168 | color:#BCC8BA;\ 169 | }\ 170 | \ 171 | .ace-clouds .ace_comment.ace_doc {\ 172 | \ 173 | }\ 174 | \ 175 | .ace-clouds .ace_comment.ace_doc.ace_tag {\ 176 | \ 177 | }\ 178 | \ 179 | .ace-clouds .ace_variable {\ 180 | \ 181 | }\ 182 | \ 183 | .ace-clouds .ace_variable.ace_language {\ 184 | \ 185 | }\ 186 | \ 187 | .ace-clouds .ace_xml_pe {\ 188 | \ 189 | }"; 190 | 191 | // import CSS once 192 | dom.importCssString(cssText); 193 | 194 | exports.cssClass = "ace-clouds"; 195 | }); -------------------------------------------------------------------------------- /lib/ace/css/editor.css: -------------------------------------------------------------------------------- 1 | .ace_editor { 2 | position: absolute; 3 | overflow: hidden; 4 | 5 | font-family: "Menlo", "Monaco", "Courier New", monospace; 6 | font-size: 12px; 7 | } 8 | 9 | .ace_scroller { 10 | position: absolute; 11 | overflow-x: scroll; 12 | overflow-y: hidden; 13 | } 14 | 15 | .ace_content { 16 | position: absolute; 17 | box-sizing: border-box; 18 | -moz-box-sizing: border-box; 19 | -webkit-box-sizing: border-box; 20 | } 21 | 22 | .ace_composition { 23 | position: absolute; 24 | background: #555; 25 | color: #DDD; 26 | z-index: 4; 27 | } 28 | 29 | .ace_gutter { 30 | position: absolute; 31 | overflow-x: hidden; 32 | overflow-y: hidden; 33 | height: 100%; 34 | } 35 | 36 | .ace_gutter-cell.ace_error { 37 | background-image: url("data:image/gif,GIF89a%10%00%10%00%D5%00%00%F5or%F5%87%88%F5nr%F4ns%EBmq%F5z%7F%DDJT%DEKS%DFOW%F1Yc%F2ah%CE(7%CE)8%D18E%DD%40M%F2KZ%EBU%60%F4%60m%DCir%C8%16(%C8%19*%CE%255%F1%3FR%F1%3FS%E6%AB%B5%CA%5DI%CEn%5E%F7%A2%9A%C9G%3E%E0a%5B%F7%89%85%F5yy%F6%82%80%ED%82%80%FF%BF%BF%E3%C4%C4%FF%FF%FF%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00%25%00%2C%00%00%00%00%10%00%10%00%00%06p%C0%92pH%2C%1A%8F%C8%D2H%93%E1d4%23%E4%88%D3%09mB%1DN%B48%F5%90%40%60%92G%5B%94%20%3E%22%D2%87%24%FA%20%24%C5%06A%00%20%B1%07%02B%A38%89X.v%17%82%11%13q%10%0Fi%24%0F%8B%10%7BD%12%0Ei%09%92%09%0EpD%18%15%24%0A%9Ci%05%0C%18F%18%0B%07%04%01%04%06%A0H%18%12%0D%14%0D%12%A1I%B3%B4%B5IA%00%3B"); 38 | background-repeat: no-repeat; 39 | background-position: 4px center; 40 | } 41 | 42 | .ace_gutter-cell.ace_warning { 43 | background-image: url("data:image/gif,GIF89a%10%00%10%00%D5%00%00%FF%DBr%FF%DE%81%FF%E2%8D%FF%E2%8F%FF%E4%96%FF%E3%97%FF%E5%9D%FF%E6%9E%FF%EE%C1%FF%C8Z%FF%CDk%FF%D0s%FF%D4%81%FF%D5%82%FF%D5%83%FF%DC%97%FF%DE%9D%FF%E7%B8%FF%CCl%7BQ%13%80U%15%82W%16%81U%16%89%5B%18%87%5B%18%8C%5E%1A%94d%1D%C5%83-%C9%87%2F%C6%84.%C6%85.%CD%8B2%C9%871%CB%8A3%CD%8B5%DC%98%3F%DF%9BB%E0%9CC%E1%A5U%CB%871%CF%8B5%D1%8D6%DB%97%40%DF%9AB%DD%99B%E3%B0p%E7%CC%AE%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00%2F%00%2C%00%00%00%00%10%00%10%00%00%06a%C0%97pH%2C%1A%8FH%A1%ABTr%25%87%2B%04%82%F4%7C%B9X%91%08%CB%99%1C!%26%13%84*iJ9(%15G%CA%84%14%01%1A%97%0C%03%80%3A%9A%3E%81%84%3E%11%08%B1%8B%20%02%12%0F%18%1A%0F%0A%03'F%1C%04%0B%10%16%18%10%0B%05%1CF%1D-%06%07%9A%9A-%1EG%1B%A0%A1%A0U%A4%A5%A6BA%00%3B"); 44 | background-repeat: no-repeat; 45 | background-position: 4px center; 46 | } 47 | 48 | .ace_editor .ace_sb { 49 | position: absolute; 50 | overflow-x: hidden; 51 | overflow-y: scroll; 52 | right: 0; 53 | } 54 | 55 | .ace_editor .ace_sb div { 56 | position: absolute; 57 | width: 1px; 58 | left: 0; 59 | } 60 | 61 | .ace_editor .ace_print_margin_layer { 62 | z-index: 0; 63 | position: absolute; 64 | overflow: hidden; 65 | margin: 0; 66 | left: 0; 67 | height: 100%; 68 | width: 100%; 69 | } 70 | 71 | .ace_editor .ace_print_margin { 72 | position: absolute; 73 | height: 100%; 74 | } 75 | 76 | .ace_editor textarea { 77 | position: fixed; 78 | z-index: -1; 79 | width: 10px; 80 | height: 30px; 81 | opacity: 0; 82 | background: transparent; 83 | appearance: none; 84 | border: none; 85 | resize: none; 86 | outline: none; 87 | overflow: hidden; 88 | } 89 | 90 | .ace_layer { 91 | z-index: 1; 92 | position: absolute; 93 | overflow: hidden; 94 | white-space: nowrap; 95 | height: 100%; 96 | width: 100%; 97 | } 98 | 99 | .ace_text-layer { 100 | font-family: Monaco, "Courier New", monospace; 101 | color: black; 102 | } 103 | 104 | .ace_cjk { 105 | display: inline-block; 106 | text-align: center; 107 | } 108 | 109 | .ace_cursor-layer { 110 | z-index: 4; 111 | cursor: text; 112 | pointer-events: none; 113 | } 114 | 115 | .ace_cursor { 116 | z-index: 4; 117 | position: absolute; 118 | } 119 | 120 | .ace_line { 121 | white-space: nowrap; 122 | } 123 | 124 | .ace_marker-layer { 125 | cursor: text; 126 | } 127 | 128 | .ace_marker-layer .ace_step { 129 | position: absolute; 130 | z-index: 3; 131 | } 132 | 133 | .ace_marker-layer .ace_selection { 134 | position: absolute; 135 | z-index: 4; 136 | } 137 | 138 | .ace_marker-layer .ace_bracket { 139 | position: absolute; 140 | z-index: 5; 141 | } 142 | 143 | .ace_marker-layer .ace_active_line { 144 | position: absolute; 145 | z-index: 2; 146 | } 147 | 148 | .ace_marker-layer .ace_selected_word { 149 | position: absolute; 150 | z-index: 6; 151 | box-sizing: border-box; 152 | -moz-box-sizing: border-box; 153 | -webkit-box-sizing: border-box; 154 | } 155 | 156 | .ace_dragging .ace_marker-layer, .ace_dragging .ace_text-layer { 157 | cursor: move; 158 | } 159 | -------------------------------------------------------------------------------- /lib/ace/layer/gutter.js: -------------------------------------------------------------------------------- 1 | /* vim:ts=4:sts=4:sw=4: 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is Ajax.org Code Editor (ACE). 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Ajax.org B.V. 19 | * Portions created by the Initial Developer are Copyright (C) 2010 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * Fabian Jakobs 24 | * Julian Viereck 25 | * 26 | * Alternatively, the contents of this file may be used under the terms of 27 | * either the GNU General Public License Version 2 or later (the "GPL"), or 28 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 29 | * in which case the provisions of the GPL or the LGPL are applicable instead 30 | * of those above. If you wish to allow use of your version of this file only 31 | * under the terms of either the GPL or the LGPL, and not to allow others to 32 | * use your version of this file under the terms of the MPL, indicate your 33 | * decision by deleting the provisions above and replace them with the notice 34 | * and other provisions required by the GPL or the LGPL. If you do not delete 35 | * the provisions above, a recipient may use your version of this file under 36 | * the terms of any one of the MPL, the GPL or the LGPL. 37 | * 38 | * ***** END LICENSE BLOCK ***** */ 39 | 40 | define(function(require, exports, module) { 41 | 42 | var dom = require("pilot/dom"); 43 | 44 | var Gutter = function(parentEl) { 45 | this.element = dom.createElement("div"); 46 | this.element.className = "ace_layer ace_gutter-layer"; 47 | parentEl.appendChild(this.element); 48 | 49 | this.$breakpoints = []; 50 | this.$annotations = []; 51 | this.$decorations = []; 52 | }; 53 | 54 | (function() { 55 | 56 | this.setSession = function(session) { 57 | this.session = session; 58 | }; 59 | 60 | this.addGutterDecoration = function(row, className){ 61 | if (!this.$decorations[row]) 62 | this.$decorations[row] = ""; 63 | this.$decorations[row] += " ace_" + className; 64 | }; 65 | 66 | this.removeGutterDecoration = function(row, className){ 67 | this.$decorations[row] = this.$decorations[row].replace(" ace_" + className, ""); 68 | }; 69 | 70 | this.setBreakpoints = function(rows) { 71 | this.$breakpoints = rows.concat(); 72 | }; 73 | 74 | this.setAnnotations = function(annotations) { 75 | // iterate over sparse array 76 | this.$annotations = []; 77 | for (var row in annotations) if (annotations.hasOwnProperty(row)) { 78 | var rowAnnotations = annotations[row]; 79 | if (!rowAnnotations) 80 | continue; 81 | 82 | var rowInfo = this.$annotations[row] = { 83 | text: [] 84 | }; 85 | for (var i=0; i", (i+1), "
"); 114 | } 115 | 116 | this.element = dom.rebuildWith(this.element, html.join("")); 117 | this.element.style.height = config.minHeight + "px"; 118 | }; 119 | 120 | }).call(Gutter.prototype); 121 | 122 | exports.Gutter = Gutter; 123 | 124 | }); 125 | -------------------------------------------------------------------------------- /lib/ace/layer/cursor.js: -------------------------------------------------------------------------------- 1 | /* vim:ts=4:sts=4:sw=4: 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is Ajax.org Code Editor (ACE). 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Ajax.org B.V. 19 | * Portions created by the Initial Developer are Copyright (C) 2010 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * Fabian Jakobs 24 | * Julian Viereck 25 | * 26 | * Alternatively, the contents of this file may be used under the terms of 27 | * either the GNU General Public License Version 2 or later (the "GPL"), or 28 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 29 | * in which case the provisions of the GPL or the LGPL are applicable instead 30 | * of those above. If you wish to allow use of your version of this file only 31 | * under the terms of either the GPL or the LGPL, and not to allow others to 32 | * use your version of this file under the terms of the MPL, indicate your 33 | * decision by deleting the provisions above and replace them with the notice 34 | * and other provisions required by the GPL or the LGPL. If you do not delete 35 | * the provisions above, a recipient may use your version of this file under 36 | * the terms of any one of the MPL, the GPL or the LGPL. 37 | * 38 | * ***** END LICENSE BLOCK ***** */ 39 | 40 | define(function(require, exports, module) { 41 | 42 | var dom = require("pilot/dom"); 43 | 44 | var Cursor = function(parentEl) { 45 | this.element = dom.createElement("div"); 46 | this.element.className = "ace_layer ace_cursor-layer"; 47 | parentEl.appendChild(this.element); 48 | 49 | this.cursor = dom.createElement("div"); 50 | this.cursor.className = "ace_cursor"; 51 | 52 | this.isVisible = false; 53 | }; 54 | 55 | (function() { 56 | 57 | this.setSession = function(session) { 58 | this.session = session; 59 | }; 60 | 61 | this.hideCursor = function() { 62 | this.isVisible = false; 63 | if (this.cursor.parentNode) { 64 | this.cursor.parentNode.removeChild(this.cursor); 65 | } 66 | clearInterval(this.blinkId); 67 | }; 68 | 69 | this.showCursor = function() { 70 | this.isVisible = true; 71 | this.element.appendChild(this.cursor); 72 | 73 | var cursor = this.cursor; 74 | cursor.style.visibility = "visible"; 75 | this.restartTimer(); 76 | }; 77 | 78 | this.restartTimer = function() { 79 | clearInterval(this.blinkId); 80 | if (!this.isVisible) { 81 | return; 82 | } 83 | 84 | var cursor = this.cursor; 85 | this.blinkId = setInterval(function() { 86 | cursor.style.visibility = "hidden"; 87 | setTimeout(function() { 88 | cursor.style.visibility = "visible"; 89 | }, 400); 90 | }, 1000); 91 | }; 92 | 93 | this.getPixelPosition = function(onScreen) { 94 | if (!this.config || !this.session) { 95 | return { 96 | left : 0, 97 | top : 0 98 | }; 99 | } 100 | 101 | var position = this.session.selection.getCursor(); 102 | var pos = this.session.documentToScreenPosition(position); 103 | var cursorLeft = Math.round(pos.column * this.config.characterWidth); 104 | var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) * 105 | this.config.lineHeight; 106 | 107 | return { 108 | left : cursorLeft, 109 | top : cursorTop 110 | }; 111 | }; 112 | 113 | this.update = function(config) { 114 | this.config = config; 115 | 116 | this.pixelPos = this.getPixelPosition(true); 117 | 118 | this.cursor.style.left = this.pixelPos.left + "px"; 119 | this.cursor.style.top = this.pixelPos.top + "px"; 120 | this.cursor.style.width = config.characterWidth + "px"; 121 | this.cursor.style.height = config.lineHeight + "px"; 122 | 123 | if (this.isVisible) { 124 | this.element.appendChild(this.cursor); 125 | } 126 | 127 | if (this.session.getOverwrite()) { 128 | dom.addCssClass(this.cursor, "ace_overwrite"); 129 | } else { 130 | dom.removeCssClass(this.cursor, "ace_overwrite"); 131 | } 132 | 133 | this.restartTimer(); 134 | }; 135 | 136 | }).call(Cursor.prototype); 137 | 138 | exports.Cursor = Cursor; 139 | 140 | }); 141 | -------------------------------------------------------------------------------- /support/requireJS-node.js: -------------------------------------------------------------------------------- 1 | var path = require("path"); 2 | var fs = require("fs"); 3 | var currentModule 4 | var defaultCompile = module.constructor.prototype._compile; 5 | 6 | module.constructor.prototype._compile = function(content, filename){ 7 | currentModule = this; 8 | try{ 9 | return defaultCompile.call(this, content, filename); 10 | } 11 | finally { 12 | currentModule = null; 13 | } 14 | }; 15 | 16 | var requireModule = module; 17 | 18 | global.define = function (id, injects, factory) { 19 | 20 | // infere the module 21 | var module = currentModule; 22 | if (!module) { 23 | module = requireModule; 24 | while (module.parent) 25 | module = module.parent; 26 | } 27 | 28 | // parse arguments 29 | if (!factory) { 30 | // two or less arguments 31 | factory = injects; 32 | if (factory) { 33 | // two args 34 | if (typeof id === "string") { 35 | if (id !== module.id) { 36 | throw new Error("Can not assign module to a different id than the current file"); 37 | } 38 | // default injects 39 | injects = []; 40 | } 41 | else{ 42 | // anonymous, deps included 43 | injects = id; 44 | } 45 | } 46 | else { 47 | // only one arg, just the factory 48 | factory = id; 49 | injects = []; 50 | } 51 | } 52 | 53 | var req = function(relativeId, callback) { 54 | if (Array.isArray(relativeId)) { 55 | // async require 56 | return callback.apply(this, relativeId.map(req)) 57 | } 58 | 59 | var chunks = relativeId.split("!"); 60 | if (chunks.length >= 2) { 61 | var prefix = chunks[0]; 62 | relativeId = chunks.slice(1).join("!") 63 | } 64 | 65 | if (relativeId.charAt(0) === '.') { 66 | var rootPath = path.dirname(path.dirname(requireModule.filename)) + "/", 67 | absolutePath = path.dirname(module.filename) + "/" + relativeId; 68 | 69 | relativeId = "../" + absolutePath.match(new RegExp(rootPath + "(.*)"))[1]; 70 | } 71 | 72 | if (prefix == "text") { 73 | return fs.readFileSync(findModulePath(relativeId)) 74 | } else 75 | return require(relativeId); 76 | }; 77 | 78 | injects.unshift("require", "exports", "module"); 79 | 80 | id = module.id; 81 | if (typeof factory !== "function") { 82 | // we can just provide a plain object 83 | return module.exports = factory; 84 | } 85 | var returned = factory.apply(module.exports, injects.map(function (injection) { 86 | switch (injection) { 87 | // check for CommonJS injection variables 88 | case "require": return req; 89 | case "exports": return module.exports; 90 | case "module": return module; 91 | default: 92 | // a module dependency 93 | return req(injection); 94 | } 95 | })); 96 | 97 | if(returned) { 98 | // since AMD encapsulates a function/callback, it can allow the factory to return the exports. 99 | module.exports = returned; 100 | } 101 | }; 102 | 103 | // slighly modified version of 104 | // https://github.com/ry/node/blob/1dad95a3a960c645ffec28f9ec023dad6a17c0d4/src/node.js#L159 105 | // 106 | // given a module name, and a list of paths to test, returns the first 107 | // matching file in the following precedence. 108 | // 109 | // require("a.") 110 | // -> a. 111 | // 112 | // require("a") 113 | // -> a 114 | // -> a. 115 | // -> a/index. 116 | function findModulePath(request) { 117 | var fs = require('fs'), 118 | exts = ["js"], 119 | paths = ['.'].concat(require.paths) 120 | 121 | paths = request.charAt(0) === '/' ? [''] : paths; 122 | 123 | // check if the file exists and is not a directory 124 | var tryFile = function(requestPath) { 125 | try { 126 | var stats = fs.statSync(requestPath); 127 | if (stats && !stats.isDirectory()) { 128 | return requestPath; 129 | } 130 | } catch (e) {} 131 | return false; 132 | }; 133 | 134 | // given a path check a the file exists with any of the set extensions 135 | var tryExtensions = function(p, extension) { 136 | for (var i = 0, EL = exts.length; i < EL; i++) { 137 | f = tryFile(p + exts[i]); 138 | if (f) { return f; } 139 | } 140 | return false; 141 | }; 142 | 143 | // For each path 144 | for (var i = 0, PL = paths.length; i < PL; i++) { 145 | var p = paths[i], 146 | // try to join the request to the path 147 | f = tryFile(path.join(p, request)) || 148 | // try it with each of the extensions 149 | tryExtensions(path.join(p, request)) || 150 | // try it with each of the extensions at "index" 151 | tryExtensions(path.join(p, request, 'index')); 152 | if (f) { return f; } 153 | } 154 | return false; 155 | } --------------------------------------------------------------------------------