// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2008-2014 Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
&& !item.hidden
&& !/rdf:http:/.test(item.getAttribute("label"))) { // FIXME
item.dactylPath = parent + item.getAttribute("label");
- if (!targetPath || targetPath.indexOf(item.dactylPath) == 0)
+ if (!targetPath || targetPath.startsWith(item.dactylPath))
items.push(item);
}
else {
let path = parent;
if (item.localName == "menu")
path += item.getAttribute("label") + ".";
- if (!targetPath || targetPath.indexOf(path) == 0)
+ if (!targetPath || targetPath.startsWith(path))
addChildren(item, path);
}
}
registerObservers: function registerObservers(obj, prop) {
for (let [signal, func] in Iterator(obj[prop || "signals"]))
- this.registerObserver(signal, obj.closure(func), false);
+ this.registerObserver(signal, func.bind(obj), false);
},
unregisterObserver: function unregisterObserver(type, callback) {
applyTriggerObserver: function triggerObserver(type, args) {
if (type in this._observers)
- this._observers[type] = this._observers[type].filter(function (callback) {
- if (callback.get()) {
- try {
- try {
- callback.get().apply(null, args);
- }
- catch (e if e.message == "can't wrap XML objects") {
- // Horrible kludge.
- callback.get().apply(null, [String(args[0])].concat(args.slice(1)));
- }
- }
- catch (e) {
- dactyl.reportError(e);
- }
+ this._observers[type] = this._observers[type]
+ .filter(callback => {
+ callback = callback.get();
+ if (callback) {
+ util.trapErrors(() => callback.apply(null, args));
return true;
}
});
let filters = args.map(arg => let (re = util.regexp.escape(arg))
util.regexp("\\b" + re + "\\b|(?:^|[()\\s])" + re + "(?:$|[()\\s])", "i"));
if (filters.length)
- results = results.filter(item => filters.every(re => keys(item).some(re.closure.test)));
+ results = results.filter(item => filters.every(re => keys(item).some(re.bound.test)));
commandline.commandOutput(
template.usage(results, params.format));
let results = array((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs()))
.array.sort((a, b) => String.localeCompare(a.name, b.name));
- let haveTag = Set.has(help.tags);
for (let obj in values(results)) {
let res = dactyl.generateHelp(obj, null, null, true);
- if (!haveTag(obj.helpTag))
+ if (!hasOwnProperty(help.tags, obj.helpTag))
res[0][1].tag = obj.helpTag;
yield res;
},
dump: deprecated("util.dump",
- { get: function dump() util.closure.dump }),
+ { get: function dump() util.bound.dump }),
dumpStack: deprecated("util.dumpStack",
- { get: function dumpStack() util.closure.dumpStack }),
+ { get: function dumpStack() util.bound.dumpStack }),
/**
* Outputs a plain message to the command line.
* should be loaded.
*/
loadScript: function loadScript(uri, context) {
+ let prefix = "literal:" + uri + ":";
+ cache.flush(s => s.startsWith(prefix));
+ delete literal.files[uri];
JSMLoader.loadSubScript(uri, context, File.defaultEncoding);
},
userEval: function userEval(str, context, fileName, lineNumber) {
- let ctxt;
- if (jsmodules.__proto__ != window && jsmodules.__proto__ != XPCNativeWrapper(window) &&
- jsmodules.isPrototypeOf(context))
- str = "with (window) { with (modules) { (this.eval || eval)(" + str.quote() + ") } }";
+ let ctxt,
+ info = contexts.context;
- let info = contexts.context;
if (fileName == null)
if (info)
({ file: fileName, line: lineNumber, context: ctxt }) = info;
if (fileName && fileName[0] == "[")
fileName = "dactyl://command-line/";
else if (!context)
- context = ctxt || _userContext;
-
- if (isinstance(context, ["Sandbox"]))
- return Cu.evalInSandbox(str, context, "1.8", fileName, lineNumber);
+ context = ctxt || userContext;
if (!context)
context = userContext || ctxt;
+ if (isinstance(context, ["Sandbox"]))
+ return Cu.evalInSandbox(str, context, "1.8", fileName, lineNumber);
+
if (services.has("dactyl") && services.dactyl.evalInContext)
return services.dactyl.evalInContext(str, context, fileName, lineNumber);
* @param {boolean} silent Whether the command should be echoed on the
* command line.
*/
- execute: function execute(str, modifiers = {}, silent = false) {
+ execute: function execute(str, modifiers={}, silent=false) {
// skip comments and blank lines
if (/^\s*("|$)/.test(str))
return;
* @param {string} feature The feature name.
* @returns {boolean}
*/
- has: function has(feature) Set.has(config.features, feature),
+ has: function has(feature) config.has(feature),
/**
* @private
}
},
- help: deprecated("help.help", { get: function help() modules.help.closure.help }),
- findHelp: deprecated("help.findHelp", { get: function findHelp() help.closure.findHelp }),
+ help: deprecated("help.help", { get: function help() modules.help.bound.help }),
+ findHelp: deprecated("help.findHelp", { get: function findHelp() help.bound.findHelp }),
/**
* @private
}
if (obj.completer && false)
- add(completion._runCompleter(obj.closure.completer, "", null, args).items
+ add(completion._runCompleter(obj.bound.completer, "", null, args).items
.map(i => [i.text, i.description]));
if (obj.options && obj.options.some(o => o.description) && false)
},
events: {
+ beforecustomization: function onbeforecustomization(event) {
+ // Show navigation bar on Australis, where it's not supposed
+ // to be collapsible, and is therefore not handled by
+ // builtin code.
+ if ("CustomizableUI" in window)
+ this.setNodeVisible(document.getElementById("nav-bar"),
+ true);
+ },
+
+ aftercustomization: function onaftercustomization(event) {
+ // Restore toolbar states.
+ options["guioptions"] = options["guioptions"];
+ },
+
click: function onClick(event) {
let elem = event.originalTarget;
* tabs.
* @returns {boolean}
*/
- open: function open(urls, params = {}, force = false) {
+ open: function open(urls, params={}, force=false) {
if (typeof urls == "string")
urls = dactyl.parseURLs(urls);
if (urls.length > prefs.get("browser.tabs.maxOpenBeforeWarn", 20) && !force)
- return commandline.input(_("dactyl.prompt.openMany", urls.length) + " ",
- function (resp) {
+ return commandline.input(_("dactyl.prompt.openMany", urls.length) + " ")
+ .then(function (resp) {
if (resp && resp.match(/^y(es)?$/i))
dactyl.open(urls, params, true);
});
if (error instanceof FailedAssertion && error.noTrace || error.message === "Interrupted") {
let context = contexts.context;
let prefix = context ? context.file + ":" + context.line + ": " : "";
- if (error.message && error.message.indexOf(prefix) !== 0 &&
+ if (error.message && !error.message.startsWith(prefix) &&
prefix != "[Command Line]:1: ")
error.message = prefix + error.message;
return [];
}
},
- wrapCallback: function wrapCallback(callback, self = this) {
+ wrapCallback: function wrapCallback(callback, self=this) {
let save = ["forceOpen"];
let saved = save.map(p => dactyl[p]);
return function wrappedCallback() {
* @property {[Window]} Returns an array of all the host application's
* open windows.
*/
- get windows() [win for (win in iter(services.windowMediator.getEnumerator("navigator:browser"))) if (win.dactyl)],
+ get windows() [w for (w of overlay.windows)]
}, {
- toolbarHidden: function hidden(elem) (elem.getAttribute("autohide") || elem.getAttribute("collapsed")) == "true"
+ toolbarHidden: function toolbarHidden(elem) "true" == (elem.getAttribute("autohide") ||
+ elem.getAttribute("collapsed"))
}, {
cache: function initCache() {
cache.register("help/plugins.xml", function () {
try {
let info = contexts.getDocs(context);
if (DOM.isJSONXML(info)) {
- let langs = info.slice(2).filter(e => isArray(e) && isObject(e[1]) && e[1].lang);
+ let langs = info.slice(2)
+ .filter(e => isArray(e) && isObject(e[1]) && e[1].lang);
if (langs) {
- let lang = config.bestLocale(l[1].lang for each (l in langs));
+ let lang = config.bestLocale(langs.map(l => l[1].lang));
info = info.slice(0, 2).concat(
info.slice(2).filter(e => !isArray(e)
|| !isObject(e[1])
|| e[1].lang == lang));
- for each (let elem in info.slice(2).filter(e => isArray(e) && e[0] == "info" && isObject(e[1])))
- for (let attr in values(["name", "summary", "href"]))
+ info.slice(2)
+ .filter(e => isArray(e) && e[0] == "info" && isObject(e[1]))
+ .forEach(elem => {
+ for (let attr of ["name", "summary", "href"])
if (attr in elem[1])
info[attr] = elem[1][attr];
+ });
}
body.push(["h2", { xmlns: "dactyl", tag: info[1].name + '-plugin' },
String(info[1].summary)]);
["toc", { start: "2" }],
body]);
- });
+ }, true);
cache.register("help/index.xml", function () {
return '<?xml version="1.0"?>\n' +
["dl", { insertafter: name + "-index" },
template.map(iter(), util.identity)],
"\n\n")]);
- });
+ }, true);
cache.register("help/gui.xml", function () {
return '<?xml version="1.0"?>\n' +
["dd", {}, val[0]]]
: undefined,
"\n")]]);
- });
+ }, true);
cache.register("help/privacy.xml", function () {
return '<?xml version="1.0"?>\n' +
[["dt", {}, name],
["dd", {}, template.linkifyHelp(description, true)]],
"\n")]]);
- });
+ }, true);
},
events: function initEvents() {
events.listen(window, dactyl, "events", true);
M: ["Always show messages outside of the status line"]
},
setter: function (opts) {
- if (loaded.commandline || ~opts.indexOf("c"))
+ if (loaded.has("commandline") || ~opts.indexOf("c"))
commandline.widgets.updateVisibility();
}
},
styles.system.add("taboptions", "chrome://*",
classes.length ? classes.join(",") + "{ display: none; }" : "");
- if (!dactyl.has("Gecko2")) {
- tabs.tabBinding.enabled = Array.some(opts, k => k in this.opts);
- tabs.updateTabCount();
- }
if (config.tabbrowser.tabContainer._positionPinnedTabs)
config.tabbrowser.tabContainer._positionPinnedTabs();
},
if (args["+purgecaches"])
cache.flush();
- util.delay(function () { util.rehash(args) });
+ util.delay(() => { util.rehash(args) });
},
{
argCount: "0", // FIXME
});
}
+ if (config.has("default-theme") && "CustomizableUI" in window)
+ overlay.overlayWindow(window, {
+ append: [
+ ["window", { id: document.documentElement.id, "dactyl-australis": "true", xmlns: "xul" }]]
+ });
+
dactyl.timeout(function () {
try {
var args = config.prefs.get("commandline-args")
// dactyl.hideGUI();
if (dactyl.userEval("typeof document", null, "test.js") === "undefined")
- jsmodules.__proto__ = XPCSafeJSObjectWrapper(window);
+ jsmodules.__proto__ = window;
if (dactyl.commandLineOptions.preCommands)
dactyl.commandLineOptions.preCommands.forEach(function (cmd) {