From ea179e89f7fcc248b27141aa71f30536d37a9ae3 Mon Sep 17 00:00:00 2001 From: Marc Singer Date: Sat, 31 Mar 2012 12:18:53 -0700 Subject: [PATCH] Issue 43: 2.10 version introduces a keyboard layout problem o From the author: I have a fix for the French and Swiss keyboard layout issues. There was also a typo in the encoding of unicode characters that prevented from typing the Euro sign. Attached is my patch. --- shellinabox/shell_in_a_box.js | 6 +++--- shellinabox/vt100.js | 39 ++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/shellinabox/shell_in_a_box.js b/shellinabox/shell_in_a_box.js index 294a914..04aa100 100644 --- a/shellinabox/shell_in_a_box.js +++ b/shellinabox/shell_in_a_box.js @@ -267,16 +267,16 @@ ShellInABox.prototype.keysPressed = function(ch) { } else if (c < 0x10000) { s += 'E' + hex.charAt( (c >> 12) ) + - hex.charAt(0x8 + (c >> 10) & 0x3 ) + + hex.charAt(0x8 + ((c >> 10) & 0x3)) + hex.charAt( (c >> 6) & 0xF ) + hex.charAt(0x8 + ((c >> 4) & 0x3)) + hex.charAt( c & 0xF ); } else if (c < 0x110000) { s += 'F' + hex.charAt( (c >> 18) ) + - hex.charAt(0x8 + (c >> 16) & 0x3 ) + + hex.charAt(0x8 + ((c >> 16) & 0x3)) + hex.charAt( (c >> 12) & 0xF ) + - hex.charAt(0x8 + (c >> 10) & 0x3 ) + + hex.charAt(0x8 + ((c >> 10) & 0x3)) + hex.charAt( (c >> 6) & 0xF ) + hex.charAt(0x8 + ((c >> 4) & 0x3)) + hex.charAt( c & 0xF ); diff --git a/shellinabox/vt100.js b/shellinabox/vt100.js index 222729e..1dafd7b 100644 --- a/shellinabox/vt100.js +++ b/shellinabox/vt100.js @@ -2719,10 +2719,14 @@ VT100.prototype.handleKey = function(event) { case 189: /* - */ ch = this.applyModifiers(45, event); break; case 190: /* . */ ch = this.applyModifiers(46, event); break; case 191: /* / */ ch = this.applyModifiers(47, event); break; - case 192: /* ` */ ch = this.applyModifiers(96, event); break; - case 219: /* [ */ ch = this.applyModifiers(91, event); break; + // Conflicts with dead key " on Swiss keyboards + //case 192: /* ` */ ch = this.applyModifiers(96, event); break; + // Conflicts with dead key " on Swiss keyboards + //case 219: /* [ */ ch = this.applyModifiers(91, event); break; case 220: /* \ */ ch = this.applyModifiers(92, event); break; - case 221: /* ] */ ch = this.applyModifiers(93, event); break; + // Conflicts with dead key ^ and ` on Swiss keaboards + // ^ and " on French keyboards + //case 221: /* ] */ ch = this.applyModifiers(93, event); break; case 222: /* ' */ ch = this.applyModifiers(39, event); break; default: return; } @@ -2892,21 +2896,36 @@ VT100.prototype.keyDown = function(event) { this.lastKeyDownEvent = undefined; this.lastNormalKeyDownEvent = event; + // Swiss keyboard conflicts: + // [ 59 + // ] 192 + // ' 219 (dead key) + // { 220 + // ~ 221 (dead key) + // } 223 + // French keyoard conflicts: + // ~ 50 (dead key) + // } 107 var asciiKey = event.keyCode == 32 || event.keyCode >= 48 && event.keyCode <= 57 || event.keyCode >= 65 && event.keyCode <= 90; var alphNumKey = asciiKey || + event.keyCode == 59 || event.keyCode >= 96 && event.keyCode <= 105 || + event.keyCode == 107 || + event.keyCode == 192 || + event.keyCode >= 219 && event.keyCode <= 221 || + event.keyCode == 223 || event.keyCode == 226; var normalKey = alphNumKey || - event.keyCode == 59 || event.keyCode == 61 || - event.keyCode == 106 || event.keyCode == 107 || + event.keyCode == 61 || + event.keyCode == 106 || event.keyCode >= 109 && event.keyCode <= 111 || - event.keyCode >= 186 && event.keyCode <= 192 || - event.keyCode >= 219 && event.keyCode <= 223 || + event.keyCode >= 186 && event.keyCode <= 191 || + event.keyCode == 222 || event.keyCode == 252; try { if (navigator.appName == 'Konqueror') { @@ -3034,10 +3053,14 @@ VT100.prototype.keyUp = function(event) { this.catchModifiersEarly = true; var asciiKey = event.keyCode == 32 || - event.keyCode >= 48 && event.keyCode <= 57 || + // Conflicts with dead key ~ (code 50) on French keyboards + //event.keyCode >= 48 && event.keyCode <= 57 || + event.keyCode >= 48 && event.keyCode <= 49 || + event.keyCode >= 51 && event.keyCode <= 57 || event.keyCode >= 65 && event.keyCode <= 90; var alphNumKey = asciiKey || + event.keyCode == 50 || event.keyCode >= 96 && event.keyCode <= 105; var normalKey = alphNumKey ||