add support for if(), set(), reset(), save()

This commit is contained in:
David Kamholz 2019-06-20 01:51:49 -07:00 • committed by Marc Durdin
parent e12de50af6
commit 46a2c981c8
5 changed files with 56 additions and 6 deletions

View file

@ -20,6 +20,7 @@
@property (strong, nonatomic) NSString *string;
- (void)setDwSystemID:(DWORD)dwID;
- (id)copyWithZone:(NSZone *)zone;
@end

View file

@ -21,6 +21,18 @@
return self;
}
- (id)copyWithZone:(NSZone *)zone {
KMCompStore *newStore = [[[self class] allocWithZone:zone] init];
if (newStore) {
[newStore setDwSystemID:[self dwSystemID]];
if ([self name]) newStore.name = [[NSString alloc] initWithString:[self name]];
if ([self string]) newStore.string = [[NSString alloc] initWithString:[self string]];
}
return newStore;
}
- (NSString *)description {
NSString *format = @"<%@:%p ID:0x%X DN:%@ N:%@ S:%@>";
NSString *str = [NSString stringWithFormat:format,

View file

@ -517,6 +517,33 @@ const NSString* kEasterEggKmxName = @"EnglishSpanish.kmx";
i+=2;
break;
}
case CODE_SETOPT: {
DWORD x1 = [outKey characterAtIndex:i+2]-1;
DWORD x2 = [outKey characterAtIndex:i+3]-1;
KMCompStore *store1 = [self.kmx.store objectAtIndex:x1];
KMCompStore *store2 = [self.kmx.store objectAtIndex:x2];
store1.string = [[NSString alloc] initWithString:store2.string];
i+=4;
break;
}
case CODE_RESETOPT: {
DWORD x1 = [outKey characterAtIndex:i+2]-1;
KMCompStore *store = [self.kmx.store objectAtIndex:x1];
KMCompStore *storeSaved = [self.kmx.storeSaved objectAtIndex:x1];
store.string = [[NSString alloc] initWithString:storeSaved.string];
i+=3;
break;
}
case CODE_SAVEOPT: {
DWORD x1 = [outKey characterAtIndex:i+2]-1;
KMCompStore *store = [self.kmx.store objectAtIndex:x1];
KMCompStore *storeSaved = [self.kmx.storeSaved objectAtIndex:x1];
storeSaved.string = [[NSString alloc] initWithString:store.string];
i+=3;
break;
}
default:
i+=2;
break;
@ -784,13 +811,21 @@ const NSString* kEasterEggKmxName = @"EnglishSpanish.kmx";
break;
}
case CODE_IFOPT: {
//DWORD x1 = [keyCtx characterAtIndex:i+2]-1;
//DWORD x2 = [keyCtx characterAtIndex:i+3]-1;
//DWORD x3 = [keyCtx characterAtIndex:i+4]-1;
//KMCompStore *store = [self.kmx.store objectAtIndex:x3];
//i+=5;
DWORD x1 = [keyCtx characterAtIndex:i+2]-1;
DWORD x2 = [keyCtx characterAtIndex:i+3]-1;
DWORD x3 = [keyCtx characterAtIndex:i+4]-1;
KMCompStore *store1 = [self.kmx.store objectAtIndex:x1];
KMCompStore *store2 = [self.kmx.store objectAtIndex:x3];
BOOL match = [store1.string isEqualToString:store2.string];
if ((match && x2 == EQUAL) || (!match && x2 == NOT_EQUAL)) {
cx+=1000;
}
else {
return 0;
}
return 0; // CODE_IFOPT is not supported
i+=5;
break;
}
case CODE_IFSYSTEMSTORE: {

View file

@ -29,6 +29,7 @@ extern NSString *const kKMVisualKeyboardKey;
@property (assign, nonatomic, readonly) BOOL isMnemonic;
@property (assign, nonatomic, readonly) DWORD version;
@property (strong, nonatomic, readonly) NSArray *store;
@property (strong, nonatomic, readonly) NSArray *storeSaved;
@property (strong, nonatomic, readonly) NSArray *group;
@property (strong, nonatomic, readonly) NSArray *startGroup;
@property (assign, nonatomic, readonly) DWORD flags;

View file

@ -95,6 +95,7 @@ NSString *const kKMVisualKeyboardKey = @"KMVisualKeyboardKey";
}
_store = [[NSArray alloc] initWithArray:mStore];
_storeSaved = [[NSArray alloc] initWithArray:mStore copyItems:YES];
struct COMP_GROUP cmp_grp[cmp_kb.cxGroupArray];
[file seekToFileOffset:cmp_kb.dpGroupArray];