mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 19:32:27 +01:00
More of the last commit, and fix :set WRT scoping.
This commit is contained in:
@@ -437,7 +437,8 @@ liberator.Options = function () //{{{
|
|||||||
if (!matches)
|
if (!matches)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ret.scope = modifiers && modifiers.scope || liberator.options.OPTION_SCOPE_BOTH;
|
|
||||||
|
ret.scope = modifiers && modifiers.scope;
|
||||||
ret.option = liberator.options.get(ret.name, ret.scope);
|
ret.option = liberator.options.get(ret.name, ret.scope);
|
||||||
|
|
||||||
ret.all = (ret.name == "all")
|
ret.all = (ret.name == "all")
|
||||||
@@ -449,7 +450,22 @@ liberator.Options = function () //{{{
|
|||||||
if (ret.value === undefined)
|
if (ret.value === undefined)
|
||||||
ret.value = "";
|
ret.value = "";
|
||||||
|
|
||||||
liberator.dump(ret);
|
if (!ret.option)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret.optionValue = ret.option.get(ret.scope);
|
||||||
|
|
||||||
|
switch (ret.option.type)
|
||||||
|
{
|
||||||
|
case "stringlist":
|
||||||
|
ret.optionHas = ret.optionValue.split(",");
|
||||||
|
ret.valueHas = ret.value.split(",");
|
||||||
|
break;
|
||||||
|
case "charlist":
|
||||||
|
ret.optionHas = ret.optionValue.split("");
|
||||||
|
ret.valueHas = ret.value.split("");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -533,9 +549,9 @@ liberator.Options = function () //{{{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (option.type == "boolean")
|
if (option.type == "boolean")
|
||||||
liberator.echo((option.get(opt.scope) ? " " : "no") + option.name);
|
liberator.echo((opt.optionValue ? " " : "no") + option.name);
|
||||||
else
|
else
|
||||||
liberator.echo(" " + option.name + "=" + option.get(opt.scope));
|
liberator.echo(" " + option.name + "=" + opt.optionValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// write access
|
// write access
|
||||||
@@ -543,7 +559,7 @@ liberator.Options = function () //{{{
|
|||||||
// improved. i.e. Vim's behavior is pretty sloppy to no real benefit
|
// improved. i.e. Vim's behavior is pretty sloppy to no real benefit
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
let currentValue = option.get(opt.scope);
|
let currentValue = opt.optionValue;
|
||||||
let newValue;
|
let newValue;
|
||||||
|
|
||||||
switch (option.type)
|
switch (option.type)
|
||||||
@@ -590,47 +606,24 @@ liberator.Options = function () //{{{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "charlist":
|
case "charlist":
|
||||||
switch (opt.operator)
|
|
||||||
{
|
|
||||||
case "+":
|
|
||||||
newValue = currentValue.replace(new RegExp("[" + opt.value + "]", "g"), "") + opt.value;
|
|
||||||
break;
|
|
||||||
case "-":
|
|
||||||
newValue = currentValue.replace(new RegExp("[" + opt.value + "]", "g"), "");
|
|
||||||
break;
|
|
||||||
case "^":
|
|
||||||
// NOTE: Vim doesn't prepend if there's a match in the current value
|
|
||||||
newValue = opt.value + currentValue.replace(new RegExp("[" + opt.value + "]", "g"), "");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
newValue = opt.value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "stringlist":
|
case "stringlist":
|
||||||
switch (opt.operator)
|
switch (opt.operator)
|
||||||
{
|
{
|
||||||
case "+":
|
case "+":
|
||||||
if (!currentValue.match(opt.value))
|
newValue = liberator.util.uniq(Array.concat(opt.optionHas, opt.valueHas), true);
|
||||||
newValue = (currentValue ? currentValue + "," : "") + opt.value;
|
|
||||||
else
|
|
||||||
newValue = currentValue;
|
|
||||||
break;
|
|
||||||
case "-":
|
|
||||||
newValue = currentValue.replace(new RegExp("^" + opt.value + ",?|," + opt.value), "");
|
|
||||||
break;
|
break;
|
||||||
case "^":
|
case "^":
|
||||||
if (!currentValue.match(opt.value))
|
// NOTE: Vim doesn't prepend if there's a match in the current value
|
||||||
newValue = opt.value + (currentValue ? "," : "") + currentValue;
|
newValue = liberator.util.uniq(Array.concat(opt.valueHas, opt.optionHas), true);
|
||||||
else
|
break;
|
||||||
newValue = currentValue;
|
case "-":
|
||||||
|
newValue = Array.filter(opt.optionHas, function (item) opt.valueHas.indexOf(item) == -1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
newValue = opt.value;
|
newValue = opt.valueHas;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
newValue = newValue.join(option.type == "charlist" ? "" : ",");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -737,10 +730,9 @@ liberator.Options = function () //{{{
|
|||||||
if (opt.get || opt.reset || !option || prefix)
|
if (opt.get || opt.reset || !option || prefix)
|
||||||
return [0, []];
|
return [0, []];
|
||||||
|
|
||||||
let len = opt.value.length;
|
|
||||||
let completer = option.completer;
|
let completer = option.completer;
|
||||||
let have = null;
|
|
||||||
let have2;
|
let len = opt.value.length;
|
||||||
|
|
||||||
switch (option.type)
|
switch (option.type)
|
||||||
{
|
{
|
||||||
@@ -748,13 +740,9 @@ liberator.Options = function () //{{{
|
|||||||
completer = function () [["true", ""], ["false", ""]]
|
completer = function () [["true", ""], ["false", ""]]
|
||||||
break;
|
break;
|
||||||
case "stringlist":
|
case "stringlist":
|
||||||
have = option.value.split(",");
|
len = opt.valueHas.pop().length;
|
||||||
have2 = opt.value.split(",");
|
|
||||||
len = have2.pop().length;
|
|
||||||
break;
|
break;
|
||||||
case "charlist":
|
case "charlist":
|
||||||
have = option.value.split("");
|
|
||||||
have2 = opt.value;
|
|
||||||
len = 0;
|
len = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -768,19 +756,20 @@ liberator.Options = function () //{{{
|
|||||||
let completions = [];
|
let completions = [];
|
||||||
if (!opt.value)
|
if (!opt.value)
|
||||||
completions = [[option.value, "Current value"], [option.defaultValue, "Default value"]].filter(function (f) f[0]);
|
completions = [[option.value, "Current value"], [option.defaultValue, "Default value"]].filter(function (f) f[0]);
|
||||||
|
|
||||||
if (completer)
|
if (completer)
|
||||||
{
|
{
|
||||||
completions = completions.concat(completer(filter));
|
completions = completions.concat(completer(filter));
|
||||||
if (have)
|
if (opt.optionHas)
|
||||||
{
|
{
|
||||||
completions = completions.filter(function (val) have2.indexOf(val[0]) == -1);
|
completions = completions.filter(function (val) opt.valueHas.indexOf(val[0]) == -1);
|
||||||
switch (opt.operator)
|
switch (opt.operator)
|
||||||
{
|
{
|
||||||
case "+":
|
case "+":
|
||||||
completions = completions.filter(function (val) have.indexOf(val[0]) == -1);
|
completions = completions.filter(function (val) opt.optionHas.indexOf(val[0]) == -1);
|
||||||
break;
|
break;
|
||||||
case "-":
|
case "-":
|
||||||
completions = completions.filter(function (val) have.indexOf(val[0]) > -1);
|
completions = completions.filter(function (val) opt.optionHas.indexOf(val[0]) > -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -543,6 +543,8 @@ liberator.CommandLine = function () //{{{
|
|||||||
// FORCE_MULTILINE is given, FORCE_MULTILINE takes precedence
|
// FORCE_MULTILINE is given, FORCE_MULTILINE takes precedence
|
||||||
APPEND_TO_MESSAGES : 1 << 3, // add the string to the message history
|
APPEND_TO_MESSAGES : 1 << 3, // add the string to the message history
|
||||||
|
|
||||||
|
get autocompleteTimer() autocompleteTimer,
|
||||||
|
|
||||||
get mode() (liberator.modes.extended == liberator.modes.EX) ? "cmd" : "search",
|
get mode() (liberator.modes.extended == liberator.modes.EX) ? "cmd" : "search",
|
||||||
|
|
||||||
getCommand: function ()
|
getCommand: function ()
|
||||||
|
|||||||
@@ -368,14 +368,23 @@ liberator.util = { //{{{
|
|||||||
return urls;
|
return urls;
|
||||||
},
|
},
|
||||||
|
|
||||||
uniq: function (ary)
|
uniq: function (ary, unsorted)
|
||||||
{
|
{
|
||||||
let ret = [];
|
let ret = [];
|
||||||
for (let [,item] in Iterator(ary.sort()))
|
if (unsorted)
|
||||||
{
|
{
|
||||||
if (item != last || !ret.length)
|
for (let [, item] in Iterator(ary))
|
||||||
ret.push(item);
|
if (ret.indexOf(item) == -1)
|
||||||
var last = item;
|
ret.push(item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (let [,item] in Iterator(ary.sort()))
|
||||||
|
{
|
||||||
|
if (item != last || !ret.length)
|
||||||
|
ret.push(item);
|
||||||
|
var last = item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user