Fixes#7419.
If the user attempts to add an invalid graphic (e.g. a .png file saved
with a .ico extension), Keyman Developer will no longer crash when
trying to load the file.
Note that while the keyboard will still compile with an invalid graphic,
Keyman for Windows will refuse to install it. I have not tested other
platform handling of such a situation.
Fixes#7425.
In the layout editor, the "Select Key" dialog was being shown sometimes
when using shortcuts such as Ctrl+V. The reason this happened was that
the shortcut handler in Delphi was capturing the keydown of the V key,
so the Ctrl event handler never saw it. Then, if you pressed Ctrl+V, and
released the Ctrl key before releasing the V key (which often happens
when you press a shortcut rapidly), the Ctrl event handler would receive
notification of the Ctrl key release and trigger the "Select Key"
dialog.
This fix shifts the Ctrl key event handler out of the keyboard editor
and into the top-level application events handler -- this is the best
place where we can preview key events before they are passed to the
shortcut handler and controls for processing.
This necessitated adding a general `ControlKeyPressedAndReleased` event
function to the TIKE editor base class. This is currently only used by
`UfrmKeymanWizard` and `UfrmOSKEditor`.
I noted that the OSK editor did not currently support the Ctrl key
event to select a new key. As a part of this fix, I added support for
this, to bring it into line with the Layout Editor and the Touch Layout
Editor.
Compiles a LDML keyboard .xml down to a KeymanWeb .js file. Currently
only supports some metadata.
Next step is to generate touch layout data, then to embed the binary kmx
data.
Fixes#7408.
For kmc*.cmd, enables source maps. If you are running kmc from node on
your own system, you may need to enable source maps in other ways.
Note that error reports should be going through to Sentry, and source
maps should already be used for those.
Relates to #4324 (but slightly orthogonal.)
We wanted some message classes to be handled in the lexical model editor
more cleanly, including drill-down to line of error. A few changes
required to make this work well:
1. Parse error messages from kmlmc. This is not perfect but works while
the two projects are kept in sync, which they always are for Keyman
Developer. Note that at this stage, .ts warnings are not captured in
this parser, as they are generated by tsc.
2. Drill-down in Wordlist Editor Frame to find line of error
3. Model editor reports ownership of .tsv files so they can be loaded
4. In case of model editor not open (e.g. building from project view),
the TSV standalone editor was not displaying the frame, so it never
actually worked.
5. If the text editor had never loaded, then FindError was effectively
a no-op; adds code to seek to error line after page load finishes.
6. Ensures that if we attempt to seek an error in a sub-file owned by
an editor (e.g. .tsv owned by .model.ts, .kvks owned by .kmn), that
the parent editor will be focused first. Does not verify all paths
here, just the tsv one.
Fixes#7005.
If a developer used single digit values in stores, unquoted (which is
not really the usual approach, but should work just fine for non-zero
values), the KMW compiler would emit invalid single-digit hexadecimal
escapes for them, e.g. `"\x1"` instead of `"\x01"`.
Sample code:
```
store(option) 1
if(option = 1) + 'a' > 'one'
if(option = 2) + 'a' > 'two'
+ '1' > set(option = 1)
+ '2' > set(option = 2)
```
It is not immediately obvious from this code, but the value `1` is
actually a character with value `'\x01'` or `U+0001`!
The more usual approach will not encounter this problem:
```
store(option) '1'
if(option = '1') + 'a' > 'one'
if(option = '2') + 'a' > 'two'
+ '1' > set(option = '1')
+ '2' > set(option = '2')
```
Note that the following is a compile error (due to internal use of
null terminated strings).
```
store(option) 0
```
Fixes#7090.
Fixes#7091.
While kmcomp loads most files just fine when paths with forward slashes
are passed in, it fails to parse target path correctly when building one
file out of a project.
For example, if the user runs:
```
kmcomp.exe -t khmer_angkor.kmn release/k/khmer_angkor/khmer_angkor.kpj
```
Then the following error arises:
```
khmer_angkor.kps: Error: 0001 Validation error: The system cannot find the path specified.
khmer_angkor.kps: Failure: Package C:\Projects\keyman\keyboards\source\khmer_angkor.kps had validation errors.
```
This patch ensures all paths passed in as command-line parameters are
converted to backslashes, matching the expected Windows format. While I
only needed to fix the `FParamTarget` parameter in order to address the
reported issues, for consistency I applied the same fix to all input
paths.
Splits file format reading, writing, and in-memory structures of .kmx,
.kvk, .kvks, .xml (ldml keyboard) into separate common module. Lots of
little fixups, sorry...
This will make it much easier for us to reuse these readers and writers
in future code.
Now has a shared object for all tests, reset between tests, and if the
test fails, prints any reported compiler messages.
Also updates kvk and kvks tests with refactored names from previous
commit.
Part of #7238.
Supports reading and writing .kvk files, and reading .kvks files,
to/from an in-memory VisualKeyboard object.
TODO:
- Full validation of .kvks files
- Writing .kvks files
- Some cleanup of API surfaces for consistency
Mocha with ts-register was failing with an error for Keyman Developer
Server.
```
Error: Debug Failure. False expression: Non-string value passed to
`ts.resolveTypeReferenceDirective`, likely by a wrapping package working
with an outdated `resolveTypeReferenceDirectives` signature. This is
probably not a problem in TS itself.
```
The `^4.5.4` version reference for typescript was too lax, and so npm
gave us typescript 4.8.3, which was the latest version in use in the
repo in this branch (in kmc-model). This is also why the build only
failed on this branch -- on master branch, the latest version referenced
was still 4.5.4.
Changing to `~4.5.4` ensures that it stayed on the 4.5.x series, and
mocha then ran version 4.5.5 of tsc.
This is something we should resolve when we move the entire repo to tsc
4.8+. Currently we are still on 4.5.
Note: it may be sensible to review all versioning for typescript,
because the minor version changes are causing functionality breaks,
which kinda violates the spirit of semver ("MINOR version when you add
functionality in a backwards compatible manner"). We can be more
restrictive by updating all package.json references to typescript to
`~4.5.4` instead of the current `^4.5.4` in use throughout. If/when we
do this, we will need to check our ts-node references also.
kmc-package had a number of gaps and errors. This fixes a bunch of
problems:
* Wrong case on XML elements
* Wrong metadata in system element
* Missing kmp.json in Files array (needs test in consumer apps later)
* Missing displayFont, oskFont in keyboard elements
* Including copyLocation when == 0
* Including an empty startMenu element
* Incorrect assumptions about location of source files in source/ folder
Note that support for followKeyboardVersion will come later; for now, it
uses the possibly-stale value from the Keyboard element in the .kps
file.