// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
-/* use strict */
+"use strict";
/** @scope modules */
get userHives() this.allHives.filter(function (h) h !== this.builtin, this),
- expandLeader: function expandLeader(keyString) keyString.replace(/<Leader>/i, function () options["mapleader"]),
+ expandLeader: deprecated("your brain", function expandLeader(keyString) keyString),
prefixes: Class.Memoize(function () {
let list = Array.map("CASM", function (s) s + "-");
}),
expand: function expand(keys) {
- keys = keys.replace(/<leader>/i, options["mapleader"]);
-
if (!/<\*-/.test(keys))
var res = keys;
else
return maps;
}
- let list = <table>
- <tr highlight="Title">
- <td/>
- <td style="padding-right: 1em;">{_("title.Mode")}</td>
- <td style="padding-right: 1em;">{_("title.Command")}</td>
- <td style="padding-right: 1em;">{_("title.Action")}</td>
- </tr>
- <col style="min-width: 6em; padding-right: 1em;"/>
- {
- template.map(hives, function ([hive, maps]) let (i = 0)
- <tr style="height: .5ex;"/> +
- template.map(maps, function (map)
- template.map(map.names, function (name)
- <tr>
- <td highlight="Title">{!i++ ? hive.name : ""}</td>
- <td>{modeSign}</td>
- <td>{name}</td>
- <td>{map.rhs || map.action.toSource()}</td>
- </tr>)) +
- <tr style="height: .5ex;"/>)
- }
- </table>;
-
- // TODO: Move this to an ItemList to show this automatically
- if (list.*.length() === list.text().length() + 2)
- dactyl.echomsg(_("map.none"));
- else
- commandline.commandOutput(list);
+ let list = ["table", {},
+ ["tr", { highlight: "Title" },
+ ["td", {}],
+ ["td", { style: "padding-right: 1em;" }, _("title.Mode")],
+ ["td", { style: "padding-right: 1em;" }, _("title.Command")],
+ ["td", { style: "padding-right: 1em;" }, _("title.Action")]],
+ ["col", { style: "min-width: 6em; padding-right: 1em;" }],
+ hives.map(function ([hive, maps]) let (i = 0) [
+ ["tr", { style: "height: .5ex;" }],
+ maps.map(function (map)
+ map.names.map(function (name)
+ ["tr", {},
+ ["td", { highlight: "Title" }, !i++ ? hive.name : ""],
+ ["td", {}, modeSign],
+ ["td", {}, name],
+ ["td", {}, map.rhs || map.action.toSource()]])),
+ ["tr", { style: "height: .5ex;" }]])]
+
+ // E4X-FIXME
+ // // TODO: Move this to an ItemList to show this automatically
+ // if (list.*.length() === list.text().length() + 2)
+ // dactyl.echomsg(_("map.none"));
+ // else
+ commandline.commandOutput(list);
}
}, {
}, {
args["-builtin"] = true;
if (!rhs) // list the mapping
- mappings.list(mapmodes, mappings.expandLeader(lhs), hives);
+ mappings.list(mapmodes, lhs, hives);
else {
util.assert(args["-group"].modifiable,
_("map.builtinImmutable"));
commands.add([ch + "no[remap]"],
"Map a key sequence without remapping keys" + modeDescription,
function (args) { map(args, true); },
- update({}, opts));
+ update({ deprecated: ":" + ch + "map -builtin" }, opts));
commands.add([ch + "unm[ap]"],
"Remove a mapping" + modeDescription,
yield {
name: name,
columns: [
- i === 0 ? "" : <span highlight="Object" style="padding-right: 1em;">{mode.name}</span>,
- hive == mappings.builtin ? "" : <span highlight="Object" style="padding-right: 1em;">{hive.name}</span>
+ i === 0 ? "" : ["span", { highlight: "Object", style: "padding-right: 1em;" },
+ mode.name],
+ hive == mappings.builtin ? "" : ["span", { highlight: "Object", style: "padding-right: 1em;" },
+ hive.name]
],
__proto__: map
};
}
},
format: {
- description: function (map) (XML.ignoreWhitespace = false, XML.prettyPrinting = false, <>
- {options.get("passkeys").has(map.name)
- ? <span highlight="URLExtra">(passed by {template.helpLink("'passkeys'")})</span>
- : <></>}
- {template.linkifyHelp(map.description + (map.rhs ? ": " + map.rhs : ""))}
- </>),
+ description: function (map) [
+ options.get("passkeys").has(map.name)
+ ? ["span", { highlight: "URLExtra" },
+ "(", template.linkifyHelp(_("option.passkeys.passedBy")), ")"]
+ : [],
+ template.linkifyHelp(map.description + (map.rhs ? ": " + map.rhs : ""))
+ ],
help: function (map) let (char = array.compact(map.modes.map(function (m) m.char))[0])
char === "n" ? map.name : char ? char + "_" + map.name : "",
headings: ["Command", "Mode", "Group", "Description"]
}
- }
+ };
dactyl.addUsageCommand({
__proto__: args,
function (context, obj, args) [[m.names, m.description] for (m in this.iterate(args[0]))]
]);
},
- options: function initOptions(dactyl, modules, window) {
- options.add(["mapleader", "ml"],
- "Define the replacement keys for the <Leader> pseudo-key",
- "string", "\\", {
- setter: function (value) {
- if (this.hasChanged)
- for (let hive in values(mappings.allHives))
- for (let stack in values(hive.stacks))
- delete stack.states;
- return value;
- }
- });
+ mappings: function initMappings(dactyl, modules, window) {
+ mappings.add([modes.COMMAND],
+ ["\\"], "Emits <Leader> pseudo-key",
+ function () { events.feedkeys("<Leader>") });
}
});