From 038a487a2468213481c03b5d2bf832cca7c307fd Mon Sep 17 00:00:00 2001 From: Michael Silva Date: Sun, 25 Jul 1999 21:44:07 +0000 Subject: [PATCH] More fixes, added NSAttributedString.m git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4649 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 2 + Source/GNUmakefile | 1 + Source/NSAttributedString.m | 95 +++++++++++++++++++++++++++++++++++++ Source/NSTextStorage.m | 3 +- 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 Source/NSAttributedString.m 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];