diff --git a/common/Makefile b/common/Makefile index 5a2a0c10..64441a35 100644 --- a/common/Makefile +++ b/common/Makefile @@ -31,7 +31,7 @@ XPI_DIRS = components $(MANGLE) defaults XPI_TEXTS = js jsm $(JAR_TEXTS) XPI_BINS = $(JAR_BINS) -XPI_NAME = $(NAME)_$(VERSION) +XPI_NAME = $(NAME)-$(VERSION) XPI_PATH = ../downloads/$(XPI_NAME) XPI = $(XPI_PATH).xpi diff --git a/common/content/commandline.js b/common/content/commandline.js index 1de329da..be38d08f 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1713,9 +1713,8 @@ var CommandLine = Module("commandline", { function () { commandline.resetCompletions(); editor.expandAbbreviation(modes.COMMAND_LINE); - return true; - }, - { route: true }); + return Events.PASS; + }); mappings.add(myModes, ["", ""], "Expand command line abbreviation", diff --git a/common/content/editor.js b/common/content/editor.js index 507fb0bb..ff4775ad 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -588,8 +588,10 @@ var Editor = Module("editor", { mappings.add([modes.INSERT], ["", ""], "Expand insert mode abbreviation", - function () { editor.expandAbbreviation(modes.INSERT); }, - { route: true }); + function () { + editor.expandAbbreviation(modes.INSERT); + return Events.PASS; + }); mappings.add([modes.INSERT], ["", ""], "Expand insert mode abbreviation", diff --git a/common/content/events.js b/common/content/events.js index 98675c80..c5795158 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -978,26 +978,24 @@ var Events = Module("events", { if (events.toString(event) === "") event.dactylString = ""; - return mode.params.onEvent(event) === false ? KILL : PASS; + return mode.params.onEvent(event) === false ? Events.KILL : Events.PASS; }; }} } } - const KILL = true, PASS = false, WAIT = null; - let refeed, ownsBuffer = 0, buffer, waiting = 0; for (let input in values(processors)) { var res = input.process(event); ownsBuffer += !!input.main.ownsBuffer; - waiting += res == WAIT; + waiting += res == Events.WAIT; buffer = buffer || input.inputBuffer; if (isArray(res) && !waiting) refeed = res; - else if (res !== PASS) + else if (res !== Events.PASS) refeed = null; - if (res === KILL) + if (res === Events.KILL) break; } @@ -1006,13 +1004,15 @@ var Events = Module("events", { if (waiting) this._processors = processors; - else if (res !== KILL && (mode.main & (modes.TEXT_EDIT | modes.VISUAL))) + else if (res !== Events.KILL && (mode.main & (modes.TEXT_EDIT | modes.VISUAL))) dactyl.beep(); - if (refeed && refeed.length == 1 && !refeed[0].getPreventDefault()) - [refeed, res] = [null, PASS]; + if (refeed && refeed[0] && !refeed[0].getPreventDefault()) { + res = Events.PASS; + refeed.pop(); + } - if (res !== PASS) + if (res !== Events.PASS) kill(event); if (refeed) @@ -1097,6 +1097,11 @@ var Events = Module("events", { } } }, { + KILL: true, + PASS: false, + WAIT: null, + + KeyProcessor: Class("KeyProcessor", { init: function init(main, extended, hive) { this.main = main; @@ -1105,7 +1110,7 @@ var Events = Module("events", { this.hive = hive; }, - toString: function () ["[instance KeyProcessor(" + this.main.name, this.extended, this.hive.name + ")]"].join(", "), + get toStringParams() [this.main.name, this.extended, this.hive.name], buffer: "", // partial command storage pendingMotionMap: null, // e.g. "d{motion}" if we wait for a motion of the "d" command @@ -1120,31 +1125,29 @@ var Events = Module("events", { }, process: function process(event) { - const KILL = true, PASS = false, WAIT = null; - function kill(event) { event.stopPropagation(); event.preventDefault(); } let res = this.onKeyPress(event); - if (res === KILL) + if (res === Events.KILL) kill(event); else if (this.fallthrough) { let evt = isArray(res) ? res[0] : event; let r = dactyl.trapErrors(this.fallthrough, this, evt); - if (r === KILL) + if (r === Events.KILL) kill(evt); - res = r === KILL ? KILL : PASS; + res = r === Events.KILL ? Events.KILL : Events.PASS; /* - if (r === KILL) + if (r === Events.KILL) res = res.slice(1); else - res = r == WAIT ? res : false; + res = r == Events.WAIT ? res : false; */ } - if (res != WAIT) + if (res != Events.WAIT) this.inputBuffer = ""; else { let motionMap = (this.pendingMotionMap && this.pendingMotionMap.names[0]) || ""; @@ -1155,7 +1158,6 @@ var Events = Module("events", { }, onKeyPress: function onKeyPress(event) { - const KILL = true, PASS = false, WAIT = null; const self = this; let key = events.toString(event); @@ -1186,7 +1188,7 @@ var Events = Module("events", { if (!this.main.count) return this.append(event); else if (this.main.input) - return PASS; + return Events.PASS; else this.append(event); } @@ -1194,7 +1196,7 @@ var Events = Module("events", { let [map, command] = this.pendingArgMap; if (!Events.isEscape(key)) execute(map, null, this.count, key, command); - return KILL; + return Events.KILL; } else if (!event.skipmap && map && candidates.length == 0) { this.pendingMap = null; @@ -1213,7 +1215,7 @@ var Events = Module("events", { let [map, command] = this.pendingMotionMap; if (!Events.isEscape(key)) execute(map, command, this.motionCount || this.count, null, command); - return KILL; + return Events.KILL; } else if (map.motion) { this.buffer = ""; @@ -1221,9 +1223,9 @@ var Events = Module("events", { } else { if (modes.replaying && !events.waitForPageLoad()) - return KILL; + return Events.KILL; - return execute(map, null, this.count, null, command) && map.route ? PASS : KILL; + return execute(map, null, this.count, null, command) === Events.PASS ? Events.PASS : Events.KILL; } } else if (!event.skipmap && this.hive.getCandidates(this.main, command).length > 0) { @@ -1234,7 +1236,7 @@ var Events = Module("events", { this.append(event); return this.events; } - return WAIT; + return Events.WAIT; } }), @@ -1291,10 +1293,9 @@ var Events = Module("events", { [""], "Pass through next key", function () { if (modes.main == modes.QUOTE) - return true; + return Events.PASS; modes.push(modes.QUOTE); - }, - { route: true }); + }); mappings.add(modes.all, [""], "Do nothing", diff --git a/common/content/hints.js b/common/content/hints.js index 4f19bafc..03fd0169 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -1120,7 +1120,7 @@ var Hints = Module("hints", { function () { hints.clearTimeout(); if (hints.prevInput !== "number") - return true; + return Events.PASS; if (hints._hintNumber > 0 && !hints._usedTabKey) { hints._hintNumber = Math.floor(hints._hintNumber / hints.hintKeys.length); @@ -1133,9 +1133,8 @@ var Hints = Module("hints", { hints._hintNumber = 0; dactyl.beep(); } - return false; - }, - { route: true }); + return Events.KILL; + }); mappings.add(modes.HINTS, [""], "Toggle hint filtering", diff --git a/common/content/mappings.js b/common/content/mappings.js index 3d253d9d..53596adb 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -22,7 +22,6 @@ * arg - see {@link Map#arg} * count - see {@link Map#count} * motion - see {@link Map#motion} - * route - see {@link Map#route} * noremap - see {@link Map#noremap} * rhs - see {@link Map#rhs} * silent - see {@link Map#silent} @@ -49,6 +48,8 @@ var Map = Class("Map", { update(this, extraInfo); }, + get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)], + /** @property {number[]} All of the modes for which this mapping applies. */ modes: null, /** @property {string[]} All of this mapping's names (key sequences). */ @@ -67,12 +68,6 @@ var Map = Class("Map", { * as an argument. */ motion: false, - /** - * @property {boolean} Whether the mapping's key events should be - * propagated to the host application. - */ - // TODO: I'm not sure this is the best name but it reflects that which it replaced. --djk - route: false, /** @property {boolean} Whether the RHS of the mapping should expand mappings recursively. */ noremap: false, /** @property {boolean} Whether any output from the mapping should be echoed on the command line. */ @@ -128,6 +123,8 @@ var MapHive = Class("MapHive", { this.stacks = {}; }, + get toStringParams() [this.name], + /** * Iterates over all mappings present in all of the given *modes*. * diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 1d5bbd40..df7fb30b 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -766,7 +766,12 @@ Class.prototype = { } }, - toString: function () "[instance " + this.constructor.className + "]", + toString: function () { + if (this.toStringParams) + var params = "(" + this.toStringParams.map(function (m) isArray(m) ? "[" + m + "]" : + isString(m) ? m.quote() : String(m)) + ")"; + return "[instance " + this.constructor.className + (params || "") + "]"; + }, /** * Executes *callback* after *timeout* milliseconds. The value of diff --git a/common/modules/finder.jsm b/common/modules/finder.jsm index a4fa3443..142d3033 100644 --- a/common/modules/finder.jsm +++ b/common/modules/finder.jsm @@ -108,7 +108,7 @@ var RangeFinder = Module("rangefinder", { }, 0); else this.commandline.echo((this.rangeFind.backward ? "?" : "/") + this.lastFindPattern, - null, this.commandline.FORCE_SINGLELINE); + "Normal", this.commandline.FORCE_SINGLELINE); if (this.options["hlfind"]) this.highlight(); diff --git a/teledactyl/content/mail.js b/teledactyl/content/mail.js index c6273b78..11d84b80 100644 --- a/teledactyl/content/mail.js +++ b/teledactyl/content/mail.js @@ -514,8 +514,7 @@ const Mail = Module("mail", { mappings.add(myModes, [""], "Scroll message or select next unread one", - function () true, - { route: true }); + function () Events.PASS); mappings.add(myModes, ["t"], "Select thread",