1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 06:17:58 +01:00

add :set validation and completion for 'eventignore' and 'suggestengines'

This commit is contained in:
Doug Kearns
2008-09-26 05:29:17 +00:00
parent 75d56ccd5d
commit 6eea753fa1
7 changed files with 49 additions and 29 deletions

View File

@@ -189,7 +189,6 @@ liberator.Buffer = function () //{{{
"Show the destination of the link under the cursor in the status bar", "Show the destination of the link under the cursor in the status bar",
"number", 1, "number", 1,
{ {
validator: function (value) value >= 0 && value <= 2,
completer: function (filter) completer: function (filter)
{ {
return [ return [
@@ -197,7 +196,8 @@ liberator.Buffer = function () //{{{
["1", "Show the link in the status line"], ["1", "Show the link in the status line"],
["2", "Show the link in the command line"] ["2", "Show the link in the command line"]
]; ];
} },
validator: function (value) value >= 0 && value <= 2
}); });
liberator.options.add(["usermode", "um"], liberator.options.add(["usermode", "um"],

View File

@@ -47,7 +47,19 @@ liberator.AutoCommands = function () //{{{
liberator.options.add(["eventignore", "ei"], liberator.options.add(["eventignore", "ei"],
"List of autocommand event names which should be ignored", "List of autocommand event names which should be ignored",
"stringlist", ""); "stringlist", "",
{
completer: function (value) Array(liberator.config.autocommands).push(["all", "All events"]),
validator: function (value)
{
let values = value.split(",");
let events = liberator.config.autocommands.map(function (e) e[0]);
events.push("all");
return values.every(function (event) events.indexOf(event) >= 0);
}
});
liberator.options.add(["focuscontent", "fc"], liberator.options.add(["focuscontent", "fc"],
"Try to stay in normal mode after loading a web page", "Try to stay in normal mode after loading a web page",

View File

@@ -591,11 +591,11 @@ liberator.Hints = function () //{{{
"How links are matched", "How links are matched",
"string", "contains", "string", "contains",
{ {
validator: function (value) /^(?:contains|wordstartswith|firstletters|custom)$/.test(value),
completer: function (filter) completer: function (filter)
{ {
return ["contains", "wordstartswith", "firstletters", "custom"].map(function (m) [m, ""]); return ["contains", "wordstartswith", "firstletters", "custom"].map(function (m) [m, ""]);
} },
validator: function (value) /^(contains|wordstartswith|firstletters|custom)$/.test(value)
}); });
liberator.options.add(["wordseparators", "wsp"], liberator.options.add(["wordseparators", "wsp"],

View File

@@ -207,8 +207,7 @@ liberator.Mail = function () //{{{
"Set the layout of the mail window", "Set the layout of the mail window",
"string", "inherit", "string", "inherit",
{ {
validator: function (value) /^(classic|wide|vertical|inherit)$/.test(value), setter: function (value)
setter: function (value)
{ {
switch (value) switch (value)
{ {
@@ -219,7 +218,8 @@ liberator.Mail = function () //{{{
} }
return value; return value;
} },
validator: function (value) /^(classic|wide|vertical|inherit)$/.test(value)
}); });
/*liberator.options.add(["threads"], /*liberator.options.add(["threads"],

View File

@@ -142,7 +142,6 @@ liberator.Tabs = function () //{{{
return value; return value;
}, },
validator: function (value) (value >= 0 && value <= 2),
completer: function (filter) completer: function (filter)
{ {
return [ return [
@@ -151,6 +150,7 @@ liberator.Tabs = function () //{{{
["2", "Always show tab bar"], ["2", "Always show tab bar"],
]; ];
}, },
validator: function (value) value >= 0 && value <= 2
}); });
if (liberator.config.name == "Vimperator") if (liberator.config.name == "Vimperator")

View File

@@ -281,8 +281,7 @@ liberator.CommandLine = function () //{{{
"number", 500, "number", 500,
{ {
validator: function (value) value >= 0 validator: function (value) value >= 0
} });
);
liberator.options.add(["more"], liberator.options.add(["more"],
"Pause the message list window when more than one screen of listings is displayed", "Pause the message list window when more than one screen of listings is displayed",
@@ -311,15 +310,25 @@ liberator.CommandLine = function () //{{{
"Engine Alias which has a feature of suggest", "Engine Alias which has a feature of suggest",
"stringlist", "google", "stringlist", "google",
{ {
validator: function (value) completer: function (value)
{ {
var ss = Components.classes["@mozilla.org/browser/search-service;1"] let ss = Components.classes["@mozilla.org/browser/search-service;1"]
.getService(Components.interfaces.nsIBrowserSearchService); .getService(Components.interfaces.nsIBrowserSearchService);
return value.split(",").every(function (item) { let engines = ss.getEngines({})
var e = ss.getEngineByAlias(item); .filter(function (engine) engine.supportsResponseType("application/x-suggestions+json"));
return (e && e.supportsResponseType("application/x-suggestions+json")) ? true : false;
}); return engines.map(function (engine) [engine.alias, engine.description]);
} },
validator: function (value)
{
let ss = Components.classes["@mozilla.org/browser/search-service;1"]
.getService(Components.interfaces.nsIBrowserSearchService);
return value.split(",").every(function (alias) {
let engine = ss.getEngineByAlias(alias);
return engine && engine.supportsResponseType("application/x-suggestions+json");
});
}
}); });
liberator.options.add(["showmode", "smd"], liberator.options.add(["showmode", "smd"],
@@ -330,12 +339,6 @@ liberator.CommandLine = function () //{{{
"Define how command line completion works", "Define how command line completion works",
"stringlist", "list:full", "stringlist", "list:full",
{ {
validator: function (value)
{
return value.split(",").every(
function (item) /^(full|longest|list|list:full|list:longest|)$/.test(item)
);
},
completer: function (filter) completer: function (filter)
{ {
return [ return [
@@ -347,6 +350,12 @@ liberator.CommandLine = function () //{{{
["list:longest", "List all and complete common string"], ["list:longest", "List all and complete common string"],
]; ];
}, },
validator: function (value)
{
return value.split(",").every(
function (item) /^(full|longest|list|list:full|list:longest|)$/.test(item)
);
}
}); });
liberator.options.add(["wildignore", "wig"], liberator.options.add(["wildignore", "wig"],
@@ -1406,7 +1415,6 @@ liberator.StatusLine = function () //{{{
return value; return value;
}, },
validator: function (value) value >= 0 && value <= 2,
completer: function (filter) completer: function (filter)
{ {
return [ return [
@@ -1414,7 +1422,8 @@ liberator.StatusLine = function () //{{{
["1", "Display status line only if there are multiple windows"], ["1", "Display status line only if there are multiple windows"],
["2", "Always display status line"], ["2", "Always display status line"],
]; ];
} },
validator: function (value) value >= 0 && value <= 2
}); });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -380,7 +380,6 @@ liberator.config = { //{{{
return value; return value;
}, },
getter: function () getter: function ()
{ {
return Components.classes['@mozilla.org/network/io-service;1'] return Components.classes['@mozilla.org/network/io-service;1']