From e40a4eaacb69511bc55f67b502b92db30c04ce90 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Mon, 7 May 2018 14:12:11 +0700 Subject: [PATCH 1/5] Adds support for 'beep' in stores to KMW. Nothing for Developer yet. --- web/source/kmwcallback.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/source/kmwcallback.ts b/web/source/kmwcallback.ts index 1466efe325..84057bab42 100644 --- a/web/source/kmwcallback.ts +++ b/web/source/kmwcallback.ts @@ -83,7 +83,13 @@ namespace com.keyman { ['t']: 'n'; } - type ContextNonCharEntry = RuleDeadkey | ContextAny | RuleIndex | ContextEx | ContextNul; + class ContextBeep { + /** Discriminant field - 'b' for `beep` + */ + ['t']: 'b'; + } + + type ContextNonCharEntry = RuleDeadkey | ContextAny | RuleIndex | ContextEx | ContextNul | ContextBeep ; type ContextEntry = RuleChar | ContextNonCharEntry; /** @@ -507,6 +513,9 @@ namespace com.keyman { mismatch = true; } break; + case 'b': + this.beep(Ptarg); + break; default: assertNever(r); } From a89376871617e34bd8e80068594dc5a888d904e1 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Mon, 7 May 2018 14:39:12 +0700 Subject: [PATCH 2/5] Incorporates Developer and corrects the application of the KMW side. --- web/source/kmwcallback.ts | 29 +++++++++++++++---- .../TIKE/compile/CompileKeymanWeb.pas | 6 +++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/web/source/kmwcallback.ts b/web/source/kmwcallback.ts index 84057bab42..00f0467186 100644 --- a/web/source/kmwcallback.ts +++ b/web/source/kmwcallback.ts @@ -83,15 +83,17 @@ namespace com.keyman { ['t']: 'n'; } - class ContextBeep { + class StoreBeep { /** Discriminant field - 'b' for `beep` */ ['t']: 'b'; } - type ContextNonCharEntry = RuleDeadkey | ContextAny | RuleIndex | ContextEx | ContextNul | ContextBeep ; + type ContextNonCharEntry = RuleDeadkey | ContextAny | RuleIndex | ContextEx | ContextNul ; type ContextEntry = RuleChar | ContextNonCharEntry; + type StoreNonCharEntry = RuleDeadkey | StoreBeep; + /** * Cache of context storing and retrieving return values from KC * Must be reset prior to each keystroke and after any text changes @@ -513,9 +515,6 @@ namespace com.keyman { mismatch = true; } break; - case 'b': - this.beep(Ptarg); - break; default: assertNever(r); } @@ -776,11 +775,29 @@ namespace com.keyman { indexOutput(Pdn: number, Ps: KeyboardStore, Pn: number, Pelem: HTMLElement): void { this.resetContextCache(); + var assertNever = function(x: never): never { + // Could be accessed by improperly handwritten calls to `fullContextMatch`. + throw new Error("Unexpected object in fullContextMatch specification: " + x); + } + var indexChar = this._Index(Ps, Pn); if(indexChar !== "") { if(typeof indexChar == 'string' ) { this.output(Pdn,Pelem,indexChar); //I3319 - } else { + } else if(indexChar['t']) { + var storeEntry = indexChar as StoreNonCharEntry; + + switch(storeEntry.t) { + case 'b': // Beep commands may appear within stores. + this.beep(Pelem); + break; + case 'd': + this.deadkeyOutput(Pdn, Pelem, indexChar['d']); + break; + default: + assertNever(storeEntry); + } + } else { // For keyboards developed during 10.0's alpha phase - t:'d' was assumed. this.deadkeyOutput(Pdn, Pelem, indexChar['d']); } } diff --git a/windows/src/developer/TIKE/compile/CompileKeymanWeb.pas b/windows/src/developer/TIKE/compile/CompileKeymanWeb.pas index b10ba0e035..d45c8ca344 100644 --- a/windows/src/developer/TIKE/compile/CompileKeymanWeb.pas +++ b/windows/src/developer/TIKE/compile/CompileKeymanWeb.pas @@ -1111,7 +1111,11 @@ begin begin if rec.Code = CODE_DEADKEY then begin - Result := Result + Format('{d:%d}', [rec.Deadkey.DeadKey]); + Result := Result + Format('{t:''d'',d:%d}', [rec.Deadkey.DeadKey]); + end + else if rec.Code = CODE_BEEP then + begin + Result := Result + '{t:''b''}' end else //if rec.Code = CODE_EXTENDED then begin From 024c38d02b0e97f48e3ac261bd4d4c9d390a2c09 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Mon, 7 May 2018 15:34:35 +0700 Subject: [PATCH 3/5] Merges store typing information for a cleaner solution. --- web/source/kmwcallback.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/web/source/kmwcallback.ts b/web/source/kmwcallback.ts index 00f0467186..faad11d1f6 100644 --- a/web/source/kmwcallback.ts +++ b/web/source/kmwcallback.ts @@ -13,14 +13,14 @@ namespace com.keyman { * No constructors or methods since keyboards will not utilize the same backing prototype, and * property names are shorthanded to promote minification. */ + type PlainKeyboardStore = string; - type PlainKeyboardStore = string; + // TODO: Implement the new 'store object-orientation proposal. + export type KeyboardStoreElement = (string|StoreNonCharEntry); + export type ComplexKeyboardStore = KeyboardStoreElement[]; - // TODO: Implement the new 'store object-orientation proposal. - export type KeyboardStoreElement = (string|{'d': number}); - export type ComplexKeyboardStore = KeyboardStoreElement[]; + type KeyboardStore = PlainKeyboardStore | ComplexKeyboardStore; - type KeyboardStore = PlainKeyboardStore | ComplexKeyboardStore; type RuleChar = string; class RuleDeadkey { @@ -478,7 +478,14 @@ namespace com.keyman { } break; case 'a': - var lookup = (typeof(context[i]) == 'string' ? context[i] as string : {'d': context[i] as number}); + var lookup: KeyboardStoreElement; + + if(typeof context[i] == 'string') { + lookup = context[i] as string; + } else { + lookup = {'t': 'd', 'd': context[i] as number}; + } + var result = this.any(i, lookup, r.a); if(!r.n) { // If it's a standard 'any'... @@ -494,7 +501,8 @@ namespace com.keyman { } break; case 'i': - var ch = this._Index(r.i, r.o); + // The context will never hold a 'beep.' + var ch = this._Index(r.i, r.o) as string | RuleDeadkey; if(ch !== undefined && (typeof(ch) == 'string' ? ch : ch.d) !== context[i]) { mismatch = true; From 90d49c120d2a6b9e6fb33c80d3e85b22536481d7 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Tue, 8 May 2018 08:18:38 +0700 Subject: [PATCH 4/5] Minor tweaks to changes in kmwcallback.ts. --- web/source/kmwcallback.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web/source/kmwcallback.ts b/web/source/kmwcallback.ts index faad11d1f6..a77cbfa7f6 100644 --- a/web/source/kmwcallback.ts +++ b/web/source/kmwcallback.ts @@ -13,13 +13,12 @@ namespace com.keyman { * No constructors or methods since keyboards will not utilize the same backing prototype, and * property names are shorthanded to promote minification. */ - type PlainKeyboardStore = string; + type PlainKeyboardStore = string; - // TODO: Implement the new 'store object-orientation proposal. - export type KeyboardStoreElement = (string|StoreNonCharEntry); - export type ComplexKeyboardStore = KeyboardStoreElement[]; + export type KeyboardStoreElement = (string|StoreNonCharEntry); + export type ComplexKeyboardStore = KeyboardStoreElement[]; - type KeyboardStore = PlainKeyboardStore | ComplexKeyboardStore; + type KeyboardStore = PlainKeyboardStore | ComplexKeyboardStore; type RuleChar = string; @@ -89,7 +88,7 @@ namespace com.keyman { ['t']: 'b'; } - type ContextNonCharEntry = RuleDeadkey | ContextAny | RuleIndex | ContextEx | ContextNul ; + type ContextNonCharEntry = RuleDeadkey | ContextAny | RuleIndex | ContextEx | ContextNul; type ContextEntry = RuleChar | ContextNonCharEntry; type StoreNonCharEntry = RuleDeadkey | StoreBeep; From 1eb05734a39e0eea3ca3e10ac0b4007ac1c1f079 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Tue, 8 May 2018 08:25:30 +0700 Subject: [PATCH 5/5] Adds history.md info for web and developer. --- web/history.md | 3 +++ windows/src/developer/history.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/web/history.md b/web/history.md index 5e2d843a76..9bb213a04a 100644 --- a/web/history.md +++ b/web/history.md @@ -1,5 +1,8 @@ # KeymanWeb Version History +## 2018-05-08 10.0.90 beta +* Fixes support for Keyman-language 'beep' statements as part of keyboard stores. (#733) + ## 2018-05-07 10.0.89 beta * Fixes an issue with case sensitive virtual keys used by some Keyman keyboards. (#162) diff --git a/windows/src/developer/history.md b/windows/src/developer/history.md index d37ac97d18..f1ad063aa8 100644 --- a/windows/src/developer/history.md +++ b/windows/src/developer/history.md @@ -1,5 +1,8 @@ # Keyman Developer Version History +## 2018-05-08 10.0.1082.0 beta +* Fixes support for 'beep' statements in keyboard stores when compiling for web or mobile targets (#733) + ## 2018-05-03 10.0.1076.0 beta * Restrict modifier options to a small set by default in touch layout editor (#810) * Touch layout editor no longer leaves broken JSON when deleting or modifying some keys (#811)