1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-09 07:44:14 +01:00

expand <Leader> in addUserMap() (Tim Hammerquist)

This commit is contained in:
Doug Kearns
2008-06-02 18:17:05 +00:00
parent 973f3e5ca3
commit c1f1b1d419
2 changed files with 10 additions and 5 deletions

View File

@@ -128,6 +128,13 @@ liberator.Mappings = function () //{{{
}
}
function expandLeader(keyString)
{
var leaderRegexp = /<Leader>/i;
var currentLeader = liberator.events.getMapLeader();
return keyString.replace(leaderRegexp, currentLeader);
}
function mappingsIterator(modes, stack)
{
var output;
@@ -172,14 +179,10 @@ liberator.Mappings = function () //{{{
// ?:\s+ <- don't remember; (...)? optional = rhs
var [, lhs, rhs] = args.match(/(\S+)(?:\s+(.+))?/);
var leaderRegexp = /<Leader>/i;
if (leaderRegexp.test(lhs))
lhs = lhs.replace(leaderRegexp, liberator.events.getMapLeader());
if (!rhs) // list the mapping
{
liberator.mappings.list(mode, lhs);
liberator.mappings.list(mode, expandLeader(lhs));
}
else
{
@@ -288,6 +291,7 @@ liberator.Mappings = function () //{{{
addUserMap: function (modes, keys, description, action, extra)
{
keys = keys.map(function (key) { return expandLeader(key); });
var map = new liberator.Map(modes, keys, description || "User defined mapping", action, extra);
// remove all old mappings to this key sequence