Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(developer): ldml scan codes support 🙀 #9615

Merged
merged 28 commits into from
Oct 3, 2023

Conversation

srl295
Copy link
Member

@srl295 srl295 commented Sep 22, 2023

  • pivot: this now dynamically generates the vkey map based on CLDR scan codes
  • add infrastructure to detect imported items
  • warn (hint) if user adds a custom scancode
  • also includes an LDML resource update - including removal of the vkeys, see feat(core): ldml vkey support 🙀 #7135
  • also minor, use source maps when launching kmc from tests.

Fixes: #9403
@keymanapp-test-bot skip

For: #9403

- unicode-org/cldr:f16d66601f309f29a64a897282fdcab440d42661
- No local modifications neded1
For: #9403

- read implied imports for scancodes
For: #9403

- use Symbols to track import status
For: #9403

- improve how forms are read in the XML structure
- warnings when custom (non-default-import) scancodes are loaded
- error, as usual, when an unknown form is present
For: #9403

- unit test the set and row count for codes
- fix errors!
@srl295 srl295 requested a review from mcdurdin as a code owner September 22, 2023 22:58
@srl295 srl295 self-assigned this Sep 22, 2023
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite ready to approve this, sorry!

common/web/types/src/consts/virtual-key-constants.ts Outdated Show resolved Hide resolved
common/web/types/src/consts/virtual-key-constants.ts Outdated Show resolved Hide resolved
common/web/types/src/consts/virtual-key-constants.ts Outdated Show resolved Hide resolved
common/web/types/src/consts/virtual-key-constants.ts Outdated Show resolved Hide resolved
common/web/types/src/consts/virtual-key-constants.ts Outdated Show resolved Hide resolved
Comment on lines 216 to 218
static impliedImport = Symbol.for('@keymanapp:implied_import');
/** item came in via import */
static import = Symbol.for('@keymanapp:import');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a new namespace that we need to be careful with -- the @keymanapp Symbol namespace. Conceptually I think it is fine but I am just a little wary about future trouble with it. Might be good to use a longer prefix, for disambiguation e.g.:

Suggested change
static impliedImport = Symbol.for('@keymanapp:implied_import');
/** item came in via import */
static import = Symbol.for('@keymanapp:import');
static impliedImport = Symbol.for('@keymanapp:common/ldml/implied_import');
/** item came in via import */
static import = Symbol.for('@keymanapp:common/ldml/import');

Also, just verifying is this just a way of tagging arbitrary structures with an "imported" flag? And you wanted to use this to avoid potential stumbling blocks in the way we use those structures, because it won't be an interable key on an object?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On reflection, I think this doesn't need a named symbol at all. this symbol should be used only within one run of kmc. it doesn't need to be independently detected. I will drop the namespace.

yes, it's just a way to tag the structure as imported - it's not iterable on the object, it doesn't affect the API at all at any level. It's metadata answering the question "how did this data object come in?"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK here?

developer/src/kmc-ldml/src/compiler/messages.ts Outdated Show resolved Hide resolved
For: #9403

- Just use a local Symbol() instead of a named one, there's no reason for a namespace here.
For: #9403

- fix a bad comment
- Warn_UnsupportedCustomForm (formerly hint)
For: #9403

- per review comments
- track CLDR PR 3282
@srl295 srl295 requested a review from mcdurdin September 25, 2023 22:08
@srl295
Copy link
Member Author

srl295 commented Sep 25, 2023

@mcdurdin ptal

@srl295
Copy link
Member Author

srl295 commented Sep 28, 2023

i'm temporarily skipping the scancode test— to show that the LDML updates are otherwise passing.

- at least make sure we're using a consistent (if wrong) vkey for each scancode?

for: feat(developer): ldml scancodes 🙀  #9403
- emit scancodes.json

for: feat(developer): ldml scancodes 🙀  #9403
@srl295
Copy link
Member Author

srl295 commented Sep 29, 2023

temporary file output => https://gist.github.com/srl295/48685c96bb23ee19ce1f14428ed5d91c

 {
  "scan": "0A",
  "vname": "K_9",
  "vcode": 57
 },
 {
  "scan": "0B",
  "vname": "K_0",
  "vcode": 48
 },
 {
  "scan": "0C",
  "vname": "K_HYPHEN",
  "vcode": 189
 },

@mcdurdin
Copy link
Member

That works, a bit verbose, but certainly easy to work with. It will be a separate generated file?

Evil alternative:

const scancodes = [
  ["0A","K_9",57],
  ["0B","K_0",48],
  ["0C","K_HYPHEN",189]
].map(x => ({scan:x[0], vname:x[1], vcode:x[2]}));

@mcdurdin mcdurdin modified the milestones: A17S22, A17S23 Sep 30, 2023
@srl295 srl295 requested a review from mcdurdin October 1, 2023 00:02
@srl295
Copy link
Member Author

srl295 commented Oct 1, 2023

@mcdurdin PTAL at progress but TODO:

  • unit test: verify that scan code map is 1:1
  • kmc: error if CLDR scancode results in no vkey

Is there any other checking needed?

@srl295
Copy link
Member Author

srl295 commented Oct 1, 2023

  0x56: k.K_oE2, // << Dup
  0x73: k.k_oC1,
  0x7D: k.K_oE2, // << Dup

except we already have dups.

- spec: 'hardware' is no longer an enum but a str.
Ripple effects here.
- custom scancodes and layouts are, interestingly, supported. But it's a warning.
- tests for bad scancodes.

Fixes: #9403
@srl295
Copy link
Member Author

srl295 commented Oct 1, 2023

Okay, PTAL.

  • see if the scancode map needs updating. But it's in one place! It was already not 1:1

@mcdurdin
Copy link
Member

mcdurdin commented Oct 2, 2023

  0x56: k.K_oE2, // << Dup
  0x73: k.k_oC1,
  0x7D: k.K_oE2, // << Dup

except we already have dups.

This would only be a problem if both 0x56 and 0x7D scan codes appear on the same hardware keyboard, which they do not: 0x56 is on ISO and ABNT2, and 0x7D is on JIS.

Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

common/web/types/src/consts/virtual-key-constants.ts Outdated Show resolved Hide resolved
developer/src/kmc-ldml/test/fixtures/basic.txt Outdated Show resolved Hide resolved
@srl295
Copy link
Member Author

srl295 commented Oct 2, 2023

  0x56: k.K_oE2, // << Dup
  0x73: k.k_oC1,
  0x7D: k.K_oE2, // << Dup

except we already have dups.

This would only be a problem if both 0x56 and 0x7D scan codes appear on the same hardware keyboard, which they do not: 0x56 is on ISO and ABNT2, and 0x7D is on JIS.

Maybe I should exclude this specific dup.

- fix casing of k_oC1
- allow vkey 226 to be doubly defined
- drop LdmlVkeyNames table and test, not needed anymore (was for vkey #7135)

Fixes: #9403
@mcdurdin
Copy link
Member

mcdurdin commented Oct 2, 2023

Maybe I should exclude this specific dup.

Sounds sensible -- then we can track if future dups appear.

- fixes to the special case test

Fixes: #9403
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@srl295 srl295 merged commit 01c171c into master Oct 3, 2023
2 checks passed
@srl295 srl295 deleted the feat/developer/9403-scancodes-epic-ldml branch October 3, 2023 13:55
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.185-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(developer): ldml scancodes 🙀
3 participants