mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-09 07:54:12 +01:00
Use lambda notation for events.is{Accept,Cancel}Key definitions.
This commit is contained in:
@@ -1200,10 +1200,7 @@ function Events() //{{{
|
|||||||
*
|
*
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isAcceptKey: function (key)
|
isAcceptKey: function (key) key == "<Return>" || key == "<C-j>" || key == "<C-m>",
|
||||||
{
|
|
||||||
return (key == "<Return>" || key == "<C-j>" || key == "<C-m>");
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether <b>key</b> is a key code defined to reject/cancel input on
|
* Whether <b>key</b> is a key code defined to reject/cancel input on
|
||||||
@@ -1211,10 +1208,7 @@ function Events() //{{{
|
|||||||
*
|
*
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isCancelKey: function (key)
|
isCancelKey: function (key) key == "<Esc>" || key == "<C-[>" || key == "<C-c>",
|
||||||
{
|
|
||||||
return (key == "<Esc>" || key == "<C-[>" || key == "<C-c>");
|
|
||||||
},
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Waits for the current buffer to successfully finish loading. Returns
|
* Waits for the current buffer to successfully finish loading. Returns
|
||||||
@@ -1408,6 +1402,8 @@ function Events() //{{{
|
|||||||
// the commandline has focus
|
// the commandline has focus
|
||||||
onKeyPress: function (event)
|
onKeyPress: function (event)
|
||||||
{
|
{
|
||||||
|
function isEscapeKey(key) key == "<Esc>" || key == "<C-[>";
|
||||||
|
|
||||||
function killEvent()
|
function killEvent()
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -1478,7 +1474,7 @@ function Events() //{{{
|
|||||||
{
|
{
|
||||||
if (modes.passNextKey)
|
if (modes.passNextKey)
|
||||||
modes.passNextKey = false; // and then let flow continue
|
modes.passNextKey = false; // and then let flow continue
|
||||||
else if (key == "<Esc>" || key == "<C-[>" || key == "<C-v>")
|
else if (isEscapeKey(key) || 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
|
||||||
stop = true;
|
stop = true;
|
||||||
@@ -1493,8 +1489,7 @@ function Events() //{{{
|
|||||||
stop = true; // set to false if we should NOT consume this event but let Firefox handle it
|
stop = true; // set to false if we should NOT consume this event but let Firefox handle it
|
||||||
|
|
||||||
// just forward event without checking any mappings when the MOW is open
|
// just forward event without checking any mappings when the MOW is open
|
||||||
if (liberator.mode == modes.COMMAND_LINE &&
|
if (liberator.mode == modes.COMMAND_LINE && (modes.extended & modes.OUTPUT_MULTILINE))
|
||||||
(modes.extended & modes.OUTPUT_MULTILINE))
|
|
||||||
{
|
{
|
||||||
commandline.onMultilineOutputEvent(event);
|
commandline.onMultilineOutputEvent(event);
|
||||||
return void killEvent();
|
return void killEvent();
|
||||||
@@ -1511,7 +1506,7 @@ function Events() //{{{
|
|||||||
|
|
||||||
// TODO: handle middle click in content area
|
// TODO: handle middle click in content area
|
||||||
|
|
||||||
if (key != "<Esc>" && key != "<C-[>")
|
if (!isEscapeKey(key))
|
||||||
{
|
{
|
||||||
// custom mode...
|
// custom mode...
|
||||||
if (liberator.mode == modes.CUSTOM)
|
if (liberator.mode == modes.CUSTOM)
|
||||||
@@ -1575,7 +1570,7 @@ function Events() //{{{
|
|||||||
input.buffer = "";
|
input.buffer = "";
|
||||||
let map = input.pendingArgMap;
|
let map = input.pendingArgMap;
|
||||||
input.pendingArgMap = null;
|
input.pendingArgMap = null;
|
||||||
if (key != "<Esc>" && key != "<C-[>")
|
if (!isEscapeKey(key))
|
||||||
{
|
{
|
||||||
if (modes.isReplaying && !waitForPageLoad())
|
if (modes.isReplaying && !waitForPageLoad())
|
||||||
return;
|
return;
|
||||||
@@ -1599,7 +1594,7 @@ function Events() //{{{
|
|||||||
}
|
}
|
||||||
else if (input.pendingMotionMap)
|
else if (input.pendingMotionMap)
|
||||||
{
|
{
|
||||||
if (key != "<Esc>" && key != "<C-[>")
|
if (!isEscapeKey(key))
|
||||||
input.pendingMotionMap.execute(candidateCommand, input.count, null);
|
input.pendingMotionMap.execute(candidateCommand, input.count, null);
|
||||||
input.pendingMotionMap = null;
|
input.pendingMotionMap = null;
|
||||||
}
|
}
|
||||||
@@ -1635,7 +1630,7 @@ function Events() //{{{
|
|||||||
input.pendingMotionMap = null;
|
input.pendingMotionMap = null;
|
||||||
input.pendingMap = null;
|
input.pendingMap = null;
|
||||||
|
|
||||||
if (key != "<Esc>" && key != "<C-[>")
|
if (!isEscapeKey(key))
|
||||||
{
|
{
|
||||||
// allow key to be passed to Firefox if we can't handle it
|
// allow key to be passed to Firefox if we can't handle it
|
||||||
stop = false;
|
stop = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user