X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fcontent%2Fmappings.js;h=c272eb5f8d9c50b26bccb33de0a33207af9f9f2c;hb=8b6fcae7eaa413bc62d645d2d0c99835c47265e6;hp=149f3fb86c170e264d2b03435e6e57e03b59b1f3;hpb=9044153cb63835e39b9de8ec4ade237c03e3888a;p=dactyl.git diff --git a/common/content/mappings.js b/common/content/mappings.js index 149f3fb..c272eb5 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -1,10 +1,10 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2008-2012 Kris Maglione // // 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 */ @@ -355,7 +355,7 @@ var Mappings = Module("mappings", { get userHives() this.allHives.filter(function (h) h !== this.builtin, this), - expandLeader: function expandLeader(keyString) keyString.replace(//i, function () options["mapleader"]), + expandLeader: deprecated("your brain", function expandLeader(keyString) keyString), prefixes: Class.Memoize(function () { let list = Array.map("CASM", function (s) s + "-"); @@ -365,8 +365,6 @@ var Mappings = Module("mappings", { }), expand: function expand(keys) { - keys = keys.replace(//i, options["mapleader"]); - if (!/<\*-/.test(keys)) var res = keys; else @@ -482,34 +480,30 @@ var Mappings = Module("mappings", { return maps; } - let list = - - - - - - - { - template.map(hives, function ([hive, maps]) let (i = 0) - + - template.map(maps, function (map) - template.map(map.names, function (name) - - - - - - )) + - ) - } -
- {_("title.Mode")}{_("title.Command")}{_("title.Action")}
{!i++ ? hive.name : ""}{modeSign}{name}{map.rhs || map.action.toSource()}
; - - // 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); } }, { }, { @@ -541,7 +535,7 @@ var Mappings = Module("mappings", { 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")); @@ -659,7 +653,7 @@ var Mappings = Module("mappings", { 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, @@ -763,25 +757,28 @@ var Mappings = Module("mappings", { yield { name: name, columns: [ - i === 0 ? "" : {mode.name}, - hive == mappings.builtin ? "" : {hive.name} + 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) - ? (passed by {template.helpLink("'passkeys'")}) - : <>} - {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, @@ -828,18 +825,10 @@ var Mappings = Module("mappings", { 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 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 pseudo-key", + function () { events.feedkeys("") }); } });