Fixed setString: when there is no previous string, so that it uses

the typingAttributes


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10691 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2001-08-13 11:44:42 +00:00
parent 9bca979b83
commit 5320d8d0ec

View file

@ -330,7 +330,24 @@ static NSNotificationCenter *nc;
return;
[_textStorage beginEditing];
[_textStorage replaceCharactersInRange: aRange withString: aString];
if (_tf.is_rich_text && [_textStorage length] == 0)
{
/* In this case, there is nothing in the _textStorage ... so the
_textStorage can't choose appropriate formatting attributes
for the string ... we want the typingAttributes to be used in
this case. So we set the attributes manually. */
NSAttributedString *as;
as = AUTORELEASE ([[NSAttributedString alloc]
initWithString: aString
attributes: _typingAttributes]);
[self replaceRange: aRange withAttributedString: as];
}
else
{
[_textStorage replaceCharactersInRange: aRange withString: aString];
}
[_textStorage endEditing];
[self didChangeText];
}
@ -604,9 +621,10 @@ static NSNotificationCenter *nc;
if (aRange.location == NSNotFound)
return;
if (![self shouldChangeTextInRange: aRange
replacementString: nil])
return;
if (![self shouldChangeTextInRange: aRange replacementString: nil])
{
return;
}
[_textStorage beginEditing];
if (color != nil)
{
@ -1343,7 +1361,7 @@ static NSNotificationCenter *nc;
if (_tf.is_rich_text)
{
NSDictionary *dict;
if (range.location > 0)
{
/* If the insertion point is after a bold word, for