mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 21:02:25 +01:00
add completion support to :*map commands
This commit is contained in:
@@ -315,9 +315,9 @@ liberator.Completion = function () //{{{
|
|||||||
mapped = files.map(function (file) {
|
mapped = files.map(function (file) {
|
||||||
return [tail ? file.leafName : (dir + file.leafName), file.isDirectory() ? "Directory" : "File"];
|
return [tail ? file.leafName : (dir + file.leafName), file.isDirectory() ? "Directory" : "File"];
|
||||||
}).sort(function (a, b) {
|
}).sort(function (a, b) {
|
||||||
return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0
|
return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
||||||
}).sort(function (a, b) {
|
}).sort(function (a, b) {
|
||||||
return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0
|
return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
@@ -560,6 +560,17 @@ liberator.Completion = function () //{{{
|
|||||||
return filtered.concat(additionalCompletions);
|
return filtered.concat(additionalCompletions);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
userMapping: function (filter, modes)
|
||||||
|
{
|
||||||
|
// TODO: add appropriate getters to l.mappings
|
||||||
|
var mappings = [];
|
||||||
|
|
||||||
|
for (var map in liberator.mappings.getUserIterator(modes))
|
||||||
|
mappings.push([map.names[0], ""]);
|
||||||
|
|
||||||
|
return [0, this.filter(mappings, filter)];
|
||||||
|
},
|
||||||
|
|
||||||
// generic helper function which checks if the given "items" array pass "filter"
|
// generic helper function which checks if the given "items" array pass "filter"
|
||||||
// items must be an array of strings
|
// items must be an array of strings
|
||||||
match: function (items, filter, caseSensitive)
|
match: function (items, filter, caseSensitive)
|
||||||
|
|||||||
@@ -203,7 +203,13 @@ liberator.Mappings = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add([ch ? ch + "m[ap]" : "map"],
|
liberator.commands.add([ch ? ch + "m[ap]" : "map"],
|
||||||
"Map a key sequence" + modeDescription,
|
"Map a key sequence" + modeDescription,
|
||||||
function (args) { map(args, modes, false); });
|
function (args) { map(args, modes, false); },
|
||||||
|
{
|
||||||
|
completer: function (filter)
|
||||||
|
{
|
||||||
|
return liberator.completion.userMapping(filter, modes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
liberator.commands.add([ch + "no[remap]"],
|
liberator.commands.add([ch + "no[remap]"],
|
||||||
"Map a key sequence without remapping keys" + modeDescription,
|
"Map a key sequence without remapping keys" + modeDescription,
|
||||||
@@ -238,12 +244,7 @@ liberator.Mappings = function () //{{{
|
|||||||
argCount: "1",
|
argCount: "1",
|
||||||
completer: function (filter)
|
completer: function (filter)
|
||||||
{
|
{
|
||||||
var mappings = []
|
return liberator.completion.userMapping(filter, modes);
|
||||||
|
|
||||||
for (var map in liberator.mappings.getUserIterator(modes))
|
|
||||||
mappings.push([map.names[0], ""]);
|
|
||||||
|
|
||||||
return [0, liberator.completion.filter(mappings, filter)];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user