mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-06 17:45:48 +01:00
expand <Leader> in addUserMap() (Tim Hammerquist)
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -24,4 +24,5 @@ Patches (in no special order):
|
|||||||
* Joseph Xu (supporting multiple top level windows better)
|
* Joseph Xu (supporting multiple top level windows better)
|
||||||
* Raimon Grau Cuscó (document relationship navigation - ]], [[)
|
* Raimon Grau Cuscó (document relationship navigation - ]], [[)
|
||||||
* Ryan Zheng (ctrl-x/a support)
|
* Ryan Zheng (ctrl-x/a support)
|
||||||
|
* Tim Hammerquist (better <Leader> support)
|
||||||
</pre>
|
</pre>
|
||||||
|
|||||||
@@ -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)
|
function mappingsIterator(modes, stack)
|
||||||
{
|
{
|
||||||
var output;
|
var output;
|
||||||
@@ -172,14 +179,10 @@ liberator.Mappings = function () //{{{
|
|||||||
|
|
||||||
// ?:\s+ <- don't remember; (...)? optional = rhs
|
// ?:\s+ <- don't remember; (...)? optional = rhs
|
||||||
var [, lhs, rhs] = args.match(/(\S+)(?:\s+(.+))?/);
|
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
|
if (!rhs) // list the mapping
|
||||||
{
|
{
|
||||||
liberator.mappings.list(mode, lhs);
|
liberator.mappings.list(mode, expandLeader(lhs));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -288,6 +291,7 @@ liberator.Mappings = function () //{{{
|
|||||||
|
|
||||||
addUserMap: function (modes, keys, description, action, extra)
|
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);
|
var map = new liberator.Map(modes, keys, description || "User defined mapping", action, extra);
|
||||||
|
|
||||||
// remove all old mappings to this key sequence
|
// remove all old mappings to this key sequence
|
||||||
|
|||||||
Reference in New Issue
Block a user