1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 06:58:00 +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;
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

View File

@@ -922,6 +922,8 @@ var CommandLine = Module("commandline", {
* @private
*/
onEvent: function onEvent(event) {
const KILL = false, PASS = true;
try {
let command = this.command;
@@ -946,7 +948,7 @@ var CommandLine = Module("commandline", {
if (this._completions)
this._completions.previewClear();
if (!this.currentExtendedMode)
return !Events.isEscape(event);
return Events.isEscape(event) ? KILL : PASS;
// user pressed <Enter> to carry out a command
// 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
return !Events.isEscape(event);
return Events.isEscape(event) ? KILL : PASS;
}
else if (event.type == "keyup") {
let key = events.toString(event);
@@ -997,7 +999,7 @@ var CommandLine = Module("commandline", {
catch (e) {
dactyl.reportError(e, true);
}
return true;
return PASS;
},
/**
@@ -1007,6 +1009,8 @@ var CommandLine = Module("commandline", {
* @param {Event} event
*/
onMultilineInputEvent: function onMultilineInputEvent(event) {
const KILL = false, PASS = true;
if (event.type == "keypress") {
let key = events.toString(event);
if (events.isAcceptKey(key)) {
@@ -1029,7 +1033,7 @@ var CommandLine = Module("commandline", {
}
else if (event.type == "input")
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
// allow a down motion after an up rather than closing
onMultilineOutputEvent: function onMultilineOutputEvent(event) {
const KILL = false, PASS = true;
let win = this.widgets.multilineOutput.contentWindow;
let elem = win.document.documentElement;
@@ -1059,7 +1065,7 @@ var CommandLine = Module("commandline", {
event.preventDefault();
return dactyl.withSavedValues(["forceNewTab"], function () {
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>":
event.preventDefault();
openLink(dactyl.CURRENT_TAB);
return false;
return KILL;
case "<MiddleMouse>":
case "<C-LeftMouse>":
case "<C-M-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: true });
return false;
return KILL;
case "<S-MiddleMouse>":
case "<C-S-LeftMouse>":
case "<C-M-S-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: false });
return false;
return KILL;
case "<S-LeftMouse>":
openLink(dactyl.NEW_WINDOW);
return false;
return KILL;
}
return true;
return PASS;
}
if (event instanceof MouseEvent)
return false;
return KILL;
function atEnd(dir) !Buffer.isScrollable(elem, dir || 1);
@@ -1096,6 +1102,7 @@ var CommandLine = Module("commandline", {
}
else
commandline.updateMorePrompt(false, true);
return PASS;
},
getSpaceNeeded: function getSpaceNeeded() {

View File

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

View File

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