Commit graph

101 commits

Author SHA1 Message Date
Marc Durdin
5eb0aec0e8
Merge pull request #4691 from keymanapp/fix/developer/named-code-constants-end-of-line-test
fix(developer): support named character codes at end of line
2021-03-16 23:26:03 +11:00
Marc Durdin
12184f1857 fix(developer): support named character codes at end of line
If a named character code was followed by a `\n`, it would not be
recognised.
2021-03-16 13:49:55 +11:00
Marc Durdin
4f958985a0 fix(developer): &CasedKeys and &MnemonicLayout are not compatible together
The test for `&mnemoniclayout` was incorrectly failing to check the
actual state of `&casedkeys`, which broke all mnemonic layouts.
2021-03-16 13:46:34 +11:00
Marc Durdin
791edee8ba
Merge pull request #4596 from keymanapp/fix/windows/4591-incxstr-potential-buffer-overrun
fix(windows): incxstr could run over buffer with malformed data
2021-03-05 14:18:02 +11: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
Marc Durdin
6a247cd081 fix(developer): tidy up expansions tests 2021-03-05 06:49:13 +11:00
Marc Durdin
e9e4e7bcb6 feat(developer): &CasedKeys system store
Fixes #2241.

The `&CasedKeys` system store is a compiler feature that reduces the
repetitive nature of keyboard rules for `CAPS` and `NCAPS`. The
`&CasedKeys` system store defines a list of virtual keys for which
'normal' Caps Lock rules apply. This store has no default value, for
backward compatibility.

Once this store is defined, then you can define just the unshifted and
shifted versions of a rule, and Keyman Developer will synthesize the
`CAPS` and `NCAPS` versions of the rule. For example, you may have the
following rules:

```
store(&CasedKeys) [K_A]
+ [K_A] > 'α'
+ [SHIFT K_A] > 'Α'
```

These would be replaced by the compiler with:

```
store(&CasedKeys) [K_A]
+ [NCAPS K_A] > 'α'
+ [SHIFT CAPS K_A] > 'α'
+ [CAPS K_A] > 'Α'
+ [SHIFT NCAPS K_A] > 'Α'
```

You can also use this functionality with characters in the key part of
the rule:

```
store(&CasedKeys) 'a'..'c'
+ 'a' > 'α'
+ 'A' > 'Α'
```

and the compiled expansion would be similar:

```
store(&CasedKeys) [K_A] [K_B] [K_C]
+ [NCAPS K_A] > 'α'
+ [SHIFT CAPS K_A] > 'α'
+ [CAPS K_A] > 'Α'
+ [SHIFT NCAPS K_A] > 'Α'
```

This feature is backwardly compatible with Keyman 6.0, as it is entirely
implemented in the compiler.

This feature is not compatible with mnemonic layouts, and the keys
defined in the `&CasedKeys` store must be the unshifted base keys as
found on a US English keyboard, or you can use ISO9995 identifiers if
you prefer.

If you define a rule where you specify either `NCAPS` or `CAPS`, for a
key found in the store, then no change will be made to that rule. You
can also continue to define rules which use `NCAPS` or `CAPS` for keys
not found in the store.

As a side-benefit, this allows the visual designer to be used and
support Caps Lock, although at this stage, the `&CasedKeys` store is not
surfaced in the visual designer.
2021-03-04 13:41:04 +11:00
Marc Durdin
49131de2c6 chore: fixup encoding 2021-03-04 10:15:53 +11:00
Marc Durdin
7e424aaa62 chore(developer): tweak expansion test 2021-03-04 10:12:24 +11:00
Marc Durdin
fe5de67c1f feat(developer): Range expansions
Relates to #2241.

Range expansions are a new language feature that reduce verbosity in
Keyman Keyboard Language (.kmn) files by making it possible to collapse
sequential ranges with a new `..` operator. It is envisioned that these
will be used primarily in stores.

Two kinds of expansions are available: character ranges, and virtual key
ranges.

The syntax is:

```
char '..' char
vkey '..' vkey
```

Where the `char` terminator is a single normal character, and the `vkey`
terminator is a single virtual key. `outs` is permissible for
terminators but no other statement is allowed. Whitespace is per normal
Keyman keyboard language syntax.

Character ranges will replace the range with the set of characters
between the terminators, based on the Unicode value of the terminators.

Examples:

```
store(alphabet) 'a' .. 'z'
store(alpha_not_bq) 'ac'..'pr'..'z'
store(capitals) U+0041 .. U+005A
```

Virtual key ranges work in a similar fashion, but with virtual keys. The
starting and terminating virtual key must have the same shift state.
This will be most useful for character and numeric virtual keys, as the
ranges are based on the numeric value of the virtual key as defined by
Windows, not its position on the keyboard.

Examples:

```
store(alphakeys) [K_A] .. [K_Z]
store(numkeys) [K_0] .. [K_9]
```

Ranges must be positive, that is, you cannot use `'z' .. 'a'`.

While this expansion is not expected to be very useful in rules, it is
still permitted. `context()` and other offsets are calculated on the
expanded form, not the collapsed form. Similarly, `any()`/`index()`
offsets are calculated on the expanded form.

'a' .. 'z' > context(3)  c this produces 'c', not 'z'

Because ranges are expanded at compile time, ranges that are overly
long will result in an error, so you cannot use, for example:

```
store(AllUnicode) U+0020 .. U+10FFFF
```

The precise maximum length of a range is dependent on the context where
it is used.

The changes are entirely compiler-based; no change is made to the .kmx
file format or to the Keyman apps.
2021-03-04 09:43:30 +11:00
Marc Durdin
1fcfefa3cf fix(developer): support for smp names 2021-03-01 16:05:17 +11:00
Marc Durdin
17c94770ef chore(windows): update test project 2021-03-01 10:34:30 +11:00
Marc Durdin
26b1d777f7 fix(developer): Improve stability of named code constants
Fixes #4423.

Using a named character constant with a store name that included
characters outside ascii could cause kmcmpdll to crash with an assertion
failure.

This fix allows store names defined in the .kmn file to use characters
outside ascii.

Note that more work needs to be done on which characters are acceptable
to use, as this is somewhat implementation-specific according to the C++
specification for `iswalpha`.

Added a test case to verify various named code constant examples.

Also removes dead code for `IsCJKUnifiedIdeograph` as this was never
used and somewhat pointless in any case.

NamedCodeConstants.cpp could stand to be rewritten using `std::map` or
equivalent. Current implementation is pretty icky.
2021-03-01 10:25:06 +11:00
Marc Durdin
9b0daf5652
Merge pull request #4410 from keymanapp/fix/developer/4280-if-nul-start-of-context
fix(developer): Compiler check for if and nul at start of context
2021-02-09 06:47:14 +11:00
Marc Durdin
0c782e22d3 fix(developer): Compiler check for if and nul at start of context
Fixes #4280.

Adds checks to verify that `if()`, `platform()`, `baselayout()` and
`nul` are at the start of the context in the appropriate order.

Adds unit tests to validate these checks.

These are conditions that have been present in earlier versions of
Keyman but not enforced until now. Keyboards that do not meet these
conditions would not work correctly in all circumstances and should be
updated to meet the requirements.

An alternative would have been to reorder the context string but that is
much more complex as manipulation would also have been required for the
output string. The enforced order is logical and reduces confusion in
any case.

Updated documentation coming along shortly.
2021-02-03 15:28:53 +11:00
Marc Durdin
83b8c4af08 chore(windows): tests should be case-sensitive
DUnitX by default does case-insensitive string equality assertions, and
we don't really want to make that assumption.

There was one minor fail uncovered in Keyman.System.UILanguageManager as
a result of this -- it now returns a matching entry as found in the
list of UI languages, rather than the input, to get same case as the UI
language list entry.

Thank you @ermshiperete.
2021-02-03 06:52:52 +11:00
Marc Durdin
b964485bf2 fix(windows): add makefile 2021-01-25 17:37:33 +11:00
Marc Durdin
7c3bbeda15 fix(windows): tweaks for strings.xml support
* Process setup strings also
* Remove legacy references to cust files from TIKE
* Add unit test to Makefile
2021-01-25 13:41:56 +11:00
Marc Durdin
4bc1730eed fix(windows): improve support for strings.xml
Fixes #4264.

The Android strings.xml format that we now use with Keyman Desktop has a
number of escapes that must be supported in order for text strings to be
rendered correctly, including: @, ?, ', ". Furthermore, positional
parameters have a slightly different format which we should transform on
load.

This change includes a unit test androidstringtokeymanlocalestring.
2021-01-25 11:17:44 +11:00
jahorton
a4aa945dfd fix(developer/compilers): kmlmc package.json no longer needs reset during build 2021-01-20 12:42:53 +07:00
Marc Durdin
5d606f0f4d fix(windows): context mismatch with if and deadkey manual test 2021-01-18 10:16:14 +11:00
Marc Durdin
498100f78b fix(windows): split signed and unsigned versions of setup.exe 2020-12-03 14:56:25 +11:00
Marc Durdin
0b62095726 feat(developer): improve downlevel support for new special labels 2020-11-23 06:23:47 +11:00
Marc Durdin
83325e878c feat(developer): add new touch layout special tags
Fixes #3863.

This adds the new `*RTLEnter*` and other tags introduced in #3851 to
the touch layout editor, and adds validation for use in 14.0 keyboards.

Due to a limitation in the compiler architecture, use of these tags
will not trigger the automatic keyboard versioning functionality; the
keyboard developer must explicitly specify `store(&VERSION) '14.0'`.

Also:

* synchronised error codes between .h and .pas.
* synchronised touch layout tags between Developer and KeymanWeb, and
  cleaned up builder.js usage thereof.
* added support for KeymanwebOsk font override when special tags are
  identified.
* added basic tests to ensure that the compiler is catching use of these
  tags as needed.
* updated keymanweb-osk.ttf font in Developer.
2020-11-18 08:58:57 +11:00
Joshua A. Horton
d6c90d1ae0 fix(developer): more same-build local change reversion 2020-11-16 14:13:49 +07:00
Marc Durdin
c9f9bfb2c2 fix(windows): Start Keyman on Demand - tasks
Fixes #3562.

Second part of the two-part special with #3772. When Keyman
Configuration starts, it creates a task that is launched whenever a
specific Keyman event with id 256 is added to the Event Log. This task
launches keyman.exe to start Keyman (and if Keyman is already running,
the newly launched process will exit with no side effects).

This feature is behind a new feature flag `Flag_UseAutoStartTask`, so it
can be disabled in the event of compatibility issues.

The task is created or updated on each launch of Keyman Configuration
(or Keyman via the 'Keyman' shortcut in the Start Menu), and is
intended to be self-maintaining.

The test_starttask project (4 of the 12 files) is just a wrapper around
the start TKeymanStartTask class to allow for manual testing. No unit
tests for this at this time; I think it would be difficult to unit test
this effectively.
2020-10-28 08:16:38 +11:00
Marc Durdin
e8d3a0eb14 fix(windows): exclude keymanmc from sigcheck 2020-10-28 08:15:24 +11:00
Marc Durdin
53a197fba5 chore(windows): Move to Windows SDK 10.0.17763.0
This removes the requirement for the Windows 8.1 SDK.
2020-10-05 14:11:34 +11:00
Marc Durdin
d5790ca9b6 fix(windows): cleanup pointer to int typecasts
Fixes #3084.

This does two things:

1. Cleans up a bunch of places where we used to use `(int)` typecasts
   for pointer math, which was problematic. We now use `(INT_PTR)` per
   MSDN https://docs.microsoft.com/en-us/windows/win32/winprog64/rules-for-using-pointers
   and then cast that down to `(int)` where necessary, e.g. when storing
   string lengths which are never going to be more than a few hundred
   characters! Doing this explicitly helps to clarify that we are aware
   of the typecast and believe it to be safe.

2. Adds in some build infrastructure for future use of Coverity Scan
   https://scan.coverity.com/ which we plan to use for further code
   quality updates. I have submitted the project to Coverity and are
   now waiting for approval so we can check results. Once we have
   approval, I do plan to add this to the nightly build (we need to
   keep submissions under 3 builds/day).

   Note: I have not yet added Keyman Core (Windows) to this project,
   nor are we currently building Keyman Core (macOS) or Keyman for
   Linux, but we should consider adding those in future.
2020-09-24 14:39:59 +10:00
Marc Durdin
3a4f00b4da feat(windows): set default UI language at install 2020-07-31 15:44:51 +10:00
Marc Durdin
220d530c08 refactor(windows): update references to locale.xml to strings.xml 2020-07-29 19:38:53 +10:00
Marc Durdin
2563624810 fix(windows): more i18n cleanup:
* Remove localedef.dtd file and infrastructure
* Remove ftMessages enum value
2020-07-29 08:03:30 +10:00
Marc Durdin
1e2c4f52cb feat(windows): unused strings check script 2020-07-28 09:28:59 +10:00
Marc Durdin
e194076d40 fix(windows): fix certificate tests 2020-04-01 15:35:18 +11:00
Marc Durdin
22238d7070 fix(windows): skip checking sentry.x64.dll signature 2020-03-28 06:22:06 +11:00
Marc Durdin
520fd5b131 fix(windows): ignore sentry.dll in sigcheck 2020-03-18 21:12:32 +11:00
Marc Durdin
1533727e80 fix(windows): release build test depended on version.txt 2020-03-18 20:50:32 +11:00
Marc Durdin
e7c5c8e9b0
Merge branch 'master' into fix/developer/1448-zero-length-store-names 2019-12-12 07:26:08 +11:00
Marc Durdin
463e61039a fix(developer): zero length store names
Fixes #1448. Zero-length store names should not
be permitted by the compiler.
2019-12-11 05:52:20 +11:00
Marc Durdin
1b531100ce chore(developer): remove references to TIKE
Fixes #1527.
2019-12-09 18:41:10 +00:00
Marc Durdin
6325954549
Merge pull request #2396 from keymanapp/feat/developer/2173-model-editor
feat(developer): Lexical Model editor
2019-12-09 09:08:04 +00:00
Marc Durdin
e6ab6cbbd4 chore: cleanup gitignore 2019-11-30 07:14:21 +00:00
Marc Durdin
dd0ee48a78 chore: add unit test to build 2019-11-28 09:47:20 +00:00
Marc Durdin
8f21a6bcff feat(developer): x64 compiler
unit test for structure sizes. This validates that the Pascal and C++
structure definitions are identical in size for each platform that they
are compiled for (x86 and x64).

Note that this uncovered an existing discrepancy in FILE_KEYBOARD. ;-)
2019-11-28 09:43:46 +00:00
Marc Durdin
4804c11592 feat(developer): Model editor, first brush strokes 2019-11-25 15:00:21 +11:00
Marc Durdin
fff86bc1cf fix(windows): RSP-19902 was fixed in Delphi 10.3 so unwind workaround 2019-10-28 09:28:20 +11:00
Marc Durdin
36f9e470a6 [Windows] Address .MD to .md and case consistency 2019-10-24 06:28:06 +07:00
Marc Durdin
f7de41ca7e [Developer] Call build.sh instead of npm directly for lexical model compiler tests 2019-10-03 05:09:06 +10:00
Marc Durdin
5485e2c5b1 [Developer] npm install before running tests 2019-09-01 10:40:16 +10:00
Marc Durdin
8fc9057318 [Developer] Actually add the test to the build 2019-09-01 10:27:37 +10:00