1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-08 18:44:12 +01:00

Fixes <C-[>, <C-\\>, <C-]>, <C-^>, and <C-_> on Mac OS/X.

On Mac OS/X, control characters 27 through 31 pass charCode=CONTROL_CHAR
rather than charCode=KEY. For example, when a user wants <C-[>
Vimperator sees <C-Esc>. Most people view this as a bug in FirefOS/X.

The following patch tests for has("MacUnix"), then checks to see if the
control character is within this buggy range. If so, it shifts the
charCode up by 64 (there is a special case for Escape where the CTRL key
is relaxed and key is set to "Esc").

For more information, see:
    [*] Vimp FAQ: http://vimperator.org/trac/wiki/Vimperator/FAQ#WhydoesntC-workforEscMacOSX
    [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/vimperator/2008-May/001548.html
    [*] Mozilla bug 416227: event.charCode in keypress handler has unexpected values on Mac for Ctrl with chars in "[ ] _ \"
        https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=416227
    [*] Mozilla bug 432951: Ctrl+'foo' doesn't seem same charCode as Meta+'foo' on Cocoa
        https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=432951
This commit is contained in:
Ted Pavlic
2009-01-23 10:05:14 -05:00
parent 8c466abdcd
commit 4884f5defc

View File

@@ -1033,6 +1033,37 @@ function Events() //{{{
}
}
}
// [Ctrl-Bug] special handling of mysterious <C-[>, <C-\\>, <C-]>, <C-^>, <C-_> bugs (OS/X)
// (i.e., cntrl codes 27--31)
// ---
// For more information, see:
// [*] Vimp FAQ: http://vimperator.org/trac/wiki/Vimperator/FAQ#WhydoesntC-workforEscMacOSX
// [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/vimperator/2008-May/001548.html
// [*] Mozilla bug 416227: event.charCode in keypress handler has unexpected values on Mac for Ctrl with chars in "[ ] _ \"
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=416227
// [*] Mozilla bug 432951: Ctrl+'foo' doesn't seem same charCode as Meta+'foo' on Cocoa
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=432951
// ---
//
// The following fixes are only activated if liberator.has("MacUnix").
// Technically, they prevent mappings from <C-Esc> (and
// <C-C-]> if your fancy keyboard permits such things<?>), but
// these <C-control> mappings are probably pathological (<C-Esc>
// certainly is on Windows), and so it is probably
// harmless to remove the has("MacUnix") if desired.
//
else if (liberator.has("MacUnix") && event.ctrlKey)
{
// [Ctrl-Bug 1/5] the <C-[> bug
if(event.charCode == 27)
{
key = "Esc";
modifier = modifier.replace('C-','');
}
// [Ctrl-Bug 2,3,4,5/5] the <C-\\>, <C-]>, <C-^>, <C-_> bugs
else if (event.charCode >= 28 && event.charCode <= 31)
key = String.fromCharCode(event.charCode + 64);
}
// special handling of the Space key
else if (event.charCode == 32)
{