├── packages ├── ace-editor │ ├── modules │ │ ├── assert.js │ │ └── ace │ │ │ └── worker │ │ │ └── worker_client.js │ ├── package.json │ ├── main.js │ └── demo.js ├── extjs-ace │ ├── lib │ │ ├── component.css │ │ └── component.js │ └── package.json ├── extjs3-ace │ ├── README.md │ ├── lib │ │ └── component.js │ └── package.json ├── extjs4-ace │ ├── README.md │ ├── lib │ │ └── component.js │ └── package.json └── ace-worker │ ├── package.json │ └── worker.js ├── .gitignore ├── www ├── ace │ ├── logo.png │ ├── icons │ │ ├── error_obj.gif │ │ ├── warning_obj.gif │ │ ├── Readme.txt │ │ └── epl.html │ ├── styles.css │ └── index.html ├── extjs3-ace │ ├── logo.png │ ├── styles.css │ └── index.html ├── extjs4-ace │ ├── logo.png │ ├── styles.css │ └── index.html └── index.html ├── docs └── images │ ├── screenshot_1.png │ └── screenshot_1_original.png ├── programs ├── extjs3-ace │ └── program.json ├── extjs4-ace │ └── program.json └── ace │ └── program.json ├── package.json ├── lib ├── build.js └── project.js ├── program.json ├── program.packages.json └── README.md /packages/ace-editor/modules/assert.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .tmp*~ 3 | .pinf-* 4 | *.local.* 5 | -------------------------------------------------------------------------------- /www/ace/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadorn/ace-extjs/HEAD/www/ace/logo.png -------------------------------------------------------------------------------- /www/extjs3-ace/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadorn/ace-extjs/HEAD/www/extjs3-ace/logo.png -------------------------------------------------------------------------------- /www/extjs4-ace/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadorn/ace-extjs/HEAD/www/extjs4-ace/logo.png -------------------------------------------------------------------------------- /docs/images/screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadorn/ace-extjs/HEAD/docs/images/screenshot_1.png -------------------------------------------------------------------------------- /www/ace/icons/error_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadorn/ace-extjs/HEAD/www/ace/icons/error_obj.gif -------------------------------------------------------------------------------- /www/ace/icons/warning_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadorn/ace-extjs/HEAD/www/ace/icons/warning_obj.gif -------------------------------------------------------------------------------- /docs/images/screenshot_1_original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadorn/ace-extjs/HEAD/docs/images/screenshot_1_original.png -------------------------------------------------------------------------------- /www/ace/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). -------------------------------------------------------------------------------- /packages/extjs-ace/lib/component.css: -------------------------------------------------------------------------------- 1 | 2 | .x-ux-ace-editor-panel { 3 | border-style: solid; 4 | border-width: 0; 5 | border-color: #99bbe8; 6 | background-color: #ffffff; 7 | } 8 | -------------------------------------------------------------------------------- /packages/extjs3-ace/README.md: -------------------------------------------------------------------------------- 1 | ExtJS 3 ACE Editor Component 2 | ============================ 3 | 4 | A component to wrap the ACE Editor for ExtJS 3. 5 | 6 | Notes 7 | ===== 8 | 9 | * The `ace`, `cockpit` and `pilot` mappings are needed in `./package.json` because the ACE plugin manager resolves 10 | plugin IDs against the program boot package (typically this package). 11 | -------------------------------------------------------------------------------- /packages/extjs4-ace/README.md: -------------------------------------------------------------------------------- 1 | ExtJS 4 ACE Editor Component 2 | ============================ 3 | 4 | A component to wrap the ACE Editor for ExtJS 4. 5 | 6 | Notes 7 | ===== 8 | 9 | * The `ace`, `cockpit` and `pilot` mappings are needed in `./package.json` because the ACE plugin manager resolves 10 | plugin IDs against the program boot package (typically this package). 11 | -------------------------------------------------------------------------------- /packages/extjs3-ace/lib/component.js: -------------------------------------------------------------------------------- 1 | 2 | module.declare(["extjs-ace/component"], function(require, exports, module) 3 | { 4 | var COMPONENT = require("extjs-ace/component"); 5 | 6 | exports.main = function() 7 | { 8 | COMPONENT.init(); 9 | 10 | var component = COMPONENT.getComponent(); 11 | 12 | Ext.ux.AceEditor = Ext.extend(Ext.BoxComponent, component); 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /programs/extjs3-ace/program.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": { 3 | "location": "../../program.packages.json" 4 | }, 5 | "boot": "github.com/cadorn/ace-extjs/packages/extjs3-ace/", 6 | "contexts": { 7 | "top": { 8 | "github.com/cadorn/ace-extjs/packages/extjs3-ace/": { 9 | }, 10 | "github.com/cadorn/ace-extjs/packages/ace-worker/@/worker": { 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /programs/extjs4-ace/program.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": { 3 | "location": "../../program.packages.json" 4 | }, 5 | "boot": "github.com/cadorn/ace-extjs/packages/extjs4-ace/", 6 | "contexts": { 7 | "top": { 8 | "github.com/cadorn/ace-extjs/packages/extjs4-ace/": { 9 | }, 10 | "github.com/cadorn/ace-extjs/packages/ace-worker/@/worker": { 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /packages/extjs4-ace/lib/component.js: -------------------------------------------------------------------------------- 1 | 2 | module.declare(["extjs-ace/component"], function(require, exports, module) 3 | { 4 | var COMPONENT = require("extjs-ace/component"); 5 | 6 | exports.main = function() 7 | { 8 | COMPONENT.init(); 9 | 10 | var component = COMPONENT.getComponent(); 11 | 12 | component.extend = "Ext.panel.Panel"; 13 | 14 | Ext.define("Ext.ux.AceEditor", component); 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /packages/ace-worker/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "uid": "http://github.com/cadorn/ace-extjs/packages/ace-worker/", 3 | "main": "worker.js", 4 | "directories": { 5 | "lib": "" 6 | }, 7 | "mappings": { 8 | "ace": { 9 | "id": "github.com/ajaxorg/ace/" 10 | }, 11 | "cockpit": { 12 | "id": "github.com/ajaxorg/cockpit/" 13 | }, 14 | "pilot": { 15 | "id": "github.com/ajaxorg/pilot/" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/extjs-ace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "uid": "http://github.com/cadorn/ace-extjs/packages/extjs-ace/", 3 | "name": "extjs-ace", 4 | "main": "", 5 | "contexts": { 6 | "top": { 7 | "/": { 8 | "load": { 9 | "github.com/cadorn/ace-extjs/packages/ace-editor/": {} 10 | } 11 | } 12 | } 13 | }, 14 | "mappings": { 15 | "editor": { 16 | "id": "github.com/cadorn/ace-extjs/packages/ace-editor/" 17 | }, 18 | "ace": { 19 | "id": "github.com/ajaxorg/ace/" 20 | }, 21 | "cockpit": { 22 | "id": "github.com/ajaxorg/cockpit/" 23 | }, 24 | "pilot": { 25 | "id": "github.com/ajaxorg/pilot/" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /www/extjs3-ace/styles.css: -------------------------------------------------------------------------------- 1 | 2 | #ace-editor-tests { 3 | font-family: Arial, Helvetica, sans-serif, Tahoma, Verdana, sans-serif; 4 | font-size: 12px; 5 | background: rgb(14, 98, 165); 6 | color: white; 7 | } 8 | 9 | #ace-editor-tests TD { 10 | padding: 3px; 11 | } 12 | 13 | #cockpitInput { 14 | position: absolute; 15 | width: 100%; 16 | bottom: 0; 17 | 18 | border: none; outline: none; 19 | font-family: consolas, courier, monospace; 20 | font-size: 120%; 21 | } 22 | 23 | #cockpitOutput { 24 | padding: 10px; 25 | margin: 0 15px; 26 | border: 1px solid #AAA; 27 | -moz-border-radius-topleft: 10px; 28 | -moz-border-radius-topright: 10px; 29 | border-top-left-radius: 4px; border-top-right-radius: 4px; 30 | background: #DDD; color: #000; 31 | } 32 | -------------------------------------------------------------------------------- /www/extjs4-ace/styles.css: -------------------------------------------------------------------------------- 1 | 2 | #ace-editor-tests { 3 | font-family: Arial, Helvetica, sans-serif, Tahoma, Verdana, sans-serif; 4 | font-size: 12px; 5 | background: rgb(14, 98, 165); 6 | color: white; 7 | } 8 | 9 | #ace-editor-tests TD { 10 | padding: 3px; 11 | } 12 | 13 | #cockpitInput { 14 | position: absolute; 15 | width: 100%; 16 | bottom: 0; 17 | 18 | border: none; outline: none; 19 | font-family: consolas, courier, monospace; 20 | font-size: 120%; 21 | } 22 | 23 | #cockpitOutput { 24 | padding: 10px; 25 | margin: 0 15px; 26 | border: 1px solid #AAA; 27 | -moz-border-radius-topleft: 10px; 28 | -moz-border-radius-topright: 10px; 29 | border-top-left-radius: 4px; border-top-right-radius: 4px; 30 | background: #DDD; color: #000; 31 | } 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ace-extjs", 3 | "engine": [ 4 | "node" 5 | ], 6 | "main": "lib/project.js", 7 | "scripts": { 8 | "build": { 9 | "location": "./", 10 | "module": "/lib/build.js" 11 | } 12 | }, 13 | "mappings": { 14 | "nodejs": { 15 | "id": "nodejs.org/" 16 | }, 17 | "pinf": { 18 | "id": "pinf.org/loader/" 19 | }, 20 | "jsgi": { 21 | "id": "github.com/kriszyp/jsgi-node/" 22 | }, 23 | "connect": { 24 | "id": "github.com/senchalabs/connect/" 25 | }, 26 | "extjs3": { 27 | "id": "sencha.com/products/extjs3" 28 | }, 29 | "extjs4": { 30 | "id": "sencha.com/products/extjs4" 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /packages/extjs3-ace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "uid": "http://github.com/cadorn/ace-extjs/packages/extjs3-ace/", 3 | "name": "extjs3-ace", 4 | "main": "lib/component.js", 5 | "contexts": { 6 | "top": { 7 | "/lib/component": { 8 | "include": { 9 | "github.com/cadorn/ace-extjs/packages/extjs-ace/": {} 10 | } 11 | } 12 | } 13 | }, 14 | "mappings": { 15 | "extjs-ace": { 16 | "id": "github.com/cadorn/ace-extjs/packages/extjs-ace/" 17 | }, 18 | "ace": { 19 | "id": "github.com/ajaxorg/ace/" 20 | }, 21 | "cockpit": { 22 | "id": "github.com/ajaxorg/cockpit/" 23 | }, 24 | "pilot": { 25 | "id": "github.com/ajaxorg/pilot/" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /packages/extjs4-ace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "uid": "http://github.com/cadorn/ace-extjs/packages/extjs4-ace/", 3 | "name": "extjs4-ace", 4 | "main": "lib/component.js", 5 | "contexts": { 6 | "top": { 7 | "/lib/component": { 8 | "include": { 9 | "github.com/cadorn/ace-extjs/packages/extjs-ace/": {} 10 | } 11 | } 12 | } 13 | }, 14 | "mappings": { 15 | "extjs-ace": { 16 | "id": "github.com/cadorn/ace-extjs/packages/extjs-ace/" 17 | }, 18 | "ace": { 19 | "id": "github.com/ajaxorg/ace/" 20 | }, 21 | "cockpit": { 22 | "id": "github.com/ajaxorg/cockpit/" 23 | }, 24 | "pilot": { 25 | "id": "github.com/ajaxorg/pilot/" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /programs/ace/program.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": { 3 | "location": "../../program.packages.json" 4 | }, 5 | "boot": "github.com/cadorn/ace-extjs/packages/ace-editor/", 6 | "contexts": { 7 | "top": { 8 | "github.com/cadorn/ace-extjs/packages/ace-editor/": {}, 9 | "github.com/cadorn/ace-extjs/packages/ace-worker/@/worker": {} 10 | } 11 | }, 12 | "packages": { 13 | "github.com/cadorn/ace-extjs/packages/ace-editor/": { 14 | "descriptor": { 15 | "contexts": { 16 | "top": { 17 | "/main": { 18 | "include": { 19 | "github.com/cadorn/ace-extjs/packages/ace-editor/@/demo": {} 20 | } 21 | } 22 | } 23 | } 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /packages/ace-editor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "uid": "http://github.com/cadorn/ace-extjs/packages/ace-editor/", 3 | "main": "main.js", 4 | "directories": { 5 | "lib": "" 6 | }, 7 | "contexts": { 8 | "top": { 9 | "/main": { 10 | "include": { 11 | "github.com/ajaxorg/pilot/@/lib/pilot/index": {}, 12 | "github.com/ajaxorg/ace/@/lib/ace/defaults": {}, 13 | "github.com/ajaxorg/cockpit/@/lib/cockpit/index": {}, 14 | "github.com/ajaxorg/ace/": {} 15 | } 16 | } 17 | } 18 | }, 19 | "mappings": { 20 | "worker": { 21 | "id": "github.com/cadorn/ace-extjs/packages/ace-worker/" 22 | }, 23 | "ace": { 24 | "id": "github.com/ajaxorg/ace/" 25 | }, 26 | "cockpit": { 27 | "id": "github.com/ajaxorg/cockpit/" 28 | }, 29 | "pilot": { 30 | "id": "github.com/ajaxorg/pilot/" 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /www/ace/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 | #cockpitInput { 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 | #cockpitOutput { 40 | padding: 10px; 41 | margin: 0 15px; 42 | border: 1px solid #AAA; 43 | -moz-border-radius-topleft: 10px; 44 | -moz-border-radius-topright: 10px; 45 | border-top-left-radius: 4px; border-top-right-radius: 4px; 46 | background: #DDD; color: #000; 47 | } -------------------------------------------------------------------------------- /lib/build.js: -------------------------------------------------------------------------------- 1 | 2 | var PATH = require("nodejs/path"), 3 | PROMISE = require("jsgi/promise"), 4 | PROGRAM_SERVER = require("pinf/program-server"); 5 | 6 | exports.main = function(env) 7 | { 8 | var server = new PROGRAM_SERVER.JSGI({ 9 | api: { 10 | PROMISE: PROMISE 11 | }, 12 | map: { 13 | "/ace/AceEditor.js": { 14 | programPath: PATH.dirname(PATH.dirname(module.id)) + "/programs/ace/program.json" 15 | }, 16 | "/extjs3-ace/Component.js": { 17 | programPath: PATH.dirname(PATH.dirname(module.id)) + "/programs/extjs3-ace/program.json" 18 | }, 19 | "/extjs4-ace/Component.js": { 20 | programPath: PATH.dirname(PATH.dirname(module.id)) + "/programs/extjs4-ace/program.json" 21 | } 22 | } 23 | }); 24 | 25 | server.spider("/ace/AceEditor.js", PATH.dirname(PATH.dirname(module.id)) + "/build"); 26 | server.spider("/extjs3-ace/Component.js", PATH.dirname(PATH.dirname(module.id)) + "/build"); 27 | server.spider("/extjs4-ace/Component.js", PATH.dirname(PATH.dirname(module.id)) + "/build"); 28 | } 29 | -------------------------------------------------------------------------------- /program.json: -------------------------------------------------------------------------------- 1 | { 2 | "boot": "project", 3 | "engine": [ 4 | "node" 5 | ], 6 | "packages": { 7 | "project": { 8 | "locator": { 9 | "location": "./" 10 | } 11 | }, 12 | "sencha.com/products/extjs3": { 13 | "locator": { 14 | "archive": "http://extjs.cachefly.net/ext-3.3.1.zip", 15 | "resource": true 16 | } 17 | }, 18 | "sencha.com/products/extjs4": { 19 | "locator": { 20 | "archive": "http://extjs.cachefly.net/ext-4.0.0-com.zip", 21 | "resource": true 22 | } 23 | }, 24 | "nodejs.org/": { 25 | "provider": "nodejs.org/" 26 | }, 27 | "pinf.org/loader/": { 28 | "provider": "pinf.org/loader/" 29 | }, 30 | "github.com/kriszyp/jsgi-node/": { 31 | "locator": { 32 | "archive": "https://github.com/kriszyp/jsgi-node/zipball/v0.2.4", 33 | "descriptor": { 34 | "uid": "https://github.com/kriszyp/jsgi-node/", 35 | "native": true 36 | } 37 | } 38 | }, 39 | "github.com/senchalabs/connect/": { 40 | "locator": { 41 | "name": "connect", 42 | "version": "1.6.2", 43 | "pm": "npm" 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 12 | 13 | 29 | 30 | 31 | 34 | 35 | 36 | 39 | 40 |
14 | ExtJS 3 Examples | 15 | ExtJS 4 Examples 16 |     17 | DEV: 18 | ACE Standalone | 19 | ACE on ExtJS 3 | 20 | ACE on ExtJS 4 21 |     22 | BUILD: 23 | ACE Standalone | 24 | ACE on ExtJS 3 | 25 | ACE on ExtJS 4 26 |     27 | Docs 28 |
32 | 33 |
37 | Project by Christoph Dorn facilitated by PINF. Copyright various parties. Various licenses in effect. 38 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /packages/ace-editor/main.js: -------------------------------------------------------------------------------- 1 | 2 | module.declare([ 3 | // required for this module 4 | "pilot/fixoldbrowsers", 5 | "pilot/plugin_manager", 6 | "pilot/settings", 7 | "pilot/environment", 8 | // preload typically used 9 | "pilot/canon", 10 | "pilot/event", 11 | "ace/editor", 12 | "ace/virtual_renderer", 13 | "ace/edit_session", 14 | "ace/undomanager", 15 | "ace/theme/textmate", 16 | "ace/mode/text" 17 | ], function(require, exports, module) 18 | { 19 | var env, 20 | launchCallback; 21 | exports.main = function() 22 | { 23 | exports.init(); 24 | } 25 | exports.init = function(callback) 26 | { 27 | var plugins = [ 28 | "pilot/index", 29 | "cockpit/index", 30 | "ace/defaults" 31 | ]; 32 | var catalog = require("pilot/plugin_manager").catalog; 33 | catalog.registerPlugins(plugins).then(function() 34 | { 35 | env = require("pilot/environment").create(); 36 | catalog.startupPlugins({ env: env }).then(function() 37 | { 38 | if (typeof callback != "undefined") 39 | callback(env); 40 | if (typeof launchCallback != "undefined") 41 | launchCallback(env); 42 | }); 43 | }); 44 | } 45 | exports.module = function(id) 46 | { 47 | return require(id); 48 | } 49 | exports.launch = function(callback) 50 | { 51 | if (typeof callback == "string") 52 | { 53 | if (callback == "demo") 54 | { 55 | callback = function(env) 56 | { 57 | module.load(require.id("./demo", true), function(id) 58 | { 59 | require(id).launch(env); 60 | }); 61 | } 62 | } 63 | else 64 | throw new Error("Unknown editor configuration: " + callback); 65 | } 66 | 67 | if (typeof env != "undefined") 68 | callback(env); 69 | else 70 | launchCallback = callback; 71 | } 72 | }); 73 | -------------------------------------------------------------------------------- /packages/ace-worker/worker.js: -------------------------------------------------------------------------------- 1 | 2 | module.declare(["pilot/event_emitter", "pilot/oop", "pilot/fixoldbrowsers"], function(require, exports, module) 3 | { 4 | exports.main = function() 5 | { 6 | var console = { 7 | log: function(msg) { 8 | postMessage({type: "log", data: msg}); 9 | } 10 | }; 11 | 12 | var window = { 13 | console: console 14 | }; 15 | 16 | function initSender() { 17 | 18 | var EventEmitter = require("pilot/event_emitter").EventEmitter; 19 | var oop = require("pilot/oop"); 20 | 21 | var Sender = function() {}; 22 | 23 | (function() { 24 | 25 | oop.implement(this, EventEmitter); 26 | 27 | this.callback = function(data, callbackId) { 28 | postMessage({ 29 | type: "call", 30 | id: callbackId, 31 | data: data 32 | }); 33 | }; 34 | 35 | this.emit = function(name, data) { 36 | postMessage({ 37 | type: "event", 38 | name: name, 39 | data: data 40 | }); 41 | }; 42 | 43 | }).call(Sender.prototype); 44 | 45 | return new Sender(); 46 | } 47 | 48 | onmessage = function(e) { 49 | var msg = e.data; 50 | if (msg.command) { 51 | main[msg.command].apply(main, msg.args); 52 | } 53 | else if (msg.init) { 54 | require("pilot/fixoldbrowsers"); 55 | sender = initSender(); 56 | 57 | module.load(require.id(msg.module, true), function(id) 58 | { 59 | var clazz = require(id)[msg.classname]; 60 | main = new clazz(sender); 61 | }); 62 | } 63 | else if (msg.event) { 64 | sender._dispatchEvent(msg.event, msg.data); 65 | } 66 | }; 67 | } 68 | }); 69 | -------------------------------------------------------------------------------- /packages/ace-editor/modules/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 | this.$worker = new Worker(require.uri("worker/worker.js")); 20 | 21 | this.$worker.postMessage({ 22 | init : true, 23 | module: module, 24 | classname: classname 25 | }); 26 | 27 | this.callbackId = 1; 28 | this.callbacks = {}; 29 | 30 | var _self = this; 31 | this.$worker.onerror = function(e) { 32 | window.console && console.log && console.log(e); 33 | throw e; 34 | }; 35 | this.$worker.onmessage = function(e) { 36 | var msg = e.data; 37 | switch(msg.type) { 38 | case "log": 39 | window.console && console.log && console.log(msg.data); 40 | break; 41 | 42 | case "event": 43 | _self._dispatchEvent(msg.name, {data: msg.data}); 44 | break; 45 | 46 | case "call": 47 | var callback = _self.callbacks[msg.id]; 48 | if (callback) { 49 | callback(msg.data); 50 | delete _self.callbacks[msg.id]; 51 | } 52 | break; 53 | } 54 | }; 55 | }; 56 | 57 | (function(){ 58 | 59 | oop.implement(this, EventEmitter); 60 | 61 | this.terminate = function() { 62 | this._dispatchEvent("terminate", {}); 63 | this.$worker.terminate(); 64 | }; 65 | 66 | this.send = function(cmd, args) { 67 | this.$worker.postMessage({command: cmd, args: args}); 68 | }; 69 | 70 | this.call = function(cmd, args, callback) { 71 | if (callback) { 72 | var id = this.callbackId++; 73 | this.callbacks[id] = callback; 74 | args.push(id); 75 | } 76 | this.send(cmd, args); 77 | }; 78 | 79 | this.emit = function(event, data) { 80 | this.$worker.postMessage({event: event, data: data}); 81 | }; 82 | 83 | }).call(WorkerClient.prototype); 84 | 85 | exports.WorkerClient = WorkerClient; 86 | 87 | }); 88 | -------------------------------------------------------------------------------- /lib/project.js: -------------------------------------------------------------------------------- 1 | 2 | var host = "localhost", 3 | port = 8003; 4 | 5 | var CONNECT = require("connect/connect"), 6 | PATH = require("nodejs/path"), 7 | PROMISE = require("jsgi/promise"), 8 | PROGRAM_SERVER = require("pinf/program-server"); 9 | 10 | exports.main = function() 11 | { 12 | module.print("\n\0cyan(\0bold(Welcome to the project server for the ACE Editor ExtJS Component!\0)\0)\n\n"); 13 | module.print("\0yellow(\0bold(Use your browser to navigate to: " + "http://" + host + ":" + port + "/" + "\0)\0)\n\n"); 14 | 15 | CONNECT() 16 | .use('/extjs3', CONNECT.static(require.pkg("extjs3").id(), { 17 | maxAge: 0 18 | })) 19 | .use('/extjs4', CONNECT.static(require.pkg("extjs4").id(), { 20 | maxAge: 0 21 | })) 22 | .use('/', CONNECT.static(PATH.dirname(PATH.dirname(module.id)) + "/www", { 23 | maxAge: 0 24 | })) 25 | .use('/build/', CONNECT.static(PATH.dirname(PATH.dirname(module.id)) + "/build", { 26 | maxAge: 0 27 | })) 28 | .use('/ace', jsgi(new PROGRAM_SERVER.JSGI({ 29 | api: { 30 | PROMISE: PROMISE 31 | }, 32 | map: { 33 | "/ace/AceEditor.js": { 34 | programPath: PATH.dirname(PATH.dirname(module.id)) + "/programs/ace/program.json" 35 | } 36 | }, 37 | trackRoutes: true 38 | }).responder(null))) 39 | .use('/extjs3-ace', jsgi(new PROGRAM_SERVER.JSGI({ 40 | api: { 41 | PROMISE: PROMISE 42 | }, 43 | map: { 44 | "/extjs3-ace/Component.js": { 45 | programPath: PATH.dirname(PATH.dirname(module.id)) + "/programs/extjs3-ace/program.json" 46 | } 47 | }, 48 | trackRoutes: true 49 | }).responder(null))) 50 | .use('/extjs4-ace', jsgi(new PROGRAM_SERVER.JSGI({ 51 | api: { 52 | PROMISE: PROMISE 53 | }, 54 | map: { 55 | "/extjs4-ace/Component.js": { 56 | programPath: PATH.dirname(PATH.dirname(module.id)) + "/programs/extjs4-ace/program.json" 57 | } 58 | }, 59 | trackRoutes: true 60 | }).responder(null))) 61 | .listen(port); 62 | } 63 | 64 | // TODO: This should move to https://github.com/senchalabs/connect/blob/master/lib/middleware/jsgi.js 65 | var jsgi = function jsgi(app, options) 66 | { 67 | options = options || {}; 68 | 69 | return function(req, res, next) 70 | { 71 | var env = { 72 | pathInfo: req.originalUrl, 73 | port: port, // TODO: This should come from req 74 | host: host // TODO: This should come from req 75 | }; 76 | 77 | var data = app(env); 78 | 79 | if (typeof data == "object") 80 | { 81 | if (typeof data.then == "function") 82 | { 83 | function handle(data) 84 | { 85 | res.statusCode = data.status; 86 | for (var name in data.headers) 87 | { 88 | // TODO: Camelcase names 89 | res.setHeader(name, data.headers[name]); 90 | } 91 | res.end(data.body.join("")); 92 | } 93 | data.then( 94 | handle, 95 | function (error) 96 | { 97 | module.print("Error: " + error.stack); 98 | handle({ status:500, headers:{}, body:[error.message] }); 99 | }, 100 | function (data) 101 | { 102 | throw new Error("NYI"); 103 | // @see https://github.com/kriszyp/jsgi-node/blob/v0.2.4/lib/jsgi-node.js#L128 104 | // TODO: handle(data, true); 105 | } 106 | ); 107 | return; 108 | } 109 | else 110 | throw new Error("NYI"); 111 | } 112 | else 113 | throw new Error("NYI"); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /program.packages.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": { 3 | "github.com/cadorn/ace-extjs/packages/extjs3-ace/": { 4 | "locator": { 5 | "location": "./packages/extjs3-ace" 6 | } 7 | }, 8 | "github.com/cadorn/ace-extjs/packages/extjs4-ace/": { 9 | "locator": { 10 | "location": "./packages/extjs4-ace" 11 | } 12 | }, 13 | "github.com/cadorn/ace-extjs/packages/extjs-ace/": { 14 | "locator": { 15 | "location": "./packages/extjs-ace" 16 | } 17 | }, 18 | "github.com/cadorn/ace-extjs/packages/ace-editor/": { 19 | "locator": { 20 | "location": "./packages/ace-editor" 21 | } 22 | }, 23 | "github.com/cadorn/ace-extjs/packages/ace-worker/": { 24 | "locator": { 25 | "location": "./packages/ace-worker" 26 | } 27 | }, 28 | "github.com/ajaxorg/ace/": { 29 | "locator": { 30 | "archive": "https://github.com/cadorn/ace/zipball/c13896a1e2ca93f912cba337dfe0faba3eb3fdb3" 31 | }, 32 | "descriptor": { 33 | "uid": "https://github.com/ajaxorg/ace/", 34 | "main": "", 35 | "directories": { 36 | "lib": "lib/ace" 37 | }, 38 | "contexts": { 39 | "top": { 40 | "/": { 41 | "include": { 42 | "/lib/ace/range": {}, 43 | "/lib/ace/tokenizer": {}, 44 | "/lib/ace/mode/text": {}, 45 | "/lib/ace/mode/matching_brace_outdent": {}, 46 | "/lib/ace/mode/doc_comment_highlight_rules": {} 47 | }, 48 | "load": { 49 | "/lib/ace/mode/*": {}, 50 | "/lib/ace/theme/*": {} 51 | } 52 | } 53 | } 54 | }, 55 | "modules": { 56 | "/lib/ace/worker/worker_client": { 57 | "id": "github.com/cadorn/ace-extjs/packages/ace-editor/", 58 | "module": "modules/ace/worker/worker_client" 59 | } 60 | }, 61 | "mappings": { 62 | "ace": { 63 | "id": "github.com/ajaxorg/ace/" 64 | }, 65 | "pilot": { 66 | "id": "github.com/ajaxorg/pilot/" 67 | }, 68 | "asyncjs": { 69 | "available": false 70 | } 71 | }, 72 | "dependencies": [ 73 | { 74 | "id": "github.com/cadorn/ace-extjs/packages/ace-editor/", 75 | "descriptor": { 76 | "directories": { 77 | "lib": "modules" 78 | } 79 | } 80 | } 81 | ] 82 | } 83 | }, 84 | "github.com/ajaxorg/cockpit/": { 85 | "locator": { 86 | "archive": "https://github.com/ajaxorg/cockpit/zipball/33f02ab3af5d755c98b3c58309ac2c62fc6de736" 87 | }, 88 | "descriptor": { 89 | "uid": "https://github.com/ajaxorg/cockpit/", 90 | "directories": { 91 | "lib": "lib/cockpit" 92 | }, 93 | "mappings": { 94 | "cockpit": { 95 | "id": "github.com/ajaxorg/cockpit/" 96 | }, 97 | "pilot": { 98 | "id": "github.com/ajaxorg/pilot/" 99 | } 100 | } 101 | } 102 | }, 103 | "github.com/ajaxorg/pilot/": { 104 | "locator": { 105 | "archive": "https://github.com/ajaxorg/pilot/zipball/ab8065643f28a1a4a3db30f6f68d378581397ff4" 106 | }, 107 | "descriptor": { 108 | "uid": "https://github.com/ajaxorg/pilot/", 109 | "directories": { 110 | "lib": "lib/pilot" 111 | }, 112 | "mappings": { 113 | "pilot": { 114 | "id": "github.com/ajaxorg/pilot/" 115 | } 116 | } 117 | } 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ACE Editor as ExtJS Component 2 | ============================= 3 | 4 | Status: alpha 5 | 6 | This project packages the [ACE Editor](http://ace.ajax.org/) as an [ExtJS](http://www.sencha.com/products/extjs/) component. 7 | 8 | ![Screenshot](https://github.com/cadorn/ace-extjs/raw/master/docs/images/screenshot_1.png) 9 | 10 | The [PINF JavaScript Loader](https://github.com/pinf/loader-js) is used to provide a development environment and package releases for this project. 11 | 12 | **NOTE:** It is assumed you have the _PINF JavaScript Loader_ mapped to the `commonjs` command and are using the `node` platform by default as explained [here](https://github.com/pinf/loader-js/blob/master/docs/Setup.md). 13 | 14 | Demo 15 | ==== 16 | 17 | commonjs -v https://github.com/cadorn/ace-extjs 18 | 19 | 20 | Development 21 | =========== 22 | 23 | git clone git://github.com/cadorn/ace-extjs.git 24 | cd ace-extjs 25 | commonjs -v ./ 26 | 27 | TODO 28 | ---- 29 | 30 | * Toolbar for editor component 31 | * Footer for editor component (line wrapping, caret position, read only, charset, ...) 32 | * Persist editor styling to survive reload 33 | * Better API Docs 34 | * ACE Command-line support 35 | * Fix ACE worker logic (see: [https://github.com/pinf/loader-js/tree/master/demos/ACE](https://github.com/pinf/loader-js/tree/master/demos/ACE)) 36 | 37 | 38 | Production 39 | ========== 40 | 41 | When using this component in production a build containing static files only should be used. 42 | 43 | Assuming `Development` setup (see above). 44 | 45 | commonjs --script build ./ 46 | 47 | This will bundle the component and store static files in [./build/](https://github.com/cadorn/ace-extjs/tree/master/build). 48 | 49 | To use on a page: 50 | 51 | // TODO: Include ExtJS CSS and JS files 52 | 58 | 59 | **NOTE:** The `bravojs.url` must be set to the same URL as used for the `SCRIPT` tag. 60 | 61 | See [./www/extjs3-ace/index.html](https://github.com/cadorn/ace-extjs/blob/master/www/extjs3-ace/index.html) for example. 62 | 63 | 64 | API 65 | === 66 | 67 | See implementation: [./packages/extjs3-ace/lib/component.js](https://github.com/cadorn/ace-extjs/blob/master/packages/extjs3-ace/lib/component.js) 68 | 69 | Usage example: [./www/extjs3-ace/index.html](https://github.com/cadorn/ace-extjs/blob/master/www/extjs3-ace/index.html) 70 | 71 | 72 | Support & Feedback 73 | ================== 74 | 75 | Please use github features for now. 76 | 77 | 78 | Contribute 79 | ========== 80 | 81 | Collaboration Platform: [https://github.com/cadorn/ace-extjs/](https://github.com/cadorn/ace-extjs/) 82 | 83 | Collaboration Process: 84 | 85 | 1. Send message to discuss your change 86 | 2. Write a patch on your own 87 | 3. Send pull request on github 88 | 4. Discuss pull request on github to refine 89 | 90 | You must explicitly license your patch by adding the following to the top of any file you modify 91 | in order for your patch to be accepted: 92 | 93 | // - , First Last , Copyright YYYY, MIT License 94 | 95 | 96 | Author 97 | ====== 98 | 99 | This project is maintained by [Christoph Dorn](http://www.christophdorn.com/). 100 | 101 | 102 | Credits 103 | ======= 104 | 105 | This project would not be possible without the following: 106 | 107 | * [ACE Editor](http://ace.ajax.org/) 108 | * [ExtJS](http://www.sencha.com/products/extjs/) 109 | * [PINF JavaScript Loader](https://github.com/pinf/loader-js) 110 | 111 | 112 | Documentation License 113 | ===================== 114 | 115 | [Creative Commons Attribution-NonCommercial-ShareAlike 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/) 116 | 117 | Copyright (c) 2011 [Christoph Dorn](http://www.christophdorn.com/) 118 | 119 | 120 | Code License 121 | ============ 122 | 123 | [MIT License](http://www.opensource.org/licenses/mit-license.php) 124 | 125 | Copyright (c) 2011 [Christoph Dorn](http://www.christophdorn.com/) 126 | 127 | Permission is hereby granted, free of charge, to any person obtaining a copy 128 | of this software and associated documentation files (the "Software"), to deal 129 | in the Software without restriction, including without limitation the rights 130 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 131 | copies of the Software, and to permit persons to whom the Software is 132 | furnished to do so, subject to the following conditions: 133 | 134 | The above copyright notice and this permission notice shall be included in 135 | all copies or substantial portions of the Software. 136 | 137 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 138 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 139 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 140 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 141 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 142 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 143 | THE SOFTWARE. 144 | -------------------------------------------------------------------------------- /packages/extjs-ace/lib/component.js: -------------------------------------------------------------------------------- 1 | 2 | module.declare(["pilot/dom", "text!./component.css"], function(require, exports, module) 3 | { 4 | var DOM = require("pilot/dom"); 5 | 6 | exports.init = function() 7 | { 8 | DOM.importCssString(require("text!./component.css")); 9 | } 10 | 11 | exports.getComponent = function() 12 | { 13 | return { 14 | 15 | baseCls: "x-ux-ace-editor-panel", 16 | 17 | initComponent: function() 18 | { 19 | Ext.ux.AceEditor.superclass.initComponent.call(this); 20 | var self = this; 21 | 22 | self.editorClass = null; 23 | self.initialized = false; 24 | self._editorLoaded = false; 25 | self._afterOnRender = false; 26 | 27 | self.value = null; 28 | self.editor = null; 29 | 30 | self.session = null; 31 | 32 | // async load editor 33 | module.load("editor/main", function(id) 34 | { 35 | self.editorClass = require(id); 36 | 37 | // init the editor 38 | self.editorClass.init(function(env) 39 | { 40 | var CANON = self.editorClass.module("pilot/canon"); 41 | 42 | self.addEvents( 43 | "editor-save", 44 | "editor-saveas" 45 | ); 46 | 47 | CANON.addCommand({ 48 | name: "save", 49 | bindKey: { 50 | win: "Ctrl-S", 51 | mac: "Command-S", 52 | sender: "editor|cli" 53 | }, 54 | exec: function() 55 | { 56 | self.fireEvent('editor-save', self); 57 | } 58 | }); 59 | 60 | CANON.addCommand({ 61 | name: "saveas", 62 | bindKey: { 63 | win: "Ctrl-Shift-S", 64 | mac: "Command-Shift-S", 65 | sender: "editor|cli" 66 | }, 67 | exec: function() 68 | { 69 | self.fireEvent('editor-saveas', self); 70 | } 71 | }); 72 | 73 | self._editorLoaded = true; 74 | if (self._afterOnRender && !self.initialized) 75 | self.firstRender(); 76 | }); 77 | }); 78 | 79 | if (typeof this.on === "function") 80 | { 81 | this.on("resize", function() 82 | { 83 | if(self.editor) { 84 | self.editor.resize(); 85 | } 86 | }); 87 | } 88 | }, 89 | 90 | firstRender: function() 91 | { 92 | var self = this; 93 | 94 | var EDITOR = self.editorClass.module("ace/editor").Editor, 95 | RENDERER = self.editorClass.module("ace/virtual_renderer").VirtualRenderer, 96 | THEME = self.editorClass.module("ace/theme/textmate"); // default 97 | // var EVENT = self.editorClass.module("pilot/event"); 98 | 99 | self.el.dom.innerHTML = ""; 100 | 101 | self.renderer = new RENDERER(self.el.dom, THEME); 102 | self.editor = new EDITOR(self.renderer); 103 | self.editor.resize(); 104 | 105 | self.initialized = true; 106 | 107 | if(self.value!==null) 108 | { 109 | self.setValue(self.value[0], self.value[1]); 110 | } 111 | }, 112 | 113 | onRender: function() 114 | { 115 | Ext.ux.AceEditor.superclass.onRender.apply(this, arguments); 116 | 117 | if (typeof this.el.addCls != "undefined") 118 | this.el.addCls(this.baseCls); // ExtJS 4 119 | else 120 | this.el.addClass(this.baseCls); // ExtJS 3 121 | 122 | if (!this.initialized) 123 | { 124 | // TODO: Make this look nicer 125 | this.el.dom.innerHTML = "Loading Editor ..."; 126 | } 127 | 128 | this._afterOnRender = true; 129 | if (this._editorLoaded && !this.initialized) 130 | this.firstRender(); 131 | }, 132 | 133 | getValue: function() 134 | { 135 | return this.editor.getDocument().getValue(); 136 | }, 137 | 138 | getEditor: function() 139 | { 140 | return this.editor; 141 | }, 142 | 143 | getSession: function() 144 | { 145 | return this.session; 146 | }, 147 | 148 | getRenderer: function() 149 | { 150 | return this.renderer; 151 | }, 152 | 153 | setValue: function(value, options) 154 | { 155 | if (!this.initialized) 156 | { 157 | this.value = [value, options]; 158 | return; 159 | } 160 | this.value = null; 161 | 162 | options = options || {}; 163 | 164 | var SESSION = this.editorClass.module("ace/edit_session").EditSession, 165 | UNDO_MANAGER = this.editorClass.module("ace/undomanager").UndoManager; 166 | 167 | var session = new SESSION(value); 168 | session.setUndoManager(new UNDO_MANAGER()); 169 | 170 | session.getDocument().addEventListener("changeDelta", function() 171 | { 172 | self.fireEvent('editor-changeDelta', self); 173 | }); 174 | 175 | var mode = "text"; 176 | if (typeof options.mode != "undefined") 177 | { 178 | mode = options.mode; 179 | } 180 | else 181 | { 182 | if(typeof options.basename != "undefined") 183 | { 184 | if (/^.*\.js$/i.test(options.basename)) { 185 | mode = "javascript"; 186 | } else if (/^.*\.xml$/i.test(options.basename)) { 187 | mode = "xml"; 188 | } else if (/^.*\.html?$/i.test(options.basename)) { 189 | mode = "html"; 190 | } else if (/^.*\.css$/i.test(options.basename)) { 191 | mode = "css"; 192 | } else if (/^.*\.py$/i.test(options.basename)) { 193 | mode = "python"; 194 | } else if (/^.*\.php$/i.test(options.basename)) { 195 | mode = "php"; 196 | } else if (/^.*\.cs$/i.test(options.basename)) { 197 | mode = "csharp"; 198 | } else if (/^.*\.java$/i.test(options.basename)) { 199 | mode = "java"; 200 | } else if (/^.*\.rb$/i.test(options.basename)) { 201 | mode = "ruby"; 202 | } else if (/^.*\.(c|cpp|h|hpp|cxx)$/i.test(options.basename)) { 203 | mode = "c_cpp"; 204 | } else if (/^.*\.coffee$/i.test(options.basename)) { 205 | mode = "coffee"; 206 | } else if (/^.*\.(pl|pm)$/i.test(options.basename)) { 207 | mode = "perl"; 208 | } 209 | } 210 | } 211 | 212 | var self = this; 213 | 214 | this.setMode(mode, { 215 | session: session, 216 | callback: function(session) 217 | { 218 | self.editor.setSession(session); 219 | 220 | self.session = session; 221 | 222 | if (typeof options.callback != "undefined") 223 | { 224 | options.callback(session); 225 | } 226 | } 227 | }); 228 | }, 229 | 230 | setMode: function(name, options) 231 | { 232 | // TODO: display loading message 233 | 234 | var self = this; 235 | 236 | var session = options.session || self.session; 237 | if (!session) 238 | throw new Error("Session required!"); 239 | 240 | // async load mode 241 | module.load("ace/mode/" + name, function(id) 242 | { 243 | var modeObj = new (require(id).Mode); 244 | session.setMode(modeObj); 245 | 246 | if (typeof options.callback != "undefined") 247 | { 248 | options.callback(session); 249 | } 250 | }); 251 | }, 252 | 253 | setTheme: function(name) 254 | { 255 | this.editor.setTheme("ace/theme/" + name); 256 | }, 257 | 258 | setKeyboardHandler: function(name, options) 259 | { 260 | if (name === null) 261 | { 262 | this.editor.setKeyboardHandler(null); 263 | return; 264 | } 265 | var self = this; 266 | 267 | // TODO: This should be done more generically 268 | var id = "ace/keyboard/keybinding/" + name; 269 | if (name == "hash_handler") { 270 | id = "ace/keyboard/" + name; 271 | } 272 | 273 | // async load keybinding 274 | module.load(id, function(id) 275 | { 276 | var obj = require(id); 277 | 278 | // TODO: This should be done more generically 279 | if (name == "vim") { 280 | obj = obj.Vim; 281 | } else 282 | if (name == "emacs") { 283 | obj = obj.Emacs; 284 | } else 285 | if (name == "hash_handler") { 286 | obj = new obj.HashHandler(options); 287 | } 288 | 289 | self.editor.setKeyboardHandler(obj); 290 | }); 291 | }, 292 | 293 | setFontSize: function(value) 294 | { 295 | this.el.dom.style.fontSize = value; 296 | } 297 | }; 298 | } 299 | }); 300 | -------------------------------------------------------------------------------- /www/ace/icons/epl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Eclipse Public License - Version 1.0 6 | 23 | 24 | 25 | 26 | 27 | 28 |

Eclipse Public License - v 1.0

29 | 30 |

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE 31 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR 32 | DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS 33 | AGREEMENT.

34 | 35 |

1. DEFINITIONS

36 | 37 |

"Contribution" means:

38 | 39 |

a) in the case of the initial Contributor, the initial 40 | code and documentation distributed under this Agreement, and

41 |

b) in the case of each subsequent Contributor:

42 |

i) changes to the Program, and

43 |

ii) additions to the Program;

44 |

where such changes and/or additions to the Program 45 | originate from and are distributed by that particular Contributor. A 46 | Contribution 'originates' from a Contributor if it was added to the 47 | Program by such Contributor itself or anyone acting on such 48 | Contributor's behalf. Contributions do not include additions to the 49 | Program which: (i) are separate modules of software distributed in 50 | conjunction with the Program under their own license agreement, and (ii) 51 | are not derivative works of the Program.

52 | 53 |

"Contributor" means any person or entity that distributes 54 | the Program.

55 | 56 |

"Licensed Patents" mean patent claims licensable by a 57 | Contributor which are necessarily infringed by the use or sale of its 58 | Contribution alone or when combined with the Program.

59 | 60 |

"Program" means the Contributions distributed in accordance 61 | with this Agreement.

62 | 63 |

"Recipient" means anyone who receives the Program under 64 | this Agreement, including all Contributors.

65 | 66 |

2. GRANT OF RIGHTS

67 | 68 |

a) Subject to the terms of this Agreement, each 69 | Contributor hereby grants Recipient a non-exclusive, worldwide, 70 | royalty-free copyright license to reproduce, prepare derivative works 71 | of, publicly display, publicly perform, distribute and sublicense the 72 | Contribution of such Contributor, if any, and such derivative works, in 73 | source code and object code form.

74 | 75 |

b) Subject to the terms of this Agreement, each 76 | Contributor hereby grants Recipient a non-exclusive, worldwide, 77 | royalty-free patent license under Licensed Patents to make, use, sell, 78 | offer to sell, import and otherwise transfer the Contribution of such 79 | Contributor, if any, in source code and object code form. This patent 80 | license shall apply to the combination of the Contribution and the 81 | Program if, at the time the Contribution is added by the Contributor, 82 | such addition of the Contribution causes such combination to be covered 83 | by the Licensed Patents. The patent license shall not apply to any other 84 | combinations which include the Contribution. No hardware per se is 85 | licensed hereunder.

86 | 87 |

c) Recipient understands that although each Contributor 88 | grants the licenses to its Contributions set forth herein, no assurances 89 | are provided by any Contributor that the Program does not infringe the 90 | patent or other intellectual property rights of any other entity. Each 91 | Contributor disclaims any liability to Recipient for claims brought by 92 | any other entity based on infringement of intellectual property rights 93 | or otherwise. As a condition to exercising the rights and licenses 94 | granted hereunder, each Recipient hereby assumes sole responsibility to 95 | secure any other intellectual property rights needed, if any. For 96 | example, if a third party patent license is required to allow Recipient 97 | to distribute the Program, it is Recipient's responsibility to acquire 98 | that license before distributing the Program.

99 | 100 |

d) Each Contributor represents that to its knowledge it 101 | has sufficient copyright rights in its Contribution, if any, to grant 102 | the copyright license set forth in this Agreement.

103 | 104 |

3. REQUIREMENTS

105 | 106 |

A Contributor may choose to distribute the Program in object code 107 | form under its own license agreement, provided that:

108 | 109 |

a) it complies with the terms and conditions of this 110 | Agreement; and

111 | 112 |

b) its license agreement:

113 | 114 |

i) effectively disclaims on behalf of all Contributors 115 | all warranties and conditions, express and implied, including warranties 116 | or conditions of title and non-infringement, and implied warranties or 117 | conditions of merchantability and fitness for a particular purpose;

118 | 119 |

ii) effectively excludes on behalf of all Contributors 120 | all liability for damages, including direct, indirect, special, 121 | incidental and consequential damages, such as lost profits;

122 | 123 |

iii) states that any provisions which differ from this 124 | Agreement are offered by that Contributor alone and not by any other 125 | party; and

126 | 127 |

iv) states that source code for the Program is available 128 | from such Contributor, and informs licensees how to obtain it in a 129 | reasonable manner on or through a medium customarily used for software 130 | exchange.

131 | 132 |

When the Program is made available in source code form:

133 | 134 |

a) it must be made available under this Agreement; and

135 | 136 |

b) a copy of this Agreement must be included with each 137 | copy of the Program.

138 | 139 |

Contributors may not remove or alter any copyright notices contained 140 | within the Program.

141 | 142 |

Each Contributor must identify itself as the originator of its 143 | Contribution, if any, in a manner that reasonably allows subsequent 144 | Recipients to identify the originator of the Contribution.

145 | 146 |

4. COMMERCIAL DISTRIBUTION

147 | 148 |

Commercial distributors of software may accept certain 149 | responsibilities with respect to end users, business partners and the 150 | like. While this license is intended to facilitate the commercial use of 151 | the Program, the Contributor who includes the Program in a commercial 152 | product offering should do so in a manner which does not create 153 | potential liability for other Contributors. Therefore, if a Contributor 154 | includes the Program in a commercial product offering, such Contributor 155 | ("Commercial Contributor") hereby agrees to defend and 156 | indemnify every other Contributor ("Indemnified Contributor") 157 | against any losses, damages and costs (collectively "Losses") 158 | arising from claims, lawsuits and other legal actions brought by a third 159 | party against the Indemnified Contributor to the extent caused by the 160 | acts or omissions of such Commercial Contributor in connection with its 161 | distribution of the Program in a commercial product offering. The 162 | obligations in this section do not apply to any claims or Losses 163 | relating to any actual or alleged intellectual property infringement. In 164 | order to qualify, an Indemnified Contributor must: a) promptly notify 165 | the Commercial Contributor in writing of such claim, and b) allow the 166 | Commercial Contributor to control, and cooperate with the Commercial 167 | Contributor in, the defense and any related settlement negotiations. The 168 | Indemnified Contributor may participate in any such claim at its own 169 | expense.

170 | 171 |

For example, a Contributor might include the Program in a commercial 172 | product offering, Product X. That Contributor is then a Commercial 173 | Contributor. If that Commercial Contributor then makes performance 174 | claims, or offers warranties related to Product X, those performance 175 | claims and warranties are such Commercial Contributor's responsibility 176 | alone. Under this section, the Commercial Contributor would have to 177 | defend claims against the other Contributors related to those 178 | performance claims and warranties, and if a court requires any other 179 | Contributor to pay any damages as a result, the Commercial Contributor 180 | must pay those damages.

181 | 182 |

5. NO WARRANTY

183 | 184 |

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS 185 | PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 186 | OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 187 | ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY 188 | OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely 189 | responsible for determining the appropriateness of using and 190 | distributing the Program and assumes all risks associated with its 191 | exercise of rights under this Agreement , including but not limited to 192 | the risks and costs of program errors, compliance with applicable laws, 193 | damage to or loss of data, programs or equipment, and unavailability or 194 | interruption of operations.

195 | 196 |

6. DISCLAIMER OF LIABILITY

197 | 198 |

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT 199 | NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, 200 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING 201 | WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF 202 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 203 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR 204 | DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 205 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

206 | 207 |

7. GENERAL

208 | 209 |

If any provision of this Agreement is invalid or unenforceable under 210 | applicable law, it shall not affect the validity or enforceability of 211 | the remainder of the terms of this Agreement, and without further action 212 | by the parties hereto, such provision shall be reformed to the minimum 213 | extent necessary to make such provision valid and enforceable.

214 | 215 |

If Recipient institutes patent litigation against any entity 216 | (including a cross-claim or counterclaim in a lawsuit) alleging that the 217 | Program itself (excluding combinations of the Program with other 218 | software or hardware) infringes such Recipient's patent(s), then such 219 | Recipient's rights granted under Section 2(b) shall terminate as of the 220 | date such litigation is filed.

221 | 222 |

All Recipient's rights under this Agreement shall terminate if it 223 | fails to comply with any of the material terms or conditions of this 224 | Agreement and does not cure such failure in a reasonable period of time 225 | after becoming aware of such noncompliance. If all Recipient's rights 226 | under this Agreement terminate, Recipient agrees to cease use and 227 | distribution of the Program as soon as reasonably practicable. However, 228 | Recipient's obligations under this Agreement and any licenses granted by 229 | Recipient relating to the Program shall continue and survive.

230 | 231 |

Everyone is permitted to copy and distribute copies of this 232 | Agreement, but in order to avoid inconsistency the Agreement is 233 | copyrighted and may only be modified in the following manner. The 234 | Agreement Steward reserves the right to publish new versions (including 235 | revisions) of this Agreement from time to time. No one other than the 236 | Agreement Steward has the right to modify this Agreement. The Eclipse 237 | Foundation is the initial Agreement Steward. The Eclipse Foundation may 238 | assign the responsibility to serve as the Agreement Steward to a 239 | suitable separate entity. Each new version of the Agreement will be 240 | given a distinguishing version number. The Program (including 241 | Contributions) may always be distributed subject to the version of the 242 | Agreement under which it was received. In addition, after a new version 243 | of the Agreement is published, Contributor may elect to distribute the 244 | Program (including its Contributions) under the new version. Except as 245 | expressly stated in Sections 2(a) and 2(b) above, Recipient receives no 246 | rights or licenses to the intellectual property of any Contributor under 247 | this Agreement, whether expressly, by implication, estoppel or 248 | otherwise. All rights in the Program not expressly granted under this 249 | Agreement are reserved.

250 | 251 |

This Agreement is governed by the laws of the State of New York and 252 | the intellectual property laws of the United States of America. No party 253 | to this Agreement will bring a legal action under this Agreement more 254 | than one year after the cause of action arose. Each party waives its 255 | rights to a jury trial in any resulting litigation.

256 | 257 | 258 | 259 | 260 | -------------------------------------------------------------------------------- /packages/ace-editor/demo.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 | * Kevin Dangoor (kdangoor@mozilla.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 | 40 | define(function(require, exports, module) { 41 | 42 | exports.launch = function(env) { 43 | var canon = require("pilot/canon"); 44 | var event = require("pilot/event"); 45 | var Editor = require("ace/editor").Editor; 46 | var Renderer = require("ace/virtual_renderer").VirtualRenderer; 47 | var theme = require("ace/theme/textmate"); 48 | var EditSession = require("ace/edit_session").EditSession; 49 | 50 | var JavaScriptMode = require("ace/mode/javascript").Mode; 51 | var CssMode = require("ace/mode/css").Mode; 52 | var HtmlMode = require("ace/mode/html").Mode; 53 | var XmlMode = require("ace/mode/xml").Mode; 54 | var PythonMode = require("ace/mode/python").Mode; 55 | var PhpMode = require("ace/mode/php").Mode; 56 | var JavaMode = require("ace/mode/java").Mode; 57 | var CSharpMode = require("ace/mode/csharp").Mode; 58 | var RubyMode = require("ace/mode/ruby").Mode; 59 | var CCPPMode = require("ace/mode/c_cpp").Mode; 60 | var CoffeeMode = require("ace/mode/coffee").Mode; 61 | var PerlMode = require("ace/mode/perl").Mode; 62 | var SvgMode = require("ace/mode/svg").Mode; 63 | var TextileMode = require("ace/mode/textile").Mode; 64 | var TextMode = require("ace/mode/text").Mode; 65 | var UndoManager = require("ace/undomanager").UndoManager; 66 | 67 | var vim = require("ace/keyboard/keybinding/vim").Vim; 68 | var emacs = require("ace/keyboard/keybinding/emacs").Emacs; 69 | var HashHandler = require("ace/keyboard/hash_handler").HashHandler; 70 | 71 | var keybindings = { 72 | // Null = use "default" keymapping 73 | ace: null, 74 | vim: vim, 75 | emacs: emacs, 76 | // This is a way to define simple keyboard remappings 77 | custom: new HashHandler({ 78 | "gotoright": "Tab" 79 | }) 80 | } 81 | 82 | var docs = {}; 83 | 84 | // Make the lorem ipsum text a little bit longer. 85 | var loreIpsum = document.getElementById("plaintext").innerHTML; 86 | for (var i = 0; i < 5; i++) { 87 | loreIpsum += loreIpsum; 88 | } 89 | docs.plain = new EditSession(loreIpsum); 90 | docs.plain.setUseWrapMode(true); 91 | docs.plain.setWrapLimitRange(80, 80) 92 | docs.plain.setMode(new TextMode()); 93 | docs.plain.setUndoManager(new UndoManager()); 94 | 95 | docs.js = new EditSession(document.getElementById("jstext").innerHTML); 96 | docs.js.setMode(new JavaScriptMode()); 97 | docs.js.setUndoManager(new UndoManager()); 98 | 99 | docs.css = new EditSession(document.getElementById("csstext").innerHTML); 100 | docs.css.setMode(new CssMode()); 101 | docs.css.setUndoManager(new UndoManager()); 102 | 103 | docs.html = new EditSession(document.getElementById("htmltext").innerHTML); 104 | docs.html.setMode(new HtmlMode()); 105 | docs.html.setUndoManager(new UndoManager()); 106 | 107 | docs.python = new EditSession(document.getElementById("pythontext").innerHTML); 108 | docs.python.setMode(new PythonMode()); 109 | docs.python.setUndoManager(new UndoManager()); 110 | 111 | docs.php = new EditSession(document.getElementById("phptext").innerHTML); 112 | docs.php.setMode(new PhpMode()); 113 | docs.php.setUndoManager(new UndoManager()); 114 | 115 | docs.java = new EditSession(document.getElementById("javatext").innerHTML); 116 | docs.java.setMode(new JavaMode()); 117 | docs.java.setUndoManager(new UndoManager()); 118 | 119 | docs.ruby = new EditSession(document.getElementById("rubytext").innerHTML); 120 | docs.ruby.setMode(new RubyMode()); 121 | docs.ruby.setUndoManager(new UndoManager()); 122 | 123 | docs.csharp = new EditSession(document.getElementById("csharptext").innerHTML); 124 | docs.csharp.setMode(new CSharpMode()); 125 | docs.csharp.setUndoManager(new UndoManager()); 126 | 127 | docs.c_cpp = new EditSession(document.getElementById("cpptext").innerHTML); 128 | docs.c_cpp.setMode(new CCPPMode()); 129 | docs.c_cpp.setUndoManager(new UndoManager()); 130 | 131 | docs.coffee = new EditSession(document.getElementById("coffeetext").innerHTML); 132 | docs.coffee.setMode(new CoffeeMode()); 133 | docs.coffee.setUndoManager(new UndoManager()); 134 | 135 | docs.perl = new EditSession(document.getElementById("perltext").innerHTML); 136 | docs.perl.setMode(new PerlMode()); 137 | docs.perl.setUndoManager(new UndoManager()); 138 | 139 | docs.svg = new EditSession(document.getElementById("svgtext").innerHTML.replace("<", "<")); 140 | docs.svg.setMode(new SvgMode()); 141 | docs.svg.setUndoManager(new UndoManager()); 142 | 143 | docs.textile = new EditSession(document.getElementById("textiletext").innerHTML); 144 | docs.textile.setMode(new TextileMode()); 145 | docs.textile.setUndoManager(new UndoManager()); 146 | 147 | var container = document.getElementById("editor"); 148 | env.editor = new Editor(new Renderer(container, theme)); 149 | 150 | var modes = { 151 | text: new TextMode(), 152 | textile: new TextileMode(), 153 | svg: new SvgMode(), 154 | xml: new XmlMode(), 155 | html: new HtmlMode(), 156 | css: new CssMode(), 157 | javascript: new JavaScriptMode(), 158 | python: new PythonMode(), 159 | php: new PhpMode(), 160 | java: new JavaMode(), 161 | ruby: new RubyMode(), 162 | c_cpp: new CCPPMode(), 163 | coffee: new CoffeeMode(), 164 | perl: new PerlMode(), 165 | csharp: new CSharpMode() 166 | }; 167 | 168 | function getMode() { 169 | return modes[modeEl.value]; 170 | } 171 | 172 | var modeEl = document.getElementById("mode"); 173 | var wrapModeEl = document.getElementById("soft_wrap"); 174 | 175 | bindDropdown("doc", function(value) { 176 | var doc = docs[value]; 177 | env.editor.setSession(doc); 178 | 179 | var mode = doc.getMode(); 180 | if (mode instanceof JavaScriptMode) { 181 | modeEl.value = "javascript"; 182 | } 183 | else if (mode instanceof CssMode) { 184 | modeEl.value = "css"; 185 | } 186 | else if (mode instanceof HtmlMode) { 187 | modeEl.value = "html"; 188 | } 189 | else if (mode instanceof XmlMode) { 190 | modeEl.value = "xml"; 191 | } 192 | else if (mode instanceof PythonMode) { 193 | modeEl.value = "python"; 194 | } 195 | else if (mode instanceof PhpMode) { 196 | modeEl.value = "php"; 197 | } 198 | else if (mode instanceof JavaMode) { 199 | modeEl.value = "java"; 200 | } 201 | else if (mode instanceof RubyMode) { 202 | modeEl.value = "ruby"; 203 | } 204 | else if (mode instanceof CCPPMode) { 205 | modeEl.value = "c_cpp"; 206 | } 207 | else if (mode instanceof CoffeeMode) { 208 | modeEl.value = "coffee"; 209 | } 210 | else if (mode instanceof PerlMode) { 211 | modeEl.value = "perl"; 212 | } 213 | else if (mode instanceof CSharpMode) { 214 | modeEl.value = "csharp"; 215 | } 216 | else if (mode instanceof SvgMode) { 217 | modeEl.value = "svg"; 218 | } 219 | else if (mode instanceof TextileMode) { 220 | modeEl.value = "textile"; 221 | } 222 | else { 223 | modeEl.value = "text"; 224 | } 225 | 226 | if (!doc.getUseWrapMode()) { 227 | wrapModeEl.value = "off"; 228 | } else { 229 | wrapModeEl.value = doc.getWrapLimitRange().min || "free"; 230 | } 231 | env.editor.focus(); 232 | }); 233 | 234 | bindDropdown("mode", function(value) { 235 | env.editor.getSession().setMode(modes[value] || modes.text); 236 | }); 237 | 238 | bindDropdown("theme", function(value) { 239 | env.editor.setTheme(value); 240 | }); 241 | 242 | bindDropdown("keybinding", function(value) { 243 | env.editor.setKeyboardHandler(keybindings[value]); 244 | }); 245 | 246 | bindDropdown("fontsize", function(value) { 247 | document.getElementById("editor").style.fontSize = value; 248 | }); 249 | 250 | bindDropdown("soft_wrap", function(value) { 251 | var session = env.editor.getSession(); 252 | var renderer = env.editor.renderer; 253 | switch (value) { 254 | case "off": 255 | session.setUseWrapMode(false); 256 | renderer.setPrintMarginColumn(80); 257 | break; 258 | case "40": 259 | session.setUseWrapMode(true); 260 | session.setWrapLimitRange(40, 40); 261 | renderer.setPrintMarginColumn(40); 262 | break; 263 | case "80": 264 | session.setUseWrapMode(true); 265 | session.setWrapLimitRange(80, 80); 266 | renderer.setPrintMarginColumn(80); 267 | break; 268 | case "free": 269 | session.setUseWrapMode(true); 270 | session.setWrapLimitRange(null, null); 271 | renderer.setPrintMarginColumn(80); 272 | break; 273 | } 274 | }); 275 | 276 | bindCheckbox("select_style", function(checked) { 277 | env.editor.setSelectionStyle(checked ? "line" : "text"); 278 | }); 279 | 280 | bindCheckbox("highlight_active", function(checked) { 281 | env.editor.setHighlightActiveLine(checked); 282 | }); 283 | 284 | bindCheckbox("show_hidden", function(checked) { 285 | env.editor.setShowInvisibles(checked); 286 | }); 287 | 288 | bindCheckbox("show_gutter", function(checked) { 289 | env.editor.renderer.setShowGutter(checked); 290 | }); 291 | 292 | bindCheckbox("show_print_margin", function(checked) { 293 | env.editor.renderer.setShowPrintMargin(checked); 294 | }); 295 | 296 | bindCheckbox("highlight_selected_word", function(checked) { 297 | env.editor.setHighlightSelectedWord(checked); 298 | }); 299 | 300 | bindCheckbox("show_hscroll", function(checked) { 301 | env.editor.renderer.setHScrollBarAlwaysVisible(checked); 302 | }); 303 | 304 | function bindCheckbox(id, callback) { 305 | var el = document.getElementById(id); 306 | var onCheck = function() { 307 | callback(!!el.checked); 308 | }; 309 | el.onclick = onCheck; 310 | onCheck(); 311 | } 312 | 313 | function bindDropdown(id, callback) { 314 | var el = document.getElementById(id); 315 | var onChange = function() { 316 | callback(el.value); 317 | }; 318 | el.onchange = onChange; 319 | onChange(); 320 | } 321 | 322 | function onResize() { 323 | container.style.width = (document.documentElement.clientWidth) + "px"; 324 | container.style.height = (document.documentElement.clientHeight - 60 - 22) + "px"; 325 | env.editor.resize(); 326 | }; 327 | 328 | window.onresize = onResize; 329 | onResize(); 330 | 331 | event.addListener(container, "dragover", function(e) { 332 | return event.preventDefault(e); 333 | }); 334 | 335 | event.addListener(container, "drop", function(e) { 336 | try { 337 | var file = e.dataTransfer.files[0]; 338 | } catch(e) { 339 | return event.stopEvent(); 340 | } 341 | 342 | if (window.FileReader) { 343 | var reader = new FileReader(); 344 | reader.onload = function(e) { 345 | env.editor.getSelection().selectAll(); 346 | 347 | var mode = "text"; 348 | if (/^.*\.js$/i.test(file.name)) { 349 | mode = "javascript"; 350 | } else if (/^.*\.xml$/i.test(file.name)) { 351 | mode = "xml"; 352 | } else if (/^.*\.html$/i.test(file.name)) { 353 | mode = "html"; 354 | } else if (/^.*\.css$/i.test(file.name)) { 355 | mode = "css"; 356 | } else if (/^.*\.py$/i.test(file.name)) { 357 | mode = "python"; 358 | } else if (/^.*\.php$/i.test(file.name)) { 359 | mode = "php"; 360 | } else if (/^.*\.cs$/i.test(file.name)) { 361 | mode = "csharp"; 362 | } else if (/^.*\.java$/i.test(file.name)) { 363 | mode = "java"; 364 | } else if (/^.*\.rb$/i.test(file.name)) { 365 | mode = "ruby"; 366 | } else if (/^.*\.(c|cpp|h|hpp|cxx)$/i.test(file.name)) { 367 | mode = "c_cpp"; 368 | } else if (/^.*\.coffee$/i.test(file.name)) { 369 | mode = "coffee"; 370 | } else if (/^.*\.(pl|pm)$/i.test(file.name)) { 371 | mode = "perl"; 372 | } 373 | 374 | env.editor.onTextInput(reader.result); 375 | 376 | modeEl.value = mode; 377 | env.editor.getSession().setMode(modes[mode]); 378 | }; 379 | reader.readAsText(file); 380 | } 381 | 382 | return event.preventDefault(e); 383 | }); 384 | 385 | window.env = env; 386 | 387 | /** 388 | * This demonstrates how you can define commands and bind shortcuts to them. 389 | */ 390 | 391 | // Command to focus the command line from the editor. 392 | canon.addCommand({ 393 | name: "focuscli", 394 | bindKey: { 395 | win: "Ctrl-J", 396 | mac: "Command-J", 397 | sender: "editor" 398 | }, 399 | exec: function() { 400 | env.cli.cliView.element.focus(); 401 | } 402 | }); 403 | 404 | // Command to focus the editor line from the command line. 405 | canon.addCommand({ 406 | name: "focuseditor", 407 | bindKey: { 408 | win: "Ctrl-J", 409 | mac: "Command-J", 410 | sender: "cli" 411 | }, 412 | exec: function() { 413 | env.editor.focus(); 414 | } 415 | }); 416 | 417 | // Fake-Save, works from the editor and the command line. 418 | canon.addCommand({ 419 | name: "save", 420 | bindKey: { 421 | win: "Ctrl-S", 422 | mac: "Command-S", 423 | sender: "editor|cli" 424 | }, 425 | exec: function() { 426 | alert("Fake Save File"); 427 | } 428 | }); 429 | 430 | // Fake-Print with custom lookup-sender-match function. 431 | canon.addCommand({ 432 | name: "save", 433 | bindKey: { 434 | win: "Ctrl-P", 435 | mac: "Command-P", 436 | sender: function(env, sender, hashId, keyString) { 437 | if (sender == "editor") { 438 | return true; 439 | } else { 440 | alert("Sorry, can only print from the editor"); 441 | } 442 | } 443 | }, 444 | exec: function() { 445 | alert("Fake Print File"); 446 | } 447 | }); 448 | }; 449 | 450 | }); 451 | -------------------------------------------------------------------------------- /www/ace/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Editor 8 | 9 | 10 | 21 | 22 | 23 | 24 | 25 | 44 | 63 | 75 | 79 | 83 | 87 | 91 | 94 | 95 | 96 | 116 | 125 | 134 | 138 | 142 | 146 | 147 |
26 | 27 | 43 | 45 | 46 | 62 | 64 | 65 | 74 | 76 | 77 | 78 | 80 | 81 | 82 | 84 | 85 | 86 | 88 | 89 | 90 | 92 | 93 |
97 | 98 | 115 | 117 | 118 | 124 | 126 | 127 | 133 | 135 | 136 | 137 | 139 | 140 | 141 | 143 | 144 | 145 |
148 | 149 |
150 |
151 | 155 | 162 | 163 | 168 | 169 | 185 | 186 | 201 | 202 | 221 | 222 | 241 | 242 | 254 | 255 | 268 | 269 | 283 | 284 | 306 | 307 | 342 | 343 | 426 | 457 | 458 | 459 | 460 | 468 | 469 | 470 | -------------------------------------------------------------------------------- /www/extjs3-ace/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ExtJS 3 ACE Component Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 24 | 194 | 195 | 196 | 197 |
198 | 199 | 200 | 201 | 220 | 239 | 251 | 252 | 255 | 256 | 257 | 277 | 286 | 295 | 296 | 297 | 298 | 302 | 306 | 310 | 314 | 315 | 316 | 320 | 324 | 328 | 329 | 330 |
202 | 203 | 219 | 221 | 222 | 238 | 240 | 241 | 250 | 253 | 254 |
258 | 259 | 276 | 278 | 279 | 285 | 287 | 288 | 294 |
299 | 300 | 301 | 303 | 304 | 305 | 307 | 308 | 309 | 311 | 312 | 313 |
317 | 318 | 319 | 321 | 322 | 323 | 325 | 326 | 327 |
331 | 332 |
333 | 334 | 335 | 339 | 340 | 347 | 348 | 353 | 354 | 370 | 371 | 386 | 387 | 406 | 407 | 426 | 427 | 439 | 440 | 453 | 454 | 468 | 469 | 491 | 492 | 527 | 528 | 611 | 642 | 643 | 644 | 645 | 646 | -------------------------------------------------------------------------------- /www/extjs4-ace/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ExtJS 4 ACE Component Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 23 | 24 | 199 | 200 | 201 | 202 |
203 | 204 | 205 | 206 | 225 | 244 | 256 | 257 | 260 | 261 | 262 | 282 | 291 | 300 | 301 | 302 | 303 | 307 | 311 | 315 | 319 | 320 | 321 | 325 | 329 | 333 | 334 | 335 |
207 | 208 | 224 | 226 | 227 | 243 | 245 | 246 | 255 | 258 | 259 |
263 | 264 | 281 | 283 | 284 | 290 | 292 | 293 | 299 |
304 | 305 | 306 | 308 | 309 | 310 | 312 | 313 | 314 | 316 | 317 | 318 |
322 | 323 | 324 | 326 | 327 | 328 | 330 | 331 | 332 |
336 | 337 |
338 | 339 | 340 | 344 | 345 | 352 | 353 | 358 | 359 | 375 | 376 | 391 | 392 | 411 | 412 | 431 | 432 | 444 | 445 | 458 | 459 | 473 | 474 | 496 | 497 | 532 | 533 | 616 | 647 | 648 | 649 | 650 | 651 | --------------------------------------------------------------------------------