mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 21:57:59 +01:00
Don't return pointless values from keypress event handlers.
This commit is contained in:
@@ -1364,9 +1364,15 @@ function Events() //{{{
|
|||||||
// the commandline has focus
|
// the commandline has focus
|
||||||
onKeyPress: function (event)
|
onKeyPress: function (event)
|
||||||
{
|
{
|
||||||
|
function killEvent()
|
||||||
|
{
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
let key = events.toString(event);
|
let key = events.toString(event);
|
||||||
if (!key)
|
if (!key)
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
//liberator.log(key + " in mode: " + liberator.mode);
|
//liberator.log(key + " in mode: " + liberator.mode);
|
||||||
//liberator.dump(key + " in mode: " + liberator.mode);
|
//liberator.dump(key + " in mode: " + liberator.mode);
|
||||||
@@ -1378,9 +1384,7 @@ function Events() //{{{
|
|||||||
modes.isRecording = false;
|
modes.isRecording = false;
|
||||||
liberator.log("Recorded " + currentMacro + ": " + macros.get(currentMacro), 9);
|
liberator.log("Recorded " + currentMacro + ": " + macros.get(currentMacro), 9);
|
||||||
liberator.echomsg("Recorded macro '" + currentMacro + "'");
|
liberator.echomsg("Recorded macro '" + currentMacro + "'");
|
||||||
event.preventDefault();
|
return void killEvent();
|
||||||
event.stopPropagation();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else if (!mappings.hasMap(liberator.mode, input.buffer + key))
|
else if (!mappings.hasMap(liberator.mode, input.buffer + key))
|
||||||
macros.set(currentMacro, macros.get(currentMacro) + key);
|
macros.set(currentMacro, macros.get(currentMacro) + key);
|
||||||
@@ -1403,16 +1407,12 @@ function Events() //{{{
|
|||||||
modes.isReplaying = false;
|
modes.isReplaying = false;
|
||||||
setTimeout(function () { liberator.echomsg("Canceled playback of macro '" + lastMacro + "'"); }, 100);
|
setTimeout(function () { liberator.echomsg("Canceled playback of macro '" + lastMacro + "'"); }, 100);
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
return void killEvent();
|
||||||
event.stopPropagation();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
events.duringFeed += key;
|
events.duringFeed += key;
|
||||||
event.preventDefault();
|
return void killEvent();
|
||||||
event.stopPropagation();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1420,17 +1420,17 @@ function Events() //{{{
|
|||||||
|
|
||||||
let win = document.commandDispatcher.focusedWindow;
|
let win = document.commandDispatcher.focusedWindow;
|
||||||
if (win && win.document && win.document.designMode == "on" && !config.isComposeWindow)
|
if (win && win.document && win.document.designMode == "on" && !config.isComposeWindow)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
// menus have their own command handlers
|
// menus have their own command handlers
|
||||||
if (modes.extended & modes.MENU)
|
if (modes.extended & modes.MENU)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
// handle Escape-one-key mode (Ctrl-v)
|
// handle Escape-one-key mode (Ctrl-v)
|
||||||
if (modes.passNextKey && !modes.passAllKeys)
|
if (modes.passNextKey && !modes.passAllKeys)
|
||||||
{
|
{
|
||||||
modes.passNextKey = false;
|
modes.passNextKey = false;
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
// handle Escape-all-keys mode (Ctrl-q)
|
// handle Escape-all-keys mode (Ctrl-q)
|
||||||
if (modes.passAllKeys)
|
if (modes.passAllKeys)
|
||||||
@@ -1440,7 +1440,7 @@ function Events() //{{{
|
|||||||
else if (key == "<Esc>" || key == "<C-[>" || key == "<C-v>")
|
else if (key == "<Esc>" || key == "<C-[>" || key == "<C-v>")
|
||||||
; // let flow continue to handle these keys to cancel escape-all-keys mode
|
; // let flow continue to handle these keys to cancel escape-all-keys mode
|
||||||
else
|
else
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// just forward event without checking any mappings when the MOW is open
|
// just forward event without checking any mappings when the MOW is open
|
||||||
@@ -1448,16 +1448,14 @@ function Events() //{{{
|
|||||||
(modes.extended & modes.OUTPUT_MULTILINE))
|
(modes.extended & modes.OUTPUT_MULTILINE))
|
||||||
{
|
{
|
||||||
commandline.onMultilineOutputEvent(event);
|
commandline.onMultilineOutputEvent(event);
|
||||||
event.preventDefault();
|
return void killEvent();
|
||||||
event.stopPropagation();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: ugly hack for now pass certain keys to Firefox as they are without beeping
|
// XXX: ugly hack for now pass certain keys to Firefox as they are without beeping
|
||||||
// also fixes key navigation in combo boxes, submitting forms, etc.
|
// also fixes key navigation in combo boxes, submitting forms, etc.
|
||||||
// FIXME: breaks iabbr for now --mst
|
// FIXME: breaks iabbr for now --mst
|
||||||
if (key in config.ignoreKeys && (config.ignoreKeys[key] & liberator.mode))
|
if (key in config.ignoreKeys && (config.ignoreKeys[key] & liberator.mode))
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
// TODO: handle middle click in content area
|
// TODO: handle middle click in content area
|
||||||
|
|
||||||
@@ -1467,9 +1465,7 @@ function Events() //{{{
|
|||||||
if (liberator.mode == modes.CUSTOM)
|
if (liberator.mode == modes.CUSTOM)
|
||||||
{
|
{
|
||||||
plugins.onEvent(event);
|
plugins.onEvent(event);
|
||||||
event.preventDefault();
|
return void killEvent();
|
||||||
event.stopPropagation();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modes.extended & modes.HINTS)
|
if (modes.extended & modes.HINTS)
|
||||||
@@ -1481,9 +1477,7 @@ function Events() //{{{
|
|||||||
|| (/^[0-9]$/.test(key) && !hints.escNumbers))
|
|| (/^[0-9]$/.test(key) && !hints.escNumbers))
|
||||||
{
|
{
|
||||||
hints.onEvent(event);
|
hints.onEvent(event);
|
||||||
event.preventDefault();
|
return void killEvent();
|
||||||
event.stopPropagation();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// others are left to generate the 'input' event or handled by Firefox
|
// others are left to generate the 'input' event or handled by Firefox
|
||||||
@@ -1499,7 +1493,7 @@ function Events() //{{{
|
|||||||
// XXX: why not just do that as well for HINTS mode actually?
|
// XXX: why not just do that as well for HINTS mode actually?
|
||||||
|
|
||||||
if (liberator.mode == modes.CUSTOM)
|
if (liberator.mode == modes.CUSTOM)
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
let countStr = input.buffer.match(/^[0-9]*/)[0];
|
let countStr = input.buffer.match(/^[0-9]*/)[0];
|
||||||
let candidateCommand = (input.buffer + key).replace(countStr, "");
|
let candidateCommand = (input.buffer + key).replace(countStr, "");
|
||||||
@@ -1537,7 +1531,7 @@ function Events() //{{{
|
|||||||
if (key != "<Esc>" && key != "<C-[>")
|
if (key != "<Esc>" && key != "<C-[>")
|
||||||
{
|
{
|
||||||
if (modes.isReplaying && !waitForPageLoaded())
|
if (modes.isReplaying && !waitForPageLoaded())
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
tmp.execute(null, input.count, key);
|
tmp.execute(null, input.count, key);
|
||||||
}
|
}
|
||||||
@@ -1578,7 +1572,7 @@ function Events() //{{{
|
|||||||
inputBufferLength = 0;
|
inputBufferLength = 0;
|
||||||
|
|
||||||
if (modes.isReplaying && !waitForPageLoaded())
|
if (modes.isReplaying && !waitForPageLoaded())
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
let ret = map.execute(null, input.count);
|
let ret = map.execute(null, input.count);
|
||||||
if (map.flags & Mappings.flags.ALLOW_EVENT_ROUTING && ret)
|
if (map.flags & Mappings.flags.ALLOW_EVENT_ROUTING && ret)
|
||||||
@@ -1628,24 +1622,19 @@ function Events() //{{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stop)
|
if (stop)
|
||||||
{
|
killEvent();
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
|
|
||||||
let motionMap = (input.pendingMotionMap && input.pendingMotionMap.names[0]) || "";
|
let motionMap = (input.pendingMotionMap && input.pendingMotionMap.names[0]) || "";
|
||||||
statusline.updateInputBuffer(motionMap + input.buffer);
|
statusline.updateInputBuffer(motionMap + input.buffer);
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// this is need for sites like msn.com which focus the input field on keydown
|
// this is need for sites like msn.com which focus the input field on keydown
|
||||||
onKeyUpOrDown: function (event)
|
onKeyUpOrDown: function (event)
|
||||||
{
|
{
|
||||||
if (modes.passNextKey ^ modes.passAllKeys || isFormElemFocused())
|
if (modes.passNextKey ^ modes.passAllKeys || isFormElemFocused())
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: move to buffer.js?
|
// TODO: move to buffer.js?
|
||||||
|
|||||||
Reference in New Issue
Block a user