mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-21 07:07:39 +00:00
feat(core): ldml json test executor 🙀
- can now use the new key2.kmap table to lookup keys. Basic test passes #7535
This commit is contained in:
parent
47b222e8a8
commit
4689c04533
3 changed files with 23 additions and 7 deletions
|
|
@ -668,9 +668,9 @@ COMP_KMXPLUS_KEY2_Helper::getKeys(KMX_DWORD i) const {
|
|||
return keys + i;
|
||||
}
|
||||
|
||||
const COMP_KMXPLUS_KEY2_KEY *
|
||||
COMP_KMXPLUS_KEY2_Helper::findKey(KMX_DWORD strId) const {
|
||||
for (KMX_DWORD i = 0; i < key2->keyCount; i++) {
|
||||
const COMP_KMXPLUS_KEY2_KEY*
|
||||
COMP_KMXPLUS_KEY2_Helper::findKeyByStringId(KMX_DWORD strId, KMX_DWORD &i) const {
|
||||
for (i = 0; i < key2->keyCount; i++) {
|
||||
if (keys[i].id == strId) {
|
||||
return &keys[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -503,7 +503,13 @@ public:
|
|||
const COMP_KMXPLUS_KEY2_FLICK_ELEMENT *getFlickElements(KMX_DWORD element) const;
|
||||
const COMP_KMXPLUS_KEY2_KMAP *getKmap(KMX_DWORD element) const;
|
||||
|
||||
const COMP_KMXPLUS_KEY2_KEY *findKey(KMX_DWORD strId) const;
|
||||
/**
|
||||
* Search for a key by string id.
|
||||
* @param strID id to search for
|
||||
* @param index on exit, index of item if found. Undefined otherwise.
|
||||
* @return pointer to key or nullptr
|
||||
*/
|
||||
const COMP_KMXPLUS_KEY2_KEY *findKeyByStringId(KMX_DWORD strId, KMX_DWORD &index) const;
|
||||
|
||||
private:
|
||||
const COMP_KMXPLUS_KEY2 *key2;
|
||||
|
|
|
|||
|
|
@ -405,15 +405,25 @@ void LdmlJsonTestSource::set_key_from_id(key_event& k, const std::u16string& id)
|
|||
}
|
||||
|
||||
// OK. Now we can search the keybag
|
||||
auto *key2 = kmxplus->key2Helper.findKey(strId);
|
||||
KMX_DWORD keyIndex = 0;
|
||||
auto *key2 = kmxplus->key2Helper.findKeyByStringId(strId, keyIndex);
|
||||
assert(key2 != nullptr);
|
||||
if (key2 == nullptr) {
|
||||
k = {0, 0};
|
||||
return;
|
||||
}
|
||||
|
||||
k.vk = key2->vkey;
|
||||
// TODO: modifier!
|
||||
// Now, look for the _first_ candidate vkey match in the kmap.
|
||||
for (KMX_DWORD kmapIndex = 0; kmapIndex < kmxplus->key2->kmapCount; kmapIndex++) {
|
||||
auto *kmap = kmxplus->key2Helper.getKmap(kmapIndex);
|
||||
assert(kmap != nullptr);
|
||||
if (kmap->key == keyIndex) {
|
||||
k = {(km_kbp_virtual_key)kmap->vkey, (uint16_t)kmap->mod};
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Else, unfound
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue