mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-12 11:55:32 +00:00
feat(developer): use Arrays of objects instead of 2D arrays finished, tests changed accordingly
This commit is contained in:
parent
5c8ac8c650
commit
9cc6ecccee
4 changed files with 311 additions and 1090 deletions
|
|
@ -26,49 +26,46 @@ export interface convert_object {
|
|||
arrayOf_Modifiers: string[][],
|
||||
arrayOf_Rules: Rule[],
|
||||
};
|
||||
//_S2 do I need search???
|
||||
export interface ActionIdOutputBehaviourKeyModi_object {
|
||||
search: string,
|
||||
actionId: string,
|
||||
outchar: string,
|
||||
behaviour: string,
|
||||
key: string,
|
||||
modifier: string,
|
||||
|
||||
export interface allArrayContents_object {
|
||||
actionId?: string,
|
||||
keyCode?: string,
|
||||
key?: string,
|
||||
behaviour?: string,
|
||||
modifier?: string,
|
||||
outchar?: string;
|
||||
};
|
||||
|
||||
|
||||
|
||||
export interface ActionIdKeyModiOutput_object {
|
||||
actionId: string,
|
||||
keyCode: string,
|
||||
key: string,
|
||||
modifier: string,
|
||||
outchar: string;
|
||||
};
|
||||
export interface modifierKey_object {
|
||||
key: string; // _S2 todo change everywhere!!!
|
||||
modifier: number,
|
||||
};
|
||||
export interface modifier_object {
|
||||
modifier: string,
|
||||
};
|
||||
export interface behaviourKey_object {
|
||||
behaviour: string,
|
||||
key: string,
|
||||
};
|
||||
export interface idStateOutput_object {
|
||||
id: string,
|
||||
state: string,
|
||||
output: string,
|
||||
};
|
||||
|
||||
export class KeylayoutToKmnConverter {
|
||||
/**
|
||||
* @brief member function to find the number of keys defined in a .keykayout file.
|
||||
* We process 'MAX_KEY_COUNT' keys at maximum. In case a keylayout has fewer keys defined, we use that smaller number of keys (USE_KEY_COUNT)
|
||||
* @param data data read from keylayout file
|
||||
* @return static variable USE_KEY_COUNT holding the number of keys used in a .keykayout file.
|
||||
*/
|
||||
export function find_usedKeysCount(data: any): number {
|
||||
let USE_KEY_COUNT = KeylayoutToKmnConverter.MAX_KEY_COUNT;
|
||||
for (let i = 0; i < data.keyboard.keyMapSet[0].keyMap.length; i++) {
|
||||
if (data.keyboard.keyMapSet[0].keyMap[i].key.length < USE_KEY_COUNT) {
|
||||
// set the max to n-1 (use key 0 -> nth-1)
|
||||
USE_KEY_COUNT = data.keyboard.keyMapSet[0].keyMap[i].key.length - 1;
|
||||
}
|
||||
}
|
||||
return USE_KEY_COUNT;
|
||||
}
|
||||
|
||||
export class KeylayoutToKmnConverter {
|
||||
static readonly INPUT_FILE_EXTENSION = '.keylayout';
|
||||
static readonly OUTPUT_FILE_EXTENSION = '.kmn';
|
||||
static readonly USED_KEYS_COUNT = 49; // we use key Nr 0 (A) -> key Nr 49 (Space)
|
||||
static readonly MAX_CTRL_CHARACTER = 32;
|
||||
static readonly SKIP_COMMENTED_LINES = false;
|
||||
static readonly MAX_CTRL_CHARACTER = 32;
|
||||
static readonly MAX_KEY_COUNT = 49; // At most we use key Nr 0 (A) -> key Nr 49 (Space)
|
||||
static USE_KEY_COUNT = KeylayoutToKmnConverter.MAX_KEY_COUNT; // we use key Nr 0 (A) -> highest available key of .keylayout file
|
||||
|
||||
private options: CompilerOptions;
|
||||
|
||||
|
|
@ -94,6 +91,11 @@ export class KeylayoutToKmnConverter {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (outputFilename === null) {
|
||||
this.callbacks.reportMessage(ConverterMessages.Error_OutputFilenameIsRequired());
|
||||
return null;
|
||||
}
|
||||
|
||||
const KeylayoutReader = new KeylayoutFileReader(this.callbacks/*, this.options*/);
|
||||
const jsonO: KeylayoutXMLSourceFile = KeylayoutReader.read(inputFilename);
|
||||
|
||||
|
|
@ -162,6 +164,10 @@ export class KeylayoutToKmnConverter {
|
|||
}
|
||||
modifierBehavior.push(singleModifierSet);
|
||||
}
|
||||
|
||||
// fix the amount of processable keys to the maximun nr of keys of a keyMap to avoid processing more keys than defined
|
||||
KeylayoutToKmnConverter.USE_KEY_COUNT = find_usedKeysCount(jsonObj);
|
||||
|
||||
// fill rules into arrayOf_Rules of data_object
|
||||
return this.createRuleData(data_object, jsonObj);
|
||||
}
|
||||
|
|
@ -181,11 +187,13 @@ export class KeylayoutToKmnConverter {
|
|||
let dk_counter_C2: number = 0;
|
||||
let action_id: string;
|
||||
|
||||
//find_max_used_keycount(data_ukelele)
|
||||
// check if we use CAPS in a modifier throughout the .keylayout file. In this case we need to add NCAPS
|
||||
const isCapsused: boolean = this.checkIfCapsIsUsed(data_ukelele.arrayOf_Modifiers);
|
||||
|
||||
// loop keys 0-50 (= all keys we use)
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USED_KEYS_COUNT; j++) {
|
||||
|
||||
// loop keys 0-49 (= all keys we use)
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USE_KEY_COUNT; j++) {
|
||||
|
||||
// loop behaviors (in ukelele it is possible to define multiple modifier combinations that behave in the same way)
|
||||
for (let i = 0; i < jsonObj.keyboard.keyMapSet[0].keyMap.length; i++) {
|
||||
|
|
@ -241,13 +249,13 @@ export class KeylayoutToKmnConverter {
|
|||
|
||||
for (let l = 0; l < data_ukelele.arrayOf_Modifiers[i].length; l++) {
|
||||
|
||||
if ((this.get_4_Output__From__ActionId_None(jsonObj, action_id) !== undefined)
|
||||
&& (this.get_4_Output__From__ActionId_None(jsonObj, action_id) !== "")) {
|
||||
if ((this.get_Output__From__ActionId_None(jsonObj, action_id) !== undefined)
|
||||
&& (this.get_Output__From__ActionId_None(jsonObj, action_id) !== "")) {
|
||||
|
||||
const outputchar: string = this.get_4_Output__From__ActionId_None(jsonObj, action_id);
|
||||
const outputchar: string = this.get_Output__From__ActionId_None(jsonObj, action_id);
|
||||
|
||||
const b1_modifierKey_obj: ActionIdOutputBehaviourKeyModi_object[] =
|
||||
this.get_8_ActionOutputBehaviourKeyModi_From__ActionIDStateOutput(jsonObj, data_ukelele.arrayOf_Modifiers, action_id, outputchar, isCapsused);
|
||||
const b1_modifierKey_obj: allArrayContents_object[] =
|
||||
this.get_ActionOutputBehaviourKeyModi_From__ActionIDStateOutput(jsonObj, data_ukelele.arrayOf_Modifiers, action_id, outputchar, isCapsused);
|
||||
|
||||
for (let m = 0; m < b1_modifierKey_obj.length; m++) {
|
||||
rule_obj = new Rule(
|
||||
|
|
@ -282,7 +290,7 @@ export class KeylayoutToKmnConverter {
|
|||
// https://docs.google.com/document/d/12J3NGO6RxIthCpZDTR8FYSRjiMgXJDLwPY2z9xqKzJ0/edit?tab=t.0#heading=h.g7jwx3lx0ydd .........
|
||||
// ...............................................................................................................................
|
||||
|
||||
const b1_actionIndex: number = this.get_1_ActionIndex__From__ActionId(jsonObj, action_id);
|
||||
const b1_actionIndex: number = this.get_ActionIndex__From__ActionId(jsonObj, action_id);
|
||||
|
||||
// with action_id from above loop all 'action' and search for a state(none)-next-pair ............................................................................................................
|
||||
// e.g. in Block 5: find <when state="none" next="1"/> for action id a18 ......................................................................................................................
|
||||
|
|
@ -299,37 +307,26 @@ export class KeylayoutToKmnConverter {
|
|||
// Data of Block Nr 4 .....................................................................................................................................................................
|
||||
// with present action_id (a18) find all keycode-behaviour-pairs that use this action (a18) => (keymapIndex 0/keycode 24 and keymapIndex 3/keycode 24) ....................................
|
||||
// from these create an array of modifier combinations e.g. [['','caps?'], ['Caps']] .....................................................................................................
|
||||
/* eg: [['24', 0], ['24', 3]] */ // const b4_deadkey_arr: number[][] = this.get_9o_KeyModifier_array__From__ActionID_oldArrayType(jsonObj, action_id); //_S2 remove&replace
|
||||
/* eg: [['24', 0], ['24', 3]] */ const b4_deadkey_obj: modifierKey_object[] = this.get_9_KeyModifier_array__From__ActionID(jsonObj, action_id);
|
||||
/* e.g. [['','caps?'], ['Caps']]*/ //const b4_deadkeyModifier_arr: string[] = this.get_3o_Modifier_array__From__KeyModifier_array_oldArrayType(data_ukelele.arrayOf_Modifiers, b4_deadkey_arr);//_S2 remove&replace
|
||||
/* e.g. [['','caps?'], ['Caps']]*/ const b4_deadkeyModifier_obj: string[] = this.get_3_Modifier_array__From__KeyModifier_array(data_ukelele.arrayOf_Modifiers, b4_deadkey_obj);
|
||||
/* eg: [['24', 0], ['24', 3]] */ const b4_deadkey_obj: allArrayContents_object[] = this.get_KeyModifier_array__From__ActionID(jsonObj, action_id);
|
||||
/* e.g. [['','caps?'], ['Caps']]*/ const b4_deadkeyModifier_obj: string[] = this.get_Modifier_array__From__KeyModifier_array(data_ukelele.arrayOf_Modifiers, b4_deadkey_obj);
|
||||
// ........................................................................................................................................................................................
|
||||
|
||||
|
||||
// Data of Block Nr 6 .....................................................................................................................................................................
|
||||
// create an array[action id,state,output] from all state-output-pairs that use state = b5_value_next (e.g. use 1 in <when state="1" output="â"/> ) ......................................
|
||||
/* eg: [ 'a9','1','â'] */ //const b6_actionId_arr: string[][] = this.get_6o_ActionStateOutput_array__From__ActionState_oldArrayType(jsonObj, b5_value_next);//_S2 remove&replace
|
||||
/* eg: [ 'a9','1','â'] */ const b6_actionId_obj: idStateOutput_object[] = this.get_6_ActionStateOutput_array__From__ActionState(jsonObj, b5_value_next);
|
||||
/* eg: [ 'a9','1','â'] */ const b6_actionId_obj: idStateOutput_object[] = this.get_ActionStateOutput_array__From__ActionState(jsonObj, b5_value_next);
|
||||
// ........................................................................................................................................................................................
|
||||
|
||||
|
||||
// Data of Block Nr 1 ....................................................................................................................................................................
|
||||
// create array[Keycode,Keyname,action id,actionIndex,output] and array[Keyname,action id,behaviour,modifier,output] ......................................................................
|
||||
/* eg: ['0','K_A','a9','0','â'] */ //const b1_keycode_arr: string[][] = this.get_5o_KeyActionOutput_array__From__ActionStateOutput_array_oldArrayType(jsonObj, b6_actionId_arr);//_S2 remove&replace
|
||||
/* eg: ['0','K_A','a9','0','â'] */ const b1_keycode_obj: ActionIdKeyModiOutput_object[] = this.get_5_KeyActionOutput_array__From__ActionStateOutput_array(jsonObj, b6_actionId_obj);
|
||||
|
||||
/* eg: ['K_A','a9','0','NCAPS','â']*/ // const b1_modifierKey_arr: string[][] = this.get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array_arr(jsonObj, b1_keycode_arr, isCapsused);//_S2 remove&replace
|
||||
/* eg: ['K_A','a9','0','NCAPS','â']*/ //const b1_modifierKey_obj: ActionIdOutputBehaviourKeyModi_object[] = this.get_7o_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(jsonObj, b1_keycode_arr, isCapsused);//_S2 remove&replace
|
||||
/* eg: ['K_A','a9','0','NCAPS','â']*/ const b1_modifierKey_obj: ActionIdOutputBehaviourKeyModi_object[] = this.get_7_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(jsonObj, b1_keycode_obj, isCapsused);//_S2 remove&replace
|
||||
/* eg: ['0','K_A','a9','0','â'] */ const b1_keycode_obj: allArrayContents_object[] = this.get_KeyActionOutput_array__From__ActionStateOutput_array(jsonObj, b6_actionId_obj);
|
||||
/* eg: ['K_A','a9','0','NCAPS','â']*/ const b1_modifierKey_obj: allArrayContents_object[] = this.get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(jsonObj, b1_keycode_obj, isCapsused);
|
||||
// .......................................................................................................................................................................................
|
||||
|
||||
//for (let n1 = 0; n1 < b4_deadkeyModifier_arr.length; n1++) {
|
||||
for (let n1 = 0; n1 < b4_deadkeyModifier_obj.length; n1++) {
|
||||
//for (let n2 = 0; n2 < b4_deadkeyModifier_arr[n1].length; n2++) {
|
||||
for (let n2 = 0; n2 < b4_deadkeyModifier_obj[n1].length; n2++) {
|
||||
// for (let n3 = 0; n3 < b4_deadkey_arr.length; n3++) {
|
||||
for (let n3 = 0; n3 < b4_deadkey_obj.length; n3++) {
|
||||
//for (let n4 = 0; n4 < b1_modifierKey_arr.length; n4++) {//_S2 remove&replace
|
||||
for (let n4 = 0; n4 < b1_modifierKey_obj.length; n4++) {
|
||||
|
||||
rule_obj = new Rule(
|
||||
|
|
@ -340,27 +337,15 @@ export class KeylayoutToKmnConverter {
|
|||
/* id_prev_deadkey */ 0,
|
||||
/* unique A */ 0,
|
||||
|
||||
/* modifier_deadkey */ //this.create_kmn_modifier(b4_deadkeyModifier_arr[n1][n2], isCapsused),
|
||||
/* modifier_deadkey */ this.create_kmn_modifier(b4_deadkeyModifier_obj[n1][n2], isCapsused),
|
||||
/* deadkey */ //this.map_UkeleleKC_To_VK(Number(b4_deadkey_arr[n3][0])),
|
||||
/* deadkey */ this.map_UkeleleKC_To_VK(Number(b4_deadkey_obj[n3].key)),
|
||||
/* dk for C2*/ dk_counter_C2++,
|
||||
/* unique B */ 0,
|
||||
|
||||
/* modifier_key*/ // b1_modifierKey_arr[n4][3],//_S2 remove&replace
|
||||
/* key */ //b1_modifierKey_arr[n4][0],
|
||||
/* output */ // new TextEncoder().encode(b1_modifierKey_arr[n4][4]),
|
||||
|
||||
/* modifier_key*/ b1_modifierKey_obj[n4].modifier,
|
||||
/* key */ b1_modifierKey_obj[n4].key,
|
||||
/* output */ new TextEncoder().encode(b1_modifierKey_obj[n4].outchar),
|
||||
);
|
||||
/* if ((b1_modifierKey_arr[n4][4] !== undefined)//_S2 remove&replace
|
||||
&& (b1_modifierKey_arr[n4][4] !== "undefined")
|
||||
&& (b1_modifierKey_arr[n4][4] !== "")) {
|
||||
object_array.push(rule_obj);
|
||||
}*/
|
||||
|
||||
if ((b1_modifierKey_obj[n4].outchar !== undefined)
|
||||
&& (b1_modifierKey_obj[n4].outchar !== "undefined")
|
||||
&& (b1_modifierKey_obj[n4].outchar !== "")) {
|
||||
|
|
@ -399,91 +384,56 @@ export class KeylayoutToKmnConverter {
|
|||
// Data of Block Nr 4 ........................................................................................................................................................................
|
||||
// with present action_id (a16) find all keycode-behaviour-pairs that use this action (a16) => (keymapIndex 3/keycode 32) ....................................................................
|
||||
// from these create an array of modifier combinations e.g. [ [ 'anyOption', 'Caps' ] ] .....................................................................................................
|
||||
/* e.g. [['32', 3]] */ // const b4_deadkey_arr: number[][] = this.get_9o_KeyModifier_array__From__ActionID_oldArrayType(jsonObj, action_id);//_S2 remove&replace
|
||||
/* e.g. [['32', 3]] */ const b4_deadkey_obj: modifierKey_object[] = this.get_9_KeyModifier_array__From__ActionID(jsonObj, action_id);
|
||||
/* e.g. [ [ 'anyOption', 'Caps' ] ]*/ // const b4_deadkeyModifier_arr: string[] = this.get_3o_Modifier_array__From__KeyModifier_array_oldArrayType(data_ukelele.arrayOf_Modifiers, b4_deadkey_arr);
|
||||
/* e.g. [ [ 'anyOption', 'Caps' ] ]*/ const b4_deadkeyModifier_obj: string[] = this.get_3_Modifier_array__From__KeyModifier_array(data_ukelele.arrayOf_Modifiers, b4_deadkey_obj);
|
||||
/* e.g. [['32', 3]] */ const b4_deadkey_obj: allArrayContents_object[] = this.get_KeyModifier_array__From__ActionID(jsonObj, action_id);
|
||||
/* e.g. [ [ 'anyOption', 'Caps' ] ]*/ const b4_deadkeyModifier_obj: string[] = this.get_Modifier_array__From__KeyModifier_array(data_ukelele.arrayOf_Modifiers, b4_deadkey_obj);
|
||||
// ...........................................................................................................................................................................................
|
||||
|
||||
// Data of Block Nr 3 ........................................................................................................................................................................
|
||||
// get an action id from a state-output-pair that use state = b5_value_state (e.g. use 3 in <when state="none" next="3"/> ) .................................................................
|
||||
/* e.g. actioniD = a17 */ const b3_actionId: string = this.get_2_ActionID__From__ActionNext(jsonObj, b5_value_state);
|
||||
/* e.g. actioniD = a17 */ const b3_actionId: string = this.get_ActionID__From__ActionNext(jsonObj, b5_value_state);
|
||||
// ...........................................................................................................................................................................................
|
||||
|
||||
// Data of Block Nr 2 .......................................................................................................................................................................
|
||||
// with present action_id (a17) find all key names and behaviours that use this action (a17) => (keymapIndex 3/keycode 28) ....................................................................
|
||||
// from these create an array of modifier combinations e.g. [ [ 'anyOption', 'Caps' ] ] .....................................................................................................
|
||||
|
||||
|
||||
|
||||
/* eg: index=3 */ //const b2_prev_deadkey_arr: number[][] = this.get_9o_KeyModifier_array__From__ActionID_oldArrayType(jsonObj, b3_actionId); // conversion not necessary //_S2 remove&replace
|
||||
/* eg: index=3 */ const b2_prev_deadkey_obj: modifierKey_object[] = this.get_9_KeyModifier_array__From__ActionID(jsonObj, b3_actionId); // conversion not necessary //_S2 remove&replace
|
||||
/* e.g. [ [ 'anyOption', 'Caps' ] ] */ // const b2_prev_deadkeyModifier_arr: string[] = this.get_3o_Modifier_array__From__KeyModifier_array_oldArrayType(data_ukelele.arrayOf_Modifiers, b2_prev_deadkey_arr);
|
||||
/* e.g. [ [ 'anyOption', 'Caps' ] ] */ const b2_prev_deadkeyModifier_obj: string[] = this.get_3_Modifier_array__From__KeyModifier_array(data_ukelele.arrayOf_Modifiers, b2_prev_deadkey_obj);
|
||||
/* eg: index=3 */ const b2_prev_deadkey_obj: allArrayContents_object[] = this.get_KeyModifier_array__From__ActionID(jsonObj, b3_actionId);
|
||||
/* e.g. [ [ 'anyOption', 'Caps' ] ] */ const b2_prev_deadkeyModifier_obj: string[] = this.get_Modifier_array__From__KeyModifier_array(data_ukelele.arrayOf_Modifiers, b2_prev_deadkey_obj);
|
||||
// ...........................................................................................................................................................................................
|
||||
// Data of Block Nr 6 ........................................................................................................................................................................
|
||||
// create an array[action id,state,output] from all state-output-pairs that use state = b5_value_next (e.g. use 1 in <when state="1" output="â"/> ) .........................................
|
||||
/* eg:[ [ 'a9','1','â'] ]*/ // const b6_actionId_arr: string[][] = this.get_6o_ActionStateOutput_array__From__ActionState_oldArrayType(jsonObj, b5_value_next);
|
||||
/* eg:[ [ 'a9','1','â'] ]*/ const b6_actionId_obj: idStateOutput_object[] = this.get_6_ActionStateOutput_array__From__ActionState(jsonObj, b5_value_next); /* eg:[ [ 'a9','1','â'] ]*/
|
||||
/* eg:[ [ 'a9','1','â'] ]*/ const b6_actionId_obj: idStateOutput_object[] = this.get_ActionStateOutput_array__From__ActionState(jsonObj, b5_value_next); /* eg:[ [ 'a9','1','â'] ]*/
|
||||
// ...........................................................................................................................................................................................
|
||||
|
||||
// Data of Block Nr 1 .......................................................................................................................................................................
|
||||
// create array[Keycode,Keyname,action id,actionIndex,output] and array[Keyname,action id,behaviour,modifier,output] .........................................................................
|
||||
/* eg: ['49','K_SPACE','a0','0','Â'] */ //const b1_keycode_arr: string[][] = this.get_5o_KeyActionOutput_array__From__ActionStateOutput_array_oldArrayType(jsonObj, b6_actionId_arr);
|
||||
/* eg: ['0','K_A','a9','0','â'] */ const b1_keycode_obj: ActionIdKeyModiOutput_object[] = this.get_5_KeyActionOutput_array__From__ActionStateOutput_array(jsonObj, b6_actionId_obj);
|
||||
// console.log("b1_keycode_obj ", b1_keycode_obj);
|
||||
//this.compareBoth(b1_keycode_arr, b1_keycode_obj);
|
||||
|
||||
/* eg: ['K_SPACE','a0','0','NCAPS','Â'] */ //const b1_modifierKey_arr: string[][] = this.get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array_arr(jsonObj, b1_keycode_arr, isCapsused);//_S2 remove&replace
|
||||
/* eg: ['K_SPACE','a0','0','NCAPS','Â'] */ //const b1_modifierKey_obj: ActionIdOutputBehaviourKeyModi_object[] = this.get_7o_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(jsonObj, b1_keycode_arr, isCapsused);
|
||||
const b1_modifierKey_obj: ActionIdOutputBehaviourKeyModi_object[] = this.get_7_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(jsonObj, b1_keycode_obj, isCapsused);//_S2 remove&replace
|
||||
/* eg: ['49','K_SPACE','a0','0','Â'] */ const b1_keycode_obj: allArrayContents_object[] = this.get_KeyActionOutput_array__From__ActionStateOutput_array(jsonObj, b6_actionId_obj);
|
||||
/* eg: ['K_SPACE','a0','0','NCAPS','Â'] */ const b1_modifierKey_obj: allArrayContents_object[] = this.get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(jsonObj, b1_keycode_obj, isCapsused);
|
||||
// ...........................................................................................................................................................................................
|
||||
|
||||
//for (let n1 = 0; n1 < b2_prev_deadkeyModifier_arr.length; n1++) {
|
||||
for (let n1 = 0; n1 < b2_prev_deadkeyModifier_obj.length; n1++) {
|
||||
//for (let n2 = 0; n2 < b2_prev_deadkeyModifier_arr[n1].length; n2++) {
|
||||
for (let n2 = 0; n2 < b2_prev_deadkeyModifier_obj[n1].length; n2++) {
|
||||
//for (let n3 = 0; n3 < b2_prev_deadkey_arr.length; n3++) {
|
||||
for (let n3 = 0; n3 < b2_prev_deadkey_obj.length; n3++) {
|
||||
//for (let n4 = 0; n4 < b4_deadkeyModifier_arr.length; n4++) {
|
||||
for (let n4 = 0; n4 < b4_deadkeyModifier_obj.length; n4++) {
|
||||
// for (let n5 = 0; n5 < b4_deadkeyModifier_arr[n4].length; n5++) {
|
||||
for (let n5 = 0; n5 < b4_deadkeyModifier_obj[n4].length; n5++) {
|
||||
//for (let n6 = 0; n6 < b4_deadkey_arr.length; n6++) {
|
||||
for (let n6 = 0; n6 < b4_deadkey_obj.length; n6++) {
|
||||
// for (let n7 = 0; n7 < b1_modifierKey_arr.length; n7++) {//_S2 remove&replace
|
||||
for (let n7 = 0; n7 < b1_modifierKey_obj.length; n7++) {
|
||||
|
||||
rule_obj = new Rule(
|
||||
/* rule_type */ "C3",
|
||||
/* modifier_prev_deadkey*/ //this.create_kmn_modifier(b2_prev_deadkeyModifier_arr[n1][n2], isCapsused),
|
||||
/* modifier_prev_deadkey*/ this.create_kmn_modifier(b2_prev_deadkeyModifier_obj[n1][n2], isCapsused),
|
||||
/* prev_deadkey */ //this.map_UkeleleKC_To_VK(Number(b2_prev_deadkey_arr[n3][0])),
|
||||
/* prev_deadkey */ this.map_UkeleleKC_To_VK(Number(b2_prev_deadkey_obj[n3].key)),
|
||||
/* id_prev_deadkey */ dk_counter_C3++,
|
||||
/* unique A */ 0,
|
||||
|
||||
/* modifier_deadkey */ // this.create_kmn_modifier(b4_deadkeyModifier_arr[n4][n5], isCapsused),
|
||||
/* modifier_deadkey */ this.create_kmn_modifier(b4_deadkeyModifier_obj[n4][n5], isCapsused),
|
||||
/* deadkey */ // this.map_UkeleleKC_To_VK(Number(b4_deadkey_arr[n6][0])),
|
||||
/* deadkey */ this.map_UkeleleKC_To_VK(Number(b4_deadkey_obj[n6].key)),
|
||||
/* dk for C2*/ 0,
|
||||
/* unique B */ 0,
|
||||
|
||||
/* modifier_key*/ //b1_modifierKey_arr[n7][3],//_S2 remove&replace
|
||||
/* key */ //b1_modifierKey_arr[n7][0],
|
||||
/* output */ //new TextEncoder().encode(b1_modifierKey_arr[n7][4]),
|
||||
|
||||
/* modifier_key*/ b1_modifierKey_obj[n7].modifier,
|
||||
/* key */ b1_modifierKey_obj[n7].key,
|
||||
/* output */ new TextEncoder().encode(b1_modifierKey_obj[n7].outchar),
|
||||
);
|
||||
|
||||
/* if ((b1_modifierKey_arr[n7][4] !== undefined)//_S2 remove&replace
|
||||
&& (b1_modifierKey_arr[n7][4] !== "undefined")
|
||||
&& (b1_modifierKey_arr[n7][4] !== "")) {
|
||||
object_array.push(rule_obj);
|
||||
}*/
|
||||
if ((b1_modifierKey_obj[n7].outchar !== undefined)
|
||||
&& (b1_modifierKey_obj[n7].outchar !== "undefined")
|
||||
&& (b1_modifierKey_obj[n7].outchar !== "")) {
|
||||
|
|
@ -700,7 +650,7 @@ export class KeylayoutToKmnConverter {
|
|||
}
|
||||
|
||||
else {
|
||||
add_modifier = String(modifier_state[i]) + " ";
|
||||
add_modifier = modifier_state[i] + " ";
|
||||
}
|
||||
kmn_modifier += kmn_ncaps + add_modifier;
|
||||
}
|
||||
|
|
@ -822,13 +772,13 @@ export class KeylayoutToKmnConverter {
|
|||
}
|
||||
}
|
||||
|
||||
/* @brief member function to return an index for a given actionID
|
||||
* @param data :any - an object containing all data read from a .keylayout file
|
||||
* @param search :string - value 'id' to be found
|
||||
* @return a number specifying the index of an actionId
|
||||
*/
|
||||
// _S2 get 1 OK
|
||||
public get_1_ActionIndex__From__ActionId(data: any, search: string): number {
|
||||
/**
|
||||
* @brief member function to return an index for a given actionID
|
||||
* @param data :any - an object containing all data read from a .keylayout file
|
||||
* @param search :string - value 'id' to be found
|
||||
* @return a number specifying the index of an actionId
|
||||
*/
|
||||
public get_ActionIndex__From__ActionId(data: any, search: string): number {
|
||||
for (let i = 0; i < data.keyboard.actions.action.length; i++) {
|
||||
if (data.keyboard.actions.action[i]['@_id'] === search) {
|
||||
return i;
|
||||
|
|
@ -836,14 +786,14 @@ export class KeylayoutToKmnConverter {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief member function to find the actionID of a certain state-next pair
|
||||
* @param data :any an object containing all data read from a .keylayout file
|
||||
* @param search :string value 'next' to be found
|
||||
* @return a string containing the actionId of a certain state-next pair
|
||||
*/
|
||||
// _S2 get 2 OK
|
||||
public get_2_ActionID__From__ActionNext(data: any, search: string): string {
|
||||
public get_ActionID__From__ActionNext(data: any, search: string): string {
|
||||
if (search !== "none") {
|
||||
for (let i = 0; i < data.keyboard.actions.action.length; i++) {
|
||||
for (let j = 0; j < data.keyboard.actions.action[i].when.length; j++) {
|
||||
|
|
@ -857,41 +807,15 @@ export class KeylayoutToKmnConverter {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief member function to create an array of modifier behaviours for a given keycode in [keycode,modifier]
|
||||
* @brief member function to create an array of (modifier) behaviours for a given keycode in [{keycode,modifier}]
|
||||
* @param data : any - an object containing all data read from a .keylayout file
|
||||
* @param search : (string | number)[][] - an array[keycode,modifier] to be found
|
||||
* @param search : allArrayContents_object[] - an array[{keycode,modifier}] to be found
|
||||
* @return an array: string[] containing modifiers
|
||||
*/
|
||||
// _S2 get 3 OK
|
||||
public get_3o_Modifier_array__From__KeyModifier_array_oldArrayType(data: any, search: (string | number)[][]): string[] {
|
||||
const mapIndexArray_2D: string[] = [];
|
||||
|
||||
//console.log("Xsearch old ",search);
|
||||
for (let i = 0; i < search.length; i++) {
|
||||
mapIndexArray_2D.push(data[search[i][1]]);
|
||||
}
|
||||
return mapIndexArray_2D;
|
||||
}
|
||||
|
||||
public get_3_Modifier_array__From__KeyModifier_array_retObj(data: any, search: modifierKey_object[]): modifier_object[] {
|
||||
const returnObjarray1D = [];
|
||||
// console.log("Xsearch 3",search);
|
||||
|
||||
let returnObject: modifier_object;
|
||||
for (let i = 0; i < search.length; i++) {
|
||||
returnObject = {
|
||||
modifier: (data[search[i].modifier])
|
||||
};
|
||||
returnObjarray1D.push(returnObject);
|
||||
}
|
||||
return returnObjarray1D;
|
||||
}
|
||||
|
||||
|
||||
public get_3_Modifier_array__From__KeyModifier_array(data: any, search: modifierKey_object[]): string[] {
|
||||
public get_Modifier_array__From__KeyModifier_array(data: any, search: allArrayContents_object[]): string[] {
|
||||
const returnString1D: string[] = [];
|
||||
for (let i = 0; i < search.length; i++) {
|
||||
returnString1D.push(data[search[i].modifier]);
|
||||
returnString1D.push(data[search[i].behaviour]);
|
||||
}
|
||||
return returnString1D;
|
||||
}
|
||||
|
|
@ -903,10 +827,8 @@ export class KeylayoutToKmnConverter {
|
|||
* @param search :string an actionId to be found
|
||||
* @return a string containing the output character
|
||||
*/
|
||||
// _S2 get 4 OK
|
||||
public get_4_Output__From__ActionId_None(data: any, search: string): string {
|
||||
public get_Output__From__ActionId_None(data: any, search: string): string {
|
||||
let OutputValue: string = "";
|
||||
|
||||
for (let i = 0; i < data.keyboard.actions.action.length; i++) {
|
||||
if (data.keyboard.actions.action[i]['@_id'] === search) {
|
||||
for (let j = 0; j < data.keyboard.actions.action[i].when.length; j++) {
|
||||
|
|
@ -922,55 +844,28 @@ export class KeylayoutToKmnConverter {
|
|||
/**
|
||||
* @brief member function to return array of [Keycode,Keyname,actionId,actionIDIndex, output] for a given actionID in of [ actionID,state,output]
|
||||
* @param data :any - an object containing all data read from a .keylayout file
|
||||
* @param search :string[][] - array of [ actionID,state,output]
|
||||
* @return a string[][] containing [Keycode,Keyname,actionId,actionIDIndex, output]
|
||||
* @param search :idStateOutput_object[] - array of [{ actionID,state,output }]
|
||||
* @return a allArrayContents_object[] containing [{Keycode,Keyname,actionId,actionID, output}]
|
||||
*/
|
||||
// _S2 get 5 OK
|
||||
public get_5o_KeyActionOutput_array__From__ActionStateOutput_array_oldArrayType(data: any, search: string[][]): string[][] {
|
||||
|
||||
if ((search === undefined) || (search === null))
|
||||
return [];
|
||||
|
||||
|
||||
const returnarray2D: string[][] = [];
|
||||
for (let k = 0; k < search.length; k++) {
|
||||
for (let i = 0; i < data.keyboard.keyMapSet[0].keyMap.length; i++) {
|
||||
for (let j = 0; j < data.keyboard.keyMapSet[0].keyMap[i].key.length; j++) {
|
||||
if (data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_action'] === search[k][0] &&
|
||||
data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'] <= KeylayoutToKmnConverter.USED_KEYS_COUNT) {
|
||||
returnarray2D.push([
|
||||
data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'],
|
||||
this.map_UkeleleKC_To_VK(Number(data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'])),
|
||||
data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_action'],
|
||||
data.keyboard.keyMapSet[0].keyMap[i]['@_index'],
|
||||
search[k][2]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnarray2D;
|
||||
}
|
||||
// _S2 get 5 OK
|
||||
public get_5_KeyActionOutput_array__From__ActionStateOutput_array(data: any, search: idStateOutput_object[]): ActionIdKeyModiOutput_object[] {
|
||||
public get_KeyActionOutput_array__From__ActionStateOutput_array(data: any, search: idStateOutput_object[]): allArrayContents_object[] {
|
||||
|
||||
if ((search === undefined) || (search === null))
|
||||
return [];
|
||||
|
||||
const returnObjarray1D = [];
|
||||
let returnObject: ActionIdKeyModiOutput_object;
|
||||
let returnObject: allArrayContents_object;
|
||||
|
||||
for (let k = 0; k < search.length; k++) {
|
||||
for (let i = 0; i < data.keyboard.keyMapSet[0].keyMap.length; i++) {
|
||||
for (let j = 0; j < data.keyboard.keyMapSet[0].keyMap[i].key.length; j++) {
|
||||
if (data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_action'] === search[k].id &&
|
||||
data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'] <= KeylayoutToKmnConverter.USED_KEYS_COUNT) {
|
||||
data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'] <= KeylayoutToKmnConverter.USE_KEY_COUNT) {
|
||||
|
||||
returnObject = {
|
||||
keyCode: data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'],
|
||||
key: this.map_UkeleleKC_To_VK(Number(data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'])),
|
||||
actionId: data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_action'],
|
||||
modifier: data.keyboard.keyMapSet[0].keyMap[i]['@_index'],
|
||||
behaviour: data.keyboard.keyMapSet[0].keyMap[i]['@_index'],
|
||||
outchar: search[k].output
|
||||
};
|
||||
returnObjarray1D.push(returnObject);
|
||||
|
|
@ -985,27 +880,9 @@ export class KeylayoutToKmnConverter {
|
|||
* @brief member function to get an array of all actionId-output pairs for a certain state
|
||||
* @param data : any an object containing all data read from a .keylayout file
|
||||
* @param search : string a 'state' to be found
|
||||
* @return an array: string[][] containing all [actionId, state, output] for a certain state
|
||||
* @return an array: idStateOutput_object[] containing all [{actionId, state, output}] for a certain state
|
||||
*/
|
||||
// _S2 get 6 OK
|
||||
public get_6o_ActionStateOutput_array__From__ActionState_oldArrayType(data: any, search: string): string[][] {
|
||||
const returnarray2D: string[][] = [];
|
||||
|
||||
for (let i = 0; i < data.keyboard.actions.action.length; i++) {
|
||||
for (let j = 0; j < data.keyboard.actions.action[i].when.length; j++) {
|
||||
if ((data.keyboard.actions.action[i].when[j]['@_state'] === search)) {
|
||||
returnarray2D.push([
|
||||
data.keyboard.actions.action[i]['@_id'],
|
||||
data.keyboard.actions.action[i].when[j]['@_state'],
|
||||
data.keyboard.actions.action[i].when[j]['@_output']
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnarray2D;
|
||||
}
|
||||
// _S2 get 6 OK
|
||||
public get_6_ActionStateOutput_array__From__ActionState(data: any, search: string): idStateOutput_object[] {
|
||||
public get_ActionStateOutput_array__From__ActionState(data: any, search: string): idStateOutput_object[] {
|
||||
const returnObjarray1D: idStateOutput_object[] = [];
|
||||
let returnObject: idStateOutput_object;
|
||||
|
||||
|
|
@ -1022,83 +899,31 @@ export class KeylayoutToKmnConverter {
|
|||
}
|
||||
}
|
||||
}
|
||||
return returnObjarray1D;
|
||||
return returnObjarray1D; // _S2 ToDo rewrite/change all functio comments to new datatypes!!!
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief member function to create an 2D array of [KeyName,actionId,behaviour,modifier,output]
|
||||
* @param data : any an object containing all data read from a .keylayout file
|
||||
* @param search : array of [keycode,keyname,actionId,behaviour,output] to be found
|
||||
* @param search : array of [{keycode,keyname,actionId,behaviour,output}] to be found
|
||||
* @param isCAPSused : boolean flag to indicate if CAPS is used in a keylayout file or not
|
||||
* @return an array: string[][] containing [KeyName,actionId,behaviour,modifier,output]
|
||||
* @return an array: allArrayContents_object[] containing [{KeyName,actionId,behaviour,modifier,output}]
|
||||
*/
|
||||
// _S2 get 7 OK --> tests not OK
|
||||
public get_7o_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array_oldArrayType(data: any, search: (boolean | string)[][], isCAPSused: boolean): string[][] {
|
||||
const returnarray: string[][] = [];
|
||||
|
||||
if (!((search === undefined) || (search === null) || (search.length === 0))) {
|
||||
for (let i = 0; i < search.length; i++) {
|
||||
const behaviour: number = Number(search[i][3]);
|
||||
for (let j = 0; j < data.keyboard.modifierMap.keyMapSelect[behaviour].modifier.length; j++) {
|
||||
returnarray.push([
|
||||
// KeyName
|
||||
String(search[i][1]),
|
||||
// actionId
|
||||
String(search[i][2]),
|
||||
// behaviour
|
||||
String(search[i][3]),
|
||||
// modifier
|
||||
String(this.create_kmn_modifier(data.keyboard.modifierMap.keyMapSelect[behaviour].modifier[j]['@_keys'], isCAPSused)),
|
||||
// output
|
||||
String(search[i][4])
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove duplicates
|
||||
const [unique_returnarray] = returnarray.reduce((acc, curr) => {
|
||||
const [uniq, set] = acc;
|
||||
if (!set.has(curr.join(','))) {
|
||||
set.add(curr.join(','));
|
||||
uniq.push(curr);
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
[[], new Set()],
|
||||
);
|
||||
return unique_returnarray;
|
||||
}
|
||||
public get_7o_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(data: any, search: ((boolean | string)[])[], isCAPSused: boolean): ActionIdOutputBehaviourKeyModi_object[] {
|
||||
const returnarray: string[][] = [];
|
||||
public get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(data: any, search: allArrayContents_object[], isCAPSused: boolean): allArrayContents_object[] {
|
||||
const returnObjarray1D = [];
|
||||
let returnObject: ActionIdOutputBehaviourKeyModi_object;
|
||||
|
||||
let returnObject: allArrayContents_object;
|
||||
|
||||
if (!((search === undefined) || (search === null) || (search.length === 0))) {
|
||||
for (let i = 0; i < search.length; i++) {
|
||||
const behaviour: number = Number(search[i][3]);
|
||||
for (let j = 0; j < data.keyboard.modifierMap.keyMapSelect[behaviour].modifier.length; j++) {
|
||||
|
||||
returnarray.push([
|
||||
// KeyName
|
||||
String(search[i][1]),
|
||||
// actionId
|
||||
String(search[i][2]),
|
||||
// behaviour
|
||||
String(search[i][3]),
|
||||
// modifier
|
||||
String(this.create_kmn_modifier(data.keyboard.modifierMap.keyMapSelect[behaviour].modifier[j]['@_keys'], isCAPSused)),
|
||||
// output
|
||||
String(search[i][4])
|
||||
]);
|
||||
const behaviour_idx: number = Number(search[i].behaviour);
|
||||
for (let j = 0; j < data.keyboard.modifierMap.keyMapSelect[behaviour_idx].modifier.length; j++) {
|
||||
|
||||
returnObject = {
|
||||
search: "",
|
||||
actionId: String(search[i][2]),
|
||||
behaviour: String(search[i][3]),
|
||||
modifier: String(this.create_kmn_modifier(data.keyboard.modifierMap.keyMapSelect[behaviour].modifier[j]['@_keys'], isCAPSused)),
|
||||
key: String(search[i][1]),
|
||||
outchar: String(search[i][4]),
|
||||
actionId: search[i].actionId,
|
||||
key: search[i].key,
|
||||
behaviour: search[i].behaviour,
|
||||
modifier: this.create_kmn_modifier(data.keyboard.modifierMap.keyMapSelect[behaviour_idx].modifier[j]['@_keys'], isCAPSused),
|
||||
outchar: search[i].outchar,
|
||||
};
|
||||
returnObjarray1D.push(returnObject);
|
||||
}
|
||||
|
|
@ -1108,55 +933,15 @@ export class KeylayoutToKmnConverter {
|
|||
const unique_Objarray = returnObjarray1D.reduce((unique, o) => {
|
||||
if (!unique.some(obj =>
|
||||
obj.actionId === o.actionId &&
|
||||
obj.key === o.key &&
|
||||
obj.behaviour === o.behaviour &&
|
||||
obj.modifier === o.modifier &&
|
||||
obj.key === o.key &&
|
||||
obj.outchar === o.outchar
|
||||
)) {
|
||||
unique.push(o);
|
||||
}
|
||||
return unique;
|
||||
}, []);
|
||||
|
||||
return unique_Objarray;
|
||||
}
|
||||
public get_7_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(data: any, search: ActionIdKeyModiOutput_object[], isCAPSused: boolean): ActionIdOutputBehaviourKeyModi_object[] {
|
||||
|
||||
const returnObjarray1D = [];
|
||||
let returnObject: ActionIdOutputBehaviourKeyModi_object;
|
||||
|
||||
|
||||
if (!((search === undefined) || (search === null) || (search.length === 0))) {
|
||||
for (let i = 0; i < search.length; i++) {
|
||||
const behaviour: number = Number(search[i].modifier);
|
||||
for (let j = 0; j < data.keyboard.modifierMap.keyMapSelect[behaviour].modifier.length; j++) {
|
||||
|
||||
returnObject = {
|
||||
search: "",
|
||||
actionId: String(search[i].actionId),
|
||||
behaviour: String(search[i].modifier),
|
||||
modifier: String(this.create_kmn_modifier(data.keyboard.modifierMap.keyMapSelect[behaviour].modifier[j]['@_keys'], isCAPSused)),
|
||||
key: String(search[i].key),
|
||||
outchar: String(search[i].outchar),
|
||||
};
|
||||
returnObjarray1D.push(returnObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove duplicates
|
||||
const unique_Objarray = returnObjarray1D.reduce((unique, o) => {
|
||||
if (!unique.some(obj =>
|
||||
obj.actionId === o.actionId &&
|
||||
obj.behaviour === o.behaviour &&
|
||||
obj.modifier === o.modifier &&
|
||||
obj.key === o.key &&
|
||||
obj.outchar === o.outchar
|
||||
)) {
|
||||
unique.push(o);
|
||||
}
|
||||
return unique;
|
||||
}, []);
|
||||
|
||||
return unique_Objarray;
|
||||
}
|
||||
|
||||
|
|
@ -1167,30 +952,28 @@ export class KeylayoutToKmnConverter {
|
|||
* @param search : string - an actionId to be found
|
||||
* @param outchar : string - the output character
|
||||
* @param isCAPSused : boolean - flag to indicate if CAPS is used in a keylayout file or not
|
||||
* @return an array: string[][] containing [actionID,output,actionID, behaviour,keyname,modifier]
|
||||
* @return an array: allArrayContents_object[] containing [{actionID,output,actionID, behaviour,keyname,modifier}]
|
||||
*/
|
||||
// _S2 get 8 OK
|
||||
public get_8_ActionOutputBehaviourKeyModi_From__ActionIDStateOutput(data: any, modi: any, search: string, outchar: string, isCapsused: boolean): ActionIdOutputBehaviourKeyModi_object[] {
|
||||
public get_ActionOutputBehaviourKeyModi_From__ActionIDStateOutput(data: any, modi: string[][], search: string, outchar: string, isCapsused: boolean): allArrayContents_object[] {
|
||||
const returnObjarray1D = [];
|
||||
let returnObject: ActionIdOutputBehaviourKeyModi_object;
|
||||
let returnObject: allArrayContents_object;
|
||||
|
||||
if ((search === "") || (search === undefined) || !((isCapsused === true) || (isCapsused === false))) {
|
||||
return [];
|
||||
}
|
||||
// loop behaviors (in ukelele it is possible to define multiple modifier combinations that behave in the same way)
|
||||
for (let i = 0; i < data.keyboard.keyMapSet[0].keyMap.length; i++) {
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USED_KEYS_COUNT; j++) {
|
||||
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USE_KEY_COUNT; j++) {
|
||||
if (data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_action'] === search) {
|
||||
for (let k = 0; k < modi[data.keyboard.keyMapSet[0].keyMap[i]['@_index']].length; k++) {
|
||||
const behaviour: string = data.keyboard.keyMapSet[0].keyMap[i]['@_index'];
|
||||
|
||||
const behaviour_idx: number = data.keyboard.keyMapSet[0].keyMap[i]['@_index'];
|
||||
returnObject = {
|
||||
search: search,
|
||||
outchar: outchar,
|
||||
actionId: data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_action'],
|
||||
behaviour: data.keyboard.keyMapSet[0].keyMap[i]['@_index'],
|
||||
key: this.map_UkeleleKC_To_VK(Number(data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'])),
|
||||
modifier: this.create_kmn_modifier(modi[behaviour][k], isCapsused),
|
||||
modifier: this.create_kmn_modifier(modi[behaviour_idx][k], isCapsused),
|
||||
};
|
||||
returnObjarray1D.push(returnObject);
|
||||
}
|
||||
|
|
@ -1203,9 +986,8 @@ export class KeylayoutToKmnConverter {
|
|||
// remove duplicates
|
||||
const unique_Objarray = returnObjarray1D.reduce((unique, o) => {
|
||||
if (!unique.some(obj =>
|
||||
obj.actionId === o.actionId &&
|
||||
obj.outchar === o.outchar &&
|
||||
obj.search === o.search &&
|
||||
obj.actionId === o.actionId &&
|
||||
obj.behaviour === o.behaviour &&
|
||||
obj.key === o.key &&
|
||||
obj.modifier === o.modifier
|
||||
|
|
@ -1219,47 +1001,24 @@ export class KeylayoutToKmnConverter {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief member function to create an array of [keycode,behaviour] for a given actionId
|
||||
* @brief member function to create an array of [{keycode,behaviour}] for a given actionId
|
||||
* @param data : any - an object containing all data read from a .keylayout file
|
||||
* @param search : string - an actionId to be found
|
||||
* @return an array: number[][] containing [keycode,behaviour]
|
||||
* @return an array: allArrayContents_object[] containing [{keycode,behaviour}]
|
||||
*/
|
||||
// _S2 get 9 OK //_S2 remove&replace
|
||||
public get_9o_KeyModifier_array__From__ActionID_oldArrayType(data: any, search: string): number[][] {
|
||||
public get_KeyModifier_array__From__ActionID(data: any, search: string): allArrayContents_object[] {
|
||||
const mapIndexArray_2D: number[][] = [];
|
||||
let returnObject: modifierKey_object;
|
||||
const mapIndexObject1D: modifierKey_object[] = [];
|
||||
let returnObject: allArrayContents_object;
|
||||
const mapIndexObject1D: allArrayContents_object[] = [];
|
||||
|
||||
for (let i = 0; i < data.keyboard.keyMapSet[0].keyMap.length; i++) {
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USED_KEYS_COUNT; j++) {
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USE_KEY_COUNT; j++) {
|
||||
if (data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_action'] === search) {
|
||||
|
||||
mapIndexArray_2D.push([data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'], i]);
|
||||
|
||||
returnObject = {
|
||||
key: data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'],
|
||||
modifier: i
|
||||
};
|
||||
mapIndexObject1D.push(returnObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mapIndexArray_2D;
|
||||
}
|
||||
public get_9_KeyModifier_array__From__ActionID(data: any, search: string): modifierKey_object[] {
|
||||
const mapIndexArray_2D: number[][] = [];
|
||||
let returnObject: modifierKey_object;
|
||||
const mapIndexObject1D: modifierKey_object[] = [];
|
||||
|
||||
for (let i = 0; i < data.keyboard.keyMapSet[0].keyMap.length; i++) {
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USED_KEYS_COUNT; j++) {
|
||||
if (data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_action'] === search) {
|
||||
|
||||
mapIndexArray_2D.push([data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'], i]);
|
||||
|
||||
returnObject = {
|
||||
key: data.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'],
|
||||
modifier: i
|
||||
behaviour: String(i),
|
||||
};
|
||||
mapIndexObject1D.push(returnObject);
|
||||
}
|
||||
|
|
@ -1272,101 +1031,6 @@ export class KeylayoutToKmnConverter {
|
|||
public convert_bound = {
|
||||
convert: this.convert.bind(this),
|
||||
};
|
||||
|
||||
|
||||
|
||||
public dummy(into: any) {
|
||||
}
|
||||
public compareBoth(arr: any, obj: any,) {
|
||||
|
||||
// compare:-----------------------------------
|
||||
for (let k = 0; k < obj.length; k++) {
|
||||
/*console.log("k ", k);
|
||||
|
||||
console.log(" arr", typeof (arr), arr, "----", typeof (arr[k]), arr[k]);
|
||||
console.log("-------------------- ",);
|
||||
console.log(" obj", typeof (obj), obj, "----", typeof (obj[k]), obj[k]);
|
||||
|
||||
console.log("arr[k ", arr[k]);
|
||||
console.log("obj[k].modifier ", obj[k].modifier);*/
|
||||
if (
|
||||
(arr.length === obj.length) &&
|
||||
|
||||
|
||||
(arr[k] === obj[k].modifier)
|
||||
// (arr[k][1] === obj[k].key)
|
||||
|
||||
/*(arr[k][0] === obj[k].key) &&
|
||||
(arr[k][1] === obj[k].actionId) &&
|
||||
(arr[k][2] === obj[k].behaviour) &&
|
||||
(arr[k][3] === obj[k].modifier) &&
|
||||
(arr[k][4] === obj[k].outchar)*/
|
||||
|
||||
) {
|
||||
console.log("IS_EQUAL ",);
|
||||
}
|
||||
else console.log("NONONO not_EQUAL \n",
|
||||
(arr.length === obj.length), obj.length, "<->", arr.length, "\n",
|
||||
|
||||
(arr[k] === obj[k].modifier), obj[k].modifier, "<->", arr[k], "\n",
|
||||
// (arr[k][1] === obj[k].key), obj[k].key, "<->", arr[k][1], "\n",
|
||||
|
||||
|
||||
/* (arr[k][0] === obj[k].key), obj[k].key, "<->", arr[k][0], "\n",
|
||||
(arr[k][1] === obj[k].actionId), obj[k].actionId, "<->", arr[k][1], "\n",
|
||||
(arr[k][2] === obj[k].behaviour), obj[k].behaviour, "<->", arr[k][2], "\n",
|
||||
(arr[k][3] === obj[k].modifier), obj[k].modifier, "<->", arr[k][3], "\n",
|
||||
(arr[k][4] === obj[k].outchar), obj[k].outchar, "<->", arr[k][4]*/
|
||||
);
|
||||
}
|
||||
}
|
||||
public compareSameType(arr1: any, arr2: any,) {
|
||||
|
||||
|
||||
// compare:-----------------------------------
|
||||
for (let k = 0; k < arr1.length; k++) {
|
||||
/*console.log("k ", k);
|
||||
|
||||
console.log(" arr1", typeof (arr1), arr1, "----", typeof (arr1[k]), arr1[k]);
|
||||
console.log("-------------------- ",);
|
||||
console.log(" arr2", typeof (arr2), arr2, "----", typeof (arr2[k]), arr2[k]);
|
||||
|
||||
console.log("arr1[k ", arr1[k]);
|
||||
console.log("arr2[k].modifier ", arr2[k].modifier);*/
|
||||
if (
|
||||
(arr1.length === arr2.length) &&
|
||||
|
||||
(arr1[k].search === arr2[k].search) &&
|
||||
(arr1[k].actionId === arr2[k].actionId) &&
|
||||
(arr1[k].behaviour === arr2[k].behaviour) &&
|
||||
(arr1[k].modifier === arr2[k].modifier) &&
|
||||
(arr1[k].key === arr2[k].key) &&
|
||||
(arr1[k].outchar === arr2[k].outchar)
|
||||
|
||||
) {
|
||||
console.log("compareSameType: IS_EQUAL ",);
|
||||
}
|
||||
else console.log("compareSameType: NONONO not_EQUAL \n",
|
||||
(arr1.length === arr2.length), arr2.length, "<->", arr1.length, "\n",
|
||||
|
||||
(arr1[k] === arr2[k].modifier), arr2[k].modifier, "<->", arr1[k], "\n",
|
||||
// (arr1[k][1] === arr2[k].key), arr2[k].key, "<->", arr1[k][1], "\n",
|
||||
|
||||
|
||||
/* (arr1[k][0] === arr2[k].key), arr2[k].key, "<->", arr1[k][0], "\n",
|
||||
(arr1[k][1] === arr2[k].actionId), arr2[k].actionId, "<->", arr1[k][1], "\n",
|
||||
(arr1[k][2] === arr2[k].behaviour), arr2[k].behaviour, "<->", arr1[k][2], "\n",
|
||||
(arr1[k][3] === arr2[k].modifier), arr2[k].modifier, "<->", arr1[k][3], "\n",
|
||||
(arr1[k][4] === arr2[k].outchar), arr2[k].outchar, "<->", arr1[k][4]*/
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ export class KmnFileWriter {
|
|||
|
||||
// lookup key nr of the key which is being processed
|
||||
let keyNr: number = 0;
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USED_KEYS_COUNT; j++) {
|
||||
for (let j = 0; j <= KeylayoutToKmnConverter.USE_KEY_COUNT; j++) {
|
||||
if (keylayoutKmnConverter.map_UkeleleKC_To_VK(j) === unique_data_Rules[k].key) {
|
||||
keyNr = j;
|
||||
break;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -36,7 +36,6 @@ describe('KmnFileWriter', function () {
|
|||
const converted_unavailable = sut.convert_bound.convert(read_unavailable, inputFilename_unavailable.replace(/\.keylayout$/, '.kmn'));
|
||||
|
||||
it('write() should return true (no error) if written', async function () {
|
||||
|
||||
const result = sut_w.write(converted);
|
||||
assert.isTrue(result);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue