1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 15:48:00 +01:00

Forbid unknown keys in TEXTAREA mode. Closes issue #34.

This commit is contained in:
Kris Maglione
2010-10-06 23:13:51 -04:00
parent 8c98658e74
commit 03fc7f24d8

View File

@@ -793,15 +793,14 @@ const Events = Module("events", {
let key = events.toString(event); let key = events.toString(event);
if (!key) if (!key)
return; return null;
if (modes.isRecording) { if (modes.isRecording) {
if (key == "q" && !modes.mainMode.input) { // TODO: should not be hardcoded if (key == "q" && !modes.mainMode.input) { // TODO: should not be hardcoded
modes.isRecording = false; modes.isRecording = false;
dactyl.log("Recorded " + this._currentMacro + ": " + this._macros.get(this._currentMacro, {}).keys, 9); dactyl.log("Recorded " + this._currentMacro + ": " + this._macros.get(this._currentMacro, {}).keys, 9);
dactyl.echomsg("Recorded macro '" + this._currentMacro + "'"); dactyl.echomsg("Recorded macro '" + this._currentMacro + "'");
killEvent(); return killEvent();
return;
} }
else if (!mappings.hasMap(dactyl.mode, this._input.buffer + key)) else if (!mappings.hasMap(dactyl.mode, this._input.buffer + key))
this._macros.set(this._currentMacro, { this._macros.set(this._currentMacro, {
@@ -828,8 +827,7 @@ const Events = Module("events", {
else else
events.duringFeed.push(event); events.duringFeed.push(event);
killEvent(); return killEvent();
return;
} }
try { try {
@@ -858,7 +856,7 @@ const Events = Module("events", {
if (stop) { if (stop) {
this._input.buffer = ""; this._input.buffer = "";
return; return null;
} }
stop = true; // set to false if we should NOT consume this event but let the host app handle it stop = true; // set to false if we should NOT consume this event but let the host app handle it
@@ -866,7 +864,7 @@ const Events = Module("events", {
// 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 (dactyl.mode == modes.COMMAND_LINE && (modes.extended & modes.OUTPUT_MULTILINE)) { if (dactyl.mode == modes.COMMAND_LINE && (modes.extended & modes.OUTPUT_MULTILINE)) {
commandline.onMultilineOutputEvent(event); commandline.onMultilineOutputEvent(event);
throw killEvent(); return killEvent();
} }
// XXX: ugly hack for now pass certain keys to the host app as // XXX: ugly hack for now pass certain keys to the host app as
@@ -875,7 +873,7 @@ const Events = Module("events", {
// FIXME: breaks iabbr for now --mst // FIXME: breaks iabbr for now --mst
if (key in config.ignoreKeys && (config.ignoreKeys[key] & dactyl.mode)) { if (key in config.ignoreKeys && (config.ignoreKeys[key] & dactyl.mode)) {
this._input.buffer = ""; this._input.buffer = "";
return; return null;
} }
// TODO: handle middle click in content area // TODO: handle middle click in content area
@@ -884,7 +882,7 @@ const Events = Module("events", {
// custom mode... // custom mode...
if (dactyl.mode == modes.CUSTOM) { if (dactyl.mode == modes.CUSTOM) {
plugins.onEvent(event); plugins.onEvent(event);
throw killEvent(); return killEvent();
} }
// All of these special cases for hint mode are driving // All of these special cases for hint mode are driving
@@ -897,11 +895,11 @@ const Events = Module("events", {
|| (hints.isHintKey(key) && !hints.escNumbers)) { || (hints.isHintKey(key) && !hints.escNumbers)) {
hints.onEvent(event); hints.onEvent(event);
this._input.buffer = ""; this._input.buffer = "";
throw killEvent(); return killEvent();
} }
// others are left to generate the 'input' event or handled by the host app // others are left to generate the 'input' event or handled by the host app
return; return null;
} }
} }
@@ -913,7 +911,7 @@ const Events = Module("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 (dactyl.mode == modes.CUSTOM) if (dactyl.mode == modes.CUSTOM)
return; return null;
let inputStr = this._input.buffer + key; let inputStr = this._input.buffer + key;
let countStr = inputStr.match(/^[1-9][0-9]*|/)[0]; let countStr = inputStr.match(/^[1-9][0-9]*|/)[0];
@@ -942,7 +940,7 @@ const Events = Module("events", {
this._input.pendingArgMap = null; this._input.pendingArgMap = null;
if (!isEscapeKey(key)) { if (!isEscapeKey(key)) {
if (modes.isReplaying && !this.waitForPageLoad()) if (modes.isReplaying && !this.waitForPageLoad())
return; return null;
map.execute(null, this._input.count, key); map.execute(null, this._input.count, key);
} }
} }
@@ -969,7 +967,7 @@ const Events = Module("events", {
} }
else { else {
if (modes.isReplaying && !this.waitForPageLoad()) if (modes.isReplaying && !this.waitForPageLoad())
throw killEvent(); return killEvent();
let ret = map.execute(null, this._input.count); let ret = map.execute(null, this._input.count);
if (map.route && ret) if (map.route && ret)
@@ -993,7 +991,7 @@ const Events = Module("events", {
if (!isEscapeKey(key)) { if (!isEscapeKey(key)) {
// allow key to be passed to the host app if we can't handle it // allow key to be passed to the host app if we can't handle it
stop = false; stop = (dactyl.mode == modes.TEXTAREA);
if (dactyl.mode == modes.COMMAND_LINE) { if (dactyl.mode == modes.COMMAND_LINE) {
if (!(modes.extended & modes.INPUT_MULTILINE)) if (!(modes.extended & modes.INPUT_MULTILINE))
@@ -1010,7 +1008,6 @@ const Events = Module("events", {
killEvent(); killEvent();
} }
catch (e) { catch (e) {
if (e !== undefined)
dactyl.reportError(e); dactyl.reportError(e);
} }
finally { finally {