1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-03 17:55:47 +01:00

Fix escaping from Textarea mode in input fields.

When escaping from Textarea mode in input fields, and also text areas if
'insertmode' is set, return to Insert mode.
This commit is contained in:
Doug Kearns
2009-10-11 01:38:11 +11:00
parent 55c013366d
commit 29de612097
5 changed files with 41 additions and 10 deletions

View File

@@ -320,7 +320,7 @@ function Editor() //{{{
// FIXME: <esc> does not work correctly
mappings.add([modes.INSERT],
["<C-t>"], "Edit text field in vi mode",
["<C-t>"], "Edit text field in Vi mode",
function () { liberator.mode = modes.TEXTAREA; });
mappings.add([modes.INSERT],

View File

@@ -1314,7 +1314,7 @@ function Events() //{{{
if (elem instanceof HTMLTextAreaElement || (elem && elem.contentEditable == "true"))
{
if (options["insertmode"])
modes.set(modes.INSERT, modes.TEXTAREA);
modes.set(modes.INSERT);
else if (elem.selectionEnd - elem.selectionStart > 0)
modes.set(modes.VISUAL, modes.TEXTAREA);
else
@@ -1374,6 +1374,7 @@ function Events() //{{{
{
if (modes.passNextKey)
return;
if (modes.passAllKeys)
{
modes.passAllKeys = false;
@@ -1403,12 +1404,35 @@ function Events() //{{{
case modes.CARET:
// setting this option will trigger an observer which will
// care about all other details like setting the NORMAL mode
// take care of all other details like setting the NORMAL
// mode
options.setPref("accessibility.browsewithcaret", false);
break;
case modes.TEXTAREA:
// TODO: different behaviour for text areas and other input
// fields seems unnecessarily complicated. If the user
// likes Vi-mode then they probably like it for all input
// fields, if not they can enter it explicitly for only
// text areas. The mode name TEXTAREA is confusing and
// would be better replaced with something indicating that
// it's a Vi editing mode. Extended modes really need to be
// displayed too. --djk
function isInputField()
{
let elem = liberator.focus;
return ((elem instanceof HTMLInputElement && !/image/.test(elem.type))
|| elem instanceof HTMLIsIndexElement);
}
if (options["insertmode"] || isInputField())
liberator.mode = modes.INSERT;
else
modes.reset();
break;
case modes.INSERT:
if ((modes.extended & modes.TEXTAREA) && !options["insertmode"])
if ((modes.extended & modes.TEXTAREA))
liberator.mode = modes.TEXTAREA;
else
modes.reset();

View File

@@ -38,6 +38,7 @@ BUGS:
- The MOW shouldn't close when executing hints and ;F isn't working.
FEATURES:
8 Document Textarea, Caret and Visual modes.
8 Incremental searches should retreat to their starting position on <Backspace>
8 Replace config.name tests in liberator with more specific feature
tests or overridable APIs where at all feasible.

View File

@@ -494,10 +494,13 @@ ____
|\'noim'| |\'noinsertmode'| |\'im'| |\'insertmode'| +
||'insertmode' 'im'|| boolean (default: on)
____
Use Insert mode as the default for text areas.
Makes Vimperator work in a way that Insert mode is the default mode for text areas.
Useful if you want to use Vimperator as a modeless editor, keeping the known Firefox interface for editing text areas.
Use Insert mode as the default for text areas. This is useful if you want to
use the known Firefox interface for editing text areas. Input fields default to
this behaviour irrespective of this option's setting.
Textarea mode can be entered with *<C-t>* from Insert mode.
____
// TODO: <C-t> is not hyperlinked as it's not documented yet.
|\'ls'| |\'laststatus'| +

View File

@@ -483,10 +483,13 @@ ____
|\'noim'| |\'noinsertmode'| |\'im'| |\'insertmode'| +
||'insertmode' 'im'|| boolean (default: on)
____
Use Insert mode as the default for text areas.
Makes Xulmus work in a way that Insert mode is the default mode for text areas.
Useful if you want to use Xulmus as a modeless editor, keeping the known Songbird interface for editing text areas.
Use Insert mode as the default for text areas. This is useful if you want to
use the known Firefox interface for editing text areas. Input fields default to
this behaviour irrespective of this option's setting.
Textarea mode can be entered with *<C-t>* from Insert mode.
____
// TODO: <C-t> is not hyperlinked as it's not documented yet.
|\'ls'| |\'laststatus'| +