Archived
1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mathpad/MathKit/MPExpressionStorage.m
2015-01-08 22:28:00 +01:00

46 lines
1.1 KiB
Objective-C

//
// MPExpressionStorage.m
// MathKit
//
// Created by Kim Wittenburg on 22.04.14.
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//
#import "MPExpressionStorage.h"
#import "MPExpressionView.h"
#import "MPExpressionLayout.h"
#import "MPRangePath.h"
@implementation MPExpressionStorage
- (instancetype)initWithElements:(NSArray *)elements
{
self = [super initWithElements:elements];
if (self) {
_rootLayout = [[MPExpressionLayout alloc] initWithExpression:self parent:nil];
}
return self;
}
- (void)changedElementsInRangePath:(MPRangePath *)rangePath
replacementLength:(NSUInteger)replacementLength
{
if (rangePath.location.length == 0) {
return;
}
MPLayout *current = self.rootLayout;
for (NSUInteger position = 0; position < rangePath.location.length-1; position++) {
NSUInteger index = [rangePath.location indexAtPosition:position];
current = [current childLayoutAtIndex:index];
}
[current clearCacheInRange:rangePath.rangeAtLastIndex
replacementLength:replacementLength];
}
@end