From c1f1b1d41905e941bc358cf86dad1f72f5064b9e Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 2 Jun 2008 18:17:05 +0000 Subject: [PATCH] expand in addUserMap() (Tim Hammerquist) --- AUTHORS | 1 + content/mappings.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2c964c1d..03d93a3b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -24,4 +24,5 @@ Patches (in no special order): * Joseph Xu (supporting multiple top level windows better) * Raimon Grau Cuscó (document relationship navigation - ]], [[) * Ryan Zheng (ctrl-x/a support) + * Tim Hammerquist (better support) diff --git a/content/mappings.js b/content/mappings.js index 66f3cf65..2ef48b97 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -128,6 +128,13 @@ liberator.Mappings = function () //{{{ } } + function expandLeader(keyString) + { + var leaderRegexp = //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 = //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