From: Pierre Ossman Date: Tue, 24 Jan 2017 11:55:54 +0000 (+0100) Subject: Remove character substitution X-Git-Tag: v1.0.0~138^2~15 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=0a865e15ff9f43c1d697ab1f996cb5e145d0ea16;p=mirror_novnc.git Remove character substitution We can handle any Unicode codepoint now, so stop replacing symbols. --- diff --git a/core/input/util.js b/core/input/util.js index 39ac905..36bcd72 100644 --- a/core/input/util.js +++ b/core/input/util.js @@ -1,22 +1,6 @@ import KeyTable from "./keysym.js"; import keysyms from "./keysymdef.js"; -export function substituteCodepoint(cp) { - // Any Unicode code points which do not have corresponding keysym entries - // can be swapped out for another code point by adding them to this table - var substitutions = { - // {S,s} with comma below -> {S,s} with cedilla - 0x218 : 0x15e, - 0x219 : 0x15f, - // {T,t} with comma below -> {T,t} with cedilla - 0x21a : 0x162, - 0x21b : 0x163 - }; - - var sub = substitutions[cp]; - return sub ? sub : cp; -} - function isMac() { return navigator && !!(/mac/i).exec(navigator.platform); } @@ -176,7 +160,7 @@ export function getKeysym(evt){ codepoint = evt.keyCode; } if (codepoint) { - return keysyms.lookup(substituteCodepoint(codepoint)); + return keysyms.lookup(codepoint); } // we could check evt.key here. // Legal values are defined in http://www.w3.org/TR/DOM-Level-3-Events/#key-values-list, diff --git a/tests/test.helper.js b/tests/test.helper.js index 0c1ba0d..e161d34 100644 --- a/tests/test.helper.js +++ b/tests/test.helper.js @@ -49,18 +49,6 @@ describe('Helpers', function() { }); }); - describe('substituteCodepoint', function() { - it('should replace characters which don\'t have a keysym', function() { - expect(KeyboardUtil.substituteCodepoint('Ș'.charCodeAt())).to.equal('Ş'.charCodeAt()); - expect(KeyboardUtil.substituteCodepoint('ș'.charCodeAt())).to.equal('ş'.charCodeAt()); - expect(KeyboardUtil.substituteCodepoint('Ț'.charCodeAt())).to.equal('Ţ'.charCodeAt()); - expect(KeyboardUtil.substituteCodepoint('ț'.charCodeAt())).to.equal('ţ'.charCodeAt()); - }); - it('should pass other characters through unchanged', function() { - expect(KeyboardUtil.substituteCodepoint('T'.charCodeAt())).to.equal('T'.charCodeAt()); - }); - }); - describe('nonCharacterKey', function() { it('should recognize the right keys', function() { expect(KeyboardUtil.nonCharacterKey({keyCode: 0xd}), 'enter').to.be.defined; @@ -96,9 +84,6 @@ describe('Helpers', function() { expect(KeyboardUtil.getKeysym({which: 0x43, shiftKey: false})).to.be.equal(0x63); expect(KeyboardUtil.getKeysym({which: 0x43, shiftKey: true})).to.be.equal(0x43); }); - it('should substitute where applicable', function() { - expect(KeyboardUtil.getKeysym({char : 'Ș'})).to.be.equal(0x1aa); - }); }); describe('Modifier Sync', function() { // return a list of fake events necessary to fix modifier state