1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 05:47:58 +01:00

Get rid of absurd Map#route flag. Consolodate some constants.

This commit is contained in:
Kris Maglione
2011-01-18 17:35:57 -05:00
parent 3e95b19cb0
commit c78bb0f332
9 changed files with 52 additions and 50 deletions

View File

@@ -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

View File

@@ -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,
["<C-]>", "<C-5>"], "Expand command line abbreviation",

View File

@@ -588,8 +588,10 @@ var Editor = Module("editor", {
mappings.add([modes.INSERT],
["<Space>", "<Return>"], "Expand insert mode abbreviation",
function () { editor.expandAbbreviation(modes.INSERT); },
{ route: true });
function () {
editor.expandAbbreviation(modes.INSERT);
return Events.PASS;
});
mappings.add([modes.INSERT],
["<C-]>", "<C-5>"], "Expand insert mode abbreviation",

View File

@@ -978,26 +978,24 @@ var Events = Module("events", {
if (events.toString(event) === "<C-h>")
event.dactylString = "<BS>";
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", {
["<C-v>"], "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,
["<Nop>"], "Do nothing",

View File

@@ -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, ["<Leader>"],
"Toggle hint filtering",

View File

@@ -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*.
*

View File

@@ -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

View File

@@ -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();

View File

@@ -514,8 +514,7 @@ const Mail = Module("mail", {
mappings.add(myModes, ["<Space>"],
"Scroll message or select next unread one",
function () true,
{ route: true });
function () Events.PASS);
mappings.add(myModes, ["t"],
"Select thread",