1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-06 18:24:11 +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 // FIXME: <esc> does not work correctly
mappings.add([modes.INSERT], 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; }); function () { liberator.mode = modes.TEXTAREA; });
mappings.add([modes.INSERT], mappings.add([modes.INSERT],

View File

@@ -1314,7 +1314,7 @@ function Events() //{{{
if (elem instanceof HTMLTextAreaElement || (elem && elem.contentEditable == "true")) if (elem instanceof HTMLTextAreaElement || (elem && elem.contentEditable == "true"))
{ {
if (options["insertmode"]) if (options["insertmode"])
modes.set(modes.INSERT, modes.TEXTAREA); modes.set(modes.INSERT);
else if (elem.selectionEnd - elem.selectionStart > 0) else if (elem.selectionEnd - elem.selectionStart > 0)
modes.set(modes.VISUAL, modes.TEXTAREA); modes.set(modes.VISUAL, modes.TEXTAREA);
else else
@@ -1374,6 +1374,7 @@ function Events() //{{{
{ {
if (modes.passNextKey) if (modes.passNextKey)
return; return;
if (modes.passAllKeys) if (modes.passAllKeys)
{ {
modes.passAllKeys = false; modes.passAllKeys = false;
@@ -1403,12 +1404,35 @@ function Events() //{{{
case modes.CARET: case modes.CARET:
// setting this option will trigger an observer which will // 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); options.setPref("accessibility.browsewithcaret", false);
break; 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: case modes.INSERT:
if ((modes.extended & modes.TEXTAREA) && !options["insertmode"]) if ((modes.extended & modes.TEXTAREA))
liberator.mode = modes.TEXTAREA; liberator.mode = modes.TEXTAREA;
else else
modes.reset(); modes.reset();

View File

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

View File

@@ -494,10 +494,13 @@ ____
|\'noim'| |\'noinsertmode'| |\'im'| |\'insertmode'| + |\'noim'| |\'noinsertmode'| |\'im'| |\'insertmode'| +
||'insertmode' 'im'|| boolean (default: on) ||'insertmode' 'im'|| boolean (default: on)
____ ____
Use Insert mode as the default for text areas. Use Insert mode as the default for text areas. This is useful if you want to
Makes Vimperator work in a way that Insert mode is the default mode for text areas. use the known Firefox interface for editing text areas. Input fields default to
Useful if you want to use Vimperator as a modeless editor, keeping the known Firefox interface for editing text areas. 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'| + |\'ls'| |\'laststatus'| +

View File

@@ -483,10 +483,13 @@ ____
|\'noim'| |\'noinsertmode'| |\'im'| |\'insertmode'| + |\'noim'| |\'noinsertmode'| |\'im'| |\'insertmode'| +
||'insertmode' 'im'|| boolean (default: on) ||'insertmode' 'im'|| boolean (default: on)
____ ____
Use Insert mode as the default for text areas. Use Insert mode as the default for text areas. This is useful if you want to
Makes Xulmus work in a way that Insert mode is the default mode for text areas. use the known Firefox interface for editing text areas. Input fields default to
Useful if you want to use Xulmus as a modeless editor, keeping the known Songbird interface for editing text areas. 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'| + |\'ls'| |\'laststatus'| +