mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 10:17:59 +01:00
Return a sane format from Option#value, rename {join,parse}Values to stringify/parse (c.f. JSON), and deprecate Option#values.
This commit is contained in:
@@ -565,7 +565,7 @@ const Buffer = Module("buffer", {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = util.evaluateXPath(options.get("hinttags").defaultValues, frame.document);
|
let res = util.evaluateXPath(options.get("hinttags").defaultValue, frame.document);
|
||||||
for (let [, regex] in Iterator(regexes)) {
|
for (let [, regex] in Iterator(regexes)) {
|
||||||
for (let i in util.range(res.snapshotLength, 0, -1)) {
|
for (let i in util.range(res.snapshotLength, 0, -1)) {
|
||||||
let elem = res.snapshotItem(i);
|
let elem = res.snapshotItem(i);
|
||||||
|
|||||||
@@ -1269,7 +1269,7 @@ const CommandLine = Module("commandline", {
|
|||||||
this.editor = input.editor;
|
this.editor = input.editor;
|
||||||
this.selected = null;
|
this.selected = null;
|
||||||
this.wildmode = options.get("wildmode");
|
this.wildmode = options.get("wildmode");
|
||||||
this.wildtypes = this.wildmode.values;
|
this.wildtypes = this.wildmode.value;
|
||||||
this.itemList = commandline._completionList;
|
this.itemList = commandline._completionList;
|
||||||
this.itemList.setItems(this.context);
|
this.itemList.setItems(this.context);
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|||||||
@@ -874,7 +874,7 @@ const Completion = Module("completion", {
|
|||||||
return first == val || second == val;
|
return first == val || second == val;
|
||||||
},
|
},
|
||||||
has: function () {
|
has: function () {
|
||||||
test = function (val) this.values.some(function (value) this.checkHas(value, val), this);
|
test = function (val) this.value.some(function (value) this.checkHas(value, val), this);
|
||||||
return Array.some(arguments, test, this);
|
return Array.some(arguments, test, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -901,7 +901,7 @@ const Completion = Module("completion", {
|
|||||||
|
|
||||||
options.add(["wildcase", "wic"],
|
options.add(["wildcase", "wic"],
|
||||||
"Completion case matching mode",
|
"Completion case matching mode",
|
||||||
"regexmap", "smart",
|
"regexmap", ".?:smart",
|
||||||
{
|
{
|
||||||
completer: function () [
|
completer: function () [
|
||||||
["smart", "Case is significant when capital letters are typed"],
|
["smart", "Case is significant when capital letters are typed"],
|
||||||
|
|||||||
@@ -25,16 +25,19 @@ const FailedAssertion = Class("FailedAssertion", Error, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function deprecated(reason, fn) update(
|
function deprecated(reason, fn, name)
|
||||||
function deprecatedMethod() {
|
let (func = (callable(fn) ? fn : function () this[fn].apply(this, arguments)))
|
||||||
let frame = Components.stack.caller;
|
update(function deprecatedMethod() {
|
||||||
if (!set.add(deprecatedMethod.seen, frame.filename))
|
let frame = Components.stack.caller;
|
||||||
dactyl.echoerr(frame.filename + ":" + frame.lineNumber + ": " +
|
if (!set.add(deprecatedMethod.seen, frame.filename))
|
||||||
(this.className || this.constructor.className) + "." + fn.name +
|
dactyl.echoerr(
|
||||||
" is deprecated: " + reason);
|
frame.filename.replace(/^.*? -> /, "") +
|
||||||
return fn.apply(this, arguments);
|
":" + frame.lineNumber + ": " +
|
||||||
},
|
(this.className || this.constructor.className) + "." +
|
||||||
{ seen: { "chrome://dactyl/content/javascript.js": true } });
|
(fn.name || name) + " is deprecated: " + reason);
|
||||||
|
return func.apply(this, arguments);
|
||||||
|
},
|
||||||
|
{ seen: { "chrome://dactyl/content/javascript.js": true } });
|
||||||
|
|
||||||
const Dactyl = Module("dactyl", {
|
const Dactyl = Module("dactyl", {
|
||||||
init: function () {
|
init: function () {
|
||||||
@@ -243,7 +246,8 @@ const Dactyl = Module("dactyl", {
|
|||||||
if (typeof str == "object" && "echoerr" in str)
|
if (typeof str == "object" && "echoerr" in str)
|
||||||
str = str.echoerr;
|
str = str.echoerr;
|
||||||
else if (isinstance(str, ["Error"]))
|
else if (isinstance(str, ["Error"]))
|
||||||
str = str.fileName + ":" + str.lineNumber + ": " + str;
|
str = str.fileName.replace(/^.*? -> /, "")
|
||||||
|
+ ":" + str.lineNumber + ": " + str;
|
||||||
|
|
||||||
if (options["errorbells"])
|
if (options["errorbells"])
|
||||||
dactyl.beep();
|
dactyl.beep();
|
||||||
@@ -619,7 +623,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
<spec>{spec((obj.specs || obj.names)[0])}</spec>{
|
<spec>{spec((obj.specs || obj.names)[0])}</spec>{
|
||||||
!obj.type ? "" : <>
|
!obj.type ? "" : <>
|
||||||
<type>{obj.type}</type>
|
<type>{obj.type}</type>
|
||||||
<default>{obj.defaultValue}</default></>}
|
<default>{opt.stringify(obj.defaultValue)}</default></>}
|
||||||
<description>{
|
<description>{
|
||||||
obj.description ? br+<p>{obj.description.replace(/\.?$/, ".")}</p> : "" }{
|
obj.description ? br+<p>{obj.description.replace(/\.?$/, ".")}</p> : "" }{
|
||||||
extraHelp ? br+extraHelp : "" }{
|
extraHelp ? br+extraHelp : "" }{
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ const Option = Class("Option", {
|
|||||||
if (this.type in Option.getKey)
|
if (this.type in Option.getKey)
|
||||||
this.getKey = Option.getKey[this.type];
|
this.getKey = Option.getKey[this.type];
|
||||||
|
|
||||||
if (this.type in Option.parseValues)
|
if (this.type in Option.parse)
|
||||||
this.parseValues = Option.parseValues[this.type];
|
this.parse = Option.parse[this.type];
|
||||||
|
|
||||||
if (this.type in Option.joinValues)
|
if (this.type in Option.stringify)
|
||||||
this.joinValues = Option.joinValues[this.type];
|
this.stringify = Option.stringify[this.type];
|
||||||
|
|
||||||
if (this.type in Option.testValues)
|
if (this.type in Option.testValues)
|
||||||
this.testValues = Option.testValues[this.type];
|
this.testValues = Option.testValues[this.type];
|
||||||
@@ -56,8 +56,7 @@ const Option = Class("Option", {
|
|||||||
if (arguments.length > 3) {
|
if (arguments.length > 3) {
|
||||||
if (this.type == "string")
|
if (this.type == "string")
|
||||||
defaultValue = Commands.quote(defaultValue);
|
defaultValue = Commands.quote(defaultValue);
|
||||||
this.defaultValues = this.parseValues(defaultValue)
|
this.defaultValue = this.parse(defaultValue)
|
||||||
this.defaultValue = this.joinValues(this.defaultValues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extraInfo)
|
if (extraInfo)
|
||||||
@@ -68,13 +67,15 @@ const Option = Class("Option", {
|
|||||||
this.names = array([name, "no" + name] for (name in values(names))).flatten().array;
|
this.names = array([name, "no" + name] for (name in values(names))).flatten().array;
|
||||||
|
|
||||||
if (this.globalValue == undefined && !this.initialValue)
|
if (this.globalValue == undefined && !this.initialValue)
|
||||||
this.globalValue = this.parseValues(this.defaultValue);
|
this.globalValue = this.defaultValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
initValue: function () {
|
initValue: function () {
|
||||||
dactyl.trapErrors(function () this.values = this.values, this);
|
dactyl.trapErrors(function () this.value = this.value, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get isDefault() this.stringify(this.value) === this.stringify(this.defaultValue),
|
||||||
|
|
||||||
/** @property {value} The option's global value. @see #scope */
|
/** @property {value} The option's global value. @see #scope */
|
||||||
get globalValue() options.store.get(this.name, {}).value,
|
get globalValue() options.store.get(this.name, {}).value,
|
||||||
set globalValue(val) { options.store.set(this.name, { value: val, time: Date.now() }); },
|
set globalValue(val) { options.store.set(this.name, { value: val, time: Date.now() }); },
|
||||||
@@ -86,7 +87,7 @@ const Option = Class("Option", {
|
|||||||
* @param {value} value The option value.
|
* @param {value} value The option value.
|
||||||
* @returns {value|string[]}
|
* @returns {value|string[]}
|
||||||
*/
|
*/
|
||||||
parseValues: function (value) Option.dequote(value),
|
parse: function (value) Option.dequote(value),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <b>values</b> packed in the appropriate format for the option
|
* Returns <b>values</b> packed in the appropriate format for the option
|
||||||
@@ -95,11 +96,7 @@ const Option = Class("Option", {
|
|||||||
* @param {value|string[]} values The option value.
|
* @param {value|string[]} values The option value.
|
||||||
* @returns {value}
|
* @returns {value}
|
||||||
*/
|
*/
|
||||||
joinValues: function (vals) Commands.quote(vals),
|
stringify: function (vals) Commands.quote(vals),
|
||||||
|
|
||||||
/** @property {value|string[]} The option value or array of values. */
|
|
||||||
get values() this.getValues(this.scope),
|
|
||||||
set values(values) this.setValues(values, this.scope),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the option's value as an array of parsed values if the option
|
* Returns the option's value as an array of parsed values if the option
|
||||||
@@ -109,7 +106,7 @@ const Option = Class("Option", {
|
|||||||
* {@link Option#scope}).
|
* {@link Option#scope}).
|
||||||
* @returns {value|string[]}
|
* @returns {value|string[]}
|
||||||
*/
|
*/
|
||||||
getValues: function (scope) {
|
get: function (scope) {
|
||||||
if (scope) {
|
if (scope) {
|
||||||
if ((scope & this.scope) == 0) // option doesn't exist in this scope
|
if ((scope & this.scope) == 0) // option doesn't exist in this scope
|
||||||
return null;
|
return null;
|
||||||
@@ -137,7 +134,7 @@ const Option = Class("Option", {
|
|||||||
* @param {number} scope The scope to apply these values to (see
|
* @param {number} scope The scope to apply these values to (see
|
||||||
* {@link Option#scope}).
|
* {@link Option#scope}).
|
||||||
*/
|
*/
|
||||||
setValues: function (newValues, scope, skipGlobal) {
|
set: function (newValues, scope, skipGlobal) {
|
||||||
scope = scope || this.scope;
|
scope = scope || this.scope;
|
||||||
if ((scope & this.scope) == 0) // option doesn't exist in this scope
|
if ((scope & this.scope) == 0) // option doesn't exist in this scope
|
||||||
return;
|
return;
|
||||||
@@ -158,27 +155,14 @@ const Option = Class("Option", {
|
|||||||
dactyl.triggerObserver("options." + this.name, newValues);
|
dactyl.triggerObserver("options." + this.name, newValues);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
getValues: deprecated("Please use Option#get instead", "get", "getValues"),
|
||||||
* Returns the value of the option in the specified <b>scope</b>. The
|
setValues: deprecated("Please use Option#set instead", "set", "setValues"),
|
||||||
* (@link Option#getter) callback, if it exists, is invoked with this value
|
joinValues: deprecated("Please use Option#stringify instead", "stringify", "joinValues"),
|
||||||
* before it is returned.
|
parseValues: deprecated("Please use Option#parse instead", "parse", "parseValues"),
|
||||||
*
|
values: Class.Property({
|
||||||
* @param {number} scope The scope to return this value from (see
|
get: deprecated("Please use Option#value instead", function values() this.value),
|
||||||
* {@link Option#scope}).
|
set: deprecated("Please use Option#value instead", function values(val) this.value = val)
|
||||||
* @returns {value}
|
}),
|
||||||
*/
|
|
||||||
get: function (scope) this.joinValues(this.getValues(scope)),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the option value to <b>newValue</b> for the specified <b>scope</b>.
|
|
||||||
* The (@link Option#setter) callback, if it exists, is invoked with
|
|
||||||
* <b>newValue</b>.
|
|
||||||
*
|
|
||||||
* @param {value} newValue The option's new value.
|
|
||||||
* @param {number} scope The scope to apply this value to (see
|
|
||||||
* {@link Option#scope}).
|
|
||||||
*/
|
|
||||||
set: function (newValue, scope) this.setValues(this.parseValues(newValue), scope),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {value} The option's current value. The option's local value,
|
* @property {value} The option's current value. The option's local value,
|
||||||
@@ -196,7 +180,7 @@ const Option = Class("Option", {
|
|||||||
*
|
*
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
has: function () Array.some(arguments, function (val) this.values.indexOf(val) >= 0, this),
|
has: function () Array.some(arguments, function (val) this.value.indexOf(val) >= 0, this),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this option is identified by <b>name</b>.
|
* Returns whether this option is identified by <b>name</b>.
|
||||||
@@ -240,13 +224,13 @@ const Option = Class("Option", {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (!this.isValidValue(newValues))
|
if (!this.isValidValue(newValues))
|
||||||
return this.invalidArgument(str || this.joinValues(values), operator);
|
return this.invalidArgument(str || this.stringify(values), operator);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return this.invalidArgument(str || this.joinValues(values), operator) + ": " + e.message;
|
return this.invalidArgument(str || this.stringify(values), operator) + ": " + e.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setValues(newValues, scope);
|
this.set(newValues, scope);
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -400,11 +384,11 @@ const Option = Class("Option", {
|
|||||||
(typeof re.result === "string" ? ":" + Option.quote(re.result) : ""),
|
(typeof re.result === "string" ? ":" + Option.quote(re.result) : ""),
|
||||||
|
|
||||||
getKey: {
|
getKey: {
|
||||||
stringlist: function (k) this.values.indexOf(k) >= 0,
|
stringlist: function (k) this.value.indexOf(k) >= 0,
|
||||||
get charlist() this.stringlist,
|
get charlist() this.stringlist,
|
||||||
|
|
||||||
regexlist: function (k, default_) {
|
regexlist: function (k, default_) {
|
||||||
for (let re in values(this.values))
|
for (let re in values(this.value))
|
||||||
if (re.test(k))
|
if (re.test(k))
|
||||||
return re.result;
|
return re.result;
|
||||||
return arguments.length > 1 ? default_ : null;
|
return arguments.length > 1 ? default_ : null;
|
||||||
@@ -412,7 +396,7 @@ const Option = Class("Option", {
|
|||||||
get regexmap() this.regexlist
|
get regexmap() this.regexlist
|
||||||
},
|
},
|
||||||
|
|
||||||
joinValues: {
|
stringify: {
|
||||||
charlist: function (vals) Commands.quote(vals.join("")),
|
charlist: function (vals) Commands.quote(vals.join("")),
|
||||||
stringlist: function (vals) vals.map(Option.quote).join(","),
|
stringlist: function (vals) vals.map(Option.quote).join(","),
|
||||||
stringmap: function (vals) [Option.quote(k, /:/) + ":" + Option.quote(v) for ([k, v] in Iterator(vals))].join(","),
|
stringmap: function (vals) [Option.quote(k, /:/) + ":" + Option.quote(v) for ([k, v] in Iterator(vals))].join(","),
|
||||||
@@ -420,7 +404,7 @@ const Option = Class("Option", {
|
|||||||
get regexmap() this.regexlist
|
get regexmap() this.regexlist
|
||||||
},
|
},
|
||||||
|
|
||||||
parseValues: {
|
parse: {
|
||||||
number: function (value) Number(Option.dequote(value)),
|
number: function (value) Number(Option.dequote(value)),
|
||||||
boolean: function (value) Option.dequote(value) == "true" || value == true ? true : false,
|
boolean: function (value) Option.dequote(value) == "true" || value == true ? true : false,
|
||||||
charlist: function (value) Array.slice(Option.dequote(value)),
|
charlist: function (value) Array.slice(Option.dequote(value)),
|
||||||
@@ -456,7 +440,7 @@ const Option = Class("Option", {
|
|||||||
splitList: function (value, keepQuotes) {
|
splitList: function (value, keepQuotes) {
|
||||||
let res = [];
|
let res = [];
|
||||||
Option._splitAt = 0;
|
Option._splitAt = 0;
|
||||||
do {
|
while (value.length) {
|
||||||
if (count !== undefined)
|
if (count !== undefined)
|
||||||
value = value.slice(1);
|
value = value.slice(1);
|
||||||
var [count, arg, quote] = Commands.parseArg(value, /,/, keepQuotes);
|
var [count, arg, quote] = Commands.parseArg(value, /,/, keepQuotes);
|
||||||
@@ -465,7 +449,7 @@ const Option = Class("Option", {
|
|||||||
if (value.length > count)
|
if (value.length > count)
|
||||||
Option._splitAt += count + 1;
|
Option._splitAt += count + 1;
|
||||||
value = value.slice(count);
|
value = value.slice(count);
|
||||||
} while (value.length);
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
quote: function quote(str, re) Commands.quoteArg[/[\s|"'\\,]|^$/.test(str) || re && re.test && re.test(str) ? "'" : ""](str, re),
|
quote: function quote(str, re) Commands.quoteArg[/[\s|"'\\,]|^$/.test(str) || re && re.test && re.test(str) ? "'" : ""](str, re),
|
||||||
@@ -500,7 +484,7 @@ const Option = Class("Option", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
stringmap: function (operator, values, scope, invert) {
|
stringmap: function (operator, values, scope, invert) {
|
||||||
let res = update({}, this.values);
|
let res = update({}, this.value);
|
||||||
|
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
// The result is the same.
|
// The result is the same.
|
||||||
@@ -527,20 +511,19 @@ const Option = Class("Option", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
stringlist: function (operator, values, scope, invert) {
|
stringlist: function (operator, values, scope, invert) {
|
||||||
const self = this;
|
|
||||||
values = Array.concat(values);
|
values = Array.concat(values);
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case "+":
|
case "+":
|
||||||
return array.uniq(Array.concat(this.values, values), true);
|
return array.uniq(Array.concat(this.value, values), true);
|
||||||
case "^":
|
case "^":
|
||||||
// NOTE: Vim doesn't prepend if there's a match in the current value
|
// NOTE: Vim doesn't prepend if there's a match in the current value
|
||||||
return array.uniq(Array.concat(values, this.values), true);
|
return array.uniq(Array.concat(values, this.value), true);
|
||||||
case "-":
|
case "-":
|
||||||
return this.values.filter(function (item) values.indexOf(item) == -1);
|
return this.value.filter(function (item) values.indexOf(item) == -1);
|
||||||
case "=":
|
case "=":
|
||||||
if (invert) {
|
if (invert) {
|
||||||
let keepValues = this.values.filter(function (item) values.indexOf(item) == -1);
|
let keepValues = this.value.filter(function (item) values.indexOf(item) == -1);
|
||||||
let addValues = values.filter(function (item) self.values.indexOf(item) == -1);
|
let addValues = values.filter(function (item) this.value.indexOf(item) == -1, this);
|
||||||
return addValues.concat(keepValues);
|
return addValues.concat(keepValues);
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
@@ -633,7 +616,7 @@ const Options = Module("options", {
|
|||||||
// Trigger any setters.
|
// Trigger any setters.
|
||||||
let opt = options.get(option);
|
let opt = options.get(option);
|
||||||
if (event == "change" && opt)
|
if (event == "change" && opt)
|
||||||
opt.setValues(opt.globalValue, Option.SCOPE_GLOBAL, true);
|
opt.set(opt.globalValue, Option.SCOPE_GLOBAL, true);
|
||||||
}, window);
|
}, window);
|
||||||
|
|
||||||
this._branch = services.get("pref").getBranch("").QueryInterface(Ci.nsIPrefBranch2);
|
this._branch = services.get("pref").getBranch("").QueryInterface(Ci.nsIPrefBranch2);
|
||||||
@@ -696,8 +679,8 @@ const Options = Module("options", {
|
|||||||
memoize(this.needInit, this.needInit.length, closure);
|
memoize(this.needInit, this.needInit.length, closure);
|
||||||
|
|
||||||
// quickly access options with options["wildmode"]:
|
// quickly access options with options["wildmode"]:
|
||||||
this.__defineGetter__(name, function () this._optionMap[name].values);
|
this.__defineGetter__(name, function () this._optionMap[name].value);
|
||||||
this.__defineSetter__(name, function (value) { this._optionMap[name].values = value; });
|
this.__defineSetter__(name, function (value) { this._optionMap[name].value = value; });
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -741,9 +724,9 @@ const Options = Module("options", {
|
|||||||
function opts(opt) {
|
function opts(opt) {
|
||||||
for (let opt in Iterator(options)) {
|
for (let opt in Iterator(options)) {
|
||||||
let option = {
|
let option = {
|
||||||
isDefault: opt.value === opt.defaultValue,
|
isDefault: opt.isDefault,
|
||||||
name: opt.name,
|
name: opt.name,
|
||||||
default: opt.defaultValue,
|
default: opt.stringify(opt.defaultValue),
|
||||||
pre: "\u00a0\u00a0", // Unicode nonbreaking space.
|
pre: "\u00a0\u00a0", // Unicode nonbreaking space.
|
||||||
value: <></>
|
value: <></>
|
||||||
};
|
};
|
||||||
@@ -759,7 +742,7 @@ const Options = Module("options", {
|
|||||||
option.default = (option.default ? "" : "no") + opt.name;
|
option.default = (option.default ? "" : "no") + opt.name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
option.value = <>={template.highlight(opt.value)}</>;
|
option.value = <>={template.highlight(opt.stringify(opt.value))}</>;
|
||||||
yield option;
|
yield option;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -870,9 +853,8 @@ const Options = Module("options", {
|
|||||||
ret.value = "";
|
ret.value = "";
|
||||||
|
|
||||||
ret.optionValue = ret.option.get(ret.scope);
|
ret.optionValue = ret.option.get(ret.scope);
|
||||||
ret.optionValues = ret.option.getValues(ret.scope);
|
|
||||||
|
|
||||||
ret.values = ret.option.parseValues(ret.value);
|
ret.values = ret.option.parse(ret.value);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
@@ -1168,7 +1150,7 @@ const Options = Module("options", {
|
|||||||
if (option.type == "boolean")
|
if (option.type == "boolean")
|
||||||
var msg = (opt.optionValue ? " " : "no") + option.name;
|
var msg = (opt.optionValue ? " " : "no") + option.name;
|
||||||
else
|
else
|
||||||
msg = " " + option.name + "=" + opt.optionValue;
|
msg = " " + option.name + "=" + opt.option.stringify(opt.optionValue);
|
||||||
|
|
||||||
if (options["verbose"] > 0 && option.setFrom)
|
if (options["verbose"] > 0 && option.setFrom)
|
||||||
msg += "\n Last set from " + option.setFrom;
|
msg += "\n Last set from " + option.setFrom;
|
||||||
@@ -1183,7 +1165,8 @@ const Options = Module("options", {
|
|||||||
opt.values = !opt.unsetBoolean;
|
opt.values = !opt.unsetBoolean;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var res = opt.option.op(opt.operator || "=", opt.values, opt.scope, opt.invert, opt.value);
|
var res = opt.option.op(opt.operator || "=", opt.values, opt.scope, opt.invert,
|
||||||
|
opt.value);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
res = e;
|
res = e;
|
||||||
@@ -1357,7 +1340,7 @@ const Options = Module("options", {
|
|||||||
: opt.name + "=" + opt.value]
|
: opt.name + "=" + opt.value]
|
||||||
}
|
}
|
||||||
for (opt in options)
|
for (opt in options)
|
||||||
if (!opt.getter && opt.value !== opt.defaultValue && (opt.scope & Option.SCOPE_GLOBAL))
|
if (!opt.getter && opt.isDefault && (opt.scope & Option.SCOPE_GLOBAL))
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1421,8 +1404,8 @@ const Options = Module("options", {
|
|||||||
context.completions = options;
|
context.completions = options;
|
||||||
if (prefix == "inv")
|
if (prefix == "inv")
|
||||||
context.keys.text = function (opt)
|
context.keys.text = function (opt)
|
||||||
opt.type == "boolean" || isArray(opt.values) ? opt.names.map(function (n) "inv" + n)
|
opt.type == "boolean" || isArray(opt.value) ? opt.names.map(function (n) "inv" + n)
|
||||||
: opt.names;
|
: opt.names;
|
||||||
if (scope)
|
if (scope)
|
||||||
context.filters.push(function ({ item }) item.scope & scope);
|
context.filters.push(function ({ item }) item.scope & scope);
|
||||||
};
|
};
|
||||||
@@ -1434,8 +1417,8 @@ const Options = Module("options", {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var curValues = curValue != null ? opt.parseValues(curValue) : opt.values;
|
var curValues = curValue != null ? opt.parse(curValue) : opt.value;
|
||||||
var newValues = opt.parseValues(context.filter);
|
var newValues = opt.parse(context.filter);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
context.message = "Error: " + e;
|
context.message = "Error: " + e;
|
||||||
@@ -1462,7 +1445,7 @@ const Options = Module("options", {
|
|||||||
let split = Option._splitAt;
|
let split = Option._splitAt;
|
||||||
extra.key = Option.dequote(key);
|
extra.key = Option.dequote(key);
|
||||||
extra.value = count < target.length ? Option.dequote(target.substr(count + 1)) : null;
|
extra.value = count < target.length ? Option.dequote(target.substr(count + 1)) : null;
|
||||||
extra.values = opt.parseValues(vals.join(","));
|
extra.values = opt.parse(vals.join(","));
|
||||||
Option._splitAt = split + (extra.value == null ? 0 : count + 1);
|
Option._splitAt = split + (extra.value == null ? 0 : count + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1507,7 +1490,7 @@ const Options = Module("options", {
|
|||||||
for (let opt in values(options._options))
|
for (let opt in values(options._options))
|
||||||
if (timespan.contains(opt.lastSet * 1000) && opt.domains)
|
if (timespan.contains(opt.lastSet * 1000) && opt.domains)
|
||||||
try {
|
try {
|
||||||
opt.values = opt.filterDomain(host, opt.values);
|
opt.value = opt.filterDomain(host, opt.value);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
dactyl.reportError(e);
|
dactyl.reportError(e);
|
||||||
@@ -1515,7 +1498,7 @@ const Options = Module("options", {
|
|||||||
},
|
},
|
||||||
privateEnter: function () {
|
privateEnter: function () {
|
||||||
for (let opt in values(options._options))
|
for (let opt in values(options._options))
|
||||||
if (opt.privateData && (!callable(opt.privateData) || opt.privateData(opt.values)))
|
if (opt.privateData && (!callable(opt.privateData) || opt.privateData(opt.value)))
|
||||||
opt.oldValue = opt.value;
|
opt.oldValue = opt.value;
|
||||||
},
|
},
|
||||||
privateLeave: function () {
|
privateLeave: function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user