fix(developer): ldml add JIS 🙀

- compiles, at least

For: #8161
This commit is contained in:
Steven R. Loomis 2023-03-24 12:13:36 -05:00
parent 0b2c5c99aa
commit a474d8cbc6
4 changed files with 35 additions and 5 deletions

View file

@ -161,6 +161,36 @@ export const ISOVirtualKeyMap: KeyMap = [
[ k.K_SPACE ],
];
export const JISVirtualKeyMap: KeyMap = [
// Note: showing scancode used in «…»
// [Hankaku/Zenkaku] 1 2 3 4 5 6 7 8 9 0 - ^ ¥ [bksp]
[ k.K_1, k.K_2, k.K_3, k.K_4, k.K_5, k.K_6, k.K_7, k.K_8, k.K_9, k.K_0, k.K_HYPHEN, k.K_EQUAL, k.K_oE2 /* YEN? */ ],
// [tab] Q W E R T Y U I O P @«`» [ [enter]
[ k.K_Q, k.K_W, k.K_E, k.K_R, k.K_T, k.K_Y, k.K_U, k.K_I, k.K_O, k.K_P, k.K_BKQUOTE, k.K_LBRKT ],
// [caps] A S D F G H J K L ; : ] [enter]
[ k.K_A, k.K_S, k.K_D, k.K_F, k.K_G, k.K_H, k.K_J, k.K_K, k.K_L, k.K_COLON, k.K_QUOTE, k.K_BKSLASH ],
// [shift] Z X C V B N M , . / _ [shift]
[ k.K_Z, k.K_X, k.K_C, k.K_V, k.K_B, k.K_N, k.K_M, k.K_COMMA, k.K_PERIOD, k.K_SLASH, k.k_oC1 /* ろ */ ],
// space
[ k.K_SPACE ],
];
export const ABNT2VirtualKeyMap: KeyMap = [
// TODO-LDML #8161
// ` 1 2 3 4 5 6 7 8 9 0 - = [bksp]
[ k.K_BKQUOTE, k.K_1, k.K_2, k.K_3, k.K_4, k.K_5, k.K_6, k.K_7, k.K_8, k.K_9, k.K_0, k.K_HYPHEN, k.K_EQUAL ],
// [tab] Q W E R T Y U I O P [ ]
[ k.K_Q, k.K_W, k.K_E, k.K_R, k.K_T, k.K_Y, k.K_U, k.K_I, k.K_O, k.K_P, k.K_LBRKT, k.K_RBRKT ],
// [caps] A S D F G H J K L ; ' \ [enter]
[ k.K_A, k.K_S, k.K_D, k.K_F, k.K_G, k.K_H, k.K_J, k.K_K, k.K_L, k.K_COLON, k.K_QUOTE, k.K_BKSLASH ],
// [shift] * Z X C V B N M , . / [shift] *=oE2
[ k.K_oE2, k.K_Z, k.K_X, k.K_C, k.K_V, k.K_B, k.K_N, k.K_M, k.K_COMMA, k.K_PERIOD, k.K_SLASH ],
// space
[ k.K_SPACE ],
];
/**
* Map from a hardware constant to a keymap
* For the 'key' see constants.layr_list_hardware_map
@ -169,8 +199,8 @@ export const HardwareToKeymap: Map<string, KeyMap> = new Map(
[
["us", USVirtualKeyMap],
["iso", ISOVirtualKeyMap],
//TODO-LDML: jis #8161
//TODO-LDML: abnt2 #8161
["jis", JISVirtualKeyMap],
["abnt2", ABNT2VirtualKeyMap],
]
);

View file

@ -186,7 +186,7 @@ export class KeysCompiler extends SectionCompiler {
const keys = layer.row[y].keys.split(' ');
if (keys.length > keymap[y].length) {
this.callbacks.reportMessage(CompilerMessages.Error_RowOnHardwareLayerHasTooManyKeys({ row: y + 1, hardware }));
this.callbacks.reportMessage(CompilerMessages.Error_RowOnHardwareLayerHasTooManyKeys({ row: y + 1, hardware, modifier }));
valid = false;
}

View file

@ -16,7 +16,7 @@ export class CompilerMessages {
static Error_HardwareLayerHasTooManyRows = () => m(this.ERROR_HardwareLayerHasTooManyRows, `'hardware' layer has too many rows`);
static ERROR_HardwareLayerHasTooManyRows = SevError | 0x0003;
static Error_RowOnHardwareLayerHasTooManyKeys = (o:{row: number, hardware: string}) => m(this.ERROR_RowOnHardwareLayerHasTooManyKeys, `Row #${o.row} on 'hardware' ${o.hardware} layer has too many keys`);
static Error_RowOnHardwareLayerHasTooManyKeys = (o:{row: number, hardware: string, modifier: string}) => m(this.ERROR_RowOnHardwareLayerHasTooManyKeys, `Row #${o.row} on 'hardware' ${o.hardware} layer for modifier ${o.modifier || 'none'} has too many keys`);
static ERROR_RowOnHardwareLayerHasTooManyKeys = SevError | 0x0004;
static Error_KeyNotFoundInKeyBag = (o:{keyId: string, col: number, row: number, layer: string, form: string}) =>

View file

@ -230,7 +230,7 @@ describe('keys.kmap', function () {
assert.isNull(keys);
assert.equal(compilerTestCallbacks.messages.length, 1);
assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_RowOnHardwareLayerHasTooManyKeys({row: 1, hardware: 'us'}));
assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_RowOnHardwareLayerHasTooManyKeys({row: 1, hardware: 'us', modifier: 'none'}));
});
it('should reject layouts with undefined keys', function() {