mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-18 11:57:38 +00:00
feat(developer): resolve conflict (symbol names; eroor/info_messages)
This commit is contained in:
parent
59ed7152eb
commit
d1e7f97c54
5 changed files with 41 additions and 68 deletions
|
|
@ -53,11 +53,11 @@ export class ConverterMessages {
|
|||
);
|
||||
|
||||
static ERROR_UnsupportedCharactersDetected = SevError | 0x0007;
|
||||
static Error_UnsupportedCharactersDetected = (o: { inputFilename: string, keymap_index: string, KeyName: string, output: string; }) => m(
|
||||
static Error_UnsupportedCharactersDetected = (o: { inputFilename: string, keymapIndex: string, KeyName: string, output: string; }) => m(
|
||||
this.ERROR_UnsupportedCharactersDetected,
|
||||
`Input file ${def(o.inputFilename)}
|
||||
contains unsupported character '${def(o.output)}'
|
||||
at ${def(o.keymap_index)} ${def(o.KeyName)} .`
|
||||
at ${def(o.keymapIndex)} ${def(o.KeyName)} .`
|
||||
);
|
||||
|
||||
static ERROR_InvalidFile = SevError | 0x0008;
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ export class KeylayoutToKmnConverter {
|
|||
|
||||
// fill dataObject with filenames, behaviours and (initialized) rules
|
||||
dataObject.keylayoutFilename = inputfilename;
|
||||
dataObject.kmnFilename = inputfilename.replace(/\.kkeylayoutn$/, '.kmn');;
|
||||
dataObject.kmnFilename = inputfilename.replace(/\.keylayout$/, '.kmn');;
|
||||
dataObject.arrayOfModifiers = modifierBehavior; // ukelele uses behaviours e.g. 18 modifiersCombinations in 8 KeyMapSelect(behaviors)
|
||||
dataObject.arrayOfRules = rules;
|
||||
|
||||
|
|
@ -466,9 +466,9 @@ export class KeylayoutToKmnConverter {
|
|||
} else {
|
||||
this.callbacks.reportMessage(ConverterMessages.Error_UnsupportedCharactersDetected({
|
||||
inputFilename: jsonObj.keyboard['@_name'] + ".keylayout",
|
||||
keymap_index: jsonObj.keyboard.keyMapSet[0].keyMap[i]['@_index'],
|
||||
keymapIndex: jsonObj.keyboard.keyMapSet[0].keyMap[i]['@_index'],
|
||||
output: jsonObj.keyboard.keyMapSet[0].keyMap[i].key[j]['@_output'],
|
||||
KeyName: this.map_UkeleleKC_To_VK(jsonObj.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'])
|
||||
KeyName: this.mapUkeleleKeycodeToVK(jsonObj.keyboard.keyMapSet[0].keyMap[i].key[j]['@_code'])
|
||||
}))
|
||||
return null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ export class KmnFileWriter {
|
|||
data += this.writeKmnFileHeader(dataUkelele);
|
||||
|
||||
// add bottom part of kmn file: RULES
|
||||
const data_rules = this.writeData_Rules(data_ukelele);
|
||||
if (data_rules)
|
||||
data += data_rules;
|
||||
const dataRules = this.writeDataRules(dataUkelele);
|
||||
if (dataRules)
|
||||
data += dataRules;
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -143,13 +143,9 @@ export class KmnFileWriter {
|
|||
// If it`s a ctrl character we print out the Unicode Codepoint else we print out the Unicode Character
|
||||
let versionOutputCharacter;
|
||||
const warnText = this.reviewRules(uniqueDataRules, k);
|
||||
|
||||
const outputCharacter = new TextDecoder().decode(uniqueDataRules[k].output);
|
||||
// TODO after merge of PR 14564 use functions from util instead of the ones in this class
|
||||
// const outputUnicodeCharacter = util.convertToUnicodeCharacter(outputCharacter);
|
||||
// const outputUnicodeCodePoint = util.convertToUnicodeCodePoint(outputCharacter);
|
||||
const outputUnicodeCharacter = this.convertToUnicodeCharacter(outputCharacter);
|
||||
const outputUnicodeCodePoint = this.convertToUnicodeCodePoint(outputCharacter);
|
||||
const outputUnicodeCharacter = convertUtil.convertToUnicodeCharacter(outputCharacter);
|
||||
const outputUnicodeCodePoint = convertUtil.convertControlCharacterToUnicodeCodePoint(outputCharacter);
|
||||
|
||||
if ((outputUnicodeCharacter !== undefined) && (outputUnicodeCodePoint !== undefined)) {
|
||||
|
||||
|
|
@ -170,12 +166,12 @@ export class KmnFileWriter {
|
|||
versionOutputCharacter = outputUnicodeCharacter;
|
||||
}
|
||||
}
|
||||
if ((output_Unicode_Character === undefined) || (output_Unicode_CodePoint === undefined)) {
|
||||
if ((outputUnicodeCharacter === undefined) || (outputUnicodeCodePoint === undefined)) {
|
||||
this.callbacks.reportMessage(ConverterMessages.Error_UnsupportedCharactersDetected({
|
||||
inputFilename: data_ukelele.keylayout_filename,
|
||||
output: new TextDecoder().decode(unique_data_Rules[k].output),
|
||||
keymap_index: data_ukelele.arrayOf_Rules[k].modifier_key,
|
||||
KeyName: unique_data_Rules[k].key
|
||||
inputFilename: dataUkelele.keylayoutFilename,
|
||||
output: new TextDecoder().decode(uniqueDataRules[k].output),
|
||||
keymapIndex: dataUkelele.arrayOfRules[k].modifierKey,
|
||||
KeyName: uniqueDataRules[k].key
|
||||
}));
|
||||
return null;
|
||||
}
|
||||
|
|
@ -222,11 +218,8 @@ export class KmnFileWriter {
|
|||
const warnText = this.reviewRules(uniqueDataRules, k);
|
||||
|
||||
const outputCharacter = new TextDecoder().decode(uniqueDataRules[k].output);
|
||||
// TODO after merge of PR 14564 use functions from util instead of the ones in this class
|
||||
// const outputUnicodeCharacter = util.convertToUnicodeCharacter(outputCharacter);
|
||||
// const outputUnicodeCodePoint = util.convertToUnicodeCodePoint(outputCharacter);
|
||||
const outputUnicodeCharacter = this.convertToUnicodeCharacter(outputCharacter);
|
||||
const outputUnicodeCodePoint = this.convertToUnicodeCodePoint(outputCharacter);
|
||||
const outputUnicodeCharacter = convertUtil.convertToUnicodeCharacter(outputCharacter);
|
||||
const outputUnicodeCodePoint = convertUtil.convertControlCharacterToUnicodeCodePoint(outputCharacter);
|
||||
|
||||
if ((outputUnicodeCharacter !== undefined) && (outputUnicodeCodePoint !== undefined)) {
|
||||
// if we are about to print a unicode codepoint instead of a single character we need to check if it is a control character
|
||||
|
|
@ -244,12 +237,12 @@ export class KmnFileWriter {
|
|||
versionOutputCharacter = outputUnicodeCharacter;
|
||||
}
|
||||
}
|
||||
if ((output_Unicode_Character === undefined) || (output_Unicode_CodePoint === undefined)) {
|
||||
if ((outputUnicodeCharacter === undefined) || (outputUnicodeCodePoint === undefined)) {
|
||||
this.callbacks.reportMessage(ConverterMessages.Error_UnsupportedCharactersDetected({
|
||||
inputFilename: data_ukelele.keylayout_filename,
|
||||
output: new TextDecoder().decode(unique_data_Rules[k].output),
|
||||
keymap_index: unique_data_Rules[k].modifier_key,
|
||||
KeyName: unique_data_Rules[k].key
|
||||
inputFilename: dataUkelele.keylayoutFilename,
|
||||
output: new TextDecoder().decode(uniqueDataRules[k].output),
|
||||
keymapIndex: uniqueDataRules[k].modifierKey,
|
||||
KeyName: uniqueDataRules[k].key
|
||||
}));
|
||||
return null;
|
||||
}
|
||||
|
|
@ -319,12 +312,8 @@ export class KmnFileWriter {
|
|||
|
||||
const warnText = this.reviewRules(uniqueDataRules, k);
|
||||
const outputCharacter = new TextDecoder().decode(uniqueDataRules[k].output);
|
||||
// TODO after merge of PR 14564 use functions from util instead of the ones in this class
|
||||
//const outputUnicodeCharacter = util.convertToUnicodeCharacter(outputCharacter);
|
||||
//const outputUnicodeCodePoint = util.convertToUnicodeCodePoint(outputCharacter);
|
||||
const outputUnicodeCharacter = this.convertToUnicodeCharacter(outputCharacter);
|
||||
const outputUnicodeCodePoint = this.convertToUnicodeCodePoint(outputCharacter);
|
||||
|
||||
const outputUnicodeCharacter = convertUtil.convertToUnicodeCharacter(outputCharacter);
|
||||
const outputUnicodeCodePoint = convertUtil.convertControlCharacterToUnicodeCodePoint(outputCharacter);
|
||||
if ((outputUnicodeCharacter !== undefined) && (outputUnicodeCodePoint !== undefined)) {
|
||||
// if we are about to print a unicode codepoint instead of a single character we need to check if a control character is to be used
|
||||
if (Number("0x" + outputUnicodeCodePoint.substring(2, outputUnicodeCodePoint.length)) < KeylayoutToKmnConverter.MAX_CTRL_CHARACTER) {
|
||||
|
|
@ -343,12 +332,12 @@ export class KmnFileWriter {
|
|||
versionOutputCharacter = outputUnicodeCharacter;
|
||||
}
|
||||
}
|
||||
if ((output_Unicode_Character === undefined) || (output_Unicode_CodePoint === undefined)) {
|
||||
if ((outputUnicodeCharacter === undefined) || (outputUnicodeCodePoint === undefined)) {
|
||||
this.callbacks.reportMessage(ConverterMessages.Error_UnsupportedCharactersDetected({
|
||||
inputFilename: data_ukelele.keylayout_filename,
|
||||
output: new TextDecoder().decode(unique_data_Rules[k].output),
|
||||
keymap_index: unique_data_Rules[k].modifier_key,
|
||||
KeyName: unique_data_Rules[k].key
|
||||
inputFilename: dataUkelele.keylayoutFilename,
|
||||
output: new TextDecoder().decode(uniqueDataRules[k].output),
|
||||
keymapIndex: uniqueDataRules[k].modifierKey,
|
||||
KeyName: uniqueDataRules[k].key
|
||||
}));
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,22 +73,6 @@ describe('KeylayoutToKmnConverter', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
/*=======
|
||||
*/
|
||||
/*describe('RunSpecialTestFiles - create Info', function () {
|
||||
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
|
||||
[
|
||||
[makePathToFixture('../data/Test_characters.keylayout')],
|
||||
[makePathToFixture('../data/Test_onlyOneKeymap.keylayout')],
|
||||
].forEach(function (files) {
|
||||
it(files + " should give Info: unsupported characters ", async function () {
|
||||
sut.run(files[0]);
|
||||
assert.isTrue(compilerTestCallbacks.messages.length === 1);
|
||||
assert.isTrue(compilerTestCallbacks.messages[0].code === (CompilerErrorSeverity.Info | CompilerErrorNamespace.Converter | 0x0007));
|
||||
});
|
||||
});
|
||||
});*/
|
||||
|
||||
|
||||
describe('run() ', function () {
|
||||
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@ describe('KmnFileWriter', function () {
|
|||
const converted = sut.convertBound.convert(read, inputFilename.replace(/\.keylayout$/, '.kmn'));
|
||||
|
||||
// empty ProcesData from unavailable file name
|
||||
const inputFilename_unavailable = makePathToFixture('../data/X.keylayout');
|
||||
const read_unavailable = sut_r.read(inputFilename_unavailable);
|
||||
const converted_unavailable = sut.convert_bound.convert(read_unavailable, inputFilename_unavailable.replace(/\.keylayout$/, '.kmn'));
|
||||
const inputFilenameUnavailable = makePathToFixture('../data/X.keylayout');
|
||||
const readUnavailable = sutR.read(inputFilenameUnavailable);
|
||||
const convertedUnavailable = sut.convertBound.convert(readUnavailable, inputFilenameUnavailable.replace(/\.keylayout$/, '.kmn'));
|
||||
|
||||
it('write() should return null in case of missing inputfile', async function () {
|
||||
const result = sut_w.write(converted_unavailable);
|
||||
const result = sutW.write(convertedUnavailable);
|
||||
assert.isNull(result);
|
||||
});
|
||||
|
||||
it('write() should return result for input file ' + inputFilename, async function () {
|
||||
const result = sut_w.write(converted);
|
||||
const result = sutW.write(converted);
|
||||
assert.isNotNull(result);
|
||||
});
|
||||
});
|
||||
|
|
@ -467,8 +467,8 @@ describe('KmnFileWriter', function () {
|
|||
|
||||
describe("write() should throw for invalid output characters ", function () {
|
||||
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
|
||||
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
|
||||
const sut_w = new KmnFileWriter(compilerTestCallbacks, compilerTestOptions);
|
||||
const sutR = new KeylayoutFileReader(compilerTestCallbacks);
|
||||
const sutW = new KmnFileWriter(compilerTestCallbacks, compilerTestOptions);
|
||||
|
||||
[
|
||||
['../data/Test_invalidInput_C0.keylayout', "U+-456", "CAPS", "K_S"],
|
||||
|
|
@ -476,20 +476,20 @@ describe('KmnFileWriter', function () {
|
|||
['../data/Test_invalidInput_C2.keylayout', "U+-123", "CAPS", "K_D"],
|
||||
['../data/Test_invalidInput_C3.keylayout', "U+-123", "CAPS", "K_D"],
|
||||
].forEach(function (values) {
|
||||
it(("run() should throw on invalid input output character: " + values[0] + ")") +
|
||||
it(("write() from describe: should throw on invalid input output character: " + values[0] + ")") +
|
||||
' contains unsupported character \'' + values[1] +
|
||||
"\' at " + values[2] + " " + values[3] + ".", async function () {
|
||||
const inputName = makePathToFixture(values[0]);
|
||||
const read = sut_r.read(inputName);
|
||||
const converted = sut.convert_bound.convert(read, inputName.replace(/\.keylayout$/, '.kmn'));
|
||||
const result = sut_w.writeData_Rules(converted);
|
||||
const read = sutR.read(inputName);
|
||||
const converted = sut.convertBound.convert(read, inputName);
|
||||
const result = sutW.writeDataRules(converted);
|
||||
|
||||
assert.isNull(result);
|
||||
assert.equal(compilerTestCallbacks.messages.length, 1);
|
||||
assert.deepEqual(compilerTestCallbacks.messages[0], ConverterMessages.Error_UnsupportedCharactersDetected({
|
||||
inputFilename: inputName,
|
||||
output: values[1],
|
||||
keymap_index: values[2],
|
||||
keymapIndex: values[2],
|
||||
KeyName: values[3]
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue