Commit graph

57 commits

Author SHA1 Message Date
Eberhard Beilharz
f0c3280517
fix(linux): Fix lost context after pressing K_SHIFT
This fixes typing `n>` with sil_ipa keyboard which no longer output
the expected `ŋ` because pressing the shift key reset the context.

For modifier key presses we now exit `KMX_ProcessEvent::ProcessEvent`
early.

This change also removes a redundant line from engine.c. Clearing
the context happens in `reset_context()` again if necessary.

Fixes #5591.
2021-08-18 19:26:45 +02:00
Eberhard Beilharz
c9497fd494
feat(common/core): Implement shiftFreesCaps and capsOnOnly 2021-08-06 16:13:58 +02:00
Eberhard Beilharz
f3ea1dafee
fix(common/core): Turn off capslock on key down
This change improves capslock handling with a capsAlwaysOff keyboard.
Previously, the caps lock indicator was turned on while holding down
the Caps Lock key. With this change we turn it off immediately. This
is done by forcing caps lock off even if the state already seems to
match.

Also, for capsAlwaysOff keyboards skip further processing of caps
lock key after we turned capslock off again.
2021-08-06 12:21:20 +02:00
Marc Durdin
d76eca052e fix(common/core/desktop): split smp for context chars
Fixes #5465.
Fixes #5561.

If a non-BMP Unicode char was emitted into the internal context, it was
being truncated to a WORD, which caused data loss for multi-group
keyboards.

Includes an update to a unit test to validate this fix.
2021-08-06 12:28:15 +10:00
Eberhard Beilharz
5cd1d0e432
refactor(common/core): Move comment to where it belongs 2021-08-04 12:25:49 +02:00
Marc Durdin
6c645ff03c chore: fix comment 2021-07-29 16:36:26 +10:00
Marc Durdin
bfdc3afb45 chore(common/core): refactor backspace handling
Moves the responsibility for deletion of markers when the users presses
the backspace key, from `kmx_processor::process_event` to
`KMX_ProcessEvent::ProcessGroup`. This has no effect on usage of Keyman
Core, but:

1. Simplifies the association between context and action further
2. Ensures that `m_actions` and `state->actions` will always be the
   same length, making future refactoring of these simpler
3. Allows us to use the index into the m_actions array for Debug events,
   which simplifies the interleaving of these for the upcoming Debugger.

When the user presses backspace at start of context (where there may be
markers in the cached context, but no characters), the kmx processor
will delete any markers prior to insertion point before requesting that
the consumer emit the backspace virtual key back to the application, to
allow the application to handle backspace at start of text.
2021-07-29 16:15:36 +10:00
Marc Durdin
60b1cc7545 chore: fixup damaged merge 2021-07-27 08:32:02 +10:00
Marc Durdin
5a94012f01
Merge branch 'chore/common/core/debug-additional-tests' into chore/common/core/5488-delete-markers-reliably 2021-07-27 08:23:24 +10:00
Marc Durdin
75ce10510a chore(common/core): address review comments
Also introduce a specific enum for backspace type rather than
inappropriately using the action item type enum.
2021-07-27 07:08:30 +10:00
Marc Durdin
796a2d4c85 chore(common/core): handle deletion of markers in actions
Fixes #5488.

This updates Keyman Core, corresponding tests, and Keyman Engine for
Linux to support deletion of markers through an action, ensuring that
the action queue does not desynchronize with the context.
2021-07-26 15:23:20 +10:00
Eberhard Beilharz
0eca43d4ea
feat(common/core): Implement capsAlwaysOff system store
This change implements the core part in a way that makes the tests
pass. This still needs corresponding changes in the engine.
2021-07-23 10:25:28 +02:00
Eberhard Beilharz
a16b320c17
chore(common/core/desktop): Update readme 2021-07-23 10:16:14 +02:00
Marc Durdin
4560ae4f69 feat(common/core): add action_index to all debug events 2021-07-22 16:33:31 +10:00
Marc Durdin
4fbfd33943 feat(common/core): debug action index
Adds an action_index to each debug event (not all debug events
need it). This allows the debugger to partially execute a rule
including the possibility of multiple updates to context.
2021-07-20 14:07:33 +10:00
Marc Durdin
05971a21cf chore(common): Merge branch 'master' into feat/common/core/desktop/kmx_debugger_events 2021-07-19 04:24:35 +10:00
Marc Durdin
104827f103 chore(common): rename kmx_process files 2021-07-19 04:07:31 +10:00
Marc Durdin
a389c68f07 chore(common): rename header 2021-07-19 03:43:35 +10:00
Marc Durdin
2a0adf27d0 chore(common): Merge branch 'master' into feat/common/core/desktop/kmx_debugger 2021-07-19 03:34:04 +10:00
Marc Durdin
ceec63493d chore: rename KMX_Processor to KMX_ProcessEvent 2021-07-19 03:29:44 +10:00
Marc Durdin
a99717c0a1 chore: rename source files to match master 2021-07-19 03:27:19 +10:00
Eberhard Beilharz
7d2f2cd928
refactor(common/core/desktop): Rename Load method
Rename KMX_Environment::Load to KMX_Environment::Set.

Fixes #5435.
2021-07-08 09:07:32 +02:00
Marc Durdin
37bb7b77cf feat(common/core/desktop): add debug events
Adds debug events to the kmx processor and corresponding unit tests.
This corresponds largely to the way that keyman32 emits debug events,
but with one key change: debug events in keyman32 are processed
synchronously, whereas in Keyman Core, the full set of debug events will
be returned alongside the final action list for the key event.

Given this difference, there will likely need to be some more data
returned in individual debug events, specifically around intermediate
context manipulation, as required for step-by-step debugging. However,
that will come in a subsequent PR.
2021-07-08 11:16:58 +10:00
Marc Durdin
e7d955147d chore: address review comments 2021-07-08 09:02:21 +10:00
Eberhard Beilharz
69a2e9ec27
refactor(common/core/desktop): Fix file and class names
- rename source files for `kmx_processor` -> `kmx_processor.*`
- rename class `KMX_Processor` -> `KMX_ProcessEvent` with source
  files `kmx_processevent.*`

Closes #5436.
2021-07-07 15:25:15 +02:00
Marc Durdin
29bc616b6d chore: address review comments 2021-07-06 15:31:04 +10:00
Marc Durdin
b1c0cbf405 chore(common): cleanup cross-platform code 2021-07-06 15:31:01 +10:00
Marc Durdin
2992e1ed83 feat(common/core/desktop): kmx debugger basic infrastructure
Part of #5013.

Adds all the debug infrastructure:

* public API headers
* public API implementation classes and functions
* basic unit tests
* helper classes for recording debug events
* minimal implementation of kmx-specific debug event signalling --
  just BEGIN and END events.
* tangential: unit test assertion macros and coloured output
2021-07-06 15:30:19 +10:00
Ross
889718830e fix(common): make xcode happy about empty loop 2021-06-29 17:29:33 +10:00
Ross
e83594038f fix(common): errors in comments 2021-06-29 17:03:31 +10:00
Ross
87d35c6d1c fix(common): get handle caller buffer size small than internal Fixes #5336 2021-06-29 16:42:53 +10:00
Marc Durdin
6aae56134a chore(common): rearrange rust source
Splits the rust source into a core library crate, and two interface
library crates - native and wasm. This avoids requiring WASM
dependencies on systems that don't require them, such as Debian
autopackagers.
2021-06-14 05:55:29 +10:00
Marc Durdin
67cb875eb0 chore(common): target-based dependencies 2021-06-10 17:08:30 +10:00
Marc Durdin
04806d389e chore(common): features by platform for cargo 2021-06-10 16:39:09 +10:00
Marc Durdin
0cbd91f6ce feat(common): keyboard_processor wasm build
Relates to #5069.

* Adds infrastructure for building keyboard_processor to WASM
* Updates unit tests to work in WASM environment
* Cleanup of documentation
* Consolidation of build script for most platforms
2021-06-08 08:35:59 +10:00
Marc Durdin
d0834e1f39 chore: address review comments 2021-06-07 08:44:15 +10:00
Eberhard Beilharz
e89fe746d7 fix(common): fix two Rust warnings 2021-06-02 13:52:02 +10:00
Marc Durdin
4d0c7d6395 fix(common): integer precision loss 2021-06-02 13:51:57 +10:00
Marc Durdin
8052ac9bbc feat(common): Rust infrastructure
Relates to #5069.

This establishes a baseline Rust build environment and linkage with
common/core/desktop.

This includes:

* build script build.sh which handles builds on Windows, macOS, *nix,
  with multiple targets on Windows only at present (M1 on mac to come
  when we do the mac integration work.)
* a mock rust processor with a very stubbed-out implementation
* bare bones interface between Rust library and C++ code
* unit tests on Rust and integration tests on C++ side to test the
  linkage between the libraries.

This should deliver a set of libraries that can be linked into our
target applications. For ease of deployment, it may be best to make
these static libraries, but I haven't made that decision at this point.
2021-06-02 13:51:50 +10:00
Marc Durdin
c9897bb38f fix(windows): cleanup edge cases in k32_load
Matches work completed in #5169 for Keyman Core, kmx_file.cpp.

While this code will hopefully disappear in 15.0, it's good to make sure
we aren't diverging beforehand.

Also tidies up a couple of other cases in `CopyKeyboard` in Keyman Core.
2021-05-31 10:58:23 +10:00
Eberhard Beilharz
68706c9451
fix(common/core/desktop): Fix failing tests on armhf
This change fixes the FixupKeyboard method. In the .kmx files on
disk array pointers for an empty array point to the end of the file
(one byte after the end of the data structure). When we expand the
pointers in FixupKeyboard this leads to `cgp->dpKeyArray` to point to an
unallocated memory location - this shouldn't matter since we don't
try to read or write at this location if the Key array is empty,
but armhf still seems to raise a SIGBUS, probably because we cast
the value to a `LPKEY`. This change sets `cgp->dpKeyArray` to `NULL`
if we have an empty key array, similar to what's done for the strings.

Closes #5072.
2021-05-27 17:14:06 +02:00
Eberhard Beilharz
7c78fb0adb
refactor(common/core/desktop): Use StringOffset in FixupKeyboard 2021-05-27 16:53:41 +02:00
Eberhard Beilharz
25124747b5
Merge pull request #5101 from keymanapp/fix/core/issue-5100
fix(common/core/desktop): Don't segfault on invalid .kmx file
2021-05-19 08:58:45 +02:00
Eberhard Beilharz
d91d27befa
fix(common/core/desktop): Don't segfault on invalid .kmx file
(Fixes #5100)
2021-05-18 19:14:35 +02:00
Eberhard Beilharz
99e9a7cf61
fix(common/core/desktop): Fix warnings when compiling for armhf
Compiling on armhf outputs two warnings:
- NULL used in arithmetic [-Wpointer-arith] (line 289 and 290)
- unused parameter ‘dwFileSize’ [-Wunused-parameter] (line 264)

(related to #5072)
2021-05-18 18:31:29 +02:00
Marc Durdin
fe2c1cd187 fix(windows): incxstr could run over buffer with malformed data
Fixes #4591.

I fixed incxstr in 4 places:

1. Common/Core: kmx_xstring.cpp
2. Engine: xstring.cpp
3. Test project importkeyboard importkeyboard.cpp
4. Test project m-to-p m-to-p.cpp

I updated mcompile to remove its own copy of incxstr (identical to that
in xstring.cpp) to reduce WETness but opted not to do so for the test
apps, which are pretty much throwaway anyway.

I note that there is more work we could do here; we need to check every
character as we increment so we don't miss a `U+0000` end of string with
malformed data. But I would like to tackle that as a separate job at
some point in the future after Core integration.
2021-03-05 12:50:29 +11:00
Eberhard Beilharz
268a42cba4
chore(common): Fix Windows build 2021-03-02 17:37:31 +01:00
Eberhard Beilharz
2421af506e
chore(common): write debug output to console
We have a `g_debug_ToConsole` variable. However, so far this was
always set to true and output to `syslog`. This change modifies
the default to `false`, and in that case logs to `syslog`. If
`g_debug_ToConsole` is true we no output to the console.

When running the KMX unit tests we set `g_debug_ToConsole` to true.
2021-03-02 16:55:22 +01:00
Marc Durdin
081471218e fix(common): add test case and fix smp bugs
Turns out that @darcywong00's suggestion for a test case was a Very Good
Idea. The SMP handling in Keyman Core had an egregious bug where only
half of a surrogate pair was being deleted in the UTF-16 context; see
kmx_processor.cpp 425-428. This was then masked by the test runner
masking the damage in the original test case; see kmx.cpp 193-203.

The new test case exercises a number of additional ways of manipulating
the context where surrogate pairs exist, to show we handle the deletion
properly within Keyman Core and in the test runner.
2021-01-29 16:05:07 +11:00
Marc Durdin
c26b9a2e2c fix(common): tweak surrogate pair deletions
Matches the work in #4360 for Windows, tweaks to documentation.

Note that this does not add the BK_SURROGATE flag at this point. I
will add that in a future update if it proves necessary, when working on
the core integration into Windows.
2021-01-28 08:40:28 +11:00