diff --git a/ChangeLog b/ChangeLog index 614b876cb..136552fc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ edited:range:changeInLength. Also changed on line 191 from > to >=. Not sure the complete implications, but alas it now works correctly. + * Source/NSAttributedString.m: new file with implementation of + some needed additions to NSMutableAttributedString. Try gstextnetwork.app, you'll see a lot of debug information. After that has cleared click twice in the textView and press a diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 740e108fa..a720c10c9 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -40,6 +40,7 @@ libgnustep-gui_OBJC_FILES = Functions.m \ NSActionCell.m \ NSAffineTransform.m \ NSApplication.m \ +NSAttributedString.m \ NSBitmapImageRep.m \ NSBox.m \ NSBrowser.m \ diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m new file mode 100644 index 000000000..c032307d6 --- /dev/null +++ b/Source/NSAttributedString.m @@ -0,0 +1,95 @@ +#include + +//@implementation NSAttributedString (AppKit) + +/* + * This is where the fun begins with RTF/RTFD/HTML + */ + +//@end + +@implementation NSMutableAttributedString (AppKit) +- (void)superscriptRange:(NSRange)range +{ + id value; + int sValue; + + value = [self attribute:NSSuperscriptAttributeName + atIndex:range.location effectiveRange:&range]; + + sValue = [value intValue]; + + sValue++; + + [self addAttribute:NSSuperscriptAttributeName value:[[NSNumber alloc] + initWithInt:sValue] range:range]; +} + +- (void)subscriptRange:(NSRange)range +{ + id value; + int sValue; + + value = [self attribute:NSSuperscriptAttributeName + atIndex:range.location effectiveRange:&range]; + + sValue = [value intValue]; + + sValue--; + + [self addAttribute:NSSuperscriptAttributeName value:[[NSNumber alloc] + initWithInt:sValue] range:range]; +} + +- (void)unscriptRange:(NSRange)range +{ + [self addAttribute:NSSuperscriptAttributeName value:[[NSNumber alloc] + initWithInt:0] range:range]; +} + +- (void)applyFontTraits:(NSFontTraitMask)traitMask range:(NSRange)range +{ +/* We don't use font traits yet, oops. */ +/* + id value; + + value = [self attribute:NSFontAttributeName + atIndex:range.location effectiveRange:range]; + + [value setFontTraits:traitMask]; + + [self addAttribute:NSFontAttributeName value:value range:range]; +*/ +} + +- (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range +{ + id value; + + value = [self attribute:NSParagraphStyleAttributeName + atIndex:range.location effectiveRange:&range]; + + [value setAlignment:alignment]; + + [self addAttribute:NSParagraphStyleAttributeName value:value range:range]; +} + +- (void)fixAttributesInRange:(NSRange)range +{ + [self fixFontAttributeInRange:range]; + [self fixParagraphStyleAttributeInRange:range]; + [self fixAttachmentAttributeInRange:range]; +} + +- (void)fixFontAttributeInRange:(NSRange)range +{ +} + +- (void)fixParagraphStyleAttributeInRange:(NSRange)range +{ +} + +- (void)fixAttachmentAttributeInRange:(NSRange)range +{ +} +@end diff --git a/Source/NSTextStorage.m b/Source/NSTextStorage.m index dfabe89d9..f07ace122 100644 --- a/Source/NSTextStorage.m +++ b/Source/NSTextStorage.m @@ -197,8 +197,7 @@ changeInLength: [attributedString length] - aRange.length]; r = editedRange; r.length += editedDelta; -// FIXME, Michael: yeah, this is needed. -// [self fixAttributesInRange: r]; + [self fixAttributesInRange: r]; [nc postNotificationName: NSTextStorageDidProcessEditingNotification object: self];