Remove character substitution

We can handle any Unicode codepoint now, so stop replacing symbols.
This commit is contained in:
Pierre Ossman 2017-01-24 12:55:54 +01:00
parent 278a5e7fbd
commit 0a865e15ff
2 changed files with 1 additions and 32 deletions

View File

@ -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,

View File

@ -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