mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-14 14:41:28 +00:00
typing attributes refactoring
This commit is contained in:
@@ -1313,6 +1313,15 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
[self insertLineBreak:sender];
|
||||
}
|
||||
|
||||
- (void)_enrichEssentialTypingAttributes:(CPDictionary)attributes
|
||||
{
|
||||
if (![attributes containsKey:CPFontAttributeName])
|
||||
[attributes setObject:[self font] forKey:CPFontAttributeName];
|
||||
|
||||
if (![attributes containsKey:CPForegroundColorAttributeName])
|
||||
[attributes setObject:[self textColor] forKey:CPForegroundColorAttributeName];
|
||||
}
|
||||
|
||||
- (void)setTypingAttributes:(CPDictionary)attributes
|
||||
{
|
||||
if (!attributes)
|
||||
@@ -1326,12 +1335,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
{
|
||||
_typingAttributes = [attributes copy];
|
||||
|
||||
/* check that new attributes contains essentials one's */
|
||||
if (![_typingAttributes containsKey:CPFontAttributeName])
|
||||
[_typingAttributes setObject:[self font] forKey:CPFontAttributeName];
|
||||
|
||||
if (![_typingAttributes containsKey:CPForegroundColorAttributeName])
|
||||
[_typingAttributes setObject:[self textColor] forKey:CPForegroundColorAttributeName];
|
||||
[self _enrichEssentialTypingAttributes:_typingAttributes];
|
||||
}
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPTextViewDidChangeTypingAttributesNotification
|
||||
@@ -1345,8 +1349,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
{
|
||||
var attributes = [[_textStorage attributesAtIndex:CPMaxRange(_selectionRange) effectiveRange:nil] copy];
|
||||
|
||||
if (![attributes containsKey:CPForegroundColorAttributeName])
|
||||
[attributes setObject:[self textColor] forKey:CPForegroundColorAttributeName];
|
||||
[self _enrichEssentialTypingAttributes:attributes];
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user