Last active
August 29, 2015 14:03
-
-
Save sarkian/a2ba90317e7099ed1e6d to your computer and use it in GitHub Desktop.
Vimperator patch for russian layout support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 2a69668fa35981a17c0fcfb7b255e9467a970a2e Mon Sep 17 00:00:00 2001 | |
From: Sarkian <[email protected]> | |
Date: Fri, 21 Nov 2014 15:41:31 +0300 | |
Subject: [PATCH] Russian layout support | |
--- | |
common/content/events.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++- | |
1 file changed, 72 insertions(+), 1 deletion(-) | |
diff --git a/common/content/events.js b/common/content/events.js | |
index 285a1e9..f9b145a 100644 | |
--- a/common/content/events.js | |
+++ b/common/content/events.js | |
@@ -17,6 +17,58 @@ const Events = Module("events", { | |
init: function () { | |
const self = this; | |
+ this._kdn_key_code = 0; | |
+ this._kdn_key_code_b = 0; | |
+ this._key_chars = []; | |
+ | |
+ // this._key_chars[48] = "0"; | |
+ // this._key_chars[49] = "1"; | |
+ // this._key_chars[50] = "2"; | |
+ // this._key_chars[51] = "3"; | |
+ // this._key_chars[52] = "4"; | |
+ // this._key_chars[53] = "5"; | |
+ // this._key_chars[54] = "6"; | |
+ // this._key_chars[55] = "7"; | |
+ // this._key_chars[56] = "8"; | |
+ // this._key_chars[57] = "9"; | |
+ this._key_chars[65] = "a"; | |
+ this._key_chars[66] = "b"; | |
+ this._key_chars[67] = "c"; | |
+ this._key_chars[68] = "d"; | |
+ this._key_chars[69] = "e"; | |
+ this._key_chars[70] = "f"; | |
+ this._key_chars[71] = "g"; | |
+ this._key_chars[72] = "h"; | |
+ this._key_chars[73] = "i"; | |
+ this._key_chars[74] = "j"; | |
+ this._key_chars[75] = "k"; | |
+ this._key_chars[76] = "l"; | |
+ this._key_chars[77] = "m"; | |
+ this._key_chars[78] = "n"; | |
+ this._key_chars[79] = "o"; | |
+ this._key_chars[80] = "p"; | |
+ this._key_chars[81] = "q"; | |
+ this._key_chars[82] = "r"; | |
+ this._key_chars[83] = "s"; | |
+ this._key_chars[84] = "t"; | |
+ this._key_chars[85] = "u"; | |
+ this._key_chars[86] = "v"; | |
+ this._key_chars[87] = "w"; | |
+ this._key_chars[88] = "x"; | |
+ this._key_chars[89] = "y"; | |
+ this._key_chars[90] = "z"; | |
+ // this._key_chars[186] = ";"; | |
+ // this._key_chars[187] = "="; | |
+ // this._key_chars[188] = ","; | |
+ // this._key_chars[189] = "-"; | |
+ // this._key_chars[190] = "."; | |
+ // this._key_chars[191] = "/"; | |
+ // this._key_chars[192] = "`"; | |
+ // this._key_chars[219] = "["; | |
+ // this._key_chars[220] = "\\"; | |
+ // this._key_chars[221] = "]"; | |
+ // this._key_chars[222] = "'"; | |
+ | |
this._fullscreen = window.fullScreen; | |
this._lastFocus = null; | |
this._currentMacro = ""; | |
@@ -504,6 +556,8 @@ const Events = Module("events", { | |
if (event.keyCode in this._code_key) | |
key = this._code_key[event.keyCode]; | |
+ else if (event.keyCode in this._key_chars) | |
+ key = this._key_chars[event.keyCode]; | |
// [Ctrl-Bug] special handling of mysterious <C-[>, <C-\\>, <C-]>, <C-^>, <C-_> <C--> bugs (OS/X) | |
// --- | |
@@ -550,7 +604,17 @@ const Events = Module("events", { | |
} | |
// a normal key like a, b, c, 0, etc. | |
else if (charCode > 0) { | |
- key = String.fromCharCode(charCode); | |
+ if (liberator.mode != modes.INSERT && liberator.mode != modes.TEXTAREA && !events.feedingKeys | |
+ && this._kdn_key_code && this._kdn_key_code in this._key_chars != false) { | |
+ key = this._key_chars[this._kdn_key_code]; | |
+ this._kdn_key_code = 0; | |
+ if (event.shiftKey) | |
+ key = key.toUpperCase(); | |
+ } | |
+ else if (event.charCode == 1093 && event.ctrlKey) | |
+ key = "["; // dirty hack | |
+ else | |
+ key = String.fromCharCode(charCode); | |
if (key in this._key_code) { | |
// a named charcode key (<Space> and <lt>) space can be shifted, <lt> must be forced | |
@@ -859,6 +923,9 @@ const Events = Module("events", { | |
if (!key) | |
return; | |
+ if (liberator.mode != modes.INSERT && liberator.mode != modes.TEXTAREA && !events.feedingKeys) | |
+ event.liberatorString = key; | |
+ | |
let url = typeof(buffer) != "undefined" ? buffer.URL : ""; | |
if (modes.isRecording) { | |
@@ -1083,6 +1150,10 @@ const Events = Module("events", { | |
// this is need for sites like msn.com which focus the input field on keydown | |
onKeyUpOrDown: function (event) { | |
+ if (event.type == 'keydown') { | |
+ this._kdn_key_code = event.keyCode; | |
+ this._kdn_key_code_b = event.keyCode; | |
+ } | |
if (modes.passNextKey || modes.passAllKeys || modes.isMenuShown || Events.isInputElemFocused()) | |
return; | |
event.stopPropagation(); | |
-- | |
1.9.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment