diff --git a/common/web/types/src/ldml-keyboard/ldml-keyboard-xml.ts b/common/web/types/src/ldml-keyboard/ldml-keyboard-xml.ts index 87f0b0515d..9d4a8e3a8d 100644 --- a/common/web/types/src/ldml-keyboard/ldml-keyboard-xml.ts +++ b/common/web/types/src/ldml-keyboard/ldml-keyboard-xml.ts @@ -168,9 +168,9 @@ export interface LKDisplayOptions { }; export interface LKDisplay { - to?: string; + output?: string; display?: string; - id?: string; + keyId?: string; }; export interface LKDisplays { diff --git a/developer/src/kmc-ldml/src/compiler/disp.ts b/developer/src/kmc-ldml/src/compiler/disp.ts index ade215b1fa..b5389103c1 100644 --- a/developer/src/kmc-ldml/src/compiler/disp.ts +++ b/developer/src/kmc-ldml/src/compiler/disp.ts @@ -11,8 +11,8 @@ import { MarkerTracker, MarkerUse } from "./marker-tracker.js"; export class DispCompiler extends SectionCompiler { static validateMarkers(keyboard: LDMLKeyboard.LKKeyboard, mt : MarkerTracker): boolean { - keyboard.displays?.display?.forEach(({ to }) => - mt.add(MarkerUse.match, MarkerParser.allReferences(to))); + keyboard.displays?.display?.forEach(({ output }) => + mt.add(MarkerUse.match, MarkerParser.allReferences(output))); // no marker references in 'id' return true; } @@ -28,23 +28,23 @@ export class DispCompiler extends SectionCompiler { const ids = new Set(); if (this.keyboard3.displays?.display) { - for (const { to, id } of this.keyboard3.displays?.display) { - if ((to && id) || (!to && !id)) { - this.callbacks.reportMessage(CompilerMessages.Error_DisplayNeedsToOrId({ to, id })); + for (const { output, keyId } of this.keyboard3.displays?.display) { + if ((output && keyId) || (!output && !keyId)) { + this.callbacks.reportMessage(CompilerMessages.Error_DisplayNeedsToOrId({ output, keyId })); return false; - } else if (to) { - if (tos.has(to)) { - this.callbacks.reportMessage(CompilerMessages.Error_DisplayIsRepeated({ to })); + } else if (output) { + if (tos.has(output)) { + this.callbacks.reportMessage(CompilerMessages.Error_DisplayIsRepeated({ output })); return false; } else { - tos.add(to); + tos.add(output); } - } else if (id) { - if (ids.has(id)) { - this.callbacks.reportMessage(CompilerMessages.Error_DisplayIsRepeated({ id })); + } else if (keyId) { + if (ids.has(keyId)) { + this.callbacks.reportMessage(CompilerMessages.Error_DisplayIsRepeated({ keyId })); return false; } else { - ids.add(id); + ids.add(keyId); } } } @@ -61,12 +61,12 @@ export class DispCompiler extends SectionCompiler { // displays result.disps = this.keyboard3.displays?.display.map(display => ({ - to: sections.strs.allocString(display.to, { + to: sections.strs.allocString(display.output, { stringVariables: true, markers: true, unescape: true, }, sections), - id: sections.strs.allocString(display.id), // not escaped, not substituted + id: sections.strs.allocString(display.keyId), // not escaped, not substituted display: sections.strs.allocString(display.display, { stringVariables: true, unescape: true, diff --git a/developer/src/kmc-ldml/src/compiler/messages.ts b/developer/src/kmc-ldml/src/compiler/messages.ts index 4f4d86f8ae..182bf1a84b 100644 --- a/developer/src/kmc-ldml/src/compiler/messages.ts +++ b/developer/src/kmc-ldml/src/compiler/messages.ts @@ -59,20 +59,20 @@ export class CompilerMessages { static FATAL_SectionCompilerFailed = SevFatal | 0x000F; /** annotate the to= or id= entry */ - private static toOrId(o:{to?: string, id?: string}) { - if (o.to && o.id) { - return `to='${o.to}' id='${o.id}'`; - } else if(o.id) { - return `id='${o.id}'`; - } else if (o.to) { - return `to='${o.to}'`; + private static outputOrKeyId(o:{output?: string, keyId?: string}) { + if (o.output && o.keyId) { + return `to='${o.output}' id='${o.keyId}'`; + } else if(o.keyId) { + return `id='${o.keyId}'`; + } else if (o.output) { + return `to='${o.output}'`; } else { return ''; } } - static Error_DisplayIsRepeated = (o:{to?: string, id?: string}) => - m(this.ERROR_DisplayIsRepeated, `display ${CompilerMessages.toOrId(o)} has more than one display entry.`); + static Error_DisplayIsRepeated = (o:{output?: string, keyId?: string}) => + m(this.ERROR_DisplayIsRepeated, `display ${CompilerMessages.outputOrKeyId(o)} has more than one display entry.`); static ERROR_DisplayIsRepeated = SevError | 0x0010; static Error_KeyMissingToGapOrSwitch = (o:{keyId: string}) => @@ -140,8 +140,8 @@ export class CompilerMessages { m(this.ERROR_MissingMarkers, `Markers used for matching but not defined: ${o.ids?.join(',')}`); static ERROR_MissingMarkers = SevError | 0x0021; - static Error_DisplayNeedsToOrId = (o:{to?: string, id?: string}) => - m(this.ERROR_DisplayNeedsToOrId, `display ${CompilerMessages.toOrId(o)} needs to= or id=, but not both`); + static Error_DisplayNeedsToOrId = (o:{output?: string, keyId?: string}) => + m(this.ERROR_DisplayNeedsToOrId, `display ${CompilerMessages.outputOrKeyId(o)} needs output= or keyId=, but not both`); static ERROR_DisplayNeedsToOrId = SevError | 0x0022; } diff --git a/developer/src/kmc-ldml/test/fixtures/basic.xml b/developer/src/kmc-ldml/test/fixtures/basic.xml index ea796e9653..382e2cf3a9 100644 --- a/developer/src/kmc-ldml/test/fixtures/basic.xml +++ b/developer/src/kmc-ldml/test/fixtures/basic.xml @@ -18,7 +18,7 @@ - + diff --git a/developer/src/kmc-ldml/test/test-disp.ts b/developer/src/kmc-ldml/test/test-disp.ts index 74c14c8c1c..fa4cd24a9c 100644 --- a/developer/src/kmc-ldml/test/test-disp.ts +++ b/developer/src/kmc-ldml/test/test-disp.ts @@ -19,7 +19,7 @@ describe('disp', function () { }); it('should compile typical disp', async function() { let disp = await loadSectionFixture(DispCompiler, 'sections/disp/typical.xml', compilerTestCallbacks) as Disp; - assert.equal(compilerTestCallbacks.messages.length, 0); + assert.equal(compilerTestCallbacks.messages, []); assert.ok(disp?.disps); assert.equal(disp.disps.length, 1); @@ -61,13 +61,13 @@ describe('disp', function () { let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-dupto.xml', compilerTestCallbacks) as Disp; assert.isNull(disp); assert.equal(compilerTestCallbacks.messages.length, 1); - assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayIsRepeated({to:'e'})); + assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayIsRepeated({output:'e'})); }); it('should reject duplicate ids', async function() { let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-dupid.xml', compilerTestCallbacks) as Disp; assert.isNull(disp); assert.equal(compilerTestCallbacks.messages.length, 1); - assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayIsRepeated({id:'e'})); + assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayIsRepeated({output:'e'})); }); it('should reject if neither to nor id', async function() { let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-none.xml', compilerTestCallbacks) as Disp; @@ -79,7 +79,7 @@ describe('disp', function () { let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-both.xml', compilerTestCallbacks) as Disp; assert.isNull(disp); assert.equal(compilerTestCallbacks.messages.length, 1); - assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayNeedsToOrId({ to: 'e', id: 'e' })); + assert.deepEqual(compilerTestCallbacks.messages[0], CompilerMessages.Error_DisplayNeedsToOrId({ output: 'e', keyId: 'e' })); }); });