X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fcontent%2Fkey-processors.js;h=d1a51d2185169ef01918bb72911e5d579b744c4f;hb=refs%2Fheads%2Fupstream;hp=e1ba321f46c35b2b446d471481f420974cb4ccf0;hpb=9044153cb63835e39b9de8ec4ade237c03e3888a;p=dactyl.git diff --git a/common/content/key-processors.js b/common/content/key-processors.js index e1ba321..d1a51d2 100644 --- a/common/content/key-processors.js +++ b/common/content/key-processors.js @@ -1,8 +1,8 @@ -// Copyright (c) 2008-2011 by 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. -/* use strict */ +"use strict"; /** @scope modules */ @@ -20,11 +20,11 @@ var ProcessorStack = Class("ProcessorStack", { this.modes = array([mode.params.keyModes, main, mode.main.allBases.slice(1)]).flatten().compact(); if (builtin) - hives = hives.filter(function (h) h.name === "builtin"); + hives = hives.filter(h => h.name === "builtin"); - this.processors = this.modes.map(function (m) hives.map(function (h) KeyProcessor(m, h))) + this.processors = this.modes.map(m => hives.map(h => KeyProcessor(m, h))) .flatten().array; - this.ownsBuffer = !this.processors.some(function (p) p.main.ownsBuffer); + this.ownsBuffer = !this.processors.some(p => p.main.ownsBuffer); for (let [i, input] in Iterator(this.processors)) { let params = input.main.params; @@ -77,7 +77,7 @@ var ProcessorStack = Class("ProcessorStack", { if (this.ownsBuffer) statusline.inputBuffer = this.processors.length ? this.buffer : ""; - if (!this.processors.some(function (p) !p.extended) && this.actions.length) { + if (!this.processors.some(p => !p.extended) && this.actions.length) { // We have matching actions and no processors other than // those waiting on further arguments. Execute actions as // long as they continue to return PASS. @@ -107,8 +107,8 @@ var ProcessorStack = Class("ProcessorStack", { this.timer = services.Timer(this, options["timeoutlen"], services.Timer.TYPE_ONE_SHOT); } else if (result !== Events.KILL && !this.actions.length && - !(this.events[0].isReplay || this.passUnknown - || this.modes.some(function (m) m.passEvent(this), this.events[0]))) { + !(this.events[0].isReplay || this.passUnknown || + this.modes.some(function (m) m.passEvent(this), this.events[0]))) { // No patching processors, this isn't a fake, pass-through // event, we're not in pass-through mode, and we're not // choosing to pass unknown keys. Kill the event and beep. @@ -134,17 +134,17 @@ var ProcessorStack = Class("ProcessorStack", { events.passing = true; if (result === Events.PASS_THROUGH && this.keyEvents.length) - events.dbg("PASS_THROUGH:\n\t" + this.keyEvents.map(function (e) [e.type, DOM.Event.stringify(e)]).join("\n\t")); + events.dbg("PASS_THROUGH:\n\t" + this.keyEvents.map(e => [e.type, DOM.Event.stringify(e)]).join("\n\t")); if (result === Events.PASS_THROUGH) events.feedevents(null, this.keyEvents, { skipmap: true, isMacro: true, isReplay: true }); else { - let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented); + let list = this.events.filter(e => e.defaultPrevented && !e.dactylDefaultPrevented); if (result === Events.PASS) - events.dbg("PASS THROUGH: " + list.slice(0, length).filter(function (e) e.type === "keypress").map(DOM.Event.closure.stringify)); + events.dbg("PASS THROUGH: " + list.slice(0, length).filter(e => e.type === "keypress").map(DOM.Event.bound.stringify)); if (list.length > length) - events.dbg("REFEED: " + list.slice(length).filter(function (e) e.type === "keypress").map(DOM.Event.closure.stringify)); + events.dbg("REFEED: " + list.slice(length).filter(e => e.type === "keypress").map(DOM.Event.bound.stringify)); if (result === Events.PASS) events.feedevents(null, list.slice(0, length), { skipmap: true, isMacro: true, isReplay: true }); @@ -159,7 +159,7 @@ var ProcessorStack = Class("ProcessorStack", { if (this.timer) this.timer.cancel(); - let key = DOM.Event.stringify(event); + let key = event.dactylString || DOM.Event.stringify(event); this.events.push(event); if (this.keyEvents) this.keyEvents.push(event); @@ -190,7 +190,7 @@ var ProcessorStack = Class("ProcessorStack", { processors.push(res); } - events.dbg("RESULT: " + event.getPreventDefault() + " " + this._result(result)); + events.dbg("RESULT: " + event.defaultPrevented + " " + this._result(result)); events.dbg("ACTIONS: " + actions.length + " " + this.actions.length); events.dbg("PROCESSORS:", processors, "\n"); @@ -233,7 +233,7 @@ var KeyProcessor = Class("KeyProcessor", { append: function append(event) { this.events.push(event); - let key = DOM.Event.stringify(event); + let key = event.dactylString || DOM.Event.stringify(event); if (this.wantCount && !this.command && (this.countStr ? /^[0-9]$/ : /^[1-9]$/).test(key)) @@ -250,18 +250,17 @@ var KeyProcessor = Class("KeyProcessor", { }, execute: function execute(map, args) - let (self = this) - function execute() { - if (self.preExecute) - self.preExecute.apply(self, args); + () => { + if (this.preExecute) + this.preExecute.apply(this, args); - args.self = self.main.params.mappingSelf || self.main.mappingSelf || map; - let res = map.execute.call(map, args); + args.self = this.main.params.mappingSelf || this.main.mappingSelf || map; + let res = map.execute.call(map, args); - if (self.postExecute) - self.postExecute.apply(self, args); - return res; - }, + if (this.postExecute) + this.postExecute.apply(this, args); + return res; + }, onKeyPress: function onKeyPress(event) { if (event.skipmap) @@ -322,3 +321,4 @@ var KeyArgProcessor = Class("KeyArgProcessor", KeyProcessor, { } }); +// vim: set fdm=marker sw=4 sts=4 ts=8 et: