Skip to content

Commit

Permalink
Merge pull request #10275 from keymanapp/fix/mac/10273-persist-options
Browse files Browse the repository at this point in the history
fix(mac): write persisted options returned from Core
  • Loading branch information
sgschantz authored Jan 8, 2024
2 parents 74927f8 + ccee68c commit 904f815
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
ReferencedContainer = "container:KeymanEngine4Mac.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "KMEngineTests/testArmenianMnemonic_triggerPersistOptions_ReturnsOptions">
</Test>
<Test
Identifier = "KMEngineTests/testCheckPlatform_Browsers_ReturnsNo">
</Test>
Expand Down
16 changes: 3 additions & 13 deletions mac/KeymanEngine4Mac/KeymanEngine4Mac/CoreWrapper/CoreWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -191,28 +191,18 @@ -(CoreKeyOutput*) createCoreKeyOutputForActionsStruct:(km_core_actions*)actions
}

-(NSDictionary*)convertOptionsArray:(km_core_option_item*)options {
NSDictionary* optionsDictionary = nil;
unichar const * optionsKey = options->key;
unichar const * optionsValue = options->value;
if ((optionsKey != nil) && (optionsValue != nil)) {
optionsDictionary = [[NSDictionary alloc] init];
NSString *key = [self.coreHelper createNSStringFromUnicharString:optionsKey];
NSString *value = [self.coreHelper createNSStringFromUnicharString:optionsValue];
[optionsDictionary insertValue:value inPropertyWithKey:key];
}
/*
NSMutableDictionary* optionsDictionary = nil;
if (options) {
optionsDictionary = [[NSDictionary alloc] init];
optionsDictionary = [[NSMutableDictionary alloc] init];
for (; options->key != 0; ++options) {
unichar const * optionsKey = options->key;
unichar const * valueKey = options->value;

NSString *key = [self.coreHelper createNSStringFromUnicharString:optionsKey];
NSString *value = [self.coreHelper createNSStringFromUnicharString:valueKey];
[optionsDictionary insertValue:value inPropertyWithKey:key];
[optionsDictionary setObject:value forKey:key];
}
}
*/
return optionsDictionary;
}

Expand Down
6 changes: 4 additions & 2 deletions mac/KeymanEngine4Mac/KeymanEngine4MacTests/KMEngineTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,15 @@ - (void)testCoreProcessEvent_eventForFWithElNuerKmx_ReturnsCorrectCharacter {
XCTAssert(!output.emitKeystroke, @"expected to emit nothing");
}

// TODO: enable after resolving issue getting options from Keyman Core
- (void)testArmenianMnemonic_triggerPersistOptions_ReturnsOptions {
KMXFile *kmxFile = [KeymanEngineTestsStaticHelperMethods getKmxFileForArmenianMnemonicTests];
KMEngine *engine = [[KMEngine alloc] initWithKMX:kmxFile context:@"" verboseLogging:YES];
NSEvent *event = [NSEvent keyEventWithType:NSEventTypeKeyDown location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0 windowNumber:0 context:nil characters:@"w" charactersIgnoringModifiers:@"w" isARepeat:NO keyCode:kVK_ANSI_W];
CoreKeyOutput *output = [engine processEvent:event];
XCTAssert(!output.hasCodePointsToDelete, @"expected to delete nothing");
NSString *key = @"option_ligature_ew";
NSDictionary *options = output.optionsToPersist;
NSString *value = options[key];
XCTAssertEqualObjects(value, @"1", @"expected 'option_ligature_ew' with value of '1'");
}

- (void)testCoreProcessEvent_backspaceElNuerEmptyContext_PassesThrough {
Expand Down

0 comments on commit 904f815

Please sign in to comment.