mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 00:27:57 +01:00
comments improved on mappings.list
This commit is contained in:
@@ -1436,7 +1436,7 @@ vimperator.Commands = function () //{{{
|
|||||||
"list/remove autocommands matching {pat}<br/>" +
|
"list/remove autocommands matching {pat}<br/>" +
|
||||||
"<code class='command'>:autocmd[!]</code><br />" +
|
"<code class='command'>:autocmd[!]</code><br />" +
|
||||||
"list/remove all autocommands",
|
"list/remove all autocommands",
|
||||||
completer: function (filter) { return vimperator.completion.autocommands(filter); } //TODO: improve
|
completer: function (filter) { return vimperator.completion.autocommands(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
// 0 args -> list all maps
|
// 0 args -> list all maps
|
||||||
@@ -1616,7 +1616,6 @@ vimperator.Commands = function () //{{{
|
|||||||
var line = "\" " + vimperator.version + "\n";
|
var line = "\" " + vimperator.version + "\n";
|
||||||
line += "\" Mappings\n";
|
line += "\" Mappings\n";
|
||||||
|
|
||||||
// TODO: write user maps for all modes when we have mode dependant map support
|
|
||||||
var mode = [[[vimperator.modes.NORMAL], ""], [[vimperator.modes.COMMAND_LINE], "c"],
|
var mode = [[[vimperator.modes.NORMAL], ""], [[vimperator.modes.COMMAND_LINE], "c"],
|
||||||
[[vimperator.modes.INSERT, vimperator.modes.TEXTAREA], "i"]];
|
[[vimperator.modes.INSERT, vimperator.modes.TEXTAREA], "i"]];
|
||||||
for (var y = 0; y < mode.length; y++)
|
for (var y = 0; y < mode.length; y++)
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ vimperator.Mappings = function () //{{{
|
|||||||
|
|
||||||
add: function (map)
|
add: function (map)
|
||||||
{
|
{
|
||||||
|
// a map can have multiple names (see default-map sections, there are many multiples)
|
||||||
for (var i = 0; i < map.names.length; i++)
|
for (var i = 0; i < map.names.length; i++)
|
||||||
{
|
{
|
||||||
// only store keysyms with uppercase modifier strings
|
// only store keysyms with uppercase modifier strings
|
||||||
@@ -223,6 +224,7 @@ vimperator.Mappings = function () //{{{
|
|||||||
removeMap(map.modes[j], map.names[i]);
|
removeMap(map.modes[j], map.names[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// all maps got removed (matching names = lhs), and added newly here
|
||||||
for (var k = 0; k < map.modes.length; k++)
|
for (var k = 0; k < map.modes.length; k++)
|
||||||
user[map.modes[k]].push(map);
|
user[map.modes[k]].push(map);
|
||||||
},
|
},
|
||||||
@@ -274,7 +276,9 @@ vimperator.Mappings = function () //{{{
|
|||||||
list: function (modes, filter)
|
list: function (modes, filter)
|
||||||
{
|
{
|
||||||
|
|
||||||
var maps = user[modes[0]]; // duplicate (reference)
|
// modes means, a map must exist in both modes in order to get listed
|
||||||
|
|
||||||
|
var maps = user[modes[0]]; // duplicate (reference) (first mode where it must match)
|
||||||
var output = [];
|
var output = [];
|
||||||
|
|
||||||
if (!maps || maps.length == 0)
|
if (!maps || maps.length == 0)
|
||||||
@@ -286,15 +290,15 @@ vimperator.Mappings = function () //{{{
|
|||||||
for (var i = 0; i < maps.length; i++) // check on maps items (first mode)
|
for (var i = 0; i < maps.length; i++) // check on maps items (first mode)
|
||||||
{
|
{
|
||||||
output.push(true);
|
output.push(true);
|
||||||
if (filter && maps[i].names[0] != filter) // XXX: may compare <C-... stuff lowercase?
|
if (filter && maps[i].names[0] != filter) // does it match the filter first of all?
|
||||||
{
|
{
|
||||||
output[output.length - 1] = false;
|
output[output.length - 1] = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var index = 1; index < modes.length; index++) // modes
|
for (var index = 1; index < modes.length; index++) // check if found in the other modes (1(2nd)-last)
|
||||||
{
|
{
|
||||||
output[output.length - 1] = false; // toggle false, only true whan also found in this mode
|
output[output.length - 1] = false; // toggle false, only true whan also found in this mode
|
||||||
for (var z = 0; z < user[modes[index]].length; z++) // maps
|
for (var z = 0; z < user[modes[index]].length; z++) // maps on the other modes
|
||||||
{
|
{
|
||||||
// XXX: on user maps, names.length is always 1? (per mode, and names = user-keybinding or so)
|
// XXX: on user maps, names.length is always 1? (per mode, and names = user-keybinding or so)
|
||||||
if (maps[i].rhs == user[modes[index]][z].rhs && maps[i].names[0] == user[modes[index]][z].names[0])
|
if (maps[i].rhs == user[modes[index]][z].rhs && maps[i].names[0] == user[modes[index]][z].names[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user