Commit graph

37 commits

Author SHA1 Message Date
Marc Durdin
d1dd8b022e fix(developer): buffer size for range expansions
Fixes #4830.

There remain some additional buffer size checks we should be doing in
`GetXString` but this will address the current issue by using the
standard maximum buffer size.
2021-03-31 19:10:12 +11:00
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
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
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
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
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
d8e70bea77 fix(developer): support for notany() and context()
This is part 1 of 2 of a fix for #917. This adds in version 14.0
targeting and a new function `KNO` which is used in one specific place:
when a context() statement references a notany() statement. This
minimizes any risk in this change because existing supported patterns
should compile identically.

If the compiler finds this pattern, it will enforce 14.0 minimum version
for web targets.
2020-11-04 13:49:48 +11:00
Marc Durdin
41fb5296e4
Update windows/src/developer/kmcmpdll/Compiler.cpp
additional braces

Co-authored-by: Joshua Horton <joshua_horton@sil.org>
2020-10-05 13:07:39 +11:00
Marc Durdin
50ad8335ef
Apply suggestions from code review
Co-authored-by: Joshua Horton <joshua_horton@sil.org>
2020-10-02 09:18:49 +10:00
Marc Durdin
508441ebf4 fix(developer): coverity reports for compiler
Addresses Coverity reports for compiler.cpp and other files.

Note that whitespace was reformatted on this PR. You may want to compare
with ignore-whitespace.
2020-09-30 14:20:41 +10:00
Marc Durdin
dd4ac89468 fix(developer): coverity issues for compiler.cpp
CID 309307 through 309313, 309318, 309321, 309371, 309388.
2020-09-30 11:58:28 +10: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
5928052d93 feat(windows): use crashpad and better call stacks
Also moves to sentry native 2.0.
2020-04-01 12:02:26 +11:00
Marc Durdin
3f41a6505f fix(developer): add calling convention 2020-03-31 20:20:02 +11:00
Marc Durdin
fed63d4690 feat(windows): sentry integration test points 2020-03-31 16:16:56 +11:00
Marc Durdin
6d0caaf3d2 feat(developer): allow use of ISO9995 in key ids
ISO9995 describes keys by positions, where E00 is 5th (top) row,
left-most key. This feature allows keyboard developers to use
clearly positional identifiers in place of K_ identifiers.
2020-02-26 23:25:08 +07: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
50a382d181 chore: typos 2019-12-08 17:27:26 +00:00
Marc Durdin
1b83de9b65 fix(developer): Hotkeys in .kmn unquoted
Fixes #138. Hotkeys in .kmn files no longer need to be quoted. This
update does not change compatibility with earlier versions of Keyman
Engine as the difference is entirely in the compiler.
2019-12-08 17:24:40 +00:00
Marc Durdin
e0767f2aeb fix(developer): use size_t instead of long 2019-11-17 09:16:08 +11:00
Marc Durdin
aa7c340dbb [Developer] Calls to non-Unicode versions of ctype functions could cause instability 2019-04-24 06:18:55 +07:00
Marc Durdin
738e1946a6 [Windows] Debug logging and proof of concept tests for keyboarding support within metro-style apps
[Windows] More tidyup and robustness for metro app support - debug cleanup and serialization of input (not quite finished)

[windows] Refactor serialized input code when used with key event thread model

[windows] Add consistent precompiled headers for other projects

[windows] Merge console window test into metro support

[Windows] Tidy up work and identify additional TODOs for metro-style app support

[Windows] Ensure error case falls through to default hook processing for console windows

[Windows] Refactor shared memory into memory mapped file so we can cross 32-64 bit boundary

[Windows] Tweaks to C++ security calls and parameters

[Windows] Start refactor of SerialKeyEvent* classes

[Windows] Rename to SerialKeyEventServer (refactoring)

[Windows] Complete refactoring of SerialKeyEventClient class

[Windows] Further encapsulation and cleanup with 'interfaces' to reduce header pollution

[Windows] Complete serialization fix with move of modifier state management from client thread to server thread to guarantee consistency

[Windows] Replace atom-based keyboard switching with memory mapped file indexed to avoid security constraints

[Windows] Fixup Left Alt+Shift interaction with serializer

[Windows] Use Windows 8.1 SDK for test
2018-10-18 20:00:49 +11:00
Marc Durdin
8083146768 [Developer] Treat files without preambles as UTF-8 unless they have non-UTF-8 sequences in them 2018-10-08 08:43:17 +11:00
Marc Durdin
de28a41025 Fix loop in test for match and nomatch validity 2018-04-30 08:09:40 +07:00
Marc Durdin
30cdf441e0 Fixes #718 - context and index are not valid in the output of a match or nomatch rule 2018-04-27 10:39:55 +07:00
Marc Durdin
ac83ebb8a9 Keyman Developer Compiler should warn on deprecated language tags for Keyman 10 keyboards 2018-02-16 10:53:01 +07:00
Marc Durdin
99144df7bf Fix issue with errors arising compiling when no version line specified 2018-02-16 10:03:59 +07:00
Marc Durdin
0241a358ac Add version 10.0 keyboard compiler and development tool support 2017-11-08 13:54:59 +07:00
Marc Durdin
ef0da35537 Rename VerifyKeyboardVersion to make it clear it is a macro -- it has a 'return' side-effect 2017-09-29 14:53:20 +07:00
Marc Durdin
2d65cc66ff Remove spurious warning 2017-09-28 19:29:15 +07:00
Marc Durdin
eba15549eb Make version store optional in compiler 2017-09-28 19:25:05 +07:00
Marc Durdin
2dfcbfe746 Tweak test for mixing left/right modifiers in same rule 2017-09-25 14:10:26 +07:00
Marc Durdin
737bd781a9 Warn if LCTRL/RCTRL or LALT/RALT are used in the same rule 2017-09-19 13:50:43 +07:00
Marc Durdin
b65b982584 Keyman Desktop and Keyman Developer open source 10.0 alpha seed (#121)
* Keyman for Windows 10.0 Open Source

* Squashed 'windows/src/ext/jedi/jedi/' content from commit f444ad2

git-subtree-dir: windows/src/ext/jedi/jedi
git-subtree-split: f444ad2da4693851e523f1ea6bd541f701904c24

* Squashed 'windows/src/ext/jedi/jcl/' content from commit d63d3c9fd

git-subtree-dir: windows/src/ext/jedi/jcl
git-subtree-split: d63d3c9fd9ff84efdd8159084ec6a60313644243

* Squashed 'windows/src/ext/jedi/jvcl/' content from commit bee19f3b4

git-subtree-dir: windows/src/ext/jedi/jvcl
git-subtree-split: bee19f3b46909fde2fa92c06cd2706f41d99f6c3

* Add required .res files

* Add required .res files

* Add docbook files (forced)

* Add required libxslt

* Add required jedi files

* Add installation files

* Tweak .gitignore for open

* CI

* Remove KMW from Developer source (#122)

* Remove KMW from Developer source (copies during build)

* Remove KMW from Developer source (copies during build)

* Remove KMW from Developer source (copies during build)

* Fixup release build and copy license, readme from kmw during build

* Remove obsolete build help documentation

* Keyman Engine 10 on Windows regression for shift states (#129)

* Improve #128 -- cleaner debug messages

* Fixes #127, shift state now resets correctly; and more work for #128

* Fixes #130 (#131)
2017-07-25 10:53:06 +07:00