From efcfcbe8cc5fd5ef30e7b26d43b32dad01356256 Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 25 Jul 1999 03:34:10 +0000 Subject: [PATCH] More text fixes. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4642 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 ++++ Source/NSTextStorage.m | 32 ++++++++++++++++++++++++++++++++ Source/NSTextView.m | 9 +++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cade4a6d4..c2c409d76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ * Source/GSServicesManager.m: minor temp debug NSlog. * Source/NSMenuView.m: debug logs. * Source/NSText.m: debug logs. + * Source/NSTextStorage.m: in processEditing: add code to notify + every layoutManager of editing done in textStorage. + Also fixed code to return the string. This makes debugging ohh so + much easier. ;-) Look at core/Testing/gstextnetwork.app. That is the text application for NSTextView/TextNetwork. Edit.app has been diff --git a/Source/NSTextStorage.m b/Source/NSTextStorage.m index 189bfe66c..bf291cdc3 100644 --- a/Source/NSTextStorage.m +++ b/Source/NSTextStorage.m @@ -26,6 +26,7 @@ #include #include +#include #include @implementation NSTextStorage @@ -68,6 +69,16 @@ static Class concrete; return self; } +/* + * Return a string + */ + +- (NSString*) string +{ + [self subclassResponsibility: _cmd]; + return nil; +} + /* * Managing NSLayoutManagers */ @@ -159,6 +170,7 @@ static Class concrete; - (void) processEditing { NSRange r; + int i; NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; @@ -171,6 +183,26 @@ static Class concrete; [nc postNotificationName: NSTextStorageDidProcessEditingNotification object: self]; + + /* + * Calls textStorage:edited:range:changeInLength:invalidatedRange: for + * every layoutManager. + * + * FIXME, Michael: are the ranges used correct? + */ + + for (i=0;i<[layoutManagers count];i++) + { + id lManager = [layoutManagers objectAtIndex:i]; + + [lManager textStorage:self edited:editedMask range:editedRange + changeInLength:editedDelta invalidatedRange:r]; + } + + /* + * Why are we resetting the values? + */ + editedRange = NSMakeRange(0, 0); editedDelta = 0; editedMask = 0; diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 0436bc94a..b5e1ba207 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -146,12 +146,10 @@ /* We override NSView's setNeedsDisplayInRect: */ -/* - (void)setNeedsDisplayInRect:(NSRect)aRect { [self setNeedsDisplayInRect:aRect avoidAdditionalLayout:NO]; } -*/ - (BOOL)shouldDrawInsertionPoint { @@ -915,12 +913,19 @@ container, returning the modified location. */ - (void)insertText:(NSString *)aString { + NSLog(@"%@", aString); + if (![aString isKindOfClass:[NSAttributedString class]]) aString = [[[NSAttributedString alloc] initWithString:aString attributes:[self typingAttributes]] autorelease]; [textStorage replaceCharactersInRange:[self selectedRange] withAttributedString:(NSAttributedString *)aString]; + + [self setSelectedRange:NSMakeRange([self + selectedRange].location+[aString length],0)]; + + NSLog(@"%@", [textStorage string]); } - (void)drawRect:(NSRect)aRect