Archived
1

Corrected Fractions' property name: nominator to numerator

This commit is contained in:
Kim Wittenburg
2015-01-09 15:58:15 +01:00
parent 1f7e924c19
commit 1a8dd6e901
7 changed files with 31 additions and 32 deletions

View File

@@ -145,7 +145,6 @@
if (!selectWords && !extendingSelection && (locationInElement == 0 || locationInTarget == targetExpression.countSymbols)) {
// First or last index in an element or expression
// Last element in the expression
if (locationInTarget == targetExpression.countSymbols) {
// The selection is inside a function and should proceed
if (selectionPath.length > 1) {
@@ -805,7 +804,7 @@
if (self.selection.length == 0) {
MPExpression *targetExpression = [self.expressionStorage elementAtIndexPath:[self.selection.location indexPathByRemovingLastIndex]];
NSInteger index = self.selection.location.lastIndex;
NSRange nominatorSymbols = NSMakeRange(index, 0);
NSRange numeratorSymbols = NSMakeRange(index, 0);
while (--index >= 0) {
id<MPExpressionElement> symbol = [targetExpression symbolAtIndex:index];
if ([symbol isString]) {
@@ -814,33 +813,33 @@
toReferenceFrame:MPTokenReferenceFrame];
id<MPToken> token = [targetExpression tokenAtIndex:tokenIndex];
if (token.tokenType == MPNumberToken || token.tokenType == MPVariableToken || token.tokenType == MPElementaryFunctionToken) {
nominatorSymbols.location--;
nominatorSymbols.length++;
numeratorSymbols.location--;
numeratorSymbols.length++;
} else {
break;
}
} else if (nominatorSymbols.length == 0) {
nominatorSymbols.location--;
nominatorSymbols.length++;
} else if (numeratorSymbols.length == 0) {
numeratorSymbols.location--;
numeratorSymbols.length++;
} else {
break;
}
}
MPExpression *nominatorExpression = [targetExpression subexpressionWithRange:nominatorSymbols
MPExpression *numeratorExpression = [targetExpression subexpressionWithRange:numeratorSymbols
referenceFrame:MPSymbolReferenceFrame];
MPFractionFunction *function = [[MPFractionFunction alloc] init];
function.nominatorExpression = nominatorExpression;
[targetExpression replaceItemsInRange:nominatorSymbols referenceFrame:MPSymbolReferenceFrame withElements:@[function]];
NSUInteger functionElementIndex = [targetExpression convertIndex:nominatorSymbols.location
function.numeratorExpression = numeratorExpression;
[targetExpression replaceItemsInRange:numeratorSymbols referenceFrame:MPSymbolReferenceFrame withElements:@[function]];
NSUInteger functionElementIndex = [targetExpression convertIndex:numeratorSymbols.location
fromReferenceFrame:MPSymbolReferenceFrame
toReferenceFrame:MPElementReferenceFrame];
NSUInteger selectedSubexpression = nominatorSymbols.length == 0 ? 0 : 1;
NSUInteger selectedSubexpression = numeratorSymbols.length == 0 ? 0 : 1;
self.selection = MPMakeRangePath([[[self.selection.location indexPathByReplacingLastIndexWithIndex:functionElementIndex] indexPathByAddingIndex:selectedSubexpression] indexPathByAddingIndex:0], 0);
} else {
MPExpression *selectedElementsExpression = [self.expressionStorage subexpressionWithRangePath:self.selection
referenceFrame:MPSymbolReferenceFrame];
MPFractionFunction *function = [[MPFractionFunction alloc] init];
function.nominatorExpression = selectedElementsExpression;
function.numeratorExpression = selectedElementsExpression;
[self.expressionStorage replaceItemsInRangePath:self.selection
referenceFrame:MPSymbolReferenceFrame
withElements:@[function]];