Skip to content

Commit

Permalink
"Move to" bugfixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
percontation committed Oct 14, 2014
1 parent c9af48e commit e57b46e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
8 changes: 7 additions & 1 deletion app/sources/BaseDataDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,11 @@ - (void)jumpToOffset:(NSMenuItem *)sender {
return;
}
if (! jumpToOffsetView) jumpToOffsetView = [self newOperationViewForNibName:@"JumpToOffsetBanner" displayName:@"Jumping to Offset" fixedHeight:YES];
[self prepareBannerWithView:jumpToOffsetView withTargetFirstResponder:[jumpToOffsetView viewNamed:@"moveSelectionByTextField"]];
if (operationView == jumpToOffsetView) {
[self saveFirstResponderIfNotInBannerAndThenSetItTo:[jumpToOffsetView viewNamed:@"moveSelectionByTextField"]];
} else {
[self prepareBannerWithView:jumpToOffsetView withTargetFirstResponder:[jumpToOffsetView viewNamed:@"moveSelectionByTextField"]];
}
}

- (BOOL)movingRanges:(NSArray *)ranges byAmount:(unsigned long long)value isNegative:(BOOL)isNegative isValidForLength:(unsigned long long)length {
Expand Down Expand Up @@ -1544,6 +1548,7 @@ - (IBAction)moveSelectionToAction:(id)sender {
}
}
if (! success) NSBeep();
else [self restoreFirstResponderToSavedResponder];
}

- (IBAction)moveSelectionByAction:(id)sender {
Expand All @@ -1563,6 +1568,7 @@ - (IBAction)moveSelectionByAction:(id)sender {
}
}
if (! success) NSBeep();
else [self restoreFirstResponderToSavedResponder];
}

- (NSArray *)copyBookmarksMenuItems {
Expand Down
22 changes: 11 additions & 11 deletions framework/sources/HFRepresenterTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -453,23 +453,23 @@ - (void)updateSelectionPulse {
NSWindow *thisWindow = [self window];
NSRange firstRange = [ranges[0] rangeValue];
NSRange lastRange = [[ranges lastObject] rangeValue];
BOOL emptySelection = [ranges count] == 1 && firstRange.length == 0;
NSPoint startPoint = [self originForCharacterAtByteIndex:firstRange.location];
// don't just use originForCharacterAtByteIndex:NSMaxRange(lastRange), because if the last selected character is at the end of the line, this will cause us to highlight the next line. Instead, get the last selected character, and add an advance to it.
// HFASSERT(lastRange.length > 0);
NSPoint endPoint;
if (! NSEqualRanges(firstRange, lastRange)) {
endPoint = [self originForCharacterAtByteIndex:NSMaxRange(lastRange) - 1];
}
else {
endPoint = startPoint;
}
NSPoint endPoint = [self originForCharacterAtByteIndex:NSMaxRange(lastRange) - 1];
endPoint.x += [self advancePerCharacter];
HFASSERT(endPoint.y >= startPoint.y);
NSRect bounds = [self bounds];
NSRect windowFrameInBoundsCoords;
windowFrameInBoundsCoords.origin.x = bounds.origin.x;
if (emptySelection) {
CGFloat w = (CGFloat)fmax([self advancePerColumn], [self advancePerCharacter]);
windowFrameInBoundsCoords.origin.x = startPoint.x - w/2;
windowFrameInBoundsCoords.size.width = w;
} else {
windowFrameInBoundsCoords.origin.x = bounds.origin.x;
windowFrameInBoundsCoords.size.width = bounds.size.width;
}
windowFrameInBoundsCoords.origin.y = startPoint.y;
windowFrameInBoundsCoords.size.width = bounds.size.width;
windowFrameInBoundsCoords.size.height = endPoint.y - startPoint.y + [self lineHeight];

pulseWindowBaseFrameInScreenCoordinates = [self convertRect:windowFrameInBoundsCoords toView:nil];
Expand Down Expand Up @@ -508,7 +508,7 @@ - (void)updateSelectionPulse {
}

if (pulseWindow) {
CGFloat scale = (CGFloat)(selectionPulseAmount * .25 + 1.);
CGFloat scale = (CGFloat)(1. + .08 * selectionPulseAmount);
NSRect scaledWindowFrame;
scaledWindowFrame.size.width = HFRound(pulseWindowBaseFrameInScreenCoordinates.size.width * scale);
scaledWindowFrame.size.height = HFRound(pulseWindowBaseFrameInScreenCoordinates.size.height * scale);
Expand Down

0 comments on commit e57b46e

Please sign in to comment.