Compare commits
46 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e41a14a211 | ||
|
|
77cf3b64e3 | ||
|
|
b16e7ef478 | ||
|
|
facbfe8ccf | ||
|
|
abd9a0b5e1 | ||
|
|
103255f4d2 | ||
|
|
86910f6605 | ||
|
|
b5a3e64f60 | ||
|
|
7a33ecbbce | ||
|
|
6a5ac01453 | ||
|
|
a6c9a0463d | ||
|
|
34bc1cf6ea | ||
|
|
3ba5c09099 | ||
|
|
817ff7ce5e | ||
|
|
45a7be6b43 | ||
|
|
6af328f0f4 | ||
|
|
ab3ac17533 | ||
|
|
6e7d9e61c0 | ||
|
|
4fc695fb67 | ||
|
|
b6e3f52faf | ||
|
|
2ddec8717c | ||
|
|
2d43ddd047 | ||
|
|
d80f0fe66e | ||
|
|
d8cb48191d | ||
|
|
37e9c8ed56 | ||
|
|
9530383e41 | ||
|
|
953cc3b240 | ||
|
|
1e24a23ca5 | ||
|
|
a48d0e7688 | ||
|
|
4900fa2f9f | ||
|
|
6508ebea8c | ||
|
|
f70310742a | ||
|
|
667b11e013 | ||
|
|
a6aa2ec6ee | ||
|
|
88a335b500 | ||
|
|
f332454b38 | ||
|
|
ed7427cd79 | ||
|
|
13c5afa300 | ||
|
|
d22f292b81 | ||
|
|
bc088c7130 | ||
|
|
a87c219c30 | ||
|
|
96966f5035 | ||
|
|
b4de6451c8 | ||
|
|
e59930c372 | ||
|
|
a9e93ef6ba | ||
|
|
3c534b62ae |
56 changed files with 1813 additions and 568 deletions
5
.gitmodules
vendored
5
.gitmodules
vendored
|
|
@ -1,6 +1,3 @@
|
||||||
[submodule "support/cockpit"]
|
[submodule "support/cockpit"]
|
||||||
path = support/cockpit
|
path = support/cockpit
|
||||||
url = git://github.com/ajaxorg/cockpit.git
|
url = git://github.com/joewalker/cockpit.git
|
||||||
[submodule "support/pilot"]
|
|
||||||
path = support/pilot
|
|
||||||
url = git://github.com/ajaxorg/pilot.git
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ var project = copy.createCommonJsProject([
|
||||||
aceHome + '/demo'
|
aceHome + '/demo'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
copy({
|
copy({
|
||||||
source: "build_support/editor.html",
|
source: "build_support/editor.html",
|
||||||
dest: 'build/editor.html'
|
dest: 'build/editor.html'
|
||||||
|
|
@ -74,8 +75,8 @@ copy({
|
||||||
require: [
|
require: [
|
||||||
"pilot/fixoldbrowsers",
|
"pilot/fixoldbrowsers",
|
||||||
"pilot/index",
|
"pilot/index",
|
||||||
"pilot/plugin_manager",
|
"ace/plugin_manager",
|
||||||
"pilot/environment",
|
"ace/environment",
|
||||||
"ace/editor",
|
"ace/editor",
|
||||||
"ace/edit_session",
|
"ace/edit_session",
|
||||||
"ace/undomanager",
|
"ace/undomanager",
|
||||||
|
|
@ -118,50 +119,50 @@ copy({
|
||||||
dest: 'build/src/ace-uncompressed.js'
|
dest: 'build/src/ace-uncompressed.js'
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('# cockpit ---------');
|
console.log('# gcli ---------');
|
||||||
|
|
||||||
project.assumeAllFilesLoaded();
|
project.assumeAllFilesLoaded();
|
||||||
project.addRoot(aceHome + '/support/cockpit/lib');
|
project.addRoot(aceHome + '/support/gcli/lib');
|
||||||
|
|
||||||
var cockpit = copy.createDataObject();
|
var gcli = copy.createDataObject();
|
||||||
copy({
|
copy({
|
||||||
source: [
|
source: [
|
||||||
copy.source.commonjs({
|
copy.source.commonjs({
|
||||||
project: project,
|
project: project,
|
||||||
require: [ 'cockpit/index' ]
|
require: [ 'gcli/index' ]
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
filter: [ copy.filter.moduleDefines ],
|
filter: [ copy.filter.moduleDefines ],
|
||||||
dest: cockpit
|
dest: gcli
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: {
|
source: {
|
||||||
root: aceHome + '/support/cockpit/lib',
|
root: aceHome + '/support/gcli/lib',
|
||||||
include: /.*\.css$|.*\.html$/,
|
include: /.*\.css$|.*\.html$/,
|
||||||
exclude: /tests?\//
|
exclude: /tests?\//
|
||||||
},
|
},
|
||||||
filter: [ copy.filter.addDefines ],
|
filter: [ copy.filter.addDefines ],
|
||||||
dest: cockpit
|
dest: gcli
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: {
|
source: {
|
||||||
root: aceHome + '/support/cockpit/lib',
|
root: aceHome + '/support/gcli/lib',
|
||||||
include: /.*\.png$|.*\.gif$/,
|
include: /.*\.png$|.*\.gif$/,
|
||||||
exclude: /tests?\//
|
exclude: /tests?\//
|
||||||
},
|
},
|
||||||
filter: [ copy.filter.base64 ],
|
filter: [ copy.filter.base64 ],
|
||||||
dest: cockpit
|
dest: gcli
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the compressed and uncompressed output files
|
// Create the compressed and uncompressed output files
|
||||||
copy({
|
copy({
|
||||||
source: cockpit,
|
source: gcli,
|
||||||
filter: copy.filter.uglifyjs,
|
filter: copy.filter.uglifyjs,
|
||||||
dest: 'build/src/cockpit.js'
|
dest: 'build/src/gcli.js'
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: cockpit,
|
source: gcli,
|
||||||
dest: 'build/src/cockpit-uncompressed.js'
|
dest: 'build/src/gcli-uncompressed.js'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -269,7 +270,7 @@ copy({
|
||||||
// source: aceHome + "/editor.html",
|
// source: aceHome + "/editor.html",
|
||||||
// filter: [ function(data) {
|
// filter: [ function(data) {
|
||||||
// var includes = [
|
// var includes = [
|
||||||
// "ace", "cockpit",
|
// "ace", "gcli",
|
||||||
// "keybinding-vim", "keybinding-emacs",
|
// "keybinding-vim", "keybinding-emacs",
|
||||||
// "mode-javascript", "mode-css", "mode-html", "mode-php", "mode-python",
|
// "mode-javascript", "mode-css", "mode-html", "mode-php", "mode-python",
|
||||||
// "mode-xml",
|
// "mode-xml",
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,8 @@ copy({
|
||||||
require: [
|
require: [
|
||||||
"pilot/fixoldbrowsers",
|
"pilot/fixoldbrowsers",
|
||||||
"pilot/index",
|
"pilot/index",
|
||||||
"pilot/plugin_manager",
|
"ace/plugin_manager",
|
||||||
"pilot/environment",
|
"ace/environment",
|
||||||
"ace/editor",
|
"ace/editor",
|
||||||
"ace/edit_session",
|
"ace/edit_session",
|
||||||
"ace/undomanager",
|
"ace/undomanager",
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@
|
||||||
var deps = [
|
var deps = [
|
||||||
"pilot/fixoldbrowsers",
|
"pilot/fixoldbrowsers",
|
||||||
"pilot/index",
|
"pilot/index",
|
||||||
"pilot/plugin_manager",
|
"ace/plugin_manager",
|
||||||
"pilot/environment",
|
"ace/environment",
|
||||||
"ace/editor",
|
"ace/editor",
|
||||||
"ace/edit_session",
|
"ace/edit_session",
|
||||||
"ace/virtual_renderer",
|
"ace/virtual_renderer",
|
||||||
|
|
@ -72,7 +72,7 @@ require(deps, function() {
|
||||||
var editor = new Editor(new Renderer(el, "ace/theme/textmate"));
|
var editor = new Editor(new Renderer(el, "ace/theme/textmate"));
|
||||||
editor.setSession(doc);
|
editor.setSession(doc);
|
||||||
|
|
||||||
var env = require("pilot/environment").create();
|
var env = require("ace/environment").create();
|
||||||
catalog.startupPlugins({ env: env }).then(function() {
|
catalog.startupPlugins({ env: env }).then(function() {
|
||||||
env.document = doc;
|
env.document = doc;
|
||||||
env.editor = editor;
|
env.editor = editor;
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ var require = window.__ace_shadowed__.require;
|
||||||
var deps = [
|
var deps = [
|
||||||
"pilot/fixoldbrowsers",
|
"pilot/fixoldbrowsers",
|
||||||
"pilot/index",
|
"pilot/index",
|
||||||
"pilot/plugin_manager",
|
"ace/plugin_manager",
|
||||||
"pilot/environment",
|
"ace/environment",
|
||||||
"ace/editor",
|
"ace/editor",
|
||||||
"ace/edit_session",
|
"ace/edit_session",
|
||||||
"ace/virtual_renderer",
|
"ace/virtual_renderer",
|
||||||
|
|
@ -58,7 +58,7 @@ catalog.registerPlugins([ "pilot/index" ]);
|
||||||
|
|
||||||
var Dom = require("pilot/dom");
|
var Dom = require("pilot/dom");
|
||||||
var Event = require("pilot/event");
|
var Event = require("pilot/event");
|
||||||
var UA = require("pilot/useragent")
|
var UA = require("pilot/useragent");
|
||||||
|
|
||||||
var Editor = require("ace/editor").Editor;
|
var Editor = require("ace/editor").Editor;
|
||||||
var EditSession = require("ace/edit_session").EditSession;
|
var EditSession = require("ace/edit_session").EditSession;
|
||||||
|
|
@ -77,7 +77,7 @@ window.__ace_shadowed__.edit = function(el) {
|
||||||
var editor = new Editor(new Renderer(el, "ace/theme/textmate"));
|
var editor = new Editor(new Renderer(el, "ace/theme/textmate"));
|
||||||
editor.setSession(doc);
|
editor.setSession(doc);
|
||||||
|
|
||||||
var env = require("pilot/environment").create();
|
var env = require("ace/environment").create();
|
||||||
catalog.startupPlugins({ env: env }).then(function() {
|
catalog.startupPlugins({ env: env }).then(function() {
|
||||||
env.document = doc;
|
env.document = doc;
|
||||||
env.editor = env;
|
env.editor = env;
|
||||||
|
|
@ -88,7 +88,7 @@ window.__ace_shadowed__.edit = function(el) {
|
||||||
el.env = env;
|
el.env = env;
|
||||||
});
|
});
|
||||||
return editor;
|
return editor;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -203,7 +203,7 @@ function setupContainer(element, getValue) {
|
||||||
if (oldSumit) {
|
if (oldSumit) {
|
||||||
oldSumit.call(this, evt);
|
oldSumit.call(this, evt);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parentNode = parentNode.parentNode;
|
parentNode = parentNode.parentNode;
|
||||||
|
|
@ -284,13 +284,13 @@ window.__ace_shadowed__.transformTextarea = function(element) {
|
||||||
editorDiv.appendChild(settingOpener);
|
editorDiv.appendChild(settingOpener);
|
||||||
|
|
||||||
// Create the API.
|
// Create the API.
|
||||||
var api = setupApi(editor, editorDiv, settingDiv, ace, options)
|
var api = setupApi(editor, editorDiv, settingDiv, ace, options);
|
||||||
|
|
||||||
// Create the setting's panel.
|
// Create the setting's panel.
|
||||||
setupSettingPanel(settingDiv, settingOpener, api, options);
|
setupSettingPanel(settingDiv, settingOpener, api, options);
|
||||||
|
|
||||||
return api;
|
return api;
|
||||||
}
|
};
|
||||||
|
|
||||||
function setupApi(editor, editorDiv, settingDiv, ace, options) {
|
function setupApi(editor, editorDiv, settingDiv, ace, options) {
|
||||||
var session = editor.getSession();
|
var session = editor.getSession();
|
||||||
|
|
@ -372,7 +372,7 @@ function setupApi(editor, editorDiv, settingDiv, ace, options) {
|
||||||
|
|
||||||
case "showPrintMargin":
|
case "showPrintMargin":
|
||||||
renderer.setShowPrintMargin(toBool(value));
|
renderer.setShowPrintMargin(toBool(value));
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
options[key] = value;
|
options[key] = value;
|
||||||
|
|
@ -385,7 +385,7 @@ function setupApi(editor, editorDiv, settingDiv, ace, options) {
|
||||||
getOptions: function() {
|
getOptions: function() {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
for (option in ace.options) {
|
for (option in ace.options) {
|
||||||
ret.setOption(option, ace.options[option]);
|
ret.setOption(option, ace.options[option]);
|
||||||
|
|
@ -398,7 +398,7 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
|
||||||
var BOOL = {
|
var BOOL = {
|
||||||
"true": true,
|
"true": true,
|
||||||
"false": false
|
"false": false
|
||||||
}
|
};
|
||||||
|
|
||||||
var desc = {
|
var desc = {
|
||||||
mode: "Mode:",
|
mode: "Mode:",
|
||||||
|
|
@ -408,7 +408,7 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
|
||||||
softWrap: "Soft Wrap:",
|
softWrap: "Soft Wrap:",
|
||||||
showPrintMargin: "Show Print Margin:",
|
showPrintMargin: "Show Print Margin:",
|
||||||
useSoftTabs: "Use Soft Tabs:"
|
useSoftTabs: "Use Soft Tabs:"
|
||||||
}
|
};
|
||||||
|
|
||||||
var optionValues = {
|
var optionValues = {
|
||||||
mode: {
|
mode: {
|
||||||
|
|
@ -453,13 +453,13 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
|
||||||
},
|
},
|
||||||
showPrintMargin: BOOL,
|
showPrintMargin: BOOL,
|
||||||
useSoftTabs: BOOL
|
useSoftTabs: BOOL
|
||||||
}
|
};
|
||||||
|
|
||||||
var table = [];
|
var table = [];
|
||||||
table.push("<table><tr><th>Setting</th><th>Value</th></tr>");
|
table.push("<table><tr><th>Setting</th><th>Value</th></tr>");
|
||||||
|
|
||||||
function renderOption(builder, option, obj, cValue) {
|
function renderOption(builder, option, obj, cValue) {
|
||||||
builder.push("<select title='" + option + "'>")
|
builder.push("<select title='" + option + "'>");
|
||||||
for (var value in obj) {
|
for (var value in obj) {
|
||||||
builder.push("<option value='" + value + "' ");
|
builder.push("<option value='" + value + "' ");
|
||||||
|
|
||||||
|
|
@ -471,7 +471,7 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
|
||||||
obj[value],
|
obj[value],
|
||||||
"</option>");
|
"</option>");
|
||||||
}
|
}
|
||||||
builder.push("</select>")
|
builder.push("</select>");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var option in options) {
|
for (var option in options) {
|
||||||
|
|
@ -491,7 +491,7 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
|
||||||
var option = select.title;
|
var option = select.title;
|
||||||
var value = select.value;
|
var value = select.value;
|
||||||
api.setOption(option, value);
|
api.setOption(option, value);
|
||||||
}
|
};
|
||||||
})();
|
})();
|
||||||
selects[i].onchange = onChange;
|
selects[i].onchange = onChange;
|
||||||
}
|
}
|
||||||
|
|
@ -501,12 +501,12 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
|
||||||
button.value = "Hide";
|
button.value = "Hide";
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
api.setDisplaySettings(false);
|
api.setDisplaySettings(false);
|
||||||
}
|
};
|
||||||
settingDiv.appendChild(button);
|
settingDiv.appendChild(button);
|
||||||
|
|
||||||
settingOpener.onclick = function() {
|
settingOpener.onclick = function() {
|
||||||
api.setDisplaySettings(true);
|
api.setDisplaySettings(true);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default startup options.
|
// Default startup options.
|
||||||
|
|
@ -518,8 +518,8 @@ window.__ace_shadowed__.options = {
|
||||||
softWrap: "off",
|
softWrap: "off",
|
||||||
showPrintMargin: "false",
|
showPrintMargin: "false",
|
||||||
useSoftTabs: "true"
|
useSoftTabs: "true"
|
||||||
}
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})()
|
})();
|
||||||
|
|
|
||||||
|
|
@ -40,14 +40,14 @@
|
||||||
* @param module a name for the payload
|
* @param module a name for the payload
|
||||||
* @param payload a function to call with (require, exports, module) params
|
* @param payload a function to call with (require, exports, module) params
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
if (window.require) {
|
if (window.require) {
|
||||||
require.packaged = true;
|
require.packaged = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _define = function(module, deps, payload) {
|
var _define = function(module, deps, payload) {
|
||||||
if (typeof module !== 'string') {
|
if (typeof module !== 'string') {
|
||||||
if (_define.original)
|
if (_define.original)
|
||||||
|
|
@ -64,12 +64,12 @@ var _define = function(module, deps, payload) {
|
||||||
|
|
||||||
if (!define.modules)
|
if (!define.modules)
|
||||||
define.modules = {};
|
define.modules = {};
|
||||||
|
|
||||||
define.modules[module] = payload;
|
define.modules[module] = payload;
|
||||||
};
|
};
|
||||||
if (window.define)
|
if (window.define)
|
||||||
_define.original = window.define;
|
_define.original = window.define;
|
||||||
|
|
||||||
window.define = _define;
|
window.define = _define;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -93,11 +93,11 @@ var _require = function(module, callback) {
|
||||||
var payload = lookup(module);
|
var payload = lookup(module);
|
||||||
if (!payload && _require.original)
|
if (!payload && _require.original)
|
||||||
return _require.original.apply(window, arguments);
|
return _require.original.apply(window, arguments);
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -108,7 +108,7 @@ var _require = function(module, callback) {
|
||||||
|
|
||||||
if (window.require)
|
if (window.require)
|
||||||
_require.original = window.require;
|
_require.original = window.require;
|
||||||
|
|
||||||
window.require = _require;
|
window.require = _require;
|
||||||
require.packaged = true;
|
require.packaged = true;
|
||||||
|
|
||||||
|
|
@ -134,4 +134,4 @@ var lookup = function(moduleName) {
|
||||||
return module;
|
return module;
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ var _require = function(module, callback) {
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
_require.packaged = true;
|
_require.packaged = true;
|
||||||
_require.noWorker = true;
|
_require.noWorker = true;
|
||||||
|
|
|
||||||
24
demo/boot.js
24
demo/boot.js
|
|
@ -39,21 +39,29 @@ require({
|
||||||
paths: {
|
paths: {
|
||||||
demo: "../demo",
|
demo: "../demo",
|
||||||
ace: "../lib/ace",
|
ace: "../lib/ace",
|
||||||
cockpit: "../support/cockpit/lib/cockpit",
|
gcli: "../support/cockpit/lib/gcli",
|
||||||
pilot: "../support/pilot/lib/pilot"
|
pilot: "../support/cockpit/support/pilot/lib/pilot"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var deps = [ "pilot/fixoldbrowsers", "pilot/plugin_manager", "pilot/settings",
|
var deps = [
|
||||||
"pilot/environment", "demo/demo" ];
|
"pilot/fixoldbrowsers",
|
||||||
|
"ace/plugin_manager",
|
||||||
|
"ace/environment",
|
||||||
|
"demo/demo"
|
||||||
|
];
|
||||||
|
|
||||||
var plugins = [ "pilot/index", "cockpit/index", "ace/defaults" ];
|
|
||||||
require(deps, function() {
|
require(deps, function() {
|
||||||
var catalog = require("pilot/plugin_manager").catalog;
|
var catalog = require("ace/plugin_manager").catalog;
|
||||||
|
|
||||||
|
var plugins = [ "gcli/index", "ace/index" ];
|
||||||
catalog.registerPlugins(plugins).then(function() {
|
catalog.registerPlugins(plugins).then(function() {
|
||||||
var env = require("pilot/environment").create();
|
var env = require("ace/environment").create();
|
||||||
catalog.startupPlugins({ env: env }).then(function() {
|
catalog.startupPlugins({ env: env }).then(function() {
|
||||||
require("demo/demo").launch(env);
|
require("demo/demo").launch(env);
|
||||||
|
|
||||||
|
var gcli = require("gcli/index");
|
||||||
|
gcli.createView({ env: env });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
53
demo/demo.js
53
demo/demo.js
|
|
@ -36,11 +36,13 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
||||||
|
var keybinding = require('ace/keyboard/keybinding');
|
||||||
|
|
||||||
exports.launch = function(env) {
|
exports.launch = function(env) {
|
||||||
var canon = require("pilot/canon");
|
var gcli = require("gcli/index");
|
||||||
var event = require("pilot/event");
|
var event = require("pilot/event");
|
||||||
var Editor = require("ace/editor").Editor;
|
var Editor = require("ace/editor").Editor;
|
||||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||||
|
|
@ -77,7 +79,7 @@ exports.launch = function(env) {
|
||||||
custom: new HashHandler({
|
custom: new HashHandler({
|
||||||
"gotoright": "Tab"
|
"gotoright": "Tab"
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
var docs = {};
|
var docs = {};
|
||||||
|
|
||||||
|
|
@ -88,7 +90,7 @@ exports.launch = function(env) {
|
||||||
}
|
}
|
||||||
docs.plain = new EditSession(loreIpsum);
|
docs.plain = new EditSession(loreIpsum);
|
||||||
docs.plain.setUseWrapMode(true);
|
docs.plain.setUseWrapMode(true);
|
||||||
docs.plain.setWrapLimitRange(80, 80)
|
docs.plain.setWrapLimitRange(80, 80);
|
||||||
docs.plain.setMode(new TextMode());
|
docs.plain.setMode(new TextMode());
|
||||||
docs.plain.setUndoManager(new UndoManager());
|
docs.plain.setUndoManager(new UndoManager());
|
||||||
|
|
||||||
|
|
@ -393,62 +395,31 @@ exports.launch = function(env) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Command to focus the command line from the editor.
|
// Command to focus the command line from the editor.
|
||||||
canon.addCommand({
|
gcli.addCommand({
|
||||||
name: "focuscli",
|
name: "focuscli",
|
||||||
bindKey: {
|
|
||||||
win: "Ctrl-J",
|
|
||||||
mac: "Command-J",
|
|
||||||
sender: "editor"
|
|
||||||
},
|
|
||||||
exec: function() {
|
exec: function() {
|
||||||
env.cli.cliView.element.focus();
|
env.cli.cliView.element.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-J", mac: "Command-J" }, "focuscli");
|
||||||
|
|
||||||
// Command to focus the editor line from the command line.
|
// Command to focus the editor line from the command line.
|
||||||
canon.addCommand({
|
gcli.addCommand({
|
||||||
name: "focuseditor",
|
name: "focuseditor",
|
||||||
bindKey: {
|
|
||||||
win: "Ctrl-J",
|
|
||||||
mac: "Command-J",
|
|
||||||
sender: "cli"
|
|
||||||
},
|
|
||||||
exec: function() {
|
exec: function() {
|
||||||
env.editor.focus();
|
env.editor.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-J", mac: "Command-J" }, "focuseditor");
|
||||||
|
|
||||||
// Fake-Save, works from the editor and the command line.
|
// Fake-Save, works from the editor and the command line.
|
||||||
canon.addCommand({
|
gcli.addCommand({
|
||||||
name: "save",
|
name: "save",
|
||||||
bindKey: {
|
|
||||||
win: "Ctrl-S",
|
|
||||||
mac: "Command-S",
|
|
||||||
sender: "editor|cli"
|
|
||||||
},
|
|
||||||
exec: function() {
|
exec: function() {
|
||||||
alert("Fake Save File");
|
alert("Fake Save File");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-S", mac: "Command-S" }, "save");
|
||||||
// Fake-Print with custom lookup-sender-match function.
|
|
||||||
canon.addCommand({
|
|
||||||
name: "save",
|
|
||||||
bindKey: {
|
|
||||||
win: "Ctrl-P",
|
|
||||||
mac: "Command-P",
|
|
||||||
sender: function(env, sender, hashId, keyString) {
|
|
||||||
if (sender == "editor") {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
alert("Sorry, can only print from the editor");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
exec: function() {
|
|
||||||
alert("Fake Print File");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#cockpitInput {
|
#gcliInput {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|
@ -36,12 +36,11 @@ body {
|
||||||
font-size: 120%;
|
font-size: 120%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#cockpitOutput {
|
#gcliOutput {
|
||||||
padding: 10px;
|
|
||||||
margin: 0 15px;
|
margin: 0 15px;
|
||||||
border: 1px solid #AAA;
|
border: 1px solid #AAA;
|
||||||
-moz-border-radius-topleft: 10px;
|
-moz-border-radius-topleft: 10px;
|
||||||
-moz-border-radius-topright: 10px;
|
-moz-border-radius-topright: 10px;
|
||||||
border-top-left-radius: 4px; border-top-right-radius: 4px;
|
border-top-left-radius: 4px; border-top-right-radius: 4px;
|
||||||
background: #DDD; color: #000;
|
background: #DDD; color: #000;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ bg. Blockquote!
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<input id="cockpitInput" type="text"/>
|
<input id="gcliInput" type="text"/>
|
||||||
|
|
||||||
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
|
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="demo/boot.js" type="text/javascript"></script>
|
<script src="demo/boot.js" type="text/javascript"></script>
|
||||||
|
|
|
||||||
|
|
@ -179,5 +179,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -40,329 +40,423 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
||||||
var lang = require("pilot/lang");
|
var lang = require("pilot/lang");
|
||||||
var canon = require("pilot/canon");
|
var gcli = require("gcli/index");
|
||||||
|
var keybinding = require('ace/keyboard/keybinding');
|
||||||
|
|
||||||
function bindKey(win, mac) {
|
/**
|
||||||
return {
|
* TODO: This could be done more concisely and reversibly
|
||||||
win: win,
|
*/
|
||||||
mac: mac,
|
exports.startup = function() {
|
||||||
sender: "editor"
|
gcli.addCommand({
|
||||||
};
|
name: "null",
|
||||||
}
|
exec: function(env, args) { }
|
||||||
|
});
|
||||||
|
|
||||||
canon.addCommand({
|
gcli.addCommand({
|
||||||
name: "null",
|
name: "selectall",
|
||||||
exec: function(env, args, request) { }
|
exec: function(env, args) { env.editor.selectAll(); }
|
||||||
});
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-A", mac: "Command-A" }, "selectall");
|
||||||
|
|
||||||
canon.addCommand({
|
gcli.addCommand({
|
||||||
name: "selectall",
|
name: "removeline",
|
||||||
bindKey: bindKey("Ctrl-A", "Command-A"),
|
exec: function(env, args) { env.editor.removeLines(); }
|
||||||
exec: function(env, args, request) { env.editor.selectAll(); }
|
});
|
||||||
});
|
keybinding.bindCommand({ win: "Ctrl-D", mac: "Command-D" }, "removeline");
|
||||||
canon.addCommand({
|
|
||||||
name: "removeline",
|
gcli.addCommand({
|
||||||
bindKey: bindKey("Ctrl-D", "Command-D"),
|
name: "gotoline",
|
||||||
exec: function(env, args, request) { env.editor.removeLines(); }
|
description: "Move the cursor to the given line",
|
||||||
});
|
params: [
|
||||||
canon.addCommand({
|
{ name: "line", type: "number", description: "The line number to jump to" }
|
||||||
name: "gotoline",
|
],
|
||||||
bindKey: bindKey("Ctrl-L", "Command-L"),
|
exec: function(env, args) {
|
||||||
exec: function(env, args, request) {
|
// TODO: manual params should not be needed
|
||||||
var line = parseInt(prompt("Enter line number:"));
|
if (!args.line) {
|
||||||
if (!isNaN(line)) {
|
while (!isNaN(args.line)) {
|
||||||
env.editor.gotoLine(line);
|
args.line = parseInt(prompt("Enter line number:"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
env.editor.gotoLine(args.line);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
keybinding.bindCommand({ win: "Ctrl-L", mac: "Command-L" }, "gotoline");
|
||||||
canon.addCommand({
|
|
||||||
name: "togglecomment",
|
|
||||||
bindKey: bindKey("Ctrl-7", "Command-7"),
|
|
||||||
exec: function(env, args, request) { env.editor.toggleCommentLines(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "findnext",
|
|
||||||
bindKey: bindKey("Ctrl-K", "Command-G"),
|
|
||||||
exec: function(env, args, request) { env.editor.findNext(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "findprevious",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
|
|
||||||
exec: function(env, args, request) { env.editor.findPrevious(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "find",
|
|
||||||
bindKey: bindKey("Ctrl-F", "Command-F"),
|
|
||||||
exec: function(env, args, request) {
|
|
||||||
var needle = prompt("Find:");
|
|
||||||
env.editor.find(needle);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "replace",
|
|
||||||
bindKey: bindKey("Ctrl-R", "Command-Option-F"),
|
|
||||||
exec: function(env, args, request) {
|
|
||||||
var needle = prompt("Find:");
|
|
||||||
if (!needle)
|
|
||||||
return;
|
|
||||||
var replacement = prompt("Replacement:");
|
|
||||||
if (!replacement)
|
|
||||||
return;
|
|
||||||
env.editor.replace(replacement, {needle: needle});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "replaceall",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"),
|
|
||||||
exec: function(env, args, request) {
|
|
||||||
var needle = prompt("Find:");
|
|
||||||
if (!needle)
|
|
||||||
return;
|
|
||||||
var replacement = prompt("Replacement:");
|
|
||||||
if (!replacement)
|
|
||||||
return;
|
|
||||||
env.editor.replaceAll(replacement, {needle: needle});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "undo",
|
|
||||||
bindKey: bindKey("Ctrl-Z", "Command-Z"),
|
|
||||||
exec: function(env, args, request) { env.editor.undo(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "redo",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
|
|
||||||
exec: function(env, args, request) { env.editor.redo(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "overwrite",
|
|
||||||
bindKey: bindKey("Insert", "Insert"),
|
|
||||||
exec: function(env, args, request) { env.editor.toggleOverwrite(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "copylinesup",
|
|
||||||
bindKey: bindKey("Ctrl-Alt-Up", "Command-Option-Up"),
|
|
||||||
exec: function(env, args, request) { env.editor.copyLinesUp(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "movelinesup",
|
|
||||||
bindKey: bindKey("Alt-Up", "Option-Up"),
|
|
||||||
exec: function(env, args, request) { env.editor.moveLinesUp(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selecttostart",
|
|
||||||
bindKey: bindKey("Alt-Shift-Up", "Command-Shift-Up"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectFileStart(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotostart",
|
|
||||||
bindKey: bindKey("Ctrl-Home|Ctrl-Up", "Command-Home|Command-Up"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateFileStart(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectup",
|
|
||||||
bindKey: bindKey("Shift-Up", "Shift-Up"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectUp(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "golineup",
|
|
||||||
bindKey: bindKey("Up", "Up|Ctrl-P"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateUp(args.times); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "copylinesdown",
|
|
||||||
bindKey: bindKey("Ctrl-Alt-Down", "Command-Option-Down"),
|
|
||||||
exec: function(env, args, request) { env.editor.copyLinesDown(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "movelinesdown",
|
|
||||||
bindKey: bindKey("Alt-Down", "Option-Down"),
|
|
||||||
exec: function(env, args, request) { env.editor.moveLinesDown(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selecttoend",
|
|
||||||
bindKey: bindKey("Alt-Shift-Down", "Command-Shift-Down"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectFileEnd(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotoend",
|
|
||||||
bindKey: bindKey("Ctrl-End|Ctrl-Down", "Command-End|Command-Down"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateFileEnd(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectdown",
|
|
||||||
bindKey: bindKey("Shift-Down", "Shift-Down"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectDown(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "golinedown",
|
|
||||||
bindKey: bindKey("Down", "Down|Ctrl-N"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateDown(args.times); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectwordleft",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectWordLeft(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotowordleft",
|
|
||||||
bindKey: bindKey("Ctrl-Left", "Option-Left"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateWordLeft(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selecttolinestart",
|
|
||||||
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotolinestart",
|
|
||||||
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateLineStart(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectleft",
|
|
||||||
bindKey: bindKey("Shift-Left", "Shift-Left"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectLeft(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotoleft",
|
|
||||||
bindKey: bindKey("Left", "Left|Ctrl-B"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateLeft(args.times); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectwordright",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectWordRight(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotowordright",
|
|
||||||
bindKey: bindKey("Ctrl-Right", "Option-Right"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateWordRight(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selecttolineend",
|
|
||||||
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotolineend",
|
|
||||||
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateLineEnd(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectright",
|
|
||||||
bindKey: bindKey("Shift-Right", "Shift-Right"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectRight(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotoright",
|
|
||||||
bindKey: bindKey("Right", "Right|Ctrl-F"),
|
|
||||||
exec: function(env, args, request) { env.editor.navigateRight(args.times); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectpagedown",
|
|
||||||
bindKey: bindKey("Shift-PageDown", "Shift-PageDown"),
|
|
||||||
exec: function(env, args, request) { env.editor.selectPageDown(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "pagedown",
|
|
||||||
bindKey: bindKey(null, "PageDown"),
|
|
||||||
exec: function(env, args, request) { env.editor.scrollPageDown(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotopagedown",
|
|
||||||
bindKey: bindKey("PageDown", "Option-PageDown|Ctrl-V"),
|
|
||||||
exec: function(env, args, request) { env.editor.gotoPageDown(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectpageup",
|
|
||||||
bindKey: bindKey("Shift-PageUp", "Shift-PageUp"),
|
|
||||||
exec: function(env, args, request) { env.editor.selectPageUp(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "pageup",
|
|
||||||
bindKey: bindKey(null, "PageUp"),
|
|
||||||
exec: function(env, args, request) { env.editor.scrollPageUp(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "gotopageup",
|
|
||||||
bindKey: bindKey("PageUp", "Option-PageUp"),
|
|
||||||
exec: function(env, args, request) { env.editor.gotoPageUp(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectlinestart",
|
|
||||||
bindKey: bindKey("Shift-Home", "Shift-Home"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "selectlineend",
|
|
||||||
bindKey: bindKey("Shift-End", "Shift-End"),
|
|
||||||
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "del",
|
|
||||||
bindKey: bindKey("Delete", "Delete|Ctrl-D"),
|
|
||||||
exec: function(env, args, request) { env.editor.removeRight(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "backspace",
|
|
||||||
bindKey: bindKey(
|
|
||||||
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
|
|
||||||
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
|
|
||||||
),
|
|
||||||
exec: function(env, args, request) { env.editor.removeLeft(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "removetolinestart",
|
|
||||||
bindKey: bindKey(null, "Option-Backspace"),
|
|
||||||
exec: function(env, args, request) { env.editor.removeToLineStart(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "removetolineend",
|
|
||||||
bindKey: bindKey(null, "Ctrl-K"),
|
|
||||||
exec: function(env, args, request) { env.editor.removeToLineEnd(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "removewordleft",
|
|
||||||
bindKey: bindKey(null, "Alt-Backspace|Ctrl-Alt-Backspace"),
|
|
||||||
exec: function(env, args, request) { env.editor.removeWordLeft(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "removewordright",
|
|
||||||
bindKey: bindKey(null, "Alt-Delete"),
|
|
||||||
exec: function(env, args, request) { env.editor.removeWordRight(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "outdent",
|
|
||||||
bindKey: bindKey("Shift-Tab", "Shift-Tab"),
|
|
||||||
exec: function(env, args, request) { env.editor.blockOutdent(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "indent",
|
|
||||||
bindKey: bindKey("Tab", "Tab"),
|
|
||||||
exec: function(env, args, request) { env.editor.indent(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "inserttext",
|
|
||||||
exec: function(env, args, request) {
|
|
||||||
env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "centerselection",
|
|
||||||
bindKey: bindKey(null, "Ctrl-L"),
|
|
||||||
exec: function(env, args, request) { env.editor.centerSelection(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "splitline",
|
|
||||||
bindKey: bindKey(null, "Ctrl-O"),
|
|
||||||
exec: function(env, args, request) { env.editor.splitLine(); }
|
|
||||||
});
|
|
||||||
canon.addCommand({
|
|
||||||
name: "transposeletters",
|
|
||||||
bindKey: bindKey("Ctrl-T", "Ctrl-T"),
|
|
||||||
exec: function(env, args, request) { env.editor.transposeLetters(); }
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
gcli.addCommand({
|
||||||
|
name: "togglecomment",
|
||||||
|
exec: function(env, args) { env.editor.toggleCommentLines(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-7", mac: "Command-7" }, "togglecomment");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "findnext",
|
||||||
|
exec: function(env, args) { env.editor.findNext(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-K", mac: "Command-G" }, "findnext");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "findprevious",
|
||||||
|
exec: function(env, args) { env.editor.findPrevious(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Shift-K", mac: "Command-Shift-G" }, "findprevious");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "find",
|
||||||
|
description: "Search for the next instance of a string",
|
||||||
|
params: [
|
||||||
|
{ name: "findWhat", type: "string", description: "The text to search for" }
|
||||||
|
],
|
||||||
|
exec: function(env, args) {
|
||||||
|
// TODO: manual params should not be needed
|
||||||
|
if (!args.findWhat) {
|
||||||
|
args.findWhat = prompt("Find:");
|
||||||
|
}
|
||||||
|
env.editor.find(args.findWhat);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-F", mac: "Command-F" }, "find");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "replace",
|
||||||
|
description: "Replace the next instance of a string with a given replacement",
|
||||||
|
params: [
|
||||||
|
{ name: "findWhat", type: "string", description: "The text to search for" },
|
||||||
|
{ name: "replacement", type: "string", description: "The replacement text" }
|
||||||
|
],
|
||||||
|
exec: function(env, args) {
|
||||||
|
// TODO: manual params should not be needed
|
||||||
|
if (!args.findWhat) {
|
||||||
|
args.findWhat = prompt("Find:");
|
||||||
|
if (!args.findWhat) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
args.replacement = prompt("Replacement:");
|
||||||
|
if (!args.replacement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
env.editor.replace(args.replacement, {needle: args.findWhat});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-R", mac: "Command-Option-F" }, "replace");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "replaceall",
|
||||||
|
description: "Replace all instances of a string with a given replacement",
|
||||||
|
params: [
|
||||||
|
{ name: "findWhat", type: "string", description: "The text to search for" },
|
||||||
|
{ name: "replacement", type: "string", description: "The replacement text" }
|
||||||
|
],
|
||||||
|
exec: function(env, args) {
|
||||||
|
// TODO: manual params should not be needed
|
||||||
|
if (!args.findWhat) {
|
||||||
|
args.findWhat = prompt("Find:");
|
||||||
|
if (!args.findWhat) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
args.replacement = prompt("Replacement:");
|
||||||
|
if (!args.replacement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
env.editor.replaceAll(args.replacement, {needle: args.findWhat});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Shift-R", mac: "Command-Shift-Option-F" }, "replaceall");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "undo",
|
||||||
|
exec: function(env, args) { env.editor.undo(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Z", mac: "Command-Z" }, "undo");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "redo",
|
||||||
|
exec: function(env, args) { env.editor.redo(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Shift-Z|Ctrl-Y", mac: "Command-Shift-Z|Command-Y" }, "redo");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "overwrite",
|
||||||
|
exec: function(env, args) { env.editor.toggleOverwrite(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Insert", mac: "Insert" }, "overwrite");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "copylinesup",
|
||||||
|
exec: function(env, args) { env.editor.copyLinesUp(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Alt-Up", mac: "Command-Option-Up" }, "copylinesup");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "movelinesup",
|
||||||
|
exec: function(env, args) { env.editor.moveLinesUp(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Alt-Up", mac: "Option-Up" }, "movelinesup");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selecttostart",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectFileStart(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Alt-Shift-Up", mac: "Command-Shift-Up" }, "selecttostart");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotostart",
|
||||||
|
exec: function(env, args) { env.editor.navigateFileStart(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Home|Ctrl-Up", mac: "Command-Home|Command-Up" }, "gotostart");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectup",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectUp(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-Up", mac: "Shift-Up" }, "selectup");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "golineup",
|
||||||
|
exec: function(env, args) { env.editor.navigateUp(args.times); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Up", mac: "Up|Ctrl-P" }, "golineup");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "copylinesdown",
|
||||||
|
exec: function(env, args) { env.editor.copyLinesDown(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Alt-Down", mac: "Command-Option-Down" }, "copylinesdown");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "movelinesdown",
|
||||||
|
exec: function(env, args) { env.editor.moveLinesDown(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Alt-Down", mac: "Option-Down" }, "movelinesdown");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selecttoend",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectFileEnd(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Alt-Shift-Down", mac: "Command-Shift-Down" }, "selecttoend");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotoend",
|
||||||
|
exec: function(env, args) { env.editor.navigateFileEnd(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-End|Ctrl-Down", mac: "Command-End|Command-Down" }, "gotoend");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectdown",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectDown(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-Down", mac: "Shift-Down" }, "selectdown");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "golinedown",
|
||||||
|
exec: function(env, args) { env.editor.navigateDown(args.times); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Down", mac: "Down|Ctrl-N" }, "golinedown");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectwordleft",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectWordLeft(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Shift-Left", mac: "Option-Shift-Left" }, "selectwordleft");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotowordleft",
|
||||||
|
exec: function(env, args) { env.editor.navigateWordLeft(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Left", mac: "Option-Left" }, "gotowordleft");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selecttolinestart",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectLineStart(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Alt-Shift-Left", mac: "Command-Shift-Left" }, "selecttolinestart");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotolinestart",
|
||||||
|
exec: function(env, args) { env.editor.navigateLineStart(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Alt-Left|Home", mac: "Command-Left|Home|Ctrl-A" }, "");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectleft",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectLeft(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-Left", mac: "Shift-Left" }, "gotolinestart");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotoleft",
|
||||||
|
exec: function(env, args) { env.editor.navigateLeft(args.times); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Left", mac: "Left|Ctrl-B" }, "gotoleft");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectwordright",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectWordRight(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Shift-Right", mac: "Option-Shift-Right" }, "selectwordright");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotowordright",
|
||||||
|
exec: function(env, args) { env.editor.navigateWordRight(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-Right", mac: "Option-Right" }, "");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selecttolineend",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectLineEnd(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Alt-Shift-Right", mac: "Command-Shift-Right" }, "gotowordright");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotolineend",
|
||||||
|
exec: function(env, args) { env.editor.navigateLineEnd(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Alt-Right|End", mac: "Command-Right|End|Ctrl-E" }, "gotolineend");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectright",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectRight(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-Right", mac: "Shift-Right" }, "selectright");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotoright",
|
||||||
|
exec: function(env, args) { env.editor.navigateRight(args.times); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Right", mac: "Right|Ctrl-F" }, "gotoright");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectpagedown",
|
||||||
|
exec: function(env, args) { env.editor.selectPageDown(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-PageDown", mac: "Shift-PageDown" }, "selectpagedown");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "pagedown",
|
||||||
|
exec: function(env, args) { env.editor.scrollPageDown(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: null, mac: "PageDown" }, "pagedown");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotopagedown",
|
||||||
|
exec: function(env, args) { env.editor.gotoPageDown(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "PageDown", mac: "Option-PageDown|Ctrl-V" }, "gotopagedown");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectpageup",
|
||||||
|
exec: function(env, args) { env.editor.selectPageUp(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-PageUp", mac: "Shift-PageUp" }, "selectpageup");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "pageup",
|
||||||
|
exec: function(env, args) { env.editor.scrollPageUp(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: null, mac: "PageUp" }, "pageup");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "gotopageup",
|
||||||
|
exec: function(env, args) { env.editor.gotoPageUp(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "PageUp", mac: "Option-PageUp" }, "gotopageup");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectlinestart",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectLineStart(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-Home", mac: "Shift-Home" }, "selectlinestart");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "selectlineend",
|
||||||
|
exec: function(env, args) { env.editor.getSelection().selectLineEnd(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-End", mac: "Shift-End" }, "selectlineend");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "del",
|
||||||
|
exec: function(env, args) { env.editor.removeRight(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Delete", mac: "Delete|Ctrl-D" }, "del");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "backspace",
|
||||||
|
exec: function(env, args) { env.editor.removeLeft(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({
|
||||||
|
win: "Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
|
||||||
|
mac: "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
|
||||||
|
}, "backspace");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "removetolinestart",
|
||||||
|
exec: function(env, args) { env.editor.removeToLineStart(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: null, mac: "Option-Backspace" }, "removetolinestart");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "removetolineend",
|
||||||
|
exec: function(env, args) { env.editor.removeToLineEnd(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: null, mac: "Ctrl-K" }, "removetolineend");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "removewordleft",
|
||||||
|
exec: function(env, args) { env.editor.removeWordLeft(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: null, mac: "Alt-Backspace|Ctrl-Alt-Backspace" }, "removewordleft");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "removewordright",
|
||||||
|
exec: function(env, args) { env.editor.removeWordRight(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: null, mac: "Alt-Delete" }, "removewordright");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "outdent",
|
||||||
|
exec: function(env, args) { env.editor.blockOutdent(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Shift-Tab", mac: "Shift-Tab" }, "outdent");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "indent",
|
||||||
|
exec: function(env, args) { env.editor.indent(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Tab", mac: "Tab" }, "indent");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "inserttext",
|
||||||
|
exec: function(env, args) {
|
||||||
|
env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "centerselection",
|
||||||
|
exec: function(env, args) { env.editor.centerSelection(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: null, mac: "Ctrl-L" }, "centerselection");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "splitline",
|
||||||
|
exec: function(env, args) { env.editor.splitLine(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: null, mac: "Ctrl-O" }, "splitline");
|
||||||
|
|
||||||
|
gcli.addCommand({
|
||||||
|
name: "transposeletters",
|
||||||
|
exec: function(env, args) { env.editor.transposeLetters(); }
|
||||||
|
});
|
||||||
|
keybinding.bindCommand({ win: "Ctrl-T", mac: "Ctrl-T" }, "transposeletters");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.shutdown = function() {
|
||||||
|
// TODO: unregister commands
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
||||||
136
lib/ace/commands/settings.js
Normal file
136
lib/ace/commands/settings.js
Normal file
|
|
@ -0,0 +1,136 @@
|
||||||
|
/* ***** 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
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Skywriter.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Skywriter Team (skywriter@mozilla.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
||||||
|
var gcli = require('gcli/index');
|
||||||
|
|
||||||
|
var pref = {
|
||||||
|
metadata: {
|
||||||
|
description: 'Commands for managing preferences'
|
||||||
|
},
|
||||||
|
|
||||||
|
showMetadata: {
|
||||||
|
description: 'Show preferences',
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
name: 'filter',
|
||||||
|
type: 'string',
|
||||||
|
description: 'Regex filter to show only some settings',
|
||||||
|
defaultValue: null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
show: function(filter) {
|
||||||
|
var names = gcli.getEnvironment().settings.getSettingNames();
|
||||||
|
// first sort the settingsList based on the name
|
||||||
|
names.sort(function(name1, name2) {
|
||||||
|
return name1.localeCompare(name2);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
filter = new RegExp(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = '';
|
||||||
|
names.forEach(function(name) {
|
||||||
|
if (!filter || filter.test(name)) {
|
||||||
|
var setting = gcli.getEnvironment().settings.getSetting(name);
|
||||||
|
var url = 'https://wiki.mozilla.org/Labs/Skywriter/Settings#' +
|
||||||
|
setting.name;
|
||||||
|
html += '<a class="setting" href="' + url +
|
||||||
|
'" title="View external documentation on setting: ' +
|
||||||
|
setting.name +
|
||||||
|
'" target="_blank">' +
|
||||||
|
setting.name +
|
||||||
|
'</a> = ' +
|
||||||
|
setting.value +
|
||||||
|
'<br/>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return html;
|
||||||
|
},
|
||||||
|
|
||||||
|
setMetadata: {
|
||||||
|
description: 'Alter current settings',
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
name: 'setting',
|
||||||
|
type: 'setting',
|
||||||
|
description: 'The name of the setting to display or alter'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'value',
|
||||||
|
type: 'settingValue',
|
||||||
|
description: 'The new value for the chosen setting'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
set: function(setting, value) {
|
||||||
|
setting.set(value);
|
||||||
|
return 'Setting: <b>' + setting.name + '</b> = ' + setting.get();
|
||||||
|
},
|
||||||
|
|
||||||
|
resetMetadata: {
|
||||||
|
description: 'Reset a preference to it\'s default values',
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
name: 'setting',
|
||||||
|
type: 'setting',
|
||||||
|
description: 'The name of the setting to return to defaults'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
reset: function(setting) {
|
||||||
|
setting.reset();
|
||||||
|
return 'Reset ' + setting.name + ' to default: ' + setting.value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.startup = function() {
|
||||||
|
gcli.addCommands(pref, 'pref');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.shutdown = function() {
|
||||||
|
gcli.removeCommands(pref, 'pref');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -46,7 +46,6 @@ define(function(require, exports, module) {
|
||||||
var Document = require("ace/document").Document;
|
var Document = require("ace/document").Document;
|
||||||
var Range = require("ace/range").Range;
|
var Range = require("ace/range").Range;
|
||||||
var assert = require("ace/test/assertions");
|
var assert = require("ace/test/assertions");
|
||||||
var async = require("asyncjs");
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
|
|
@ -310,5 +309,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -246,14 +246,14 @@ var EditSession = function(text, mode) {
|
||||||
renderer: typeof type == "function" ? type : null,
|
renderer: typeof type == "function" ? type : null,
|
||||||
clazz : clazz,
|
clazz : clazz,
|
||||||
inFront: !!inFront
|
inFront: !!inFront
|
||||||
}
|
};
|
||||||
|
|
||||||
if (inFront) {
|
if (inFront) {
|
||||||
this.$frontMarkers[id] = marker;
|
this.$frontMarkers[id] = marker;
|
||||||
this._dispatchEvent("changeFrontMarker")
|
this._dispatchEvent("changeFrontMarker");
|
||||||
} else {
|
} else {
|
||||||
this.$backMarkers[id] = marker;
|
this.$backMarkers[id] = marker;
|
||||||
this._dispatchEvent("changeBackMarker")
|
this._dispatchEvent("changeBackMarker");
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
|
@ -606,11 +606,11 @@ var EditSession = function(text, mode) {
|
||||||
deltas = deltas.map(function(delta) {
|
deltas = deltas.map(function(delta) {
|
||||||
var d = {
|
var d = {
|
||||||
range: delta.range
|
range: delta.range
|
||||||
}
|
};
|
||||||
if (delta.action == "insertText" || delta.action == "insertLines")
|
if (delta.action == "insertText" || delta.action == "insertLines")
|
||||||
d.action = "removeText"
|
d.action = "removeText";
|
||||||
else
|
else
|
||||||
d.action = "insertText"
|
d.action = "insertText";
|
||||||
return d;
|
return d;
|
||||||
}).reverse();
|
}).reverse();
|
||||||
|
|
||||||
|
|
@ -627,7 +627,7 @@ var EditSession = function(text, mode) {
|
||||||
isInsert: isInsert,
|
isInsert: isInsert,
|
||||||
start: isInsert ? delta.range.start : delta.range.end,
|
start: isInsert ? delta.range.start : delta.range.end,
|
||||||
end: isInsert ? delta.range.end : delta.range.start
|
end: isInsert ? delta.range.end : delta.range.start
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isInsert)
|
if (isInsert)
|
||||||
|
|
@ -958,7 +958,7 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return splits;
|
return splits;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.$getDisplayTokens = function(str) {
|
this.$getDisplayTokens = function(str) {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
|
|
@ -986,7 +986,7 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the width of the a string on the screen while assuming that
|
* Calculates the width of the a string on the screen while assuming that
|
||||||
|
|
@ -1005,16 +1005,16 @@ var EditSession = function(text, mode) {
|
||||||
if (c == 9) {
|
if (c == 9) {
|
||||||
screenColumn += this.getScreenTabSize(screenColumn);
|
screenColumn += this.getScreenTabSize(screenColumn);
|
||||||
}
|
}
|
||||||
// full width characters
|
// full width characters
|
||||||
else if (isFullWidth(c)) {
|
else if (isFullWidth(c)) {
|
||||||
screenColumn += 2;
|
screenColumn += 2;
|
||||||
} else {
|
} else {
|
||||||
screenColumn += 1;
|
screenColumn += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return screenColumn;
|
return screenColumn;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.getRowHeight = function(config, row) {
|
this.getRowHeight = function(config, row) {
|
||||||
var rows;
|
var rows;
|
||||||
|
|
@ -1025,7 +1025,7 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return rows * config.lineHeight;
|
return rows * config.lineHeight;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.getScreenLastRowColumn = function(screenRow, returnDocPosition) {
|
this.getScreenLastRowColumn = function(screenRow, returnDocPosition) {
|
||||||
if (!this.$useWrapMode) {
|
if (!this.$useWrapMode) {
|
||||||
|
|
@ -1059,7 +1059,7 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
var screenRow = this.documentToScreenRow(docRow, docColumn);
|
var screenRow = this.documentToScreenRow(docRow, docColumn);
|
||||||
return this.getScreenLastRowColumn(screenRow, true);
|
return this.getScreenLastRowColumn(screenRow, true);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.getScreenFirstRowColumn = function(screenRow) {
|
this.getScreenFirstRowColumn = function(screenRow) {
|
||||||
if (!this.$useWrapMode) {
|
if (!this.$useWrapMode) {
|
||||||
|
|
@ -1138,7 +1138,7 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (docRow >= linesCount) {
|
if (docRow >= linesCount) {
|
||||||
docRow = linesCount-1
|
docRow = linesCount-1;
|
||||||
row = wrapData[docRow].length;
|
row = wrapData[docRow].length;
|
||||||
}
|
}
|
||||||
docColumn = wrapData[docRow][row - 1] || 0;
|
docColumn = wrapData[docRow][row - 1] || 0;
|
||||||
|
|
@ -1182,7 +1182,7 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
// Clamp docColumn.
|
// Clamp docColumn.
|
||||||
if (this.$useWrapMode) {
|
if (this.$useWrapMode) {
|
||||||
column = wrapData[docRow][row]
|
column = wrapData[docRow][row];
|
||||||
if (docColumn >= column) {
|
if (docColumn >= column) {
|
||||||
// We remove one character at the end such that the docColumn
|
// We remove one character at the end such that the docColumn
|
||||||
// position returned is not associated to the next row on the
|
// position returned is not associated to the next row on the
|
||||||
|
|
@ -1237,11 +1237,11 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return [screenRow, screenRowOffset];
|
return [screenRow, screenRowOffset];
|
||||||
}
|
};
|
||||||
|
|
||||||
this.documentToScreenRow = function(docRow, docColumn) {
|
this.documentToScreenRow = function(docRow, docColumn) {
|
||||||
return this.$documentToScreenRow(docRow, docColumn)[0];
|
return this.$documentToScreenRow(docRow, docColumn)[0];
|
||||||
}
|
};
|
||||||
|
|
||||||
this.documentToScreenPosition = function(pos, column) {
|
this.documentToScreenPosition = function(pos, column) {
|
||||||
var str;
|
var str;
|
||||||
|
|
@ -1300,7 +1300,7 @@ var EditSession = function(text, mode) {
|
||||||
screenRows += this.$wrapData[row].length + 1;
|
screenRows += this.$wrapData[row].length + 1;
|
||||||
}
|
}
|
||||||
return screenRows;
|
return screenRows;
|
||||||
}
|
};
|
||||||
|
|
||||||
// For every keystroke this gets called once per char in the whole doc!!
|
// For every keystroke this gets called once per char in the whole doc!!
|
||||||
// Wouldn't hurt to make it a bit faster for c >= 0x1100
|
// Wouldn't hurt to make it a bit faster for c >= 0x1100
|
||||||
|
|
|
||||||
|
|
@ -161,5 +161,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -211,5 +211,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -156,5 +156,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -48,6 +48,7 @@ var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||||
var UndoManager = require("ace/undomanager").UndoManager;
|
var UndoManager = require("ace/undomanager").UndoManager;
|
||||||
var MockRenderer = require("ace/test/mockrenderer");
|
var MockRenderer = require("ace/test/mockrenderer");
|
||||||
var assert = require("ace/test/assertions");
|
var assert = require("ace/test/assertions");
|
||||||
|
require("gcli").startup();
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"test: delete line from the middle" : function() {
|
"test: delete line from the middle" : function() {
|
||||||
|
|
@ -495,5 +496,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
/* vim:ts=4:sts=4:sw=4:
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
|
@ -12,15 +11,14 @@
|
||||||
* for the specific language governing rights and limitations under the
|
* for the specific language governing rights and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*
|
*
|
||||||
* The Original Code is Ajax.org Code Editor (ACE).
|
* The Original Code is DomTemplate.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is
|
* The Initial Developer of the Original Code is Mozilla.
|
||||||
* Ajax.org B.V.
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
* the Initial Developer. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
* Joe Walker (jwalker@mozilla.com) (original author)
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
|
@ -38,14 +36,19 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var settings = require("ace/settings/default-settings")
|
|
||||||
|
|
||||||
exports.startup = function startup(data, reason) {
|
var settings = require("ace/settings").settings;
|
||||||
settings.startup(data, reason)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.shutdown = function shutdown(data, reason) {
|
/**
|
||||||
settings.shutdown(data, reason)
|
* Create an environment object
|
||||||
}
|
*/
|
||||||
|
function create() {
|
||||||
|
return {
|
||||||
|
settings: settings
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
})
|
exports.create = create;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
58
lib/ace/index.js
Normal file
58
lib/ace/index.js
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
/* vim:ts=4:sts=4:sw=4:
|
||||||
|
* ***** 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
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Ajax.org Code Editor (ACE).
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Ajax.org B.V.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Joe Walker (jwalker@mozilla.com)
|
||||||
|
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
||||||
|
exports.startup = function startup(data) {
|
||||||
|
require("ace/settings").startup(data);
|
||||||
|
require("ace/commands/settings").startup(data);
|
||||||
|
require('ace/commands/default_commands').startup(data);
|
||||||
|
require("ace/settings/default-settings").startup(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.shutdown = function shutdown(data) {
|
||||||
|
require("ace/settings/default-settings").shutdown(data);
|
||||||
|
require('ace/commands/default_commands').shutdown(data);
|
||||||
|
require("ace/commands/settings").shutdown(data);
|
||||||
|
require("ace/settings").shutdown(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var keyUtil = require("pilot/keys");
|
var keyUtil = require("ace/keys");
|
||||||
|
|
||||||
function HashHandler(config) {
|
function HashHandler(config) {
|
||||||
this.setConfig(config);
|
this.setConfig(config);
|
||||||
|
|
@ -100,17 +100,17 @@ function HashHandler(config) {
|
||||||
if (hashId != 0 || keyCode != 0) {
|
if (hashId != 0 || keyCode != 0) {
|
||||||
return {
|
return {
|
||||||
command: (this.$config.reverse[hashId] || {})[textOrKey]
|
command: (this.$config.reverse[hashId] || {})[textOrKey]
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
command: "inserttext",
|
command: "inserttext",
|
||||||
args: {
|
args: {
|
||||||
text: textOrKey
|
text: textOrKey
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}).call(HashHandler.prototype)
|
}).call(HashHandler.prototype);
|
||||||
|
|
||||||
exports.HashHandler = HashHandler;
|
exports.HashHandler = HashHandler;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -38,17 +38,23 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var useragent = require("pilot/useragent");
|
|
||||||
var keyUtil = require("pilot/keys");
|
var useragent = require('pilot/useragent');
|
||||||
var event = require("pilot/event");
|
var event = require('pilot/event');
|
||||||
var settings = require("pilot/settings").settings;
|
var typecheck = require('pilot/typecheck');
|
||||||
var canon = require("pilot/canon");
|
|
||||||
require("ace/commands/default_commands");
|
var keyUtil = require('ace/keys');
|
||||||
|
var settings = require('ace/settings').settings;
|
||||||
|
var Requisition = require('gcli/index').Requisition;
|
||||||
|
|
||||||
var KeyBinding = function(editor) {
|
var KeyBinding = function(editor) {
|
||||||
this.$editor = editor;
|
this.$editor = editor;
|
||||||
this.$data = { };
|
this.$data = { };
|
||||||
this.$keyboardHandler = null;
|
this.$keyboardHandler = null;
|
||||||
|
|
||||||
|
// TODO: This is WRONG: we should be taking the env passed in to setup
|
||||||
|
this.$env = { editor: this.$editor };
|
||||||
|
this.$requisition = new Requisition(this.$env);
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
@ -64,8 +70,7 @@ var KeyBinding = function(editor) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$callKeyboardHandler = function (e, hashId, keyOrText, keyCode) {
|
this.$callKeyboardHandler = function (e, hashId, keyOrText, keyCode) {
|
||||||
var env = {editor: this.$editor},
|
var toExecute;
|
||||||
toExecute;
|
|
||||||
|
|
||||||
if (this.$keyboardHandler) {
|
if (this.$keyboardHandler) {
|
||||||
toExecute =
|
toExecute =
|
||||||
|
|
@ -76,21 +81,23 @@ var KeyBinding = function(editor) {
|
||||||
if (!toExecute || !toExecute.command) {
|
if (!toExecute || !toExecute.command) {
|
||||||
if (hashId != 0 || keyCode != 0) {
|
if (hashId != 0 || keyCode != 0) {
|
||||||
toExecute = {
|
toExecute = {
|
||||||
command: canon.findKeyCommand(env, "editor", hashId, keyOrText)
|
command: findKeyCommand(hashId, keyOrText),
|
||||||
}
|
args: { }
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
toExecute = {
|
toExecute = {
|
||||||
command: "inserttext",
|
command: "inserttext",
|
||||||
args: {
|
args: { text: keyOrText }
|
||||||
text: keyOrText
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toExecute) {
|
if (toExecute) {
|
||||||
var success = canon.exec(toExecute.command,
|
var success = this.$requisition.exec({
|
||||||
env, "editor", toExecute.args);
|
typed: toExecute.command,
|
||||||
|
args: toExecute.args
|
||||||
|
});
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
return event.stopEvent(e);
|
return event.stopEvent(e);
|
||||||
}
|
}
|
||||||
|
|
@ -104,9 +111,68 @@ var KeyBinding = function(editor) {
|
||||||
|
|
||||||
this.onTextInput = function(text) {
|
this.onTextInput = function(text) {
|
||||||
this.$callKeyboardHandler({}, 0, text, 0);
|
this.$callKeyboardHandler({}, 0, text, 0);
|
||||||
}
|
};
|
||||||
|
|
||||||
}).call(KeyBinding.prototype);
|
}).call(KeyBinding.prototype);
|
||||||
|
|
||||||
exports.KeyBinding = KeyBinding;
|
exports.KeyBinding = KeyBinding;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A lookup has for command key bindings.
|
||||||
|
*/
|
||||||
|
var commmandKeyBinding = { };
|
||||||
|
|
||||||
|
function findKeyCommand(hashId, textOrKey) {
|
||||||
|
// Convert keyCode to the string representation.
|
||||||
|
if (typecheck.isNumber(textOrKey)) {
|
||||||
|
textOrKey = keyUtil.keyCodeToString(textOrKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return commmandKeyBinding[hashId] && commmandKeyBinding[hashId][textOrKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
function splitSafe(s, separator, limit, bLowerCase) {
|
||||||
|
return (bLowerCase && s.toLowerCase() || s)
|
||||||
|
.replace(/(?:^\s+|\n|\s+$)/g, "")
|
||||||
|
.split(new RegExp("[\\s ]*" + separator + "[\\s ]*", "g"), limit || 999);
|
||||||
|
}
|
||||||
|
|
||||||
|
var platform = useragent.isMac ? "mac" : "win";
|
||||||
|
|
||||||
|
function bindCommand(bindKey, value) {
|
||||||
|
|
||||||
|
if (!bindKey.mac && bindKey.mac !== null) {
|
||||||
|
throw new Error('All key bindings must have a mac key binding');
|
||||||
|
}
|
||||||
|
if (!bindKey.win && bindKey.win !== null) {
|
||||||
|
throw new Error('All key bindings must have a windows key binding');
|
||||||
|
}
|
||||||
|
if (!bindKey[platform]) {
|
||||||
|
// No key mapping for this platform.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bindKey[platform].split("|").forEach(function(keys) {
|
||||||
|
var key;
|
||||||
|
var hashId = 0;
|
||||||
|
|
||||||
|
var parts = splitSafe(keys, "\\-", null, true);
|
||||||
|
parts.forEach(function(part) {
|
||||||
|
if (keyUtil.KEY_MODS[part])
|
||||||
|
hashId = hashId | keyUtil.KEY_MODS[part];
|
||||||
|
else
|
||||||
|
key = part || "-"; // when empty, the splitSafe removed a '-'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (commmandKeyBinding[hashId] == null) {
|
||||||
|
commmandKeyBinding[hashId] = {};
|
||||||
|
}
|
||||||
|
commmandKeyBinding[hashId][key] = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.bindCommand = bindCommand;
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ var emacsState = {
|
||||||
{
|
{
|
||||||
name: "text",
|
name: "text",
|
||||||
match: 2,
|
match: 2,
|
||||||
type: "text"
|
type: "string"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ StateHandler.prototype = {
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a useful matching function and therefore is defined here so that
|
* This is a useful matching function and therefore is defined here so that
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ var TextInput = function(parentNode, host) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (useragent.isIE) {
|
if (useragent.isIE) {
|
||||||
event.addListener(text, "beforecopy", function(e) {
|
event.addListener(text, "beforecopy", function(e) {
|
||||||
var copyText = host.getCopyText();
|
var copyText = host.getCopyText();
|
||||||
if(copyText)
|
if(copyText)
|
||||||
clipboardData.setData("Text", copyText);
|
clipboardData.setData("Text", copyText);
|
||||||
|
|
@ -179,7 +179,7 @@ var TextInput = function(parentNode, host) {
|
||||||
clipboardData.setData("Text", copyText);
|
clipboardData.setData("Text", copyText);
|
||||||
host.onCut();
|
host.onCut();
|
||||||
}
|
}
|
||||||
event.preventDefault(e)
|
event.preventDefault(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -225,12 +225,12 @@ var TextInput = function(parentNode, host) {
|
||||||
if(!tempStyle)
|
if(!tempStyle)
|
||||||
tempStyle = text.style.cssText;
|
tempStyle = text.style.cssText;
|
||||||
text.style.cssText = 'position:fixed; z-index:1000;' +
|
text.style.cssText = 'position:fixed; z-index:1000;' +
|
||||||
'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;'
|
'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;';
|
||||||
|
|
||||||
}
|
}
|
||||||
if (isEmpty)
|
if (isEmpty)
|
||||||
text.value='';
|
text.value='';
|
||||||
}
|
};
|
||||||
|
|
||||||
this.onContextMenuClose = function(){
|
this.onContextMenuClose = function(){
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
@ -240,7 +240,7 @@ var TextInput = function(parentNode, host) {
|
||||||
}
|
}
|
||||||
sendText();
|
sendText();
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.TextInput = TextInput;
|
exports.TextInput = TextInput;
|
||||||
|
|
|
||||||
118
lib/ace/keys.js
Normal file
118
lib/ace/keys.js
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
/*! @license
|
||||||
|
==========================================================================
|
||||||
|
SproutCore -- JavaScript Application Framework
|
||||||
|
copyright 2006-2009, Sprout Systems Inc., Apple Inc. and contributors.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
SproutCore and the SproutCore logo are trademarks of Sprout Systems, Inc.
|
||||||
|
|
||||||
|
For more information about SproutCore, visit http://www.sproutcore.com
|
||||||
|
|
||||||
|
|
||||||
|
==========================================================================
|
||||||
|
@license */
|
||||||
|
|
||||||
|
// Most of the following code is taken from SproutCore with a few changes.
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
var oop = require("pilot/oop");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper functions and hashes for key handling.
|
||||||
|
*/
|
||||||
|
var Keys = (function() {
|
||||||
|
var ret = {
|
||||||
|
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: '\"'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// A reverse map of FUNCTION_KEYS
|
||||||
|
for (i in ret.FUNCTION_KEYS) {
|
||||||
|
var name = ret.FUNCTION_KEYS[i].toUpperCase();
|
||||||
|
ret[name] = parseInt(i, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the MODIFIER_KEYS, FUNCTION_KEYS and PRINTABLE_KEYS to the KEY
|
||||||
|
// variables as well.
|
||||||
|
oop.mixin(ret, ret.MODIFIER_KEYS);
|
||||||
|
oop.mixin(ret, ret.PRINTABLE_KEYS);
|
||||||
|
oop.mixin(ret, ret.FUNCTION_KEYS);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
})();
|
||||||
|
oop.mixin(exports, Keys);
|
||||||
|
|
||||||
|
exports.keyCodeToString = function(keyCode) {
|
||||||
|
return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase();
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -61,7 +61,7 @@ var Gutter = function(parentEl) {
|
||||||
if (!this.$decorations[row])
|
if (!this.$decorations[row])
|
||||||
this.$decorations[row] = "";
|
this.$decorations[row] = "";
|
||||||
this.$decorations[row] += " ace_" + className;
|
this.$decorations[row] += " ace_" + className;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.removeGutterDecoration = function(row, className){
|
this.removeGutterDecoration = function(row, className){
|
||||||
this.$decorations[row] = this.$decorations[row].replace(" ace_" + className, "");
|
this.$decorations[row] = this.$decorations[row].replace(" ace_" + className, "");
|
||||||
|
|
@ -73,12 +73,12 @@ var Gutter = function(parentEl) {
|
||||||
|
|
||||||
this.setAnnotations = function(annotations) {
|
this.setAnnotations = function(annotations) {
|
||||||
// iterate over sparse array
|
// iterate over sparse array
|
||||||
this.$annotations = [];
|
this.$annotations = [];
|
||||||
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
|
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
|
||||||
var rowAnnotations = annotations[row];
|
var rowAnnotations = annotations[row];
|
||||||
if (!rowAnnotations)
|
if (!rowAnnotations)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var rowInfo = this.$annotations[row] = {
|
var rowInfo = this.$annotations[row] = {
|
||||||
text: []
|
text: []
|
||||||
};
|
};
|
||||||
|
|
@ -112,7 +112,8 @@ var Gutter = function(parentEl) {
|
||||||
"' title='", annotation.text.join("\n"),
|
"' title='", annotation.text.join("\n"),
|
||||||
"' style='height:", this.session.getRowHeight(config, i), "px;'>", (i+1), "</div>");
|
"' style='height:", this.session.getRowHeight(config, i), "px;'>", (i+1), "</div>");
|
||||||
}
|
}
|
||||||
this.element = dom.setInnerHtml(this.element, html.join(""));
|
|
||||||
|
this.element = dom.rebuildWith(this.element, html.join(""));
|
||||||
this.element.style.height = config.minHeight + "px";
|
this.element.style.height = config.minHeight + "px";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ var Marker = function(parentEl) {
|
||||||
this.setSession = function(session) {
|
this.setSession = function(session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setMarkers = function(markers) {
|
this.setMarkers = function(markers) {
|
||||||
this.markers = markers;
|
this.markers = markers;
|
||||||
};
|
};
|
||||||
|
|
@ -65,7 +65,7 @@ var Marker = function(parentEl) {
|
||||||
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
var html = [];
|
var html = [];
|
||||||
for ( var key in this.markers) {
|
for ( var key in this.markers) {
|
||||||
var marker = this.markers[key];
|
var marker = this.markers[key];
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ var Marker = function(parentEl) {
|
||||||
|
|
||||||
if (marker.renderer) {
|
if (marker.renderer) {
|
||||||
var top = this.$getTop(range.start.row, config);
|
var top = this.$getTop(range.start.row, config);
|
||||||
var left = Math.round(range.start.column * config.characterWidth);
|
var left = Math.round(range.start.column * config.characterWidth);
|
||||||
marker.renderer(html, range, left, top, config);
|
marker.renderer(html, range, left, top, config);
|
||||||
}
|
}
|
||||||
else if (range.isMultiLine()) {
|
else if (range.isMultiLine()) {
|
||||||
|
|
@ -90,7 +90,7 @@ var Marker = function(parentEl) {
|
||||||
this.drawSingleLineMarker(html, range, marker.clazz, config);
|
this.drawSingleLineMarker(html, range, marker.clazz, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.element = dom.setInnerHtml(this.element, html.join(""));
|
this.element = dom.rebuildWith(this.element, html.join(""));
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$getTop = function(row, layerConfig) {
|
this.$getTop = function(row, layerConfig) {
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ var Text = function(parentEl) {
|
||||||
|
|
||||||
var html = [];
|
var html = [];
|
||||||
this.$renderLine(html, i, tokens[i-first].tokens);
|
this.$renderLine(html, i, tokens[i-first].tokens);
|
||||||
lineElement = dom.setInnerHtml(lineElement, html.join(""));
|
lineElement = dom.rebuildWith(lineElement, html.join(""));
|
||||||
lineElement.style.height =
|
lineElement.style.height =
|
||||||
this.session.getRowHeight(config, i) + "px";
|
this.session.getRowHeight(config, i) + "px";
|
||||||
}
|
}
|
||||||
|
|
@ -249,7 +249,7 @@ var Text = function(parentEl) {
|
||||||
var html = [];
|
var html = [];
|
||||||
if (tokens.length > row-firstRow)
|
if (tokens.length > row-firstRow)
|
||||||
this.$renderLine(html, row, tokens[row-firstRow].tokens);
|
this.$renderLine(html, row, tokens[row-firstRow].tokens);
|
||||||
// don't use setInnerHtml since we are working with an empty DIV
|
// don't use dom.rebuildWith since we are working with an empty DIV
|
||||||
lineEl.innerHTML = html.join("");
|
lineEl.innerHTML = html.join("");
|
||||||
fragment.appendChild(lineEl);
|
fragment.appendChild(lineEl);
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +261,7 @@ var Text = function(parentEl) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
var html = [];
|
var html = [];
|
||||||
var tokens = this.session.getTokens(config.firstRow, config.lastRow)
|
var tokens = this.session.getTokens(config.firstRow, config.lastRow);
|
||||||
var fragment = this.$renderLinesFragment(config, config.firstRow, config.lastRow);
|
var fragment = this.$renderLinesFragment(config, config.firstRow, config.lastRow);
|
||||||
|
|
||||||
// Clear the current content of the element and add the rendered fragment.
|
// Clear the current content of the element and add the rendered fragment.
|
||||||
|
|
@ -299,11 +299,11 @@ var Text = function(parentEl) {
|
||||||
var space = new Array(c.length+1).join(self.SPACE_CHAR);
|
var space = new Array(c.length+1).join(self.SPACE_CHAR);
|
||||||
return "<span class='ace_invisible'>" + space + "</span>";
|
return "<span class='ace_invisible'>" + space + "</span>";
|
||||||
} else {
|
} else {
|
||||||
return " "
|
return " ";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
screenColumn += 1;
|
screenColumn += 1;
|
||||||
return "<span class='ace_cjk' style='width:" + (characterWidth * 2) + "px'>" + c + "</span>"
|
return "<span class='ace_cjk' style='width:" + (characterWidth * 2) + "px'>" + c + "</span>";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
screenColumn += value.length;
|
screenColumn += value.length;
|
||||||
|
|
|
||||||
|
|
@ -77,5 +77,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -91,5 +91,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -69,5 +69,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -88,5 +88,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -151,5 +151,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -113,5 +113,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -66,5 +66,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,7 @@ var TextileHighlightRules = function()
|
||||||
var phraseModifiers = lang.arrayToMap(
|
var phraseModifiers = lang.arrayToMap(
|
||||||
("_|*|__|**|??|-|+|^|%|@").split("|")
|
("_|*|__|**|??|-|+|^|%|@").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
var blockModifiers = lang.arrayToMap(
|
var blockModifiers = lang.arrayToMap(
|
||||||
("h1|h2|h3|h4|h5|h6|bq|p|bc|pre").split("|")
|
("h1|h2|h3|h4|h5|h6|bq|p|bc|pre").split("|")
|
||||||
);
|
);
|
||||||
|
|
@ -56,7 +56,7 @@ var TextileHighlightRules = function()
|
||||||
("-|--|(tm)|(r)|(c)").split("|")
|
("-|--|(tm)|(r)|(c)").split("|")
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
"start" : [
|
"start" : [
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +77,7 @@ var TextileHighlightRules = function()
|
||||||
{
|
{
|
||||||
token : "keyword",
|
token : "keyword",
|
||||||
regex : "\\. ",
|
regex : "\\. ",
|
||||||
next : "start",
|
next : "start"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
token : "keyword",
|
token : "keyword",
|
||||||
|
|
|
||||||
|
|
@ -77,5 +77,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -66,5 +66,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
159
lib/ace/plugin_manager.js
Normal file
159
lib/ace/plugin_manager.js
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
/* ***** 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
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Skywriter.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Kevin Dangoor (kdangoor@mozilla.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
var Promise = require("ace/promise").Promise;
|
||||||
|
|
||||||
|
exports.REASONS = {
|
||||||
|
APP_STARTUP: 1,
|
||||||
|
APP_SHUTDOWN: 2,
|
||||||
|
PLUGIN_ENABLE: 3,
|
||||||
|
PLUGIN_DISABLE: 4,
|
||||||
|
PLUGIN_INSTALL: 5,
|
||||||
|
PLUGIN_UNINSTALL: 6,
|
||||||
|
PLUGIN_UPGRADE: 7,
|
||||||
|
PLUGIN_DOWNGRADE: 8
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Plugin = function(name) {
|
||||||
|
this.name = name;
|
||||||
|
this.status = this.INSTALLED;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Plugin.prototype = {
|
||||||
|
/**
|
||||||
|
* constants for the state
|
||||||
|
*/
|
||||||
|
NEW: 0,
|
||||||
|
INSTALLED: 1,
|
||||||
|
REGISTERED: 2,
|
||||||
|
STARTED: 3,
|
||||||
|
UNREGISTERED: 4,
|
||||||
|
SHUTDOWN: 5,
|
||||||
|
|
||||||
|
install: function(data, reason) {
|
||||||
|
var pr = new Promise();
|
||||||
|
if (this.status > this.NEW) {
|
||||||
|
pr.resolve(this);
|
||||||
|
return pr;
|
||||||
|
}
|
||||||
|
require([this.name], function(pluginModule) {
|
||||||
|
if (pluginModule.install) {
|
||||||
|
pluginModule.install(data, reason);
|
||||||
|
}
|
||||||
|
this.status = this.INSTALLED;
|
||||||
|
pr.resolve(this);
|
||||||
|
}.bind(this));
|
||||||
|
return pr;
|
||||||
|
},
|
||||||
|
|
||||||
|
register: function(data, reason) {
|
||||||
|
var pr = new Promise();
|
||||||
|
if (this.status != this.INSTALLED) {
|
||||||
|
pr.resolve(this);
|
||||||
|
return pr;
|
||||||
|
}
|
||||||
|
require([this.name], function(pluginModule) {
|
||||||
|
if (pluginModule.register) {
|
||||||
|
pluginModule.register(data, reason);
|
||||||
|
}
|
||||||
|
this.status = this.REGISTERED;
|
||||||
|
pr.resolve(this);
|
||||||
|
}.bind(this));
|
||||||
|
return pr;
|
||||||
|
},
|
||||||
|
|
||||||
|
startup: function(data, reason) {
|
||||||
|
reason = reason || exports.REASONS.APP_STARTUP;
|
||||||
|
var pr = new Promise();
|
||||||
|
if (this.status != this.REGISTERED) {
|
||||||
|
pr.resolve(this);
|
||||||
|
return pr;
|
||||||
|
}
|
||||||
|
require([this.name], function(pluginModule) {
|
||||||
|
if (pluginModule.startup) {
|
||||||
|
pluginModule.startup(data, reason);
|
||||||
|
}
|
||||||
|
this.status = this.STARTED;
|
||||||
|
pr.resolve(this);
|
||||||
|
}.bind(this));
|
||||||
|
return pr;
|
||||||
|
},
|
||||||
|
|
||||||
|
shutdown: function(data, reason) {
|
||||||
|
if (this.status != this.STARTED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pluginModule = require(this.name);
|
||||||
|
if (pluginModule.shutdown) {
|
||||||
|
pluginModule.shutdown(data, reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.PluginCatalog = function() {
|
||||||
|
this.plugins = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.PluginCatalog.prototype = {
|
||||||
|
registerPlugins: function(pluginList, data, reason) {
|
||||||
|
var registrationPromises = [];
|
||||||
|
pluginList.forEach(function(pluginName) {
|
||||||
|
var plugin = this.plugins[pluginName];
|
||||||
|
if (plugin === undefined) {
|
||||||
|
plugin = new exports.Plugin(pluginName);
|
||||||
|
this.plugins[pluginName] = plugin;
|
||||||
|
registrationPromises.push(plugin.register(data, reason));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
return Promise.group(registrationPromises);
|
||||||
|
},
|
||||||
|
|
||||||
|
startupPlugins: function(data, reason) {
|
||||||
|
var startupPromises = [];
|
||||||
|
for (var pluginName in this.plugins) {
|
||||||
|
var plugin = this.plugins[pluginName];
|
||||||
|
startupPromises.push(plugin.startup(data, reason));
|
||||||
|
}
|
||||||
|
return Promise.group(startupPromises);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.catalog = new exports.PluginCatalog();
|
||||||
|
|
||||||
|
});
|
||||||
247
lib/ace/promise.js
Normal file
247
lib/ace/promise.js
Normal file
|
|
@ -0,0 +1,247 @@
|
||||||
|
/* ***** 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
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Mozilla Skywriter.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Joe Walker (jwalker@mozilla.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
var console = require("pilot/console");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A promise can be in one of 2 states.
|
||||||
|
* The ERROR and SUCCESS states are terminal, the PENDING state is the only
|
||||||
|
* start state.
|
||||||
|
*/
|
||||||
|
var ERROR = -1;
|
||||||
|
var PENDING = 0;
|
||||||
|
var SUCCESS = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We give promises and ID so we can track which are outstanding
|
||||||
|
*/
|
||||||
|
var _nextId = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outstanding promises. Handy list for debugging only.
|
||||||
|
*/
|
||||||
|
var _outstanding = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recently resolved promises. Also for debugging only.
|
||||||
|
*/
|
||||||
|
var _recent = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an unfulfilled promise
|
||||||
|
*/
|
||||||
|
Promise = function () {
|
||||||
|
this._status = PENDING;
|
||||||
|
this._value = undefined;
|
||||||
|
this._onSuccessHandlers = [];
|
||||||
|
this._onErrorHandlers = [];
|
||||||
|
|
||||||
|
// Debugging help
|
||||||
|
this._id = _nextId++;
|
||||||
|
_outstanding[this._id] = this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Yeay for RTTI.
|
||||||
|
*/
|
||||||
|
Promise.prototype.isPromise = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Have we either been resolve()ed or reject()ed?
|
||||||
|
*/
|
||||||
|
Promise.prototype.isComplete = function() {
|
||||||
|
return this._status != PENDING;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Have we resolve()ed?
|
||||||
|
*/
|
||||||
|
Promise.prototype.isResolved = function() {
|
||||||
|
return this._status == SUCCESS;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Have we reject()ed?
|
||||||
|
*/
|
||||||
|
Promise.prototype.isRejected = function() {
|
||||||
|
return this._status == ERROR;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take the specified action of fulfillment of a promise, and (optionally)
|
||||||
|
* a different action on promise rejection.
|
||||||
|
*/
|
||||||
|
Promise.prototype.then = function(onSuccess, onError) {
|
||||||
|
if (typeof onSuccess === 'function') {
|
||||||
|
if (this._status === SUCCESS) {
|
||||||
|
onSuccess.call(null, this._value);
|
||||||
|
} else if (this._status === PENDING) {
|
||||||
|
this._onSuccessHandlers.push(onSuccess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof onError === 'function') {
|
||||||
|
if (this._status === ERROR) {
|
||||||
|
onError.call(null, this._value);
|
||||||
|
} else if (this._status === PENDING) {
|
||||||
|
this._onErrorHandlers.push(onError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like then() except that rather than returning <tt>this</tt> we return
|
||||||
|
* a promise which
|
||||||
|
*/
|
||||||
|
Promise.prototype.chainPromise = function(onSuccess) {
|
||||||
|
var chain = new Promise();
|
||||||
|
chain._chainedFrom = this;
|
||||||
|
this.then(function(data) {
|
||||||
|
try {
|
||||||
|
chain.resolve(onSuccess(data));
|
||||||
|
} catch (ex) {
|
||||||
|
chain.reject(ex);
|
||||||
|
}
|
||||||
|
}, function(ex) {
|
||||||
|
chain.reject(ex);
|
||||||
|
});
|
||||||
|
return chain;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supply the fulfillment of a promise
|
||||||
|
*/
|
||||||
|
Promise.prototype.resolve = function(data) {
|
||||||
|
return this._complete(this._onSuccessHandlers, SUCCESS, data, 'resolve');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renege on a promise
|
||||||
|
*/
|
||||||
|
Promise.prototype.reject = function(data) {
|
||||||
|
return this._complete(this._onErrorHandlers, ERROR, data, 'reject');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal method to be called on resolve() or reject().
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
Promise.prototype._complete = function(list, status, data, name) {
|
||||||
|
// Complain if we've already been completed
|
||||||
|
if (this._status != PENDING) {
|
||||||
|
console.group('Promise already closed');
|
||||||
|
console.error('Attempted ' + name + '() with ', data);
|
||||||
|
console.error('Previous status = ', this._status,
|
||||||
|
', previous value = ', this._value);
|
||||||
|
console.trace();
|
||||||
|
|
||||||
|
console.groupEnd();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._status = status;
|
||||||
|
this._value = data;
|
||||||
|
|
||||||
|
// Call all the handlers, and then delete them
|
||||||
|
list.forEach(function(handler) {
|
||||||
|
handler.call(null, this._value);
|
||||||
|
}, this);
|
||||||
|
this._onSuccessHandlers.length = 0;
|
||||||
|
this._onErrorHandlers.length = 0;
|
||||||
|
|
||||||
|
// Remove the given {promise} from the _outstanding list, and add it to the
|
||||||
|
// _recent list, pruning more than 20 recent promises from that list.
|
||||||
|
delete _outstanding[this._id];
|
||||||
|
_recent.push(this);
|
||||||
|
while (_recent.length > 20) {
|
||||||
|
_recent.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes an array of promises and returns a promise that that is fulfilled once
|
||||||
|
* all the promises in the array are fulfilled
|
||||||
|
* @param group The array of promises
|
||||||
|
* @return the promise that is fulfilled when all the array is fulfilled
|
||||||
|
*/
|
||||||
|
Promise.group = function(promiseList) {
|
||||||
|
if (!(promiseList instanceof Array)) {
|
||||||
|
promiseList = Array.prototype.slice.call(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the original array has nothing in it, return now to avoid waiting
|
||||||
|
if (promiseList.length === 0) {
|
||||||
|
return new Promise().resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var groupPromise = new Promise();
|
||||||
|
var results = [];
|
||||||
|
var fulfilled = 0;
|
||||||
|
|
||||||
|
var onSuccessFactory = function(index) {
|
||||||
|
return function(data) {
|
||||||
|
results[index] = data;
|
||||||
|
fulfilled++;
|
||||||
|
// If the group has already failed, silently drop extra results
|
||||||
|
if (groupPromise._status !== ERROR) {
|
||||||
|
if (fulfilled === promiseList.length) {
|
||||||
|
groupPromise.resolve(results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
promiseList.forEach(function(promise, index) {
|
||||||
|
var onSuccess = onSuccessFactory(index);
|
||||||
|
var onError = groupPromise.reject.bind(groupPromise);
|
||||||
|
promise.then(onSuccess, onError);
|
||||||
|
});
|
||||||
|
|
||||||
|
return groupPromise;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Promise = Promise;
|
||||||
|
exports._outstanding = _outstanding;
|
||||||
|
exports._recent = _recent;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -171,5 +171,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -397,5 +397,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -333,5 +333,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
380
lib/ace/settings.js
Normal file
380
lib/ace/settings.js
Normal file
|
|
@ -0,0 +1,380 @@
|
||||||
|
/* vim:ts=4:sts=4:sw=4:
|
||||||
|
* ***** 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
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Mozilla Skywriter.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Joe Walker (jwalker@mozilla.com)
|
||||||
|
* Julian Viereck (jviereck@mozilla.com)
|
||||||
|
* Kevin Dangoor (kdangoor@mozilla.com)
|
||||||
|
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
||||||
|
var console = require('pilot/console');
|
||||||
|
var oop = require('pilot/oop');
|
||||||
|
var types = require('gcli/types');
|
||||||
|
var EventEmitter = require('pilot/event_emitter').EventEmitter;
|
||||||
|
|
||||||
|
var SelectionType = require('gcli/types').SelectionType;
|
||||||
|
var DeferredType = require('gcli/types').DeferredType;
|
||||||
|
var Argument = require('gcli/argument').Argument;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new setting.
|
||||||
|
* @param settingSpec An object literal that looks like this:
|
||||||
|
* {
|
||||||
|
* name: 'thing',
|
||||||
|
* description: 'Thing is an example setting',
|
||||||
|
* type: 'string',
|
||||||
|
* defaultValue: 'something'
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
function Setting(settingSpec, settings) {
|
||||||
|
this._settings = settings;
|
||||||
|
|
||||||
|
Object.keys(settingSpec).forEach(function(key) {
|
||||||
|
this[key] = settingSpec[key];
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.type = types.getType(this.type);
|
||||||
|
if (this.type == null) {
|
||||||
|
throw new Error('In ' + this.name +
|
||||||
|
': can\'t find type for: ' + JSON.stringify(settingSpec.type));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.name) {
|
||||||
|
throw new Error('Setting.name == undefined. Ignoring.', this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.defaultValue === undefined) {
|
||||||
|
throw new Error('Setting.defaultValue == undefined', this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.onChange) {
|
||||||
|
this.on('change', this.onChange.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.set(this.defaultValue);
|
||||||
|
}
|
||||||
|
Setting.prototype = {
|
||||||
|
get: function() {
|
||||||
|
return this.value;
|
||||||
|
},
|
||||||
|
|
||||||
|
set: function(value) {
|
||||||
|
if (this.value === value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.value = value;
|
||||||
|
if (this._settings.persister) {
|
||||||
|
this._settings.persister.persistValue(this._settings, this.name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._dispatchEvent('change', { setting: this, value: value });
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the value of the <code>key</code> setting to it's default
|
||||||
|
*/
|
||||||
|
resetValue: function() {
|
||||||
|
this.set(this.defaultValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
oop.implement(Setting.prototype, EventEmitter);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A base class for all the various methods of storing settings.
|
||||||
|
* <p>Usage:
|
||||||
|
* <pre>
|
||||||
|
* // Create manually, or require 'settings' from the container.
|
||||||
|
* // This is the manual version:
|
||||||
|
* // Add a new setting
|
||||||
|
* settings.addSetting({ name:'foo', ... });
|
||||||
|
* // Display the default value
|
||||||
|
* alert(settings.get('foo'));
|
||||||
|
* // Alter the value, which also publishes the change etc.
|
||||||
|
* settings.set('foo', 'bar');
|
||||||
|
* // Reset the value to the default
|
||||||
|
* settings.resetValue('foo');
|
||||||
|
* </pre>
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function Settings(persister) {
|
||||||
|
// Storage for deactivated values
|
||||||
|
this._deactivated = {};
|
||||||
|
|
||||||
|
// Storage for the active settings
|
||||||
|
this._settings = {};
|
||||||
|
// We often want sorted setting names. Cache
|
||||||
|
this._settingNames = [];
|
||||||
|
|
||||||
|
if (persister) {
|
||||||
|
this.setPersister(persister);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings.prototype = {
|
||||||
|
/**
|
||||||
|
* Function to add to the list of available settings.
|
||||||
|
* <p>Example usage:
|
||||||
|
* <pre>
|
||||||
|
* settings.addSetting({
|
||||||
|
* name: 'tabsize', // For use in settings.get('X')
|
||||||
|
* type: 'number', // To allow value checking.
|
||||||
|
* defaultValue: 4 // Default value for use when none is directly set
|
||||||
|
* });
|
||||||
|
* </pre>
|
||||||
|
* @param {object} settingSpec Object containing name/type/defaultValue members.
|
||||||
|
*/
|
||||||
|
addSetting: function(settingSpec) {
|
||||||
|
var setting = new Setting(settingSpec, this);
|
||||||
|
this._settings[setting.name] = setting;
|
||||||
|
this._settingNames.push(setting.name);
|
||||||
|
this._settingNames.sort();
|
||||||
|
},
|
||||||
|
|
||||||
|
addSettings: function addSettings(settings) {
|
||||||
|
Object.keys(settings).forEach(function (name) {
|
||||||
|
var setting = settings[name];
|
||||||
|
if (!('name' in setting)) setting.name = name;
|
||||||
|
this.addSetting(setting);
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
removeSetting: function(setting) {
|
||||||
|
var name = (typeof setting === 'string' ? setting : setting.name);
|
||||||
|
setting = this._settings[name];
|
||||||
|
delete this._settings[name];
|
||||||
|
util.arrayRemove(this._settingNames, name);
|
||||||
|
settings.removeAllListeners('change');
|
||||||
|
},
|
||||||
|
|
||||||
|
removeSettings: function removeSettings(settings) {
|
||||||
|
Object.keys(settings).forEach(function(name) {
|
||||||
|
var setting = settings[name];
|
||||||
|
if (!('name' in setting)) setting.name = name;
|
||||||
|
this.removeSettings(setting);
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
getSettings: function() {
|
||||||
|
return Object.keys(this._settings).map(function(name) {
|
||||||
|
return this._settings[name];
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
getSettingNames: function() {
|
||||||
|
return this._settingNames;
|
||||||
|
},
|
||||||
|
|
||||||
|
getSetting: function(name) {
|
||||||
|
return this._settings[name];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Persister is able to store settings. It is an object that defines
|
||||||
|
* two functions:
|
||||||
|
* loadInitialValues(settings) and persistValue(settings, key, value).
|
||||||
|
*/
|
||||||
|
setPersister: function(persister) {
|
||||||
|
this._persister = persister;
|
||||||
|
if (persister) {
|
||||||
|
persister.loadInitialValues(this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
resetAll: function() {
|
||||||
|
this.getSettingNames().forEach(function(key) {
|
||||||
|
this.resetValue(key);
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a list of the known settings and their values
|
||||||
|
*/
|
||||||
|
_list: function() {
|
||||||
|
var reply = [];
|
||||||
|
this.getSettingNames().forEach(function(setting) {
|
||||||
|
reply.push({
|
||||||
|
'key': setting,
|
||||||
|
'value': this.getSetting(setting).get()
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
return reply;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prime the local cache with the defaults.
|
||||||
|
*/
|
||||||
|
_loadDefaultValues: function() {
|
||||||
|
this._loadFromObject(this._getDefaultValues());
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to load settings from an object
|
||||||
|
*/
|
||||||
|
_loadFromObject: function(data) {
|
||||||
|
// We iterate over data rather than keys so we don't forget values
|
||||||
|
// which don't have a setting yet.
|
||||||
|
for (var key in data) {
|
||||||
|
if (data.hasOwnProperty(key)) {
|
||||||
|
var setting = this._settings[key];
|
||||||
|
if (setting) {
|
||||||
|
var value = setting.type.parseString(data[key]);
|
||||||
|
this.set(key, value);
|
||||||
|
} else {
|
||||||
|
this.set(key, data[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to grab all the settings and export them into an object
|
||||||
|
*/
|
||||||
|
_saveToObject: function() {
|
||||||
|
return this.getSettingNames().map(function(key) {
|
||||||
|
return this._settings[key].type.stringify(this.get(key));
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default initial settings
|
||||||
|
*/
|
||||||
|
_getDefaultValues: function() {
|
||||||
|
return this.getSettingNames().map(function(key) {
|
||||||
|
return this._settings[key].spec.defaultValue;
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
exports.settings = new Settings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the settings in a cookie
|
||||||
|
* This code has not been tested since reboot
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function CookiePersister() {
|
||||||
|
};
|
||||||
|
|
||||||
|
CookiePersister.prototype = {
|
||||||
|
loadInitialValues: function(settings) {
|
||||||
|
settings._loadDefaultValues();
|
||||||
|
var data = cookie.get('settings');
|
||||||
|
settings._loadFromObject(JSON.parse(data));
|
||||||
|
},
|
||||||
|
|
||||||
|
persistValue: function(settings, key, value) {
|
||||||
|
try {
|
||||||
|
var stringData = JSON.stringify(settings._saveToObject());
|
||||||
|
cookie.set('settings', stringData);
|
||||||
|
} catch (ex) {
|
||||||
|
console.error('Unable to JSONify the settings! ' + ex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.CookiePersister = CookiePersister;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This relies on us using settingValue in the same event as setting
|
||||||
|
* The alternative is to have some central place where we store the current
|
||||||
|
* command line, but this might be a lesser evil for now.
|
||||||
|
*/
|
||||||
|
var lastSetting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select from the available settings
|
||||||
|
*/
|
||||||
|
var setting = new SelectionType({
|
||||||
|
name: 'setting',
|
||||||
|
data: function() {
|
||||||
|
return env.settings.getSettings();
|
||||||
|
},
|
||||||
|
noMatch: function() {
|
||||||
|
lastSetting = null;
|
||||||
|
},
|
||||||
|
stringify: function(setting) {
|
||||||
|
lastSetting = setting;
|
||||||
|
return SelectionType.prototype.stringify.call(this, setting);
|
||||||
|
},
|
||||||
|
parse: function(arg) {
|
||||||
|
var conversion = SelectionType.prototype.parse.call(this, arg);
|
||||||
|
lastSetting = conversion.value;
|
||||||
|
return conversion;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Something of a hack to allow the set command to give a clearer definition
|
||||||
|
* of the type to the command line.
|
||||||
|
*/
|
||||||
|
var settingValue = new DeferredType({
|
||||||
|
name: 'settingValue',
|
||||||
|
defer: function() {
|
||||||
|
if (lastSetting) {
|
||||||
|
return lastSetting.type;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// console.error('Missing lastSetting. Defaulting to blank');
|
||||||
|
return types.getType('blank');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var env;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registration and de-registration.
|
||||||
|
*/
|
||||||
|
exports.startup = function(data) {
|
||||||
|
env = data.env;
|
||||||
|
types.registerType(setting);
|
||||||
|
types.registerType(settingValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.shutdown = function(data) {
|
||||||
|
types.unregisterType(setting);
|
||||||
|
types.unregisterType(settingValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -38,16 +38,8 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var types = require('pilot/types')
|
|
||||||
var SelectionType = require('pilot/types/basic').SelectionType
|
|
||||||
|
|
||||||
var env
|
var env;
|
||||||
|
|
||||||
var settingTypes = {
|
|
||||||
selectionStyle: new SelectionType({
|
|
||||||
data: [ 'line', 'text' ]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
printMargin: {
|
printMargin: {
|
||||||
|
|
@ -55,43 +47,42 @@ var settings = {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
defaultValue: 80,
|
defaultValue: 80,
|
||||||
onChange: function onChange(event) {
|
onChange: function onChange(event) {
|
||||||
if (env.editor) env.editor.setPrintMarginColumn(event.value)
|
if (env.editor) env.editor.setPrintMarginColumn(event.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showIvisibles: {
|
showIvisibles: {
|
||||||
description: 'Whether or not to show invisible characters.',
|
description: 'Whether or not to show invisible characters.',
|
||||||
type: 'bool',
|
type: 'boolean',
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
onChange: function onChange(event) {
|
onChange: function onChange(event) {
|
||||||
if (env.editor) env.editor.setShowInvisibles(event.value)
|
if (env.editor) env.editor.setShowInvisibles(event.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
highlightActiveLine: {
|
highlightActiveLine: {
|
||||||
description: 'Whether or not highlight active line.',
|
description: 'Whether or not highlight active line.',
|
||||||
type: 'bool',
|
type: 'boolean',
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
onChange: function onChange(event) {
|
onChange: function onChange(event) {
|
||||||
if (env.editor) env.editor.setHighlightActiveLine(event.value)
|
if (env.editor) env.editor.setHighlightActiveLine(event.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectionStyle: {
|
selectionStyle: {
|
||||||
description: 'Type of text selection.',
|
description: 'Type of text selection.',
|
||||||
type: 'selectionStyle',
|
type: { name: 'selection', data: [ 'line', 'text' ] },
|
||||||
defaultValue: 'line',
|
defaultValue: 'line',
|
||||||
onChange: function onChange(event) {
|
onChange: function onChange(event) {
|
||||||
if (env.editor) env.editor.setSelectionStyle(event.value)
|
if (env.editor) env.editor.setSelectionStyle(event.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.startup = function startup(data, reason) {
|
exports.startup = function startup(data) {
|
||||||
env = data.env
|
env = data.env;
|
||||||
types.registerTypes(settingTypes)
|
data.env.settings.addSettings(settings);
|
||||||
data.env.settings.addSettings(settings)
|
};
|
||||||
}
|
|
||||||
|
|
||||||
exports.shutdown = function shutdown(data, reason) {
|
exports.shutdown = function shutdown(data) {
|
||||||
data.env.settings.removeSettings(settings)
|
data.env.settings.removeSettings(settings);
|
||||||
}
|
};
|
||||||
|
|
||||||
})
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,5 +37,5 @@
|
||||||
|
|
||||||
require("../../../support/paths");
|
require("../../../support/paths");
|
||||||
|
|
||||||
var test = require("asyncjs/test");
|
var test = require("asyncjs").test;
|
||||||
test.walkTestCases(__dirname + "/..").exec()
|
test.walkTestCases(__dirname + "/..").exec()
|
||||||
|
|
@ -55,17 +55,33 @@ module.exports = {
|
||||||
|
|
||||||
var called = false;
|
var called = false;
|
||||||
emitter.addEventListener("juhu", function(e) {
|
emitter.addEventListener("juhu", function(e) {
|
||||||
called = true;
|
called = true;
|
||||||
assert.equal(e.type, "juhu");
|
assert.equal(e.type, "juhu");
|
||||||
});
|
});
|
||||||
|
|
||||||
emitter._dispatchEvent("juhu");
|
emitter._dispatchEvent("juhu");
|
||||||
assert.ok(called);
|
assert.ok(called);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test: single dispatch" : function() {
|
||||||
|
var real = new Emitter();
|
||||||
|
var ignored = new Emitter();
|
||||||
|
|
||||||
|
var calls = 0;
|
||||||
|
real.addEventListener("juhu", function(e) {
|
||||||
|
calls++;
|
||||||
|
assert.equal(e.type, "juhu");
|
||||||
|
});
|
||||||
|
|
||||||
|
real._dispatchEvent("juhu");
|
||||||
|
real._dispatchEvent("juhu");
|
||||||
|
|
||||||
|
assert.equal(2, calls);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
require({
|
require({
|
||||||
paths: {
|
paths: {
|
||||||
ace: "../lib/ace",
|
ace: "../lib/ace",
|
||||||
cockpit: "../support/cockpit/lib/cockpit",
|
gcli: "../support/gcli/lib/gcli",
|
||||||
pilot: "../support/pilot/lib/pilot"
|
pilot: "../support/pilot/lib/pilot"
|
||||||
},
|
},
|
||||||
packages : [{
|
packages : [{
|
||||||
|
|
|
||||||
|
|
@ -86,5 +86,5 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs/test").testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec()
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
"pilot": ">=0.1.1",
|
"pilot": ">=0.1.1",
|
||||||
"cockpit": ">=0.1.1",
|
"cockpit": ">=0.1.1",
|
||||||
"teleport": ">=0.2.6",
|
"teleport": ">=0.2.6",
|
||||||
"asyncjs": ">=0.0.2",
|
"asyncjs": ">=0.0.5",
|
||||||
"jsdom": ">=0.1.23",
|
"jsdom": ">=0.1.23",
|
||||||
"htmlparser": ">=1.7.2",
|
"htmlparser": ">=1.7.2",
|
||||||
"dryice": ">=0.2.2",
|
"dryice": ">=0.2.2",
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 33f02ab3af5d755c98b3c58309ac2c62fc6de736
|
Subproject commit 22ec41400312eaffe89131e6728c60bd94dff471
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
require("./requireJS-node");
|
require("./requireJS-node");
|
||||||
require.paths.unshift(__dirname + "/../lib");
|
require.paths.unshift(__dirname + "/../lib");
|
||||||
|
require.paths.unshift(__dirname + "/cockpit/lib");
|
||||||
require.paths.unshift(__dirname + "/pilot/lib");
|
require.paths.unshift(__dirname + "/pilot/lib");
|
||||||
require.paths.unshift(__dirname + "/async/lib");
|
require.paths.unshift(__dirname + "/async/lib");
|
||||||
require.paths.unshift(__dirname + "/jsdom/lib");
|
require.paths.unshift(__dirname + "/jsdom/lib");
|
||||||
require.paths.unshift(__dirname);
|
require.paths.unshift(__dirname);
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 99f887668f74e4670c29c8652f630d024e76c5ee
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue