diff --git a/build/Readme.md b/build/Readme.md
index 528051f6..93152ee2 100644
--- a/build/Readme.md
+++ b/build/Readme.md
@@ -108,9 +108,9 @@ The editor can then be opened at http://localhost:8888/index.html.
Package Ace
-----------
-To package Ace we use the dryice build tool developed by the Mozilla Skywriter team. To install dryice and all its dependencies simply call:
+To package Ace we use the dryice build tool developed by the Mozilla Skywriter team. Before you can build you need to make sure that the submodules are up to date.
- npm link .
+ git submodule update --init --recursive
Afterwards Ace can be built by calling
diff --git a/build/src/ace-uncompressed.js b/build/src/ace-uncompressed.js
index 34dd3ed7..6d6caa61 100644
--- a/build/src/ace-uncompressed.js
+++ b/build/src/ace-uncompressed.js
@@ -3785,6 +3785,9 @@ Setting.prototype = {
*/
resetValue: function() {
this.set(this.defaultValue);
+ },
+ toString: function () {
+ return this.name;
}
};
oop.implement(Setting.prototype, EventEmitter);
@@ -5070,6 +5073,7 @@ exports.scrollbarWidth = function() {
var inner = exports.createElement("p");
inner.style.width = "100%";
+ inner.style.minWidth = "0px";
inner.style.height = "200px";
var outer = exports.createElement("div");
@@ -5079,6 +5083,7 @@ exports.scrollbarWidth = function() {
style.left = "-10000px";
style.overflow = "hidden";
style.width = "200px";
+ style.minWidth = "0px";
style.height = "150px";
outer.appendChild(inner);
@@ -5164,8 +5169,7 @@ exports.setSelectionEnd = function(textarea, end) {
return textarea.selectionEnd = end;
};
-});
-/* ***** BEGIN LICENSE BLOCK *****
+});/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@@ -5901,14 +5905,14 @@ var Editor =function(renderer, session) {
var mode = session.getMode();
var cursor = this.getCursorPosition();
-
+
if (this.getBehavioursEnabled()) {
// Get a transform if the current mode wants one.
var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
if (transform)
text = transform.text;
}
-
+
text = text.replace("\t", this.session.getTabString());
// remove selected text
@@ -5930,7 +5934,7 @@ var Editor =function(renderer, session) {
var line = session.getLine(cursor.row);
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
var end = session.insert(cursor, text);
-
+
if (transform && transform.selection) {
if (transform.selection.length == 2) { // Transform relative to the current column
this.selection.setSelectionRange(
@@ -5944,7 +5948,7 @@ var Editor =function(renderer, session) {
transform.selection[3]));
}
}
-
+
var lineState = session.getState(cursor.row);
// TODO disabled multiline auto indent
@@ -5990,8 +5994,27 @@ var Editor =function(renderer, session) {
}
};
- this.onTextInput = function(text) {
- this.keyBinding.onTextInput(text);
+ this.onTextInput = function(text, notPasted) {
+ // In case the text was not pasted and we got only one character, then
+ // handel it as a command key stroke.
+ if (notPasted && text.length == 1) {
+ // Note: The `null` as `keyCode` is important here, as there are
+ // some checks in the code for `keyCode == 0` meaning the text comes
+ // from the keyBinding.onTextInput code path.
+ var handled = this.keyBinding.onCommandKey({}, 0, null, text);
+
+ // Check if the text was handled. If not, then handled it as "normal"
+ // text and insert it to the editor directly. This shouldn't be done
+ // using the this.keyBinding.onTextInput(text) function, as it would
+ // make the `text` get sent to the keyboardHandler twice, which might
+ // turn out to be a bad thing in case there is a custome keyboard
+ // handler like the StateHandler.
+ if (!handled) {
+ this.insert(text);
+ }
+ } else {
+ this.keyBinding.onTextInput(text);
+ }
};
this.onCommandKey = function(e, hashId, keyCode) {
@@ -6094,12 +6117,12 @@ var Editor =function(renderer, session) {
this.getReadOnly = function() {
return this.$readOnly;
};
-
+
this.$modeBehaviours = false;
this.setBehavioursEnabled = function (enabled) {
this.$modeBehaviours = enabled;
}
-
+
this.getBehavioursEnabled = function () {
return this.$modeBehaviours;
}
@@ -6121,7 +6144,7 @@ var Editor =function(renderer, session) {
if (this.selection.isEmpty())
this.selection.selectLeft();
-
+
var range = this.getSelectionRange();
if (this.getBehavioursEnabled()) {
var session = this.session;
@@ -6721,6 +6744,7 @@ var TextInput = function(parentNode, host) {
var inCompostion = false;
var copied = false;
+ var pasted = false;
var tempStyle = '';
function sendText(valueToSend) {
@@ -6731,15 +6755,18 @@ var TextInput = function(parentNode, host) {
value = value.slice(0, -1);
if (value)
host.onTextInput(value);
- } else
+ } else {
host.onTextInput(value);
+ }
// If editor is no longer focused we quit immediately, since
// it means that something else like CLI is in charge now.
if (!isFocused()) return false;
}
}
+
copied = false;
+ pasted = false;
// Safari doesn't fire copy events if no text is selected
text.value = PLACEHOLDER;
@@ -6824,6 +6851,8 @@ var TextInput = function(parentNode, host) {
};
event.addListener(text, "textInput", onTextInput);
event.addListener(text, "paste", function(e) {
+ // Mark that the next input text comes from past.
+ pasted = true;
// Some browsers support the event.clipboardData API. Use this to get
// the pasted content which increases speed if pasting a lot of lines.
if (e.clipboardData && e.clipboardData.getData) {
@@ -6841,7 +6870,7 @@ var TextInput = function(parentNode, host) {
};
if (useragent.isIE) {
- event.addListener(text, "beforecopy", function(e) {
+ event.addListener(text, "beforecopy", function(e) {
var copyText = host.getCopyText();
if(copyText)
clipboardData.setData("Text", copyText);
@@ -7318,22 +7347,27 @@ var KeyBinding = function(editor) {
}
}
+ var success = false;
if (toExecute) {
- var success = canon.exec(toExecute.command,
+ success = canon.exec(toExecute.command,
env, "editor", toExecute.args);
if (success) {
- return event.stopEvent(e);
+ event.stopEvent(e);
}
}
+ return success;
};
- this.onCommandKey = function(e, hashId, keyCode) {
- var keyString = keyUtil.keyCodeToString(keyCode);
- this.$callKeyboardHandler(e, hashId, keyString, keyCode);
+ this.onCommandKey = function(e, hashId, keyCode, keyString) {
+ // In case there is no keyString, try to interprete the keyCode.
+ if (!keyString) {
+ keyString = keyUtil.keyCodeToString(keyCode);
+ }
+ return this.$callKeyboardHandler(e, hashId, keyString, keyCode);
};
this.onTextInput = function(text) {
- this.$callKeyboardHandler({}, 0, text, 0);
+ return this.$callKeyboardHandler({}, 0, text, 0);
}
}).call(KeyBinding.prototype);
@@ -7765,7 +7799,6 @@ var EditSession = function(text, mode) {
this.$backMarkers = {};
this.$markerId = 1;
this.$rowCache = [];
- this.$rowCacheSize = 1000;
this.$wrapData = [];
this.$foldData = [];
this.$foldData.toString = function() {
@@ -9061,6 +9094,9 @@ var EditSession = function(text, mode) {
return [screenColumn, column];
}
+ /**
+ * Returns the number of rows required to render this row on the screen
+ */
this.getRowLength = function(row) {
if (!this.$useWrapMode || !this.$wrapData[row]) {
return 1;
@@ -9069,14 +9105,14 @@ var EditSession = function(text, mode) {
}
}
+ /**
+ * Returns the height in pixels required to render this row on the screen
+ **/
this.getRowHeight = function(config, row) {
return this.getRowLength(row) * config.lineHeight;
}
this.getScreenLastRowColumn = function(screenRow) {
- // Note: This won't work if someone has more then
- // 1.7976931348623158e+307 characters in one row. But I think we can
- // live with this limitation ;)
return this.screenToDocumentColumn(screenRow, Number.MAX_VALUE / 10)
};
@@ -9114,6 +9150,13 @@ var EditSession = function(text, mode) {
};
this.screenToDocumentPosition = function(screenRow, screenColumn) {
+ if (screenRow < 0) {
+ return {
+ row: 0,
+ column: 0
+ }
+ }
+
var line;
var docRow = 0;
var docColumn = 0;
@@ -9121,7 +9164,6 @@ var EditSession = function(text, mode) {
var foldLineRowLength;
var row = 0;
var rowLength = 0;
- var splits = null;
var rowCache = this.$rowCache;
var doCache = !rowCache.length;
@@ -9132,21 +9174,18 @@ var EditSession = function(text, mode) {
doCache = i == rowCache.length - 1;
}
}
- var docRowCacheLast = docRow;
// clamp row before clamping column, for selection on last line
var maxRow = this.getLength() - 1;
var foldLine = this.getNextFold(docRow);
- var foldStart = foldLine ?foldLine.start.row :Infinity;
+ var foldStart = foldLine ? foldLine.start.row : Infinity;
while (row <= screenRow) {
- if (doCache
- && docRow - docRowCacheLast > this.$rowCacheSize) {
+ if (doCache) {
rowCache.push({
docRow: docRow,
screenRow: row
});
- docRowCacheLast = docRow;
}
rowLength = this.getRowLength(docRow);
if (row + rowLength - 1 >= screenRow || docRow >= maxRow) {
@@ -9154,10 +9193,10 @@ var EditSession = function(text, mode) {
} else {
row += rowLength;
docRow++;
- if(docRow > foldStart) {
+ if (docRow > foldStart) {
docRow = foldLine.end.row+1;
foldLine = this.getNextFold(docRow);
- foldStart = foldLine ?foldLine.start.row :Infinity;
+ foldStart = foldLine ? foldLine.start.row : Infinity;
}
}
}
@@ -9169,6 +9208,7 @@ var EditSession = function(text, mode) {
foldLine = null;
}
+ var splits = [];
if (this.$useWrapMode) {
splits = this.$wrapData[docRow];
if (splits) {
@@ -9182,6 +9222,10 @@ var EditSession = function(text, mode) {
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
+ // clip row at the end of the documen
+ if (row + splits.length < screenRow)
+ docColumn = Number.MAX_VALUE;
+
// Need to do some clamping action here.
if (this.$useWrapMode) {
if (docColumn >= column) {
@@ -9248,7 +9292,6 @@ var EditSession = function(text, mode) {
doCache = i == rowCache.length - 1;
}
}
- var docRowCacheLast = row;
var foldLine = this.getNextFold(row);
var foldStart = foldLine ?foldLine.start.row :Infinity;
@@ -9263,13 +9306,11 @@ var EditSession = function(text, mode) {
} else {
rowEnd = row + 1;
}
- if (doCache
- && row - docRowCacheLast > this.$rowCacheSize) {
+ if (doCache) {
rowCache.push({
docRow: row,
screenRow: screenRow
});
- docRowCacheLast = row;
}
screenRow += this.getRowLength(row);
@@ -9295,7 +9336,8 @@ var EditSession = function(text, mode) {
screenRowOffset++;
}
textLine = textLine.substring(
- wrapRow[screenRowOffset - 1] || 0, textLine.length);
+ wrapRow[screenRowOffset - 1] || 0, textLine.length
+ );
}
return {
@@ -9442,8 +9484,6 @@ var Selection = function(session) {
_self._dispatchEvent("changeCursor");
if (!_self.$isEmpty)
_self._dispatchEvent("changeSelection");
- if (e.old.row == e.value.row)
- _self.$updateDesiredColumn();
});
this.selectionAnchor.on("change", function() {
@@ -9683,7 +9723,8 @@ var Selection = function(session) {
fold;
if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
this.moveCursorTo(fold.end.row, fold.end.column);
- } else if (this.selectionLead.column == this.doc.getLine(this.selectionLead.row).length) {
+ }
+ else if (this.selectionLead.column == this.doc.getLine(this.selectionLead.row).length) {
if (this.selectionLead.row < this.doc.getLength() - 1) {
this.moveCursorTo(this.selectionLead.row + 1, 0);
}
@@ -9704,25 +9745,25 @@ var Selection = function(session) {
var screenRow = this.session.documentToScreenRow(row, column);
// Determ the doc-position of the first character at the screen line.
- var firstColumnPosition =
- this.session.screenToDocumentPosition(screenRow, 0);
+ var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
- // Determ the string "before" the cursor.
+ // Determ the line
var beforeCursor = this.session.getDisplayLine(
- row, column,
- firstColumnPosition.row, firstColumnPosition.column);
+ row, null,
+ firstColumnPosition.row, firstColumnPosition.column
+ );
- //
var leadingSpace = beforeCursor.match(/^\s*/);
- if (leadingSpace[0].length == 0
- || leadingSpace[0].length >= column - firstColumnPosition.column)
- {
+ if (leadingSpace[0].length == column) {
this.moveCursorTo(
- firstColumnPosition.row, firstColumnPosition.column);
- } else {
+ firstColumnPosition.row, firstColumnPosition.column
+ );
+ }
+ else {
this.moveCursorTo(
firstColumnPosition.row,
- firstColumnPosition.column + leadingSpace[0].length);
+ firstColumnPosition.column + leadingSpace[0].length
+ );
}
};
@@ -9820,7 +9861,6 @@ var Selection = function(session) {
);
var screenCol = (chars == 0 && this.$desiredColumn) || screenPos.column;
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
-
this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0);
};
@@ -13155,7 +13195,10 @@ var VirtualRenderer = function(container, theme) {
this.$padding = null;
this.setPadding = function(padding) {
this.$padding = padding;
- this.content.style.padding = "0 " + padding + "px";
+ this.$textLayer.setPadding(padding);
+ this.$cursorLayer.setPadding(padding);
+ this.$markerFront.setPadding(padding);
+ this.$markerBack.setPadding(padding);
this.$loop.schedule(this.CHANGE_FULL);
this.$updatePrintMargin();
};
@@ -13360,7 +13403,7 @@ var VirtualRenderer = function(container, theme) {
if (this.$textLayer.showInvisibles)
charCount += 1;
- return Math.max(this.$size.scrollerWidth - this.$padding * 2, Math.round(charCount * this.characterWidth));
+ return Math.max(this.$size.scrollerWidth, Math.round(charCount * this.characterWidth));
};
this.updateFrontMarkers = function() {
@@ -13807,6 +13850,12 @@ var Marker = function(parentEl) {
(function() {
+ this.$padding = 0;
+
+ this.setPadding = function(padding) {
+ this.$padding = padding;
+ };
+
this.setSession = function(session) {
this.session = session;
};
@@ -13822,7 +13871,7 @@ var Marker = function(parentEl) {
this.config = config;
- var html = [];
+ var html = [];
for ( var key in this.markers) {
var marker = this.markers[key];
@@ -13833,7 +13882,9 @@ var Marker = function(parentEl) {
if (marker.renderer) {
var top = this.$getTop(range.start.row, config);
- var left = Math.round(range.start.column * config.characterWidth);
+ var left = Math.round(this.$padding +
+ range.start.column *
+ config.characterWidth);
marker.renderer(html, range, left, top, config);
}
else if (range.isMultiLine()) {
@@ -13919,7 +13970,8 @@ var Marker = function(parentEl) {
var height = layerConfig.lineHeight;
var width = Math.round((range.end.column + (extraLength || 0) - range.start.column) * layerConfig.characterWidth);
var top = this.$getTop(range.start.row, layerConfig);
- var left = Math.round(range.start.column * layerConfig.characterWidth);
+ var left = Math.round(this.$padding +
+ range.start.column * layerConfig.characterWidth);
stringBuilder.push(
"
=b)throw new TypeError}while(!0)}else var d=arguments[1];for(;c=0;c--)c in this&&(d=a.call(null,d,this[c],c,this));return d}),Array.prototype.indexOf||(Array.prototype.indexOf=function w(a){var b=this.length;if(!b)return-1;var c=arguments[1]||0;if(c>=b)return-1;c<0&&(c+=b);for(;c=0;c--){if(!i(this,c))continue;if(a===this[c])return c}return-1}),Object.getPrototypeOf||(Object.getPrototypeOf=function y(a){return a.__proto__||a.constructor.prototype});if(!Object.getOwnPropertyDescriptor){var z="Object.getOwnPropertyDescriptor called on a non-object: ";Object.getOwnPropertyDescriptor=function A(a,b){if(typeof a!=="object"&&typeof a!=="function"||a===null)throw new TypeError(z+a);if(!i(a,b))return undefined;var c,d,e;c={enumerable:!0,configurable:!0};if(n){var f=a.__proto__;a.__proto__=h;var d=l(a,b),e=m(a,b);a.__proto__=f;if(d||e){d&&(descriptor.get=d),e&&(descriptor.set=e);return descriptor}}descriptor.value=a[b];return descriptor}}Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function B(a){return Object.keys(a)}),Object.create||(Object.create=function C(a,b){var c;if(a===null)c={"__proto__":null};else{if(typeof a!=="object")throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}typeof b!=="undefined"&&Object.defineProperties(c,b);return c});if(!Object.defineProperty){var D="Property description must be an object: ",E="Object.defineProperty called on non-object: ",F="getters & setters can not be defined on this javascript engine";Object.defineProperty=function G(a,b,c){if(typeof a!=="object"&&typeof a!=="function")throw new TypeError(E+a);if(typeof a!=="object"||a===null)throw new TypeError(D+c);if(i(c,"value"))if(n&&(l(a,b)||m(a,b))){var d=a.__proto__;a.__proto__=h,delete a[b],a[b]=c.value,a.prototype}else a[b]=c.value;else{if(!n)throw new TypeError(F);i(c,"get")&&j(a,b,c.get),i(c,"set")&&k(a,b,c.set)}return a}}Object.defineProperties||(Object.defineProperties=function H(a,b){for(var c in b)i(b,c)&&Object.defineProperty(a,c,b[c]);return a}),Object.seal||(Object.seal=function I(a){return a}),Object.freeze||(Object.freeze=function J(a){return a});try{Object.freeze(function(){})}catch(K){Object.freeze=function J(a){return function b(b){return typeof b==="function"?b:a(b)}}(Object.freeze)}Object.preventExtensions||(Object.preventExtensions=function L(a){return a}),Object.isSealed||(Object.isSealed=function M(a){return!1}),Object.isFrozen||(Object.isFrozen=function N(a){return!1}),Object.isExtensible||(Object.isExtensible=function O(a){return!0});if(!Object.keys){var P=!0,Q=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],R=Q.length;for(var S in {toString:null})P=!1;Object.keys=function T(a){if(typeof a!=="object"&&typeof a!=="function"||a===null)throw new TypeError("Object.keys called on a non-object");var b=[];for(var c in a)i(a,c)&&b.push(c);if(P)for(var d=0,e=R;d=7?new a(c,d,e,f,g,h,i):j>=6?new a(c,d,e,f,g,h):j>=5?new a(c,d,e,f,g):j>=4?new a(c,d,e,f):j>=3?new a(c,d,e):j>=2?new a(c,d):j>=1?new a(c):new a;k.constructor=b;return k}return a.apply(this,arguments)},c=new RegExp("^(?:((?:[+-]\\d\\d)?\\d\\d\\d\\d)(?:-(\\d\\d)(?:-(\\d\\d))?)?)?(?:T(\\d\\d):(\\d\\d)(?::(\\d\\d)(?:\\.(\\d\\d\\d))?)?)?(?:Z|([+-])(\\d\\d):(\\d\\d))?$");for(var d in a)b[d]=a[d];b.now=a.now,b.UTC=a.UTC,b.prototype=a.prototype,b.prototype.constructor=b,b.parse=function e(b){var d=c.exec(b);if(d){d.shift();var e=d[0]===undefined;for(var f=0;f<10;f++){if(f===7)continue;d[f]=+(d[f]||(f<3?1:0)),f===1&&d[f]--}if(e)return((d[3]*60+d[4])*60+d[5])*1e3+d[6];var g=(d[8]*60+d[9])*60*1e3;d[6]==="-"&&(g=-g);return a.UTC.apply(this,d.slice(0,7))+g}return a.parse.apply(this,arguments)};return b}(Date));if(!String.prototype.trim){var X=/^\s\s*/,Y=/\s\s*$/;String.prototype.trim=function Z(){return String(this).replace(X,"").replace(Y,"")}}}),define("ace/ace",["require","exports","module","pilot/index","pilot/fixoldbrowsers","pilot/plugin_manager","pilot/dom","pilot/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/theme/textmate","pilot/environment"],function(a,b,c){a("pilot/index"),a("pilot/fixoldbrowsers");var d=a("pilot/plugin_manager").catalog;d.registerPlugins(["pilot/index"]);var e=a("pilot/dom"),f=a("pilot/event"),g=a("ace/editor").Editor,h=a("ace/edit_session").EditSession,i=a("ace/undomanager").UndoManager,j=a("ace/virtual_renderer").VirtualRenderer;b.edit=function(b){typeof b=="string"&&(b=document.getElementById(b));var c=new h(e.getInnerText(b));c.setUndoManager(new i),b.innerHTML="";var k=new g(new j(b,a("ace/theme/textmate")));k.setSession(c);var l=a("pilot/environment").create();d.startupPlugins({env:l}).then(function(){l.document=c,l.editor=k,k.resize(),f.addListener(window,"resize",function(){k.resize()}),b.env=l}),k.env=l;return k}}),define("pilot/index",["require","exports","module","pilot/fixoldbrowsers","pilot/types/basic","pilot/types/command","pilot/types/settings","pilot/commands/settings","pilot/commands/basic","pilot/settings/canon","pilot/canon"],function(a,b,c){b.startup=function(b,c){a("pilot/fixoldbrowsers"),a("pilot/types/basic").startup(b,c),a("pilot/types/command").startup(b,c),a("pilot/types/settings").startup(b,c),a("pilot/commands/settings").startup(b,c),a("pilot/commands/basic").startup(b,c),a("pilot/settings/canon").startup(b,c),a("pilot/canon").startup(b,c)},b.shutdown=function(b,c){a("pilot/types/basic").shutdown(b,c),a("pilot/types/command").shutdown(b,c),a("pilot/types/settings").shutdown(b,c),a("pilot/commands/settings").shutdown(b,c),a("pilot/commands/basic").shutdown(b,c),a("pilot/settings/canon").shutdown(b,c),a("pilot/canon").shutdown(b,c)}}),define("pilot/types/basic",["require","exports","module","pilot/types"],function(a,b,c){function m(a){if(a instanceof e)this.subtype=a;else{if(typeof a!=="string")throw new Error("Can' handle array subtype");this.subtype=d.getType(a);if(this.subtype==null)throw new Error("Unknown array subtype: "+a)}}function l(a){if(typeof a.defer!=="function")throw new Error("Instances of DeferredType need typeSpec.defer to be a function that returns a type");Object.keys(a).forEach(function(b){this[b]=a[b]},this)}function j(a){if(!Array.isArray(a.data)&&typeof a.data!=="function")throw new Error("instances of SelectionType need typeSpec.data to be an array or function that returns an array:"+JSON.stringify(a));Object.keys(a).forEach(function(b){this[b]=a[b]},this)}var d=a("pilot/types"),e=d.Type,f=d.Conversion,g=d.Status,h=new e;h.stringify=function(a){return a},h.parse=function(a){if(typeof a!="string")throw new Error("non-string passed to text.parse()");return new f(a)},h.name="text";var i=new e;i.stringify=function(a){if(!a)return null;return""+a},i.parse=function(a){if(typeof a!="string")throw new Error("non-string passed to number.parse()");if(a.replace(/\s/g,"").length===0)return new f(null,g.INCOMPLETE,"");var b=new f(parseInt(a,10));isNaN(b.value)&&(b.status=g.INVALID,b.message="Can't convert \""+a+'" to a number.');return b},i.decrement=function(a){return a-1},i.increment=function(a){return a+1},i.name="number",j.prototype=new e,j.prototype.stringify=function(a){return a},j.prototype.parse=function(a){if(typeof a!="string")throw new Error("non-string passed to parse()");if(!this.data)throw new Error("Missing data on selection type extension.");var b=typeof this.data==="function"?this.data():this.data,c=!1,d,e=[];b.forEach(function(b){a==b?(d=this.fromString(b),c=!0):b.indexOf(a)===0&&e.push(this.fromString(b))},this);if(c)return new f(d);this.noMatch&&this.noMatch();if(e.length>0){var h="Possibilities"+(a.length===0?"":" for '"+a+"'");return new f(null,g.INCOMPLETE,h,e)}var h="Can't use '"+a+"'.";return new f(null,g.INVALID,h,e)},j.prototype.fromString=function(a){return a},j.prototype.decrement=function(a){var b=typeof this.data==="function"?this.data():this.data,c;if(a==null)c=b.length-1;else{var d=this.stringify(a),c=b.indexOf(d);c=c===0?b.length-1:c-1}return this.fromString(b[c])},j.prototype.increment=function(a){var b=typeof this.data==="function"?this.data():this.data,c;if(a==null)c=0;else{var d=this.stringify(a),c=b.indexOf(d);c=c===b.length-1?0:c+1}return this.fromString(b[c])},j.prototype.name="selection",b.SelectionType=j;var k=new j({name:"bool",data:["true","false"],stringify:function(a){return""+a},fromString:function(a){return a==="true"?!0:!1}});l.prototype=new e,l.prototype.stringify=function(a){return this.defer().stringify(a)},l.prototype.parse=function(a){return this.defer().parse(a)},l.prototype.decrement=function(a){var b=this.defer();return b.decrement?b.decrement(a):undefined},l.prototype.increment=function(a){var b=this.defer();return b.increment?b.increment(a):undefined},l.prototype.name="deferred",b.DeferredType=l,m.prototype=new e,m.prototype.stringify=function(a){return a.join(" ")},m.prototype.parse=function(a){return this.defer().parse(a)},m.prototype.name="array";var n=!1;b.startup=function(){n||(n=!0,d.registerType(h),d.registerType(i),d.registerType(k),d.registerType(j),d.registerType(l),d.registerType(m))},b.shutdown=function(){n=!1,d.unregisterType(h),d.unregisterType(i),d.unregisterType(k),d.unregisterType(j),d.unregisterType(l),d.unregisterType(m)}}),define("pilot/types",["require","exports","module"],function(a,b,c){function i(a,b){if(a.substr(-2)==="[]"){var c=a.slice(0,-2);return new g.array(c)}var d=g[a];typeof d==="function"&&(d=new d(b));return d}function f(){}function e(a,b,c,e){this.value=a,this.status=b||d.VALID,this.message=c,this.predictions=e||[]}var d={VALID:{toString:function(){return"VALID"},valueOf:function(){return 0}},INCOMPLETE:{toString:function(){return"INCOMPLETE"},valueOf:function(){return 1}},INVALID:{toString:function(){return"INVALID"},valueOf:function(){return 2}},combine:function(a){var b=d.VALID;for(var c=0;cb.valueOf()&&(b=a[c]);return b}};b.Status=d,b.Conversion=e,f.prototype={stringify:function(a){throw new Error("not implemented")},parse:function(a){throw new Error("not implemented")},name:undefined,increment:function(a){return undefined},decrement:function(a){return undefined},getDefault:function(){return this.parse("")}},b.Type=f;var g={};b.registerType=function(a){if(typeof a==="object"){if(!(a instanceof f))throw new Error("Can't registerType using: "+a);if(!a.name)throw new Error("All registered types must have a name");g[a.name]=a}else{if(typeof a!=="function")throw new Error("Unknown type: "+a);if(!a.prototype.name)throw new Error("All registered types must have a name");g[a.prototype.name]=a}},b.registerTypes=function h(a){Object.keys(a).forEach(function(c){var d=a[c];d.name=c,b.registerType(d)})},b.deregisterType=function(a){delete g[a.name]},b.getType=function(a){if(typeof a==="string")return i(a);if(typeof a==="object"){if(!a.name)throw new Error("Missing 'name' member to typeSpec");return i(a.name,a)}throw new Error("Can't extract type from "+a)}}),define("pilot/types/command",["require","exports","module","pilot/canon","pilot/types/basic","pilot/types"],function(a,b,c){var d=a("pilot/canon"),e=a("pilot/types/basic").SelectionType,f=a("pilot/types"),g=new e({name:"command",data:function(){return d.getCommandNames()},stringify:function(a){return a.name},fromString:function(a){return d.getCommand(a)}});b.startup=function(){f.registerType(g)},b.shutdown=function(){f.unregisterType(g)}}),define("pilot/canon",["require","exports","module","pilot/console","pilot/stacktrace","pilot/oop","pilot/useragent","pilot/keys","pilot/event_emitter","pilot/typecheck","pilot/catalog","pilot/types","pilot/lang"],function(a,b,c){function J(a){a=a||{},this.command=a.command,this.args=a.args,this.typed=a.typed,this._begunOutput=!1,this.start=new Date,this.end=null,this.completed=!1,this.error=!1}function G(a,b,c,e,f){function h(){a.exec(b,g.args,g),!g.isAsync&&!g.isDone&&g.done()}typeof a==="string"&&(a=q[a]);if(!a)return!1;var g=new J({sender:c,command:a,args:e||{},typed:f});if(g.getStatus()==l.INVALID){d.error("Canon.exec: Invalid parameter(s) passed to "+a.name);return!1}if(g.getStatus()==l.INCOMPLETE){var i,j=b[c];if(!j||!j.getArgsProvider||!(i=j.getArgsProvider()))i=F;i(g,function(){g.getStatus()==l.VALID&&h()});return!0}h();return!0}function F(a,b){var c=a.args,d=a.command.params;for(var e=0;eI)H.shiftObject();b._dispatchEvent("output",{requests:H,request:this})},J.prototype.doneWithError=function(a){this.error=!0,this.done(a)},J.prototype.async=function(){this.isAsync=!0,this._begunOutput||this._beginOutput()},J.prototype.output=function(a){this._begunOutput||this._beginOutput(),typeof a!=="string"&&!(a instanceof Node)&&(a=a.toString()),this.outputs.push(a),this.isDone=!0,this._dispatchEvent("output",{});return this},J.prototype.done=function(a){this.completed=!0,this.end=new Date,this.duration=this.end.getTime()-this.start.getTime(),a&&this.output(a),this.isDone||(this.isDone=!0,this._dispatchEvent("output",{}))},b.Request=J}),define("pilot/console",["require","exports","module"],function(a,b,c){var d=function(){},e=["assert","count","debug","dir","dirxml","error","group","groupEnd","info","log","profile","profileEnd","time","timeEnd","trace","warn"];typeof window==="undefined"?e.forEach(function(a){b[a]=function(){var b=Array.prototype.slice.call(arguments),c={op:"log",method:a,args:b};postMessage(JSON.stringify(c))}}):e.forEach(function(a){window.console&&window.console[a]?b[a]=Function.prototype.bind.call(window.console[a],window.console):b[a]=d})}),define("pilot/stacktrace",["require","exports","module","pilot/useragent","pilot/console"],function(a,b,c){function i(){}function g(a){for(var b=0;b\s*\(/gm,"{anonymous}()@").split("\n")},firefox:function(a){var b=a.stack;if(!b){e.log(a);return[]}b=b.replace(/(?:\n@:0)?\s+$/m,""),b=b.replace(/^\(/gm,"{anonymous}(");return b.split("\n")},opera:function(a){var b=a.message.split("\n"),c="{anonymous}",d=/Line\s+(\d+).*?script\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i,e,f,g;for(e=4,f=0,g=b.length;e=0,b.isIPad=e.indexOf("iPad")>=0,b.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"},b.getOS=function(){return b.isMac?b.OS.MAC:b.isLinux?b.OS.LINUX:b.OS.WINDOWS}}),define("pilot/oop",["require","exports","module"],function(a,b,c){b.inherits=function(){var a=function(){};return function(b,c){a.prototype=c.prototype,b.super_=c.prototype,b.prototype=new a,b.prototype.constructor=b}}(),b.mixin=function(a,b){for(var c in b)a[c]=b[c]},b.implement=function(a,c){b.mixin(a,c)}}),define("pilot/keys",["require","exports","module","pilot/oop"],function(a,b,c){var d=a("pilot/oop"),e=function(){var a={MODIFIER_KEYS:{16:"Shift",17:"Ctrl",18:"Alt",224:"Meta"},KEY_MODS:{ctrl:1,alt:2,option:2,shift:4,meta:8,command:8},FUNCTION_KEYS:{8:"Backspace",9:"Tab",13:"Return",19:"Pause",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"Print",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Numlock",145:"Scrolllock"},PRINTABLE_KEYS:{32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:'"'}};for(i in a.FUNCTION_KEYS){var b=a.FUNCTION_KEYS[i].toUpperCase();a[b]=parseInt(i,10)}d.mixin(a,a.MODIFIER_KEYS),d.mixin(a,a.PRINTABLE_KEYS),d.mixin(a,a.FUNCTION_KEYS);return a}();d.mixin(b,e),b.keyCodeToString=function(a){return(e[a]||String.fromCharCode(a)).toLowerCase()}}),define("pilot/event_emitter",["require","exports","module"],function(a,b,c){var d={};d._emit=d._dispatchEvent=function(a,b){this._eventRegistry=this._eventRegistry||{};var c=this._eventRegistry[a];if(c&&c.length){var b=b||{};b.type=a;for(var d=0;d"+setting.name+" = "+setting.get():(b.setting.set(b.value),d="Setting: "+b.setting.name+" = "+b.setting.get());else{var e=a.settings.getSettingNames();d="",e.sort(function(a,b){return a.localeCompare(b)}),e.forEach(function(b){var c=a.settings.getSetting(b),e="https://wiki.mozilla.org/Labs/Skywriter/Settings#"+c.name;d+=''+c.name+" = "+c.value+" "})}c.done(d)}},e={name:"unset",params:[{name:"setting",type:"setting",description:"The name of the setting to return to defaults"}],description:"unset a setting entirely",exec:function(a,b,c){var d=a.settings.get(b.setting);d?(d.reset(),c.done("Reset "+d.name+" to default: "+a.settings.get(b.setting))):c.doneWithError("No setting with the name "+b.setting+".")}},f=a("pilot/canon");b.startup=function(a,b){f.addCommand(d),f.addCommand(e)},b.shutdown=function(a,b){f.removeCommand(d),f.removeCommand(e)}}),define("pilot/commands/basic",["require","exports","module","pilot/typecheck","pilot/canon"],function(require,exports,module){var checks=require("pilot/typecheck"),canon=require("pilot/canon"),helpMessages={plainPrefix:'
',plainSuffix:'For more information, see the Skywriter Wiki.'},helpCommandSpec={name:"help",params:[{name:"search",type:"text",description:"Search string to narrow the output.",defaultValue:null}],description:"Get help on the available commands.",exec:function(a,b,c){var d=[],e=canon.getCommand(b.search);if(e&&e.exec)d.push(e.description?e.description:"No description for "+b.search);else{var f=!1;!b.search&&helpMessages.plainPrefix&&d.push(helpMessages.plainPrefix),e?(d.push("
"),!b.search&&helpMessages.plainSuffix&&d.push(helpMessages.plainSuffix)}c.done(d.join(""))}},evalCommandSpec={name:"eval",params:[{name:"javascript",type:"text",description:"The JavaScript to evaluate"}],description:"evals given js code and show the result",hidden:!0,exec:function(env,args,request){var result,javascript=args.javascript;try{result=eval(javascript)}catch(e){result="Error: "+e.message+""}var msg="",type="",x;if(checks.isFunction(result))msg=(result+"").replace(/\n/g," ").replace(/ /g," "),type="function";else if(checks.isObject(result)){Array.isArray(result)?type="array":type="object";var items=[],value;for(x in result)result.hasOwnProperty(x)&&(checks.isFunction(result[x])?value="[function]":checks.isObject(result[x])?value="[object]":value=result[x],items.push({name:x,value:value}));items.sort(function(a,b){return a.name.toLowerCase()"+items[x].name+": "+items[x].value+" "}else msg=result,type=typeof result;request.done("Result for eval '"+javascript+"' (type: "+type+"):
',plainSuffix:'For more information, see the Skywriter Wiki.'},helpCommandSpec={name:"help",params:[{name:"search",type:"text",description:"Search string to narrow the output.",defaultValue:null}],description:"Get help on the available commands.",exec:function(a,b,c){var d=[],e=canon.getCommand(b.search);if(e&&e.exec)d.push(e.description?e.description:"No description for "+b.search);else{var f=!1;!b.search&&helpMessages.plainPrefix&&d.push(helpMessages.plainPrefix),e?(d.push("
"),!b.search&&helpMessages.plainSuffix&&d.push(helpMessages.plainSuffix)}c.done(d.join(""))}},evalCommandSpec={name:"eval",params:[{name:"javascript",type:"text",description:"The JavaScript to evaluate"}],description:"evals given js code and show the result",hidden:!0,exec:function(env,args,request){var result,javascript=args.javascript;try{result=eval(javascript)}catch(e){result="Error: "+e.message+""}var msg="",type="",x;if(checks.isFunction(result))msg=(result+"").replace(/\n/g," ").replace(/ /g," "),type="function";else if(checks.isObject(result)){Array.isArray(result)?type="array":type="object";var items=[],value;for(x in result)result.hasOwnProperty(x)&&(checks.isFunction(result[x])?value="[function]":checks.isObject(result[x])?value="[object]":value=result[x],items.push({name:x,value:value}));items.sort(function(a,b){return a.name.toLowerCase()"+items[x].name+": "+items[x].value+" "}else msg=result,type=typeof result;request.done("Result for eval '"+javascript+"' (type: "+type+"):
',plainSuffix:'For more information, see the Skywriter Wiki.'},helpCommandSpec={name:"help",params:[{name:"search",type:"text",description:"Search string to narrow the output.",defaultValue:null}],description:"Get help on the available commands.",exec:function(a,b,c){var d=[],e=canon.getCommand(b.search);if(e&&e.exec)d.push(e.description?e.description:"No description for "+b.search);else{var f=!1;!b.search&&helpMessages.plainPrefix&&d.push(helpMessages.plainPrefix),e?(d.push("
"),!b.search&&helpMessages.plainSuffix&&d.push(helpMessages.plainSuffix)}c.done(d.join(""))}},evalCommandSpec={name:"eval",params:[{name:"javascript",type:"text",description:"The JavaScript to evaluate"}],description:"evals given js code and show the result",hidden:!0,exec:function(env,args,request){var result,javascript=args.javascript;try{result=eval(javascript)}catch(e){result="Error: "+e.message+""}var msg="",type="",x;if(checks.isFunction(result))msg=(result+"").replace(/\n/g," ").replace(/ /g," "),type="function";else if(checks.isObject(result)){Array.isArray(result)?type="array":type="object";var items=[],value;for(x in result)result.hasOwnProperty(x)&&(checks.isFunction(result[x])?value="[function]":checks.isObject(result[x])?value="[object]":value=result[x],items.push({name:x,value:value}));items.sort(function(a,b){return a.name.toLowerCase()"+items[x].name+": "+items[x].value+" "}else msg=result,type=typeof result;request.done("Result for eval '"+javascript+"' (type: "+type+"):
',plainSuffix:'For more information, see the Skywriter Wiki.'},helpCommandSpec={name:"help",params:[{name:"search",type:"text",description:"Search string to narrow the output.",defaultValue:null}],description:"Get help on the available commands.",exec:function(a,b,c){var d=[],e=canon.getCommand(b.search);if(e&&e.exec)d.push(e.description?e.description:"No description for "+b.search);else{var f=!1;!b.search&&helpMessages.plainPrefix&&d.push(helpMessages.plainPrefix),e?(d.push("
"),!b.search&&helpMessages.plainSuffix&&d.push(helpMessages.plainSuffix)}c.done(d.join(""))}},evalCommandSpec={name:"eval",params:[{name:"javascript",type:"text",description:"The JavaScript to evaluate"}],description:"evals given js code and show the result",hidden:!0,exec:function(env,args,request){var result,javascript=args.javascript;try{result=eval(javascript)}catch(e){result="Error: "+e.message+""}var msg="",type="",x;if(checks.isFunction(result))msg=(result+"").replace(/\n/g," ").replace(/ /g," "),type="function";else if(checks.isObject(result)){Array.isArray(result)?type="array":type="object";var items=[],value;for(x in result)result.hasOwnProperty(x)&&(checks.isFunction(result[x])?value="[function]":checks.isObject(result[x])?value="[object]":value=result[x],items.push({name:x,value:value}));items.sort(function(a,b){return a.name.toLowerCase()"+items[x].name+": "+items[x].value+" "}else msg=result,type=typeof result;request.done("Result for eval '"+javascript+"' (type: "+type+"):