make paragraph selection via triple click more mac like

This commit is contained in:
daboe01
2015-05-27 07:07:51 +02:00
parent e8bb3864e3
commit a4e41a57d7
2 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -580,7 +580,7 @@ _oncontextmenuhandler = function () { return false; };
}
}
return CPNotFound;
return point.y > 0? [[_textStorage string] length] : 0;
}
- (unsigned)glyphIndexForPoint:(CGPoint)point inTextContainer:(CPTextContainer)container
+11 -5
View File
@@ -1643,8 +1643,8 @@ var kDelegateRespondsTo_textShouldBeginEditing
if (textStorageLength == 0)
return CPMakeRange(0, 0);
if (proposedRange.location >= textStorageLength)
return CPMakeRange(textStorageLength, 0);
if (proposedRange.location > textStorageLength)
proposedRange = CPMakeRange(textStorageLength, 0);
if (CPMaxRange(proposedRange) > textStorageLength)
proposedRange.length = textStorageLength - proposedRange.location;
@@ -1668,11 +1668,17 @@ var kDelegateRespondsTo_textShouldBeginEditing
parRange = CPUnionRange(parRange, [self _characterRangeForIndex:CPMaxRange(proposedRange)
inRange:proposedRange
asDefinedByRegex:[[self class] _paragraphBoundaryRegex]
skip:NO]);
if (parRange.length > 0 && [self _isCharacterAtIndex:CPMaxRange(parRange) granularity:CPSelectByParagraph])
skip:YES]);
// mac-like paragraph selection with triple clicks
if ([self _isCharacterAtIndex:CPMaxRange(parRange) granularity:CPSelectByParagraph])
parRange.length++;
if (parRange.location > 0 && _isNewlineCharacter([[_textStorage string] characterAtIndex:parRange.location]))
parRange = CPUnionRange(parRange,
[self _characterRangeForIndex:parRange.location - 1
inRange:proposedRange
asDefinedByRegex:[[self class] _paragraphBoundaryRegex]
skip:YES])
return parRange;
default: