mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-27 11:45:39 +02:00
Add :extoptions command
This commit is contained in:
+68
-46
@@ -30,15 +30,12 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm", modules);
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm", modules);
|
||||||
|
|
||||||
const plugins = {};
|
const plugins = { __proto__: modules };
|
||||||
plugins.__proto__ = modules;
|
const userContext = { __proto__: modules };
|
||||||
|
|
||||||
const EVAL_ERROR = "__liberator_eval_error";
|
const EVAL_ERROR = "__liberator_eval_error";
|
||||||
const EVAL_RESULT = "__liberator_eval_result";
|
const EVAL_RESULT = "__liberator_eval_result";
|
||||||
const EVAL_STRING = "__liberator_eval_string";
|
const EVAL_STRING = "__liberator_eval_string";
|
||||||
const userContext = {
|
|
||||||
__proto__: modules
|
|
||||||
};
|
|
||||||
|
|
||||||
const liberator = (function () //{{{
|
const liberator = (function () //{{{
|
||||||
{
|
{
|
||||||
@@ -147,43 +144,6 @@ const liberator = (function () //{{{
|
|||||||
liberator.help(tag);
|
liberator.help(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExtension(name) getExtensions().filter(function (e) e.name == name)[0]
|
|
||||||
|
|
||||||
// TODO: maybe make this a property
|
|
||||||
function getExtensions()
|
|
||||||
{
|
|
||||||
const rdf = services.get("rdf");
|
|
||||||
const extensionManager = services.get("extensionManager");
|
|
||||||
|
|
||||||
let extensions = extensionManager.getItemList(Ci.nsIUpdateItem.TYPE_EXTENSION, {});
|
|
||||||
|
|
||||||
function getRdfProperty(item, property)
|
|
||||||
{
|
|
||||||
let resource = rdf.GetResource("urn:mozilla:item:" + item.id);
|
|
||||||
let value = "";
|
|
||||||
|
|
||||||
if (resource)
|
|
||||||
{
|
|
||||||
let target = extensionManager.datasource.GetTarget(resource,
|
|
||||||
rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true);
|
|
||||||
if (target && target instanceof Ci.nsIRDFLiteral)
|
|
||||||
value = target.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//const Extension = new Struct("id", "name", "description", "icon", "enabled", "version");
|
|
||||||
return [{
|
|
||||||
id: e.id,
|
|
||||||
name: e.name,
|
|
||||||
description: getRdfProperty(e, "description"),
|
|
||||||
icon: e.iconURL,
|
|
||||||
enabled: getRdfProperty(e, "isDisabled") != "true",
|
|
||||||
version: e.version
|
|
||||||
} for ([,e] in Iterator(extensions))];
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -472,13 +432,13 @@ const liberator = (function () //{{{
|
|||||||
function action(e) { services.get("extensionManager")[command.action](e.id); };
|
function action(e) { services.get("extensionManager")[command.action](e.id); };
|
||||||
|
|
||||||
if (args.bang)
|
if (args.bang)
|
||||||
getExtensions().forEach(function (e) { action(e); });
|
liberator.extensions.forEach(function (e) { action(e); });
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
return void liberator.echoerr("E471: Argument required"); // XXX
|
return void liberator.echoerr("E471: Argument required"); // XXX
|
||||||
|
|
||||||
let extension = getExtension(name);
|
let extension = liberator.getExtension(name);
|
||||||
if (extension)
|
if (extension)
|
||||||
action(extension);
|
action(extension);
|
||||||
else
|
else
|
||||||
@@ -491,6 +451,31 @@ const liberator = (function () //{{{
|
|||||||
completer: function (context) completion.extension(context)
|
completer: function (context) completion.extension(context)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
commands.add(["exto[ptions]", "extp[references]"],
|
||||||
|
"Open an extension's preference dialog",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
let extension = liberator.getExtension(args[0]);
|
||||||
|
if (!extension || !extension.options)
|
||||||
|
return void liberator.extension("E474: Invalid argument");
|
||||||
|
if (args.bang)
|
||||||
|
window.openDialog(extension.options,
|
||||||
|
"_blank", "chrome");
|
||||||
|
else
|
||||||
|
liberator.open(extension.options,
|
||||||
|
options.get("newtab").has("all", "extoptions")
|
||||||
|
? liberator.NEW_TAB : liberator.CURRENT_TAB);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
argCount: "1",
|
||||||
|
bang: true,
|
||||||
|
completer: function (context)
|
||||||
|
{
|
||||||
|
completion.extension(context);
|
||||||
|
context.filters.push(function ({ item: e }) e.options);
|
||||||
|
},
|
||||||
|
literal: 0
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: maybe indicate pending status too?
|
// TODO: maybe indicate pending status too?
|
||||||
commands.add(["extens[ions]"],
|
commands.add(["extens[ions]"],
|
||||||
@@ -498,7 +483,7 @@ const liberator = (function () //{{{
|
|||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let filter = args[0] || "";
|
let filter = args[0] || "";
|
||||||
let extensions = getExtensions().filter(function (e) e.name.indexOf(filter) >= 0);
|
let extensions = liberator.extensions.filter(function (e) e.name.indexOf(filter) >= 0);
|
||||||
|
|
||||||
if (extensions.length > 0)
|
if (extensions.length > 0)
|
||||||
{
|
{
|
||||||
@@ -751,7 +736,7 @@ const liberator = (function () //{{{
|
|||||||
context.title = ["Extension"];
|
context.title = ["Extension"];
|
||||||
context.anchored = false;
|
context.anchored = false;
|
||||||
context.keys = { text: "name", description: "description", icon: "icon" },
|
context.keys = { text: "name", description: "description", icon: "icon" },
|
||||||
context.completions = getExtensions();
|
context.completions = liberator.extensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.help = function help(context) {
|
completion.help = function help(context) {
|
||||||
@@ -799,6 +784,43 @@ const liberator = (function () //{{{
|
|||||||
/** @property {Element} The currently focused element. */
|
/** @property {Element} The currently focused element. */
|
||||||
get focus() document.commandDispatcher.focusedElement,
|
get focus() document.commandDispatcher.focusedElement,
|
||||||
|
|
||||||
|
get extensions()
|
||||||
|
{
|
||||||
|
const rdf = services.get("rdf");
|
||||||
|
const extensionManager = services.get("extensionManager");
|
||||||
|
|
||||||
|
let extensions = extensionManager.getItemList(Ci.nsIUpdateItem.TYPE_EXTENSION, {});
|
||||||
|
|
||||||
|
function getRdfProperty(item, property)
|
||||||
|
{
|
||||||
|
let resource = rdf.GetResource("urn:mozilla:item:" + item.id);
|
||||||
|
let value = "";
|
||||||
|
|
||||||
|
if (resource)
|
||||||
|
{
|
||||||
|
let target = extensionManager.datasource.GetTarget(resource,
|
||||||
|
rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true);
|
||||||
|
if (target && target instanceof Ci.nsIRDFLiteral)
|
||||||
|
value = target.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//const Extension = new Struct("id", "name", "description", "icon", "enabled", "version");
|
||||||
|
return extensions.map(function(e) ({
|
||||||
|
id: e.id,
|
||||||
|
name: e.name,
|
||||||
|
description: getRdfProperty(e, "description"),
|
||||||
|
enabled: getRdfProperty(e, "isDisabled") != "true",
|
||||||
|
icon: e.iconURL,
|
||||||
|
options: getRdfProperty(e, "optionsURL"),
|
||||||
|
version: e.version
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
getExtension: function (name) this.extensions.filter(function (e) e.name == name)[0],
|
||||||
|
|
||||||
// Global constants
|
// Global constants
|
||||||
CURRENT_TAB: 1,
|
CURRENT_TAB: 1,
|
||||||
NEW_TAB: 2,
|
NEW_TAB: 2,
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ function Tabs() //{{{
|
|||||||
["all", "All commands"],
|
["all", "All commands"],
|
||||||
["addons", ":addo[ns] command"],
|
["addons", ":addo[ns] command"],
|
||||||
["downloads", ":downl[oads] command"],
|
["downloads", ":downl[oads] command"],
|
||||||
|
["extoptions", ":exto[ptions] command"],
|
||||||
["help", ":h[elp] command"],
|
["help", ":h[elp] command"],
|
||||||
["javascript", ":javascript! or :js! command"],
|
["javascript", ":javascript! or :js! command"],
|
||||||
["prefs", ":pref[erences]! or :prefs! command"]
|
["prefs", ":pref[erences]! or :prefs! command"]
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
and <C-A> are equivalent, to map the uppercase character use <C-S-A>.
|
and <C-A> are equivalent, to map the uppercase character use <C-S-A>.
|
||||||
|
|
||||||
* add extension related commands - :extadd, :extdelete, :extdisable,
|
* add extension related commands - :extadd, :extdelete, :extdisable,
|
||||||
:extenable, :extensions
|
:extenable, :extensions, :extoptions
|
||||||
* add '-javascript' flag to :autocommand
|
* add '-javascript' flag to :autocommand
|
||||||
* add 'private' - enter private browsing mode, matching 'PrivateMode'
|
* add 'private' - enter private browsing mode, matching 'PrivateMode'
|
||||||
autocommand
|
autocommand
|
||||||
|
|||||||
@@ -114,6 +114,15 @@ ________________________________________________________________________________
|
|||||||
List all installed extensions.
|
List all installed extensions.
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
|:exto| |:extoptions| +
|
||||||
|
|:extp| |:extpreferences| +
|
||||||
|
||:exto[ptions][!] {extension}|| +
|
||||||
|
||:extp[references][!] {extension}|| +
|
||||||
|
________________________________________________________________________________
|
||||||
|
Open the preferences dialog for an extension. If [!] is given, open a dialog,
|
||||||
|
otherwise open a buffer. See also 'newtab'.
|
||||||
|
________________________________________________________________________________
|
||||||
|
|
||||||
section:Sidebar[sidebar]
|
section:Sidebar[sidebar]
|
||||||
|
|
||||||
|:sbcl| |:sbclose| +
|
|:sbcl| |:sbclose| +
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ section:Ex{nbsp}commands[ex-cmd-index,:index]
|
|||||||
||[c]:extdelete[c]||
|
||[c]:extdelete[c]||
|
||||||
||[c]:extdisable[c]||
|
||[c]:extdisable[c]||
|
||||||
||[c]:extenable[c]||
|
||[c]:extenable[c]||
|
||||||
|
||[c]:extoptions[c]||
|
||||||
||[c]:extensions[c]|| List all installed extensions +
|
||[c]:extensions[c]|| List all installed extensions +
|
||||||
||[c]:exusage[c]|| List all Ex commands with a short description +
|
||[c]:exusage[c]|| List all Ex commands with a short description +
|
||||||
||[c]:finish[c]|| Stop sourcing a script file +
|
||[c]:finish[c]|| Stop sourcing a script file +
|
||||||
|
|||||||
@@ -566,6 +566,7 @@ The possible values:
|
|||||||
*all* All commands
|
*all* All commands
|
||||||
*addons* [c]:addo[ns][c] command
|
*addons* [c]:addo[ns][c] command
|
||||||
*downloads* [c]:downl[oads][c] command
|
*downloads* [c]:downl[oads][c] command
|
||||||
|
*extoptions* [c]:exto[ptions][c] command
|
||||||
*help* [c]:h[elp][c] command
|
*help* [c]:h[elp][c] command
|
||||||
*javascript* [c]:javascript![c] or [c]:js![c] command
|
*javascript* [c]:javascript![c] or [c]:js![c] command
|
||||||
*prefs* [c]:pref[erences]![c] or [c]:prefs![c] command
|
*prefs* [c]:pref[erences]![c] or [c]:prefs![c] command
|
||||||
|
|||||||
Reference in New Issue
Block a user