Merge remote branch 'upstream/master' into vice

This commit is contained in:
Irakli Gozalishvili 2011-01-26 18:03:05 +01:00
commit 28a46eb83c
7 changed files with 159 additions and 114 deletions

View file

@ -91,11 +91,12 @@ copy({
{ {
root: aceHome + '/lib', root: aceHome + '/lib',
include: /.*\.js$/, include: /.*\.js$/,
exclude: /tests?\/|theme\/|mode\// exclude: /tests?\/|theme\/|mode\/|ace\/worker\/host\.js/
}, },
{ base: aceHome + '/lib/', path: 'ace/theme/textmate.js' }, { base: aceHome + '/lib/', path: 'ace/theme/textmate.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/text.js' }, { base: aceHome + '/lib/', path: 'ace/mode/text.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/javascript.js' }, { base: aceHome + '/lib/', path: 'ace/mode/javascript.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/javascript_worker.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/text_highlight_rules.js' }, { base: aceHome + '/lib/', path: 'ace/mode/text_highlight_rules.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/javascript_highlight_rules.js' }, { base: aceHome + '/lib/', path: 'ace/mode/javascript_highlight_rules.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/doc_comment_highlight_rules.js' }, { base: aceHome + '/lib/', path: 'ace/mode/doc_comment_highlight_rules.js' },
@ -121,7 +122,6 @@ copy({
source: [ source: [
'build_support/mini_require.js', 'build_support/mini_require.js',
pilot, pilot,
// cockpit,
ace, ace,
'build_support/boot.js' 'build_support/boot.js'
], ],
@ -146,7 +146,14 @@ copy({
dest: 'build/ace-uncompressed.js' dest: 'build/ace-uncompressed.js'
}); });
// Create worker bootstrap code
copy({
source: "lib/ace/worker/host.js",
filter: [function(data) {
return data + "\nimportScripts('ace-uncompressed.js')";
}],
dest: 'build/host.js'
});
@ -263,7 +270,7 @@ function runFilters(value, filter, reading, name) {
return value; return value;
} }
if (filter.onRead == reading) { if ((!!filter.onRead) == reading) {
return filter(value, name); return filter(value, name);
} }
else { else {

View file

@ -35,15 +35,18 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
var deps = [ "pilot/fixoldbrowsers", "pilot/plugin_manager", "pilot/settings", // don't define it in a worker.
if (window.document) {
var deps = [ "pilot/fixoldbrowsers", "pilot/plugin_manager", "pilot/settings",
"pilot/environment" ]; "pilot/environment" ];
require(deps, function() { require(deps, function() {
var catalog = require("pilot/plugin_manager").catalog; var catalog = require("pilot/plugin_manager").catalog;
catalog.registerPlugins([ "pilot/index" ]); catalog.registerPlugins([ "pilot/index" ]);
}); });
var ace = { var ace = {
edit: function(el) { edit: function(el) {
if (typeof(el) == "string") { if (typeof(el) == "string") {
el = document.getElementById(el); el = document.getElementById(el);
@ -72,4 +75,5 @@ var ace = {
el.env = env; el.env = env;
}); });
} }
}; };
}

View file

@ -35,7 +35,10 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
function require(module, callback) { // don't define it in a worker. There we have a different implementation
if (window.document) {
window.require = function(module, callback) {
if (Array.isArray(module)) { if (Array.isArray(module)) {
var params = []; var params = [];
@ -55,10 +58,11 @@ function require(module, callback) {
} }
return payload; return payload;
} }
} }
require.modules = {}; require.modules = {};
require.packaged = true;
require._lookup = function(moduleName) { require._lookup = function(moduleName) {
var payload = require.modules[moduleName]; var payload = require.modules[moduleName];
var module_name = moduleName; var module_name = moduleName;
if (payload == null) { if (payload == null) {
@ -79,9 +83,9 @@ require._lookup = function(moduleName) {
} }
return payload; return payload;
}; };
function define(module, payload) { window.define = function(module, payload) {
if (typeof module !== 'string') { if (typeof module !== 'string') {
console.error('dropping module because define wasn\'t munged.'); console.error('dropping module because define wasn\'t munged.');
console.trace(); console.trace();
@ -90,4 +94,5 @@ function define(module, payload) {
// console.log('defining module: ' + module + ' as a ' + typeof payload); // console.log('defining module: ' + module + ' as a ' + typeof payload);
require.modules[module] = payload; require.modules[module] = payload;
}
} }

View file

@ -231,6 +231,13 @@ var Editor =function(renderer, session) {
}; };
this.focus = function() { this.focus = function() {
// Safari need the timeout
// iOS and Firefox need it called immediately
// to be on the save side we do both
var _self = this;
setTimeout(function() {
_self.textInput.focus();
});
this.textInput.focus(); this.textInput.focus();
}; };

View file

@ -7,33 +7,48 @@ var window = {
console: console console: console
}; };
var require = function(name) { var require = function(id) {
if (require.modules[name]) var module = require.modules[id];
return require.modules[name].exports; if (module) {
if (!module.initialized) {
module.exports = module.factory().exports;
module.initialized = true;
}
return module.exports;
}
var chunks = name.split("/"); var chunks = id.split("/");
chunks[0] = require.tlns[chunks[0]] || chunks[0]; chunks[0] = require.tlns[chunks[0]] || chunks[0];
path = require.baseUrl + "/" + chunks.join("/") + ".js" path = require.baseUrl + "/" + chunks.join("/") + ".js"
require.id = name; require.id = id;
importScripts(path); importScripts(path);
return require.modules[name].exports; return require(id);
}; };
require.modules = {}; require.modules = {};
require.tlns = {}; require.tlns = {};
require.baseUrl; require.baseUrl;
var define = function(factory) { var define = function(id, factory) {
if (!factory) {
factory = id;
id = require.id;
}
if (id.indexOf("text!") == 0)
return;
require.modules[id] = {
factory: function() {
var module = { var module = {
exports: {} exports: {}
}; };
var name = require.id;
var returnExports = factory(require, module.exports, module); var returnExports = factory(require, module.exports, module);
if (returnExports) if (returnExports)
module.exports = exports; module.exports = exports;
return module;
require.modules[name] = module; }
};
}; };
function initBaseUrls(baseUrl, topLevelNamespaces) { function initBaseUrls(baseUrl, topLevelNamespaces) {
@ -81,6 +96,7 @@ onmessage = function(e) {
main[msg.command].apply(main, msg.args); main[msg.command].apply(main, msg.args);
else if (msg.init) { else if (msg.init) {
initBaseUrls(msg.base, msg.tlns); initBaseUrls(msg.base, msg.tlns);
require("pilot/fixoldbrowsers");
sender = initSender(); sender = initSender();
var clazz = require(msg.module)[msg.classname]; var clazz = require(msg.module)[msg.classname];
main = new clazz(sender); main = new clazz(sender);

View file

@ -14,6 +14,11 @@ var EventEmitter = require("pilot/event_emitter").EventEmitter;
var WorkerClient = function(baseUrl, topLevelNamespaces, module, classname) { var WorkerClient = function(baseUrl, topLevelNamespaces, module, classname) {
this.callbacks = []; this.callbacks = [];
if (require.packaged) {
var worker = this.$worker = new Worker("host.js");
}
else {
var workerUrl = require.nameToUrl("ace/worker/host", null, "_"); var workerUrl = require.nameToUrl("ace/worker/host", null, "_");
var worker = this.$worker = new Worker(workerUrl); var worker = this.$worker = new Worker(workerUrl);
@ -22,6 +27,7 @@ var WorkerClient = function(baseUrl, topLevelNamespaces, module, classname) {
var ns = topLevelNamespaces[i]; var ns = topLevelNamespaces[i];
tlns[ns] = require.nameToUrl(ns, null, "_").replace(/.js$/, "").replace(require.config.baseUrl, ""); tlns[ns] = require.nameToUrl(ns, null, "_").replace(/.js$/, "").replace(require.config.baseUrl, "");
} }
}
this.$worker.postMessage({ this.$worker.postMessage({
init : true, init : true,

@ -1 +1 @@
Subproject commit dbc78536a4ea61e0f762067fb847213526500d9f Subproject commit 1fa3516d4d553af9f6edd81c20023bcfab08c2a3