Merge remote branch 'mozilla/master'

Conflicts:
	Makefile.dryice.js
	build_support/boot.js
	build_support/mini_require.js
	lib/ace/edit_session.js
	package.json
This commit is contained in:
Fabian Jakobs 2011-01-31 10:29:29 +01:00
commit 58dc601000
4 changed files with 208 additions and 1057 deletions

File diff suppressed because it is too large Load diff

View file

@ -35,21 +35,9 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
// don't define it in a worker. var deps = [ "pilot/plugin_manager", "pilot/environment" ];
if (window.document) {
require(deps, function() {
require("pilot/fixoldbrowsers");
require("pilot/settings");
var Event = require("pilot/event");
var Dom = require("pilot/dom");
var EditSession = require("ace/edit_session").EditSession;
var JavaScriptMode = require("ace/mode/javascript").Mode;
var UndoManager = require("ace/undomanager").UndoManager;
var Editor = require("ace/editor").Editor;
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
var Theme = require("ace/theme/textmate");
var catalog = require("pilot/plugin_manager").catalog; var catalog = require("pilot/plugin_manager").catalog;
catalog.registerPlugins([ "pilot/index" ]); catalog.registerPlugins([ "pilot/index" ]);
@ -81,4 +69,4 @@ if (window.document) {
return editor; return editor;
} }
}; };
} }

View file

@ -35,51 +35,43 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
// don't define it in a worker. There we have a different implementation /**
if (window.document) { * Define a module along with a payload
* @param module a name for the payload
* @param payload a function to call with (require, exports, module) params
*/
function define(module, payload) {
if (typeof module !== 'string') {
console.error('dropping module because define wasn\'t a string.');
console.trace();
return;
}
window.require = function(module, callback) { if (!define.modules) {
define.modules = {};
if (Array.isArray(module)) { }
var params = []; define.modules[module] = payload;
module.forEach(function(m) { }
params.push(require._lookup(m));
}, this); /**
* Get at functionality define()ed using the function above
if (callback) { */
callback.apply(null, params); function require(module, callback) {
} if (Array.isArray(module)) {
} var params = [];
module.forEach(function(m) {
if (typeof module === 'string') { params.push(define.lookup(m));
payload = require._lookup(module); }, this);
if (callback) {
callback(); if (callback) {
} callback.apply(null, params);
return payload;
} }
} }
require.modules = {};
require.packaged = true; if (typeof module === 'string') {
var payload = define.lookup(module);
require._lookup = function(moduleName) { if (callback) {
var payload = require.modules[moduleName]; callback();
var module_name = moduleName;
if (payload == null) {
console.error('Missing module: ' + moduleName);
console.trace();
}
if (typeof payload === 'function') {
var exports = {};
var module = {
id: moduleName,
uri: ''
};
payload(require, exports, module);
payload = exports;
// cache the resulting module object for next time
require.modules[module_name] = payload;
} }
return payload; return payload;
@ -95,4 +87,26 @@ if (window.document) {
// 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;
} }
} }
/**
* Internal function to lookup moduleNames and resolve them by calling the
* definition function if needed.
*/
define.lookup = function(moduleName) {
var module = define.modules[moduleName];
if (module == null) {
console.error('Missing module: ' + moduleName);
return null;
}
if (typeof module === 'function') {
var exports = {};
module(require, exports, { id: moduleName, uri: '' });
// cache the resulting module object for next time
define.modules[moduleName] = exports;
return exports;
}
return module;
};

View file

@ -52,9 +52,10 @@ var EditSession = function(text, mode) {
this.selection = new Selection(this); this.selection = new Selection(this);
this.$breakpoints = []; this.$breakpoints = [];
this.$wrapData = []; this.$wrapData = [];
this.listeners = [];
if (text instanceof Document) { if (text instanceof Document) {
this.setDocument(text) this.setDocument(text);
} else { } else {
this.setDocument(new Document(text)); this.setDocument(new Document(text));
} }
@ -244,7 +245,8 @@ var EditSession = function(text, mode) {
}; };
this.tokenRe = /^[\w\d]+/g; this.tokenRe = /^[\w\d]+/g;
this.nonTokenRe = /^(?:[^\w\d|[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF])+/g this.nonTokenRe = /^(?:[^\w\d|[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF])+/g;
this.getWordRange = function(row, column) { this.getWordRange = function(row, column) {
var line = this.getLine(row); var line = this.getLine(row);
@ -506,7 +508,7 @@ var EditSession = function(text, mode) {
return { return {
rows: end ? end.row - rows[0] : 0, rows: end ? end.row - rows[0] : 0,
columns: end ? end.column - column : 0 columns: end ? end.column - column : 0
} };
}; };
this.remove = function(range) { this.remove = function(range) {
@ -604,7 +606,7 @@ var EditSession = function(text, mode) {
this.remove(deleteRange); this.remove(deleteRange);
} }
return range; return range;
} };
this.moveLinesUp = function(firstRow, lastRow) { this.moveLinesUp = function(firstRow, lastRow) {
if (firstRow <= 0) return 0; if (firstRow <= 0) return 0;