X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fcontent%2Fmappings.js;h=5a1d6b269452d6c5e6439560b404591cc375335a;hb=refs%2Fheads%2Fupstream;hp=fa113b4d4de0229bd2ca5e24b202c2ffc39f7438;hpb=354a049cce8415487552ce405cce167b7071fe1f;p=dactyl.git diff --git a/common/content/mappings.js b/common/content/mappings.js index fa113b4..5a1d6b2 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -1,6 +1,6 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2013 Kris Maglione +// Copyright (c) 2008-2014 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -39,7 +39,7 @@ var Map = Class("Map", { Object.freeze(this.modes); if (info) { - if (Set.has(Map.types, info.type)) + if (hasOwnProperty(Map.types, info.type)) this.update(Map.types[info.type]); this.update(info); } @@ -107,7 +107,7 @@ var Map = Class("Map", { */ hasName: function (name) this.keys.indexOf(name) >= 0, - get keys() array.flatten(this.names.map(mappings.closure.expand)), + get keys() array.flatten(this.names.map(mappings.bound.expand)), /** * Execute the action for this mapping. @@ -171,7 +171,7 @@ var MapHive = Class("MapHive", Contexts.Hive, { * @param {[Modes.Mode]} modes The modes for which to return mappings. */ iterate: function (modes) { - let stacks = Array.concat(modes).map(this.closure.getStack); + let stacks = Array.concat(modes).map(this.bound.getStack); return values(stacks.shift().sort((m1, m2) => String.localeCompare(m1.name, m2.name)) .filter((map) => map.rhs && stacks.every(stack => stack.some(m => m.rhs && m.rhs === map.rhs && m.name === map.name)))); @@ -187,7 +187,7 @@ var MapHive = Class("MapHive", Contexts.Hive, { * @param {Object} extra An optional extra configuration hash. * @optional */ - add: function (modes, keys, description, action, extra = {}) { + add: function (modes, keys, description, action, extra={}) { modes = Array.concat(modes); if (!modes.every(util.identity)) throw TypeError(/*L*/"Invalid modes: " + modes); @@ -380,10 +380,10 @@ var Mappings = Module("mappings", { }, iterate: function (mode) { - let seen = {}; + let seen = RealSet(); for (let hive in this.hives.iterValues()) for (let map in array(hive.getStack(mode)).iterValues()) - if (!Set.add(seen, map.name)) + if (!seen.add(map.name)) yield map; }, @@ -638,10 +638,10 @@ var Mappings = Module("mappings", { } }; function userMappings(hive) { - let seen = {}; + let seen = RealSet(); for (let stack in values(hive.stacks)) for (let map in array.iterValues(stack)) - if (!Set.add(seen, map.id)) + if (!seen.add(map.id)) yield map; } @@ -714,6 +714,7 @@ var Mappings = Module("mappings", { function uniqueModes(modes) { let chars = [k for ([k, v] in Iterator(modules.modes.modeChars)) if (v.every(mode => modes.indexOf(mode) >= 0))]; + return array.uniq(modes.filter(m => chars.indexOf(m.char) < 0) .map(m => m.name.toLowerCase()) .concat(chars)); @@ -748,13 +749,13 @@ var Mappings = Module("mappings", { if (!mainOnly) modes = modes[0].allBases; - let seen = {}; + let seen = RealSet(); // Bloody hell. --Kris for (let [i, mode] in Iterator(modes)) for (let hive in mappings.hives.iterValues()) for (let map in array.iterValues(hive.getStack(mode))) for (let name in values(map.names)) - if (!Set.add(seen, name)) { + if (!seen.add(name)) yield { name: name, columns: [ @@ -765,7 +766,6 @@ var Mappings = Module("mappings", { ], __proto__: map }; - } }, format: { description: function (map) [ @@ -800,7 +800,7 @@ var Mappings = Module("mappings", { name: [mode.char + "listk[eys]", mode.char + "lk"], iterateIndex: function (args) let (self = this, prefix = /^[bCmn]$/.test(mode.char) ? "" : mode.char + "_", - haveTag = Set.has(help.tags)) + haveTag = k => hasOwnProperty(help.tags, k)) ({ helpTag: prefix + map.name, __proto__: map } for (map in self.iterate(args, true)) if (map.hive === mappings.builtin || haveTag(prefix + map.name))), @@ -812,7 +812,7 @@ var Mappings = Module("mappings", { }); }, completion: function initCompletion(dactyl, modules, window) { - completion.userMapping = function userMapping(context, modes_ = [modes.NORMAL], hive = mappings.user) { + completion.userMapping = function userMapping(context, modes_=[modes.NORMAL], hive=mappings.user) { context.keys = { text: function (m) m.names[0], description: function (m) m.description + ": " + m.action }; context.completions = hive.iterate(modes_);