separation of rows and cli, more refactoring for new world, copying images from skywriter
This commit is contained in:
parent
b4411583dd
commit
15fddc071c
19 changed files with 334 additions and 183 deletions
|
|
@ -160,7 +160,8 @@ function getCommandNames() {
|
|||
* everything it needs to about the command params
|
||||
* @param command Either a command, or the name of one
|
||||
*/
|
||||
function exec(command, args) {
|
||||
function exec(command, args, typed) {
|
||||
// TODO: Use requisition.toString rather than 'typed'
|
||||
if (typeof command === 'string') {
|
||||
command = commands[command];
|
||||
}
|
||||
|
|
@ -171,7 +172,12 @@ function exec(command, args) {
|
|||
|
||||
// TODO: Ugg. really?
|
||||
env.selection = env.editor.getSelection();
|
||||
var request = new Request();
|
||||
|
||||
var request = new Request({
|
||||
command: command,
|
||||
args: args,
|
||||
typed: typed
|
||||
});
|
||||
command.exec(env, args || {}, request);
|
||||
return true;
|
||||
};
|
||||
|
|
@ -216,21 +222,6 @@ var requests = [];
|
|||
*/
|
||||
var maxRequestLength = 100;
|
||||
|
||||
/**
|
||||
* Called by Request instances when some output (or a cell to async() happens)
|
||||
*/
|
||||
function addRequestOutput(request) {
|
||||
requests.push(request);
|
||||
// This could probably be optimized with some maths, but 99.99% of the
|
||||
// time we will only be off by one, and I'm feeling lazy.
|
||||
while (requests.length > maxRequestLength) {
|
||||
requests.shiftObject();
|
||||
}
|
||||
|
||||
exports._dispatchEvent('output', { requests: requests });
|
||||
};
|
||||
exports.addRequestOutput = addRequestOutput;
|
||||
|
||||
/**
|
||||
* To create an invocation, you need to do something like this (all the ctor
|
||||
* args are optional):
|
||||
|
|
@ -249,7 +240,6 @@ function Request(options) {
|
|||
|
||||
// Will be used in the keyboard case and the cli case
|
||||
this.command = options.command;
|
||||
this.commandExt = options.commandExt;
|
||||
|
||||
// Will be used only in the cli case
|
||||
this.args = options.args;
|
||||
|
|
@ -274,7 +264,14 @@ Request.prototype._beginOutput = function() {
|
|||
this._begunOutput = true;
|
||||
this.outputs = [];
|
||||
|
||||
exports.addRequestOutput(this);
|
||||
requests.push(this);
|
||||
// This could probably be optimized with some maths, but 99.99% of the
|
||||
// time we will only be off by one, and I'm feeling lazy.
|
||||
while (requests.length > maxRequestLength) {
|
||||
requests.shiftObject();
|
||||
}
|
||||
|
||||
exports._dispatchEvent('output', { requests: requests, request: this });
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -311,7 +308,7 @@ Request.prototype.output = function(content) {
|
|||
}
|
||||
|
||||
this.outputs.push(content);
|
||||
this._dispatchEvent('changed', {});
|
||||
this._dispatchEvent('output', {});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
|
@ -329,7 +326,7 @@ Request.prototype.done = function(content) {
|
|||
this.output(content);
|
||||
}
|
||||
|
||||
this._dispatchEvent('changed', {});
|
||||
this._dispatchEvent('output', {});
|
||||
};
|
||||
exports.Request = Request;
|
||||
|
||||
|
|
|
|||
|
|
@ -59,19 +59,15 @@ var setCommandSpec = {
|
|||
var html;
|
||||
if (!args.setting) {
|
||||
// 'set' by itself lists all the settings
|
||||
var settingsList = env.settings._list();
|
||||
var names = env.settings.getSettingNames();
|
||||
html = '';
|
||||
// first sort the settingsList based on the name
|
||||
settingsList.sort(function(a, b) {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
} else if (a.name == b.name) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
names.sort(function(name1, name2) {
|
||||
return name1.localeCompare(name2);
|
||||
});
|
||||
settingsList.forEach(function(setting) {
|
||||
|
||||
names.forEach(function(name) {
|
||||
var setting = env.settings.getSetting(name);
|
||||
var url = 'https://wiki.mozilla.org/Labs/Skywriter/Settings#' +
|
||||
setting.name;
|
||||
html += '<a class="setting" href="' + url +
|
||||
|
|
|
|||
|
|
@ -398,9 +398,7 @@ Templater.prototype.logError = function(message) {
|
|||
console.log(message);
|
||||
};
|
||||
|
||||
if (this.exports) {
|
||||
exports.Templater = Templater;
|
||||
}
|
||||
exports.Templater = Templater;
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue