1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 08:37:59 +01:00

Some constants to save my sanity.

This commit is contained in:
Kris Maglione
2010-12-31 00:30:59 -05:00
parent 2181874af3
commit 3f3e89e270
4 changed files with 33 additions and 22 deletions

View File

@@ -301,7 +301,9 @@ var Buffer = Module("buffer", {
uri && uri.scheme === "dactyl" && webProgress.isLoadingDocument; uri && uri.scheme === "dactyl" && webProgress.isLoadingDocument;
util.timeout(function () { util.timeout(function () {
buffer._triggerLoadAutocmd("LocationChange", webProgress.DOMWindow ? webProgress.DOMWindow.document : content.document, uri); buffer._triggerLoadAutocmd("LocationChange",
(webProgress.DOMWindow || content).document,
uri);
}); });
// if this is not delayed we get the position of the old buffer // if this is not delayed we get the position of the old buffer

View File

@@ -922,6 +922,8 @@ var CommandLine = Module("commandline", {
* @private * @private
*/ */
onEvent: function onEvent(event) { onEvent: function onEvent(event) {
const KILL = false, PASS = true;
try { try {
let command = this.command; let command = this.command;
@@ -946,7 +948,7 @@ var CommandLine = Module("commandline", {
if (this._completions) if (this._completions)
this._completions.previewClear(); this._completions.previewClear();
if (!this.currentExtendedMode) if (!this.currentExtendedMode)
return !Events.isEscape(event); return Events.isEscape(event) ? KILL : PASS;
// user pressed <Enter> to carry out a command // user pressed <Enter> to carry out a command
// user pressing <Esc> is handled in the global onEscape // user pressing <Esc> is handled in the global onEscape
@@ -986,7 +988,7 @@ var CommandLine = Module("commandline", {
} }
} }
// allow this event to be handled by the host app // allow this event to be handled by the host app
return !Events.isEscape(event); return Events.isEscape(event) ? KILL : PASS;
} }
else if (event.type == "keyup") { else if (event.type == "keyup") {
let key = events.toString(event); let key = events.toString(event);
@@ -997,7 +999,7 @@ var CommandLine = Module("commandline", {
catch (e) { catch (e) {
dactyl.reportError(e, true); dactyl.reportError(e, true);
} }
return true; return PASS;
}, },
/** /**
@@ -1007,6 +1009,8 @@ var CommandLine = Module("commandline", {
* @param {Event} event * @param {Event} event
*/ */
onMultilineInputEvent: function onMultilineInputEvent(event) { onMultilineInputEvent: function onMultilineInputEvent(event) {
const KILL = false, PASS = true;
if (event.type == "keypress") { if (event.type == "keypress") {
let key = events.toString(event); let key = events.toString(event);
if (events.isAcceptKey(key)) { if (events.isAcceptKey(key)) {
@@ -1029,7 +1033,7 @@ var CommandLine = Module("commandline", {
} }
else if (event.type == "input") else if (event.type == "input")
this._autosizeMultilineInputWidget(); this._autosizeMultilineInputWidget();
return true; return PASS;
}, },
/** /**
@@ -1042,6 +1046,8 @@ var CommandLine = Module("commandline", {
// FIXME: if 'more' is set and the MOW is not scrollable we should still // FIXME: if 'more' is set and the MOW is not scrollable we should still
// allow a down motion after an up rather than closing // allow a down motion after an up rather than closing
onMultilineOutputEvent: function onMultilineOutputEvent(event) { onMultilineOutputEvent: function onMultilineOutputEvent(event) {
const KILL = false, PASS = true;
let win = this.widgets.multilineOutput.contentWindow; let win = this.widgets.multilineOutput.contentWindow;
let elem = win.document.documentElement; let elem = win.document.documentElement;
@@ -1059,7 +1065,7 @@ var CommandLine = Module("commandline", {
event.preventDefault(); event.preventDefault();
return dactyl.withSavedValues(["forceNewTab"], function () { return dactyl.withSavedValues(["forceNewTab"], function () {
dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1; dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1;
dactyl.commands[command](event); return dactyl.commands[command](event);
}); });
} }
@@ -1067,26 +1073,26 @@ var CommandLine = Module("commandline", {
case "<LeftMouse>": case "<LeftMouse>":
event.preventDefault(); event.preventDefault();
openLink(dactyl.CURRENT_TAB); openLink(dactyl.CURRENT_TAB);
return false; return KILL;
case "<MiddleMouse>": case "<MiddleMouse>":
case "<C-LeftMouse>": case "<C-LeftMouse>":
case "<C-M-LeftMouse>": case "<C-M-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: true }); openLink({ where: dactyl.NEW_TAB, background: true });
return false; return KILL;
case "<S-MiddleMouse>": case "<S-MiddleMouse>":
case "<C-S-LeftMouse>": case "<C-S-LeftMouse>":
case "<C-M-S-LeftMouse>": case "<C-M-S-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: false }); openLink({ where: dactyl.NEW_TAB, background: false });
return false; return KILL;
case "<S-LeftMouse>": case "<S-LeftMouse>":
openLink(dactyl.NEW_WINDOW); openLink(dactyl.NEW_WINDOW);
return false; return KILL;
} }
return true; return PASS;
} }
if (event instanceof MouseEvent) if (event instanceof MouseEvent)
return false; return KILL;
function atEnd(dir) !Buffer.isScrollable(elem, dir || 1); function atEnd(dir) !Buffer.isScrollable(elem, dir || 1);
@@ -1096,6 +1102,7 @@ var CommandLine = Module("commandline", {
} }
else else
commandline.updateMorePrompt(false, true); commandline.updateMorePrompt(false, true);
return PASS;
}, },
getSpaceNeeded: function getSpaceNeeded() { getSpaceNeeded: function getSpaceNeeded() {

View File

@@ -1091,6 +1091,7 @@ var Events = Module("events", {
}, },
onKeyPress: function onKeyPress(event) { onKeyPress: function onKeyPress(event) {
const KILL = true, PASS = false, WAIT = null;
const self = this; const self = this;
let key = events.toString(event); let key = events.toString(event);
@@ -1101,7 +1102,7 @@ var Events = Module("events", {
function execute(map) { function execute(map) {
if (self.preExecute) if (self.preExecute)
self.preExecute.apply(self, arguments); self.preExecute.apply(self, arguments);
let res = map.execute.apply(map, Array.slice(arguments, 1)) let res = map.execute.apply(map, Array.slice(arguments, 1));
if (self.postExecute) // To do: get rid of this. if (self.postExecute) // To do: get rid of this.
self.postExecute.apply(self, arguments); self.postExecute.apply(self, arguments);
return res; return res;
@@ -1121,7 +1122,7 @@ var Events = Module("events", {
if (!this.main.count) if (!this.main.count)
return this.append(event); return this.append(event);
else if (this.main.input) else if (this.main.input)
return false; return PASS;
else else
this.append(event); this.append(event);
} }
@@ -1129,7 +1130,7 @@ var Events = Module("events", {
let [map, command] = this.pendingArgMap; let [map, command] = this.pendingArgMap;
if (!Events.isEscape(key)) if (!Events.isEscape(key))
execute(map, null, this.count, key, command); execute(map, null, this.count, key, command);
return true; return KILL;
} }
else if (map && !event.skipmap && candidates.length == 0) { else if (map && !event.skipmap && candidates.length == 0) {
this.pendingMap = null; this.pendingMap = null;
@@ -1148,7 +1149,7 @@ var Events = Module("events", {
let [map, command] = this.pendingMotionMap; let [map, command] = this.pendingMotionMap;
if (!Events.isEscape(key)) if (!Events.isEscape(key))
execute(map, command, this.motionCount || this.count, null, command); execute(map, command, this.motionCount || this.count, null, command);
return true; return KILL;
} }
else if (map.motion) { else if (map.motion) {
this.buffer = ""; this.buffer = "";
@@ -1156,9 +1157,9 @@ var Events = Module("events", {
} }
else { else {
if (modes.replaying && !events.waitForPageLoad()) if (modes.replaying && !events.waitForPageLoad())
return true; return KILL;
return !execute(map, null, this.count, null, command) || !map.route; return execute(map, null, this.count, null, command) && map.route ? PASS : KILL;
} }
} }
else if (mappings.getCandidates(this.main, command).length > 0 && !event.skipmap) { else if (mappings.getCandidates(this.main, command).length > 0 && !event.skipmap) {
@@ -1169,7 +1170,7 @@ var Events = Module("events", {
this.append(event); this.append(event);
return this.events; return this.events;
} }
return null; return WAIT;
} }
}), }),

View File

@@ -900,6 +900,7 @@ var Hints = Module("hints", {
* @param {Event} event The event to handle. * @param {Event} event The event to handle.
*/ */
onEvent: function onEvent(event) { onEvent: function onEvent(event) {
const KILL = false, PASS = true;
let key = events.toString(event); let key = events.toString(event);
this.clearTimeout(); this.clearTimeout();
@@ -918,7 +919,7 @@ var Hints = Module("hints", {
this._updateStatusline(); this._updateStatusline();
if (!this._canUpdate) if (!this._canUpdate)
return; return PASS;
if (this._docs.length == 0) { if (this._docs.length == 0) {
this._generate(); this._generate();
@@ -929,10 +930,10 @@ var Hints = Module("hints", {
dactyl.assert(this._hintNumber != 0); dactyl.assert(this._hintNumber != 0);
this._checkUnique(); this._checkUnique();
return false; return KILL;
} }
return !Events.isEscape(key); return Events.isEscape(key) ? KILL : PASS;
} }
//}}} //}}}
}, { }, {