Commit graph

133 commits

Author SHA1 Message Date
Eberhard Beilharz
aa36cfe961
fix(core): address code review comments
Some checks failed
Keyman Build Summary / Summarize build status checks (push) Has been cancelled
2026-03-24 12:43:11 +01:00
Eberhard Beilharz
382b5d45e3
fix(core): fix keydown/up handling for LDML keyboards
For LDML keyboards this change fixes the `emit_key` flag so that it has
the same value for the KeyDown and the KeyUp event. This fixes some
problems with stuck keys. Previously we would set `emit_key=TRUE` on
KeyDown but `emit_key=FALSE` on KeyUp for frame keys. This caused Linux
to never see the KeyUp event, resulting in a stuck key.

Also add unit tests that verifies that the actions that we get after
calling `km_core_process_event` are what we expect.

Fixes: #15569
Fixes: #15550
2026-03-02 17:27:36 +01:00
Eberhard Beilharz
2bd6cfd735
refactor(core): rename fields to start with underscore
Test-bot: skip
2026-03-02 17:27:15 +01:00
Eberhard Beilharz
d8a5f694da
refactor(core): fix whitespace
Build-bot: skip
Test-bot: skip
2026-03-02 17:26:14 +01:00
Eberhard Beilharz
b405bf5842
refactor(core): simplify loop for removing text
Instead of using an iterator to loop over the context items, incrementing
a counter on each iteration, and then finally removing the calculated
number of context items from the list, this change loops through the list
and looks at the last context item, removing it if necessary.

Follows: #15596
Test-bot: skip
2026-02-18 17:34:02 +01:00
Eberhard Beilharz
32bb1c8502
fix(core): fix iterator in backspace handling
This change replaces the reverse iterator loop that holds a stale iterator
across `pop_back()` calls with a pattern that directly accesses
`context.back()` on each iteration. This avoids undefined behavior from
iterator invalidation when mutating the list or vector.

While so far the previous code didn't show problems, it might still access
released memory depending on the implementation. The documentation for
`pop_back()` says "References and iterators to the erased element are
invalidated", so the previous implementation was clearly wrong.

Test-bot: skip
2026-02-18 15:58:45 +01:00
Steven R. Loomis
f1b3555114 feat(core,docs): improve kmxplus validation
- improve how validation works - a missing section does not mean an invalid section. distingush these.
- propagate errors for invalid sections
- update documentation of required sections

Fixes: #9446
2025-03-14 15:37:23 -05:00
Steven R. Loomis
2e7b5b1417 feat(core): check non-extended keys for bad unicode
- also, use U+FFFD in core if it's a bad char

Fixes: #9446
2025-03-14 09:31:38 -05:00
Steven R. Loomis
b2c3a46283
feat(core) Update core/src/ldml/ldml_processor.cpp
map bad chars to U+0020

Co-authored-by: Marc Durdin <marc@durdin.net>
2025-03-14 09:23:37 -05:00
Steven R. Loomis
d9602cede1 feat(core): assert that no noncharacter emitted from ldml_processor
- not counting markers, which have a special path

Fixes: #9446
2025-03-13 17:22:37 -05:00
Steven R. Loomis
da7c864f54 Merge remote-tracking branch 'origin/master' into fix/core/12298-get-key-list 2024-12-04 13:58:24 -06:00
Marc Durdin
9a01ac166d chore(core): Merge branch 'master' into fix/core/12619-disable-assertions-vcwin-release-build 2024-12-01 16:17:21 +07:00
Steven R. Loomis
c9643642a8 Merge remote-tracking branch 'origin/master' into fix/core/12298-get-key-list 2024-11-29 15:33:53 -06:00
Marc Durdin
b9b4ad4996 chore(developer): ifdef variables only used in assertions 2024-11-28 10:27:40 +07:00
Eberhard Beilharz
3dc3f040de
feat(core): implement loading KMX from blob
- split keyboard loading into loading KMX file into blob and then
  loading the keyboard processor from the blob.
- deprecate `km_core_keyboard_load`
- move file access next to deprecated method. This is now the only place
  that loads a file in Core; unit tests have some more places that
  load files.
- introduce GTest and add unit tests for loading from blob

Cherry-picked from `epic/web-core` branch.

Cherry-Pick-Commit: 1deaa323ad
Cherry-Pick-Commit: 59019cc8b7
Cherry-Pick-Commit: bc46458368
Cherry-Pick-Commit: d06aa29956
Cherry-Pick-Commit: 1c88166f6e
Cherry-Pick-Commit: 069cd21ecd
Cherry-Pick-Commit: 052ae2ec35
Cherry-Pick-Commit: 11a2a3ba3a

Part-of: #11293
Part-of: #8093
2024-11-27 15:30:05 +01:00
Steven R. Loomis
382b511dce feat(core): ldml: implementation for testing get_key_list()
- ldml::vkeys class updated to keep a set<> of keys
- fix the test case to not leak!

Fixes: #12298
2024-11-07 09:34:30 -06:00
Marc Durdin
96f288a83d fix(core): properly support 'other' modifier state with uint32_t type
While the modifier state property in core's API is 16-bit, internally
ldml_processor supports the modifier flag LDML_KEYS_MOD_OTHER with a
value of `0x10000`, which requires widening the value (we match the
32-bit size of the KMX_DWORD value from KMX+).

Note: this is not yet well unit-tested.

Relates-to: #11072
Fixes: #12057
2024-08-24 12:26:52 +08:00
Steven R. Loomis
fa1fd75157 fix(core): ldml fix for multiple marker deletion
- current code only deletes a single marker and falls through
- update the ldml test code, get rid of 'expected character' backspace logic (now that we have context object)
- update test cases
2024-04-25 16:59:20 -05:00
Steven R. Loomis
dc965f4e1a fix(core): ldml backspace processing should delete all markers
- current code would only delete a single marker and fall through
- should loop consuming all markers until a non-marker char is hit
2024-04-18 08:57:19 -05:00
Steven R. Loomis
8b5723028c chore(core): optimize ldml_event_state::emit_difference() when no difference
#11057
2024-03-27 08:18:03 -05:00
Steven R. Loomis
e8a8590eee fix(core): revert some interim fixes
- ldml_test_source fix moved off to issue #11083
- an optimization in ldml_processor also rolled back
2024-03-27 08:05:39 -05:00
Steven R. Loomis
18c6ecfc08 fix(core): fix 2 marker cases in ldml_event_state::emit_difference 🙀
- handle the case where old and new context strings are the same (i.e. no work to do).
- fix pointer arithmetic error in #10356 - the special case where one marker is being replaced by another. The named regression test didn't actually hit this case.

Fixes: bug(core): 'string too long' #11057
2024-03-25 16:45:01 -05:00
Steven R. Loomis
15b7a42829 feat(core): support normalization=disabled 🙀
- clean up process_output:  remove some unnecessary steps,
refactor into 3 functions, clarify
- reorder functions for ldml_state
- remove extraneous assert() clutter when the normalization
functions already assert/DebugLog at the innermost level

#10554
2024-02-06 16:09:18 -06:00
Steven R. Loomis
7572c9476e feat(developer): support normalization=disabled 🙀
- main core changes and test changes

#10554
2024-02-01 17:32:42 -06:00
Steven R. Loomis
78f81516c0 feat(core): report on (lack of) normalization 🙀
- report normalization

#10468
2024-01-31 18:22:23 -06:00
Steven R. Loomis
04a6e164d7 feat(core): ldml actions: updates per code review 🌱
- fix backspace processing
- fix k_102 - we can no longer test for context invalidation here
- fix a test that assumed non-const km_core_actions.output

For: #10410
2024-01-19 11:24:41 -06:00
Steven R. Loomis
6ea83391a7 Merge remote-tracking branch 'origin/epic/core/9999-normalization' into feat/core/10410-ldml-really-use-action-struct 2024-01-19 10:40:42 -06:00
Marc Durdin
249ed77835
Merge branch 'epic/core/9999-normalization' into chore/merge-master-into-core/9999-normalization 2024-01-19 17:42:40 +11:00
Steven R. Loomis
ae00eda4a0 chore(core): ldml shuffle some deck chairs 🌱
- move the emit_ and context functions into an ldml_event_state object

For #10410
2024-01-18 15:47:15 -06:00
Steven R. Loomis
8095977bec feat(core): ldml action struct test runner changes 🌱
- change ldml test suite, with TODOs
- backspace validation is different, as we don't know the expected char.

For: #10410
2024-01-18 22:55:06 -06:00
Steven R. Loomis
4c322ddb8a feat(core): ldml action struct 🌱
- update km_core_actions.output to be a const*
- for now, call state->actions().commit() from ldml_event_state::commit()

For: #10410
2024-01-18 22:26:46 -06:00
Steven R. Loomis
20a13fa682 feat(core): ldml attempt to use action struct 🌱
- not quite working

For: #10410
2024-01-18 17:00:04 -06:00
Steven R. Loomis
792329fba0
chore(core): tag unused args 2024-01-17 17:30:48 -06:00
Steven R. Loomis
f484615450 chore(core): ldml don't use queue action functions 🌱 2024-01-17 16:16:56 -06:00
Steven R. Loomis
c5d0e0525e feat(developer): 32 bit escapades 🙀
- escaping working, matching not yet

#10319
2024-01-13 12:55:51 -06:00
Steven R. Loomis
f38054f65a chore(core): split out some files 🙀
- markers/normalization really needs its own file
- split out ldml_markers.* from ldml_transforms.*
- split out ldml_utils.hpp for a common assert macro

#10320
2024-01-06 11:56:11 -06:00
Steven R. Loomis
b2b897970d feat(core): stacked markers 🙀
- renamed the single-segment functions to normalize_nfd_markers_segment() since they should only be run on a single segment
- commented out NFC for now, dead code
- add some additional checks/DebugLog around normalization

#10320
2024-01-06 11:33:51 -06:00
Steven R. Loomis
0d3458deef chore(core): comments in key-not-found 🙀
- typo fix
- clarify default behavior for missing keys

For: #9451
2023-12-12 18:43:00 -06:00
Steven R. Loomis
c975b61c9b
Merge branch 'fix/core/9451-key-not-found-epic-ldml' into fix/core/8069-todo-ldml-epic-ldml 2023-12-12 08:58:11 -06:00
Steven R. Loomis
1cd97fadb9 feat(core): ldml improve key-not-found 🙀
- move vkey_to_contextreset  table into a common spot in core
- assert that vk < 0x100 to avoid running off the table

For: #9451
2023-12-12 08:56:33 -06:00
Steven R. Loomis
cadf7a1e14 fix(core): remove a TODO-LDML 🙀
Fixes: #8069

(all of the rest are in other tickets)
2023-12-08 18:48:01 -06:00
Steven R. Loomis
1e32a2a963 feat(core): ldml improve key-not-found 🙀
- copy exception table for reset from VKScanCodes.cpp
- update test

For: #9451
2023-12-07 17:15:44 -06:00
Steven R. Loomis
2071d25745 feat(core): ldml_processor fix for markers 🙀
- don't skip markers when calling context_to_string()! Oops.
- update docs on ldml_processor::remove_text()
- update remove_text() to handle markers in the context string.

This is really: #9468
2023-12-07 19:54:16 +00:00
Steven R. Loomis
392c535270 feat(core): ldml improve key-not-found 🙀
- also affects markers, feat(core): normalization per spec for transforms/etc 🙀  #9468
- keep markers in nfd context string
- fix ldml test harness to handle context reset
- update test case
- still issues with overproduction of markers in the context

For: #9451
2023-12-06 18:33:51 -06:00
Steven R. Loomis
4d22b177af feat(core): ldml improve key-not-found 🙀
- unused nit fix

For: #9451
2023-11-29 14:34:33 -06:00
Steven R. Loomis
84cc59c174 feat(core): ldml improve key-not-found 🙀
- restructure keyup/keydown code some
- new utility function emit_invalidate_passthrough_keystroke()

For: #9451
2023-11-29 14:29:26 -06:00
Steven R. Loomis
11334ed7fa feat(core): ldml improve key-not-found 🙀
- distinguish between unmapped and 0-length output strings
- don't do any processing for 0-length output strings
- no change to developer, that will be next
- remove a comment referencing transform=no

For: #9451
2023-11-28 18:07:46 -06:00
Steven R. Loomis
e9e5665cb8 feat(core): ldml backspace transform 🙀
- refactor transform/normalization inner routine

For: #9450
2023-11-16 12:27:23 -06:00
Steven R. Loomis
d0c8ea5c88 feat(core): ldml backspace transform 🙀
- refactor keypress some (needs more)
- copypasta implementation of backspace transform

For: #9450
2023-11-16 12:25:15 -06:00
Steven R. Loomis
2f843d98f3 feat(core): marker normalization 🙀
- go back to NFD for the context, for now
- anticipating when the privatecontext is NFD but the public context is NFC
- also update the test cases

For: #9468
2023-11-14 16:36:15 -06:00