feat(core): ldml: basic: updates to basic.txt for layr 🙀

- more key2 chan ges

For feat(developer): ldml: include all LDML data in kmx+ 🙀 #753
This commit is contained in:
Steven R. Loomis 2022-12-15 15:27:58 -06:00
parent a126a83f6a
commit eb8c4dea7a
4 changed files with 83 additions and 13 deletions

View file

@ -108,10 +108,10 @@ export function build_key2(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS, sect_l
longPress: build_list_index(sect_list, key.longPress),
longPressDefault: build_strs_index(sect_strs, key.longPressDefault),
multiTap: build_list_index(sect_list, key.multiTap),
flicks: key2.flicks.findIndex(v => v._id === key.flicks),
flicks: key2.flicks.findIndex(v => v._id === (key.flicks || '')), // flicks id='' is the 'null' flicks
};
// Make sure the flicks were was found
if (key.flicks && !result.flicks) {
// Make sure the flicks were found
if (result.flicks === -1) {
throw new Error(`Key2: Could not find flicks id=${key.flicks} for key=${key.id.value}`);
}
return result;

View file

@ -288,6 +288,14 @@ export class Key2 extends Section {
};
export class List extends Section {
/**
* Allocate a list from a space-separated list of items.
* Note that passing undefined or null or `''` will
* end up being the same as the empty list `[]`
* @param strs Strs section for allocation
* @param s space-separated list of items
* @returns a List object
*/
allocListFromSpaces(strs: Strs, s?: string): ListItem {
if(s === undefined || s === null) {
s = '';
@ -295,9 +303,22 @@ export class List extends Section {
// TODO-LDML: support unicode escaping etc
return this.allocList(strs, s.split(' '));
}
/**
* Return a List object referring to the string list.
* Note that a falsy list, or a list containing only an empty string
* `['']` will be stored as an empty list `[]`.
* @param strs Strs section for allocation
* @param s string list to allocate
* @returns
*/
allocList(strs: Strs, s?: string[]): ListItem {
// Special case the 'null' list for [] or ['']
if (!s || (s.length === 1 && s[0] === '')) {
return this.lists[0];
}
let result = this.lists.find(item => item.isEqual(s));
if(result === undefined) {
// allocate a new ListItem
result = new ListItem(strs, s);
this.lists.push(result);
}

View file

@ -77,8 +77,8 @@ export class Key2Compiler extends SectionCompiler {
const keySwitch = sections.strs.allocString(key.switch); // 'switch' is a reserved word
flags |= constants.key2_key_flags_extend;
const to = sections.strs.allocString(key.to); // TODO-LDML: single char
const width = Math.ceil(key.width * 10.0);
const vkey: any = null; // TODO-LDML: fill in later
const width = Math.ceil((key.width || 1) * 10.0); // default, width=1
const vkey: any = 0; // TODO-LDML: fill in later
sect.keys.push({
flags,
flicks,

View file

@ -140,6 +140,10 @@ block(sectitems)
76 6b 65 79
diff(sect,vkey)
# ???? TODO
00 00 00 00
00 00 00 00
block(endsect)
# ----------------------------------------------------------------------------------------------------
@ -264,12 +268,49 @@ block(finl)
00 00 00 00 # KMXPLUS_ELEM before;
01 00 00 00 # KMX_DWORD flags;
# };
# ----------------------------------------------------------------------------------------------------
# key2
# ----------------------------------------------------------------------------------------------------
block(key2) # struct COMP_KMXPLUS_KEY2 {
5b 54 79 32 # KMX_DWORD header.ident; // 0000 Section name - key2
6b 65 79 32 # KMX_DWORD header.ident; // 0000 Section name - key2
sizeof(key2) # KMX_DWORD header.size; // 0004 Section length
# TODO: key2
02 00 00 00 # KMX_DWORD keyCount
01 00 00 00 # KMX_DWORD flicksCount
00 00 00 00 # KMX_DWORD flickCount
00 00 00 00 00 00 00 00 00 00 00 00 # Reserved[3]
# keys
# hmaqtua
00 00 00 00 # KMX_DWORD vkey
index(strNull,strKey1,2) # KMXPLUS_STR 'U+0127'
01 00 00 00 # KMX_DWORD (flags: extend)
index(strNull,strHmaqtua,2) # KMXPLUS_STR 'hmaqtua'
00 00 00 00 # KMXPLUS_STR switch
0A 00 00 00 # KMX_DWORD width*10
02 00 00 00 # LIST longPress (TODO: should be 0)
00 00 00 00 # STR longPressDefault
01 00 00 00 # LIST multiTap (TODO: should be0)
00 00 00 00 # flicks 0
# that
00 00 00 00 # KMX_DWORD vkey
index(strNull,strKey2,2) # KMXPLUS_STR 'U+0127'
01 00 00 00 # KMX_DWORD flags = extend
index(strNull,strThat,2) # KMXPLUS_STR 'hmaqtua'
00 00 00 00 # KMXPLUS_STR switch
0A 00 00 00 # KMX_DWORD width*10
00 00 00 00 # LIST longPress
00 00 00 00 # STR longPressDefault
00 00 00 00 # LIST multiTap
00 00 00 00 # flicks 0
# flicks
# flicks 0 - null
00 00 00 00 # KMX_DWORD count
00 00 00 00 # KMX_DWORD flick
00 00 00 00 # KMX_STR id
# flick
#00 00 00 00 # LIST directions
#00 00 00 01 # flags
#00 00 00 00 # str: to
# ----------------------------------------------------------------------------------------------------
# keys
# ----------------------------------------------------------------------------------------------------
@ -287,10 +328,14 @@ block(keys) # struct COMP_KMXPLUS_KEYS {
c0 00 00 00 00 00 00 00 index(strNull,strKey1,2) 01 00 00 00 # KMX_DWORD vkey, mod, to, flags;
31 00 00 00 00 00 00 00 index(strNull,strKey2,2) 01 00 00 00 # KMX_DWORD vkey, mod, to, flags;
# ----------------------------------------------------------------------------------------------------
# layr
# ----------------------------------------------------------------------------------------------------
block(layr) # struct COMP_KMXPLUS_LAYR {
6c 61 79 72 # KMX_DWORD header.ident; // 0000 Section name - layr
sizeof(layr) # KMX_DWORD header.size; // 0004 Section length
# TODO: layr
01 00 00 00 # KMX_DWORD listCount
01 00 00 00 # KMX_DWORD rowCount
02 00 00 00 # KMX_DWORD keyCount
@ -319,11 +364,15 @@ block(list) # struct COMP_KMXPLUS_LAYR_LIST {
sizeof(list) # KMX_DWORD header.size; // 0004 Section length
01 00 00 00 # KMX_DWORD listCount (should be 3)
01 00 00 00 # KMX_DWORD indexCount (should be 3)
# first the null list
00 00 00 00 # KMX_DWORD lists[0].index
# lists, first the null list
block(listNull)
index(indexNull,indexNull,2) # KMX_DWORD list index
00 00 00 00 # KMX_DWORD lists[0].count
# now the null index
00 00 00 00 # KMX_DWORD indices[0] (null)
block(endLists)
# indices
block(indexNull)
index(strNull,strNull,2) # KMXPLUS_STR string index
block(endIndices)
block(loca) # struct COMP_KMXPLUS_LOCA {
6c 6f 63 61 # KMX_DWORD header.ident; // 0000 Section name - loca