aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorPhil Crosby2010-03-07 18:38:50 -0800
committerPhil Crosby2010-03-07 22:50:32 -0800
commitfa837a226502cc5eb0f245b62b359b8ee68ac23e (patch)
tree0d615bcb075deb154ac8120f8610d626d7f060e7 /vimiumFrontend.js
parent25a813129b28a622ec17e139afedca8bc53305c8 (diff)
downloadvimium-fa837a226502cc5eb0f245b62b359b8ee68ac23e.tar.bz2
Move some of the keyboard-translation code into another file.
This keeps things tidy and will allow this code to be accessed from the Options page.
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js51
1 files changed, 0 insertions, 51 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 70ff77c6..0fe5abb6 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -9,7 +9,6 @@ var settingsToLoad = ["scrollStepSize", "linkHintCharacters"];
var getCurrentUrlHandlers = []; // function(url)
-var keyCodes = { ESC: 27, backspace: 8, deleteKey: 46, enter: 13, space: 32 };
var insertMode = false;
var findMode = false;
var findModeQuery = "";
@@ -21,30 +20,12 @@ var saveZoomLevelPort;
// Users can disable Vimium on URL patterns via the settings page.
var isEnabledForUrl = true;
// The user's operating system.
-var platform;
var currentCompletionKeys;
var linkHintCss;
// TODO(philc): This should be pulled from the extension's storage when the page loads.
var currentZoomLevel = 100;
-// This is a mapping of the incorrect keyIdentifiers generated by Webkit on Windows during keydown events to
-// the correct identifiers, which are correctly generated on Mac. We require this mapping to properly handle
-// these keys on Windows. See https://bugs.webkit.org/show_bug.cgi?id=19906 for more details.
-var keyIdentifierCorrectionMap = {
- "U+00C0": ["U+0060", "U+007E"], // `~
- "U+00BD": ["U+002D", "U+005F"], // -_
- "U+00BB": ["U+003D", "U+002B"], // =+
- "U+00DB": ["U+005B", "U+007B"], // [{
- "U+00DD": ["U+005D", "U+007D"], // ]}
- "U+00DC": ["U+005C", "U+007C"], // \|
- "U+00BA": ["U+003B", "U+003A"], // ;:
- "U+00DE": ["U+0027", "U+0022"], // '"
- "U+00BC": ["U+002C", "U+003C"], // ,<
- "U+00BE": ["U+002E", "U+003E"], // .>
- "U+00BF": ["U+002F", "U+003F"] // /?
-};
-
function getSetting(key) {
if (!settingPort)
settingPort = chrome.extension.connect({ name: "getSetting" });
@@ -74,13 +55,6 @@ function initializePreDomReady() {
// Send the key to the key handler in the background page.
keyPort = chrome.extension.connect({ name: "keyDown" });
- if (navigator.userAgent.indexOf("Mac") != -1)
- platform = "Mac";
- else if (navigator.userAgent.indexOf("Linux") != -1)
- platform = "Linux";
- else
- platform = "Windows";
-
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.name == "hideUpgradeNotification")
HUD.hideUpgradeNotification();
@@ -242,31 +216,6 @@ function toggleViewSourceCallback(url) {
else { window.location.href = "view-source:" + url; }
}
-function getKeyChar(event) {
- if (event.keyIdentifier.slice(0, 2) != "U+") { return ""; }
- var keyIdentifier = event.keyIdentifier;
- // On Windows, the keyIdentifiers for non-letter keys are incorrect. See
- // https://bugs.webkit.org/show_bug.cgi?id=19906 for more details.
- if ((platform == "Windows" || platform == "Linux") && keyIdentifierCorrectionMap[keyIdentifier]) {
- correctedIdentifiers = keyIdentifierCorrectionMap[keyIdentifier];
- keyIdentifier = event.shiftKey ? correctedIdentifiers[1] : correctedIdentifiers[0];
- }
- var unicodeKeyInHex = "0x" + keyIdentifier.substring(2);
- return String.fromCharCode(parseInt(unicodeKeyInHex)).toLowerCase();
-}
-
-function isPrimaryModifierKey(event) {
- if (platform == "Mac")
- return event.metaKey;
- else
- return event.ctrlKey;
-}
-
-function isEscape(event) {
- return event.keyCode == keyCodes.ESC ||
- (event.ctrlKey && getKeyChar(event) == '['); // c-[ is mapped to ESC in Vim by default.
-}
-
/**
* Sends everything except i & ESC to the handler in background_page. i & ESC are special because they control
* insert mode which is local state to the page. The key will be are either a single ascii letter or a