mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Attributed string fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6208 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
433d24fdb6
commit
2086baecd1
2 changed files with 200 additions and 175 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Mar 08 07:40:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSAttributedString.m: Bugfix by fred Kiefer for extending
|
||||
attributes. Related bugfixes by me, plus tidying up.
|
||||
|
||||
2000-03-06 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* config.guess: Better guess of NetBSD systems.
|
||||
|
|
|
@ -138,8 +138,8 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
//NSCopying protocol
|
||||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
if ([self isKindOfClass: [NSMutableAttributedString class]] ||
|
||||
NSShouldRetainWithZone(self, zone) == NO)
|
||||
if ([self isKindOfClass: [NSMutableAttributedString class]]
|
||||
|| NSShouldRetainWithZone(self, zone) == NO)
|
||||
return [[[[self class] _concreteClass] allocWithZone: zone]
|
||||
initWithAttributedString: self];
|
||||
else
|
||||
|
@ -220,6 +220,8 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
effectiveRange: &tmpRange];
|
||||
if ([tmpDictionary isEqualToDictionary: attrDictionary])
|
||||
aRange->location = tmpRange.location;
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (NSMaxRange(*aRange) < NSMaxRange(rangeLimit))
|
||||
{
|
||||
|
@ -229,6 +231,8 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
effectiveRange: &tmpRange];
|
||||
if ([tmpDictionary isEqualToDictionary: attrDictionary])
|
||||
aRange->length = NSMaxRange(tmpRange) - aRange->location;
|
||||
else
|
||||
break;
|
||||
}
|
||||
*aRange = NSIntersectionRange(*aRange,rangeLimit);//Clip to rangeLimit
|
||||
return attrDictionary;
|
||||
|
@ -257,7 +261,8 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
return attrValue;
|
||||
}
|
||||
|
||||
- (id) attribute: (NSString*)attributeName atIndex: (unsigned int)index longestEffectiveRange: (NSRange *)aRange inRange: (NSRange)rangeLimit
|
||||
- (id) attribute: (NSString*)attributeName atIndex: (unsigned int)index
|
||||
longestEffectiveRange: (NSRange*)aRange inRange: (NSRange)rangeLimit
|
||||
{
|
||||
NSDictionary *tmpDictionary;
|
||||
id attrValue,tmpAttrValue;
|
||||
|
@ -286,6 +291,8 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
tmpAttrValue = [tmpDictionary objectForKey: attributeName];
|
||||
if (tmpAttrValue == attrValue)
|
||||
aRange->location = tmpRange.location;
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (NSMaxRange(*aRange) < NSMaxRange(rangeLimit))
|
||||
{
|
||||
|
@ -296,6 +303,8 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
tmpAttrValue = [tmpDictionary objectForKey: attributeName];
|
||||
if (tmpAttrValue == attrValue)
|
||||
aRange->length = NSMaxRange(tmpRange) - aRange->location;
|
||||
else
|
||||
break;
|
||||
}
|
||||
*aRange = NSIntersectionRange(*aRange,rangeLimit);//Clip to rangeLimit
|
||||
return attrValue;
|
||||
|
@ -326,8 +335,8 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
|
||||
while (YES)
|
||||
{
|
||||
if (NSIntersectionRange(ownEffectiveRange,otherEffectiveRange).length > 0 &&
|
||||
![ownDictionary isEqualToDictionary: otherDictionary])
|
||||
if (NSIntersectionRange(ownEffectiveRange, otherEffectiveRange).length > 0
|
||||
&& ![ownDictionary isEqualToDictionary: otherDictionary])
|
||||
{
|
||||
result = NO;
|
||||
break;
|
||||
|
@ -458,7 +467,9 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
[self setAttributes: newDict range: effectiveRange];
|
||||
|
||||
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
|
||||
{
|
||||
effectiveRange.location = NSMaxRange(aRange);//This stops the loop...
|
||||
}
|
||||
else if (NSMaxRange(effectiveRange) < tmpLength)
|
||||
{
|
||||
attrDict = [self attributesAtIndex: NSMaxRange(effectiveRange)
|
||||
|
@ -476,15 +487,16 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
|
||||
if (!attributes)
|
||||
{
|
||||
//I cannot use NSParameterAssert here, if is has to be an NSInvalidArgumentException
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"attributes is nil in method -addAttributes: range: in class NSMutableAtrributedString"];
|
||||
format: @"attributes is nil in method -addAttributes:range: "
|
||||
@"in class NSMutableAtrributedString"];
|
||||
}
|
||||
tmpLength = [self length];
|
||||
if (aRange.location <= 0 || NSMaxRange(aRange) > tmpLength)
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"RangeError in method -addAttribute: value: range: in class NSMutableAttributedString"];
|
||||
format: @"RangeError in method -addAttribute:value:range: "
|
||||
@"in class NSMutableAttributedString"];
|
||||
}
|
||||
|
||||
attrDict = [self attributesAtIndex: aRange.location
|
||||
|
@ -500,7 +512,9 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
[self setAttributes: newDict range: effectiveRange];
|
||||
|
||||
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
|
||||
{
|
||||
effectiveRange.location = NSMaxRange(aRange);//This stops the loop...
|
||||
}
|
||||
else if (NSMaxRange(effectiveRange) < tmpLength)
|
||||
{
|
||||
attrDict = [self attributesAtIndex: NSMaxRange(effectiveRange)
|
||||
|
@ -532,7 +546,9 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
[self setAttributes: newDict range: effectiveRange];
|
||||
|
||||
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
|
||||
{
|
||||
effectiveRange.location = NSMaxRange(aRange);//This stops the loop...
|
||||
}
|
||||
else if (NSMaxRange(effectiveRange) < tmpLength)
|
||||
{
|
||||
attrDict = [self attributesAtIndex: NSMaxRange(effectiveRange)
|
||||
|
@ -548,21 +564,24 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
withAttributedString: attributedString];
|
||||
}
|
||||
|
||||
- (void) insertAttributedString: (NSAttributedString *)attributedString atIndex: (unsigned int)index
|
||||
- (void) insertAttributedString: (NSAttributedString*)attributedString
|
||||
atIndex: (unsigned int)index
|
||||
{
|
||||
[self replaceCharactersInRange: NSMakeRange(index,0)
|
||||
withAttributedString: attributedString];
|
||||
}
|
||||
|
||||
- (void) replaceCharactersInRange: (NSRange)aRange withAttributedString: (NSAttributedString *)attributedString
|
||||
- (void) replaceCharactersInRange: (NSRange)aRange
|
||||
withAttributedString: (NSAttributedString*)attributedString
|
||||
{
|
||||
NSRange effectiveRange,clipRange,ownRange;
|
||||
NSRange effectiveRange;
|
||||
NSRange clipRange;
|
||||
NSRange ownRange;
|
||||
NSDictionary *attrDict;
|
||||
NSString *tmpStr;
|
||||
|
||||
tmpStr = [attributedString string];
|
||||
[self replaceCharactersInRange: aRange
|
||||
withString: tmpStr];
|
||||
[self replaceCharactersInRange: aRange withString: tmpStr];
|
||||
|
||||
effectiveRange = NSMakeRange(0,0);
|
||||
clipRange = NSMakeRange(0,[tmpStr length]);
|
||||
|
@ -576,7 +595,8 @@ static Class NSMutableAttributedString_concrete_class;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) replaceCharactersInRange: (NSRange)aRange withString: (NSString *)aString
|
||||
- (void) replaceCharactersInRange: (NSRange)aRange
|
||||
withString: (NSString*)aString
|
||||
{
|
||||
[self subclassResponsibility: _cmd];// Primitive method!
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue