NSText works!

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4457 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Michael Silva 1999-06-22 23:37:24 +00:00
parent fdb0188039
commit acf7614115
6 changed files with 531 additions and 726 deletions

View file

@ -1,3 +1,19 @@
1999-06-22 Michael Hanni <mhanni@sprintmail.com>
* Source/NSText.m: new file from Daniel. Modifications to allow it
to work with GNUstep. Plus multiple hacks to make it work with
NSTextField and NSTextView better.
* Source/NSTextView.m: ditto.
* Source/NSCell.m: modifications to editWithFrame:::: so our field
editor is a little better lined up. Plus fieldEditor gets our
mouseDown: event. Fixed flicker, I think.
TODO:
* fix Caret. Without an insertion marker its hard to see. :-)
* fix buffer for using a fieldEditor in a cell. Possibly modify
NSTextFieldCell so it doesn't draw text directly abutting the
side?
1999-06-21 Michael Hanni <mhanni@sprintmail.com> 1999-06-21 Michael Hanni <mhanni@sprintmail.com>
* Source/NSText.m: a bunch of little tweaks. Will document today. * Source/NSText.m: a bunch of little tweaks. Will document today.

View file

@ -1,33 +1,33 @@
/* /*
NSText.h NSText.h
The text object The text object
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com> Author: Scott Christley <scottc@net-community.com>
Date: 1996 Date: 1996
Author: Felipe A. Rodriguez <far@ix.netcom.com> Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: July 1998 Date: July 1998
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de> Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998 Date: August 1998
This file is part of the GNUstep GUI Library. This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version. version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation, If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _GNUstep_H_NSText #ifndef _GNUstep_H_NSText
@ -44,6 +44,7 @@
@class NSColor; @class NSColor;
@class NSFont; @class NSFont;
#if GNUSTEP
typedef enum _NSTextAlignment { typedef enum _NSTextAlignment {
NSLeftTextAlignment, NSLeftTextAlignment,
NSRightTextAlignment, NSRightTextAlignment,
@ -55,13 +56,14 @@ typedef enum _NSTextAlignment {
enum { enum {
NSIllegalTextMovement = 0, NSIllegalTextMovement = 0,
NSReturnTextMovement = 0x10, NSReturnTextMovement = 0x10,
NSTabTextMovement = 0x11, NSTabTextMovement = 0x11,
NSBacktabTextMovement = 0x12, NSBacktabTextMovement = 0x12,
NSLeftTextMovement = 0x13, NSLeftTextMovement = 0x13,
NSRightTextMovement = 0x14, NSRightTextMovement = 0x14,
NSUpTextMovement = 0x15, NSUpTextMovement = 0x15,
NSDownTextMovement = 0x16 NSDownTextMovement = 0x16
}; };
#endif
// these definitions should migrate to NSTextView when implemented // these definitions should migrate to NSTextView when implemented
@ -71,16 +73,17 @@ typedef enum _NSSelectionGranularity
NSSelectByParagraph = 2, NSSelectByParagraph = 2,
} NSSelectionGranularity; } NSSelectionGranularity;
#if GNUSTEP
typedef enum _NSSelectionAffinity typedef enum _NSSelectionAffinity
{ NSSelectionAffinityUpstream = 0, { NSSelectionAffinityUpstream = 0,
NSSelectionAffinityDownstream = 1, NSSelectionAffinityDownstream = 1,
} NSSelectionAffinity; } NSSelectionAffinity;
#endif
@interface NSText : NSView <NSChangeSpelling,NSIgnoreMisspelledWords,NSCoding> @interface NSText : NSView <NSChangeSpelling,NSIgnoreMisspelledWords,NSCoding>
{ { // Attributes
id delegate; id delegate;
unsigned int alignment; unsigned int alignment; //NSTextAlignment
BOOL is_editable; BOOL is_editable;
BOOL is_rich_text; BOOL is_rich_text;
BOOL is_selectable; BOOL is_selectable;
@ -96,20 +99,22 @@ typedef enum _NSSelectionAffinity
NSFont *default_font; NSFont *default_font;
NSRange selected_range; NSRange selected_range;
void *be_text_reserved; // Reserved for back-end use // added by Daniel Bðhringer
NSSize minSize, maxSize; // added for Daniel Bðhringer NSSize minSize,maxSize;
// content
NSMutableString *plainContent;
NSMutableAttributedString *rtfContent;
NSCharacterSet *selectionWordGranularitySet;
NSCharacterSet *selectionParagraphGranularitySet;
id lineLayoutInformation;
NSMutableDictionary *typingAttributes; NSMutableDictionary *typingAttributes;
float currentCursorX; // column-stable cursor up/down
BOOL displayDisabled; // content
int spellCheckerDocumentTag; NSMutableString *plainContent;
NSMutableAttributedString *rtfContent;
// internal stuff
NSMutableArray *lineLayoutInformation; // contains private _GNULineLayoutInfo objects
int spellCheckerDocumentTag;
NSCharacterSet *selectionWordGranularitySet,*selectionParagraphGranularitySet;
BOOL displayDisabled;
float currentCursorX; // column-stable cursor up/down
} }
@ -293,8 +298,7 @@ typedef enum _NSSelectionAffinity
// these are implementation specific (GNU extensions) // these are implementation specific (GNU extensions)
// //
-(int) rebuildLineLayoutInformationStartingAtLine:(int) aLine; // returns count of lines actually updated (e.g. drawing optimization) -(int) rebuildLineLayoutInformationStartingAtLine:(int) aLine; // returns count of lines actually updated (e.g. drawing optimization)
-(int) rebuildPlainLineLayoutInformationStartingAtLine:(int) aLine delta:(int) insertionDelta actualLine:(int) insertionLine; // override for special layout of plain text -(int) rebuildLineLayoutInformationStartingAtLine:(int) aLine delta:(int) insertionDelta actualLine:(int) insertionLine; // override for special layout of text
-(int) rebuildRichLineLayoutInformationStartingAtLine:(int) aLine delta:(int) insertionDelta actualLine:(int) insertionLine; // ditto for rich text
-(int) lineLayoutIndexForCharacterIndex:(unsigned) anIndex; // return value is identical to the real line number (plus counted newline characters) -(int) lineLayoutIndexForCharacterIndex:(unsigned) anIndex; // return value is identical to the real line number (plus counted newline characters)
-(void) redisplayForLineRange:(NSRange) redrawLineRange; -(void) redisplayForLineRange:(NSRange) redrawLineRange;
@ -304,6 +308,7 @@ typedef enum _NSSelectionAffinity
// //
// various GNU extensions // various GNU extensions
// //
-(void) rebuildFromCharacterIndex:(int) anIndex;
-(void) setSelectionWordGranularitySet:(NSCharacterSet*) aSet; -(void) setSelectionWordGranularitySet:(NSCharacterSet*) aSet;
-(void) setSelectionParagraphGranularitySet:(NSCharacterSet*) aSet; -(void) setSelectionParagraphGranularitySet:(NSCharacterSet*) aSet;
@ -313,8 +318,6 @@ typedef enum _NSSelectionAffinity
// //
-(void) drawRectNoSelection:(NSRect)rect; -(void) drawRectNoSelection:(NSRect)rect;
-(int) rebuildPlainLineLayoutInformationStartingAtLine:(int) aLine; // low level never invoke (use rebuildLineLayoutInformationStartingAtLine:)
-(int) rebuildRichLineLayoutInformationStartingAtLine:(int) aLine; // ditto
@end @end
@ -323,6 +326,7 @@ extern NSString *NSTextDidBeginEditingNotification;
extern NSString *NSTextDidEndEditingNotification; extern NSString *NSTextDidEndEditingNotification;
extern NSString *NSTextDidChangeNotification; extern NSString *NSTextDidChangeNotification;
#ifdef GNUSTEP
@interface NSObject(NSTextDelegate) @interface NSObject(NSTextDelegate)
- (BOOL)textShouldBeginEditing:(NSText *)textObject; /* YES means do it */ - (BOOL)textShouldBeginEditing:(NSText *)textObject; /* YES means do it */
- (BOOL)textShouldEndEditing:(NSText *)textObject; /* YES means do it */ - (BOOL)textShouldEndEditing:(NSText *)textObject; /* YES means do it */
@ -330,5 +334,19 @@ extern NSString *NSTextDidChangeNotification;
- (void)textDidEndEditing:(NSNotification *)notification; - (void)textDidEndEditing:(NSNotification *)notification;
- (void)textDidChange:(NSNotification *)notification; /* Any keyDown or paste which changes the contents causes this */ - (void)textDidChange:(NSNotification *)notification; /* Any keyDown or paste which changes the contents causes this */
@end @end
#endif
#endif // _GNUstep_H_NSText #endif // _GNUstep_H_NSText
#if 0
NSFontAttributeName; /* NSFont, default Helvetica 12 */
-> NSParagraphStyleAttributeName; /* NSParagraphStyle, default defaultParagraphStyle */
NSForegroundColorAttributeName; /* NSColor, default blackColor */
NSUnderlineStyleAttributeName; /* int, default 0: no underline */
NSSuperscriptAttributeName; /* int, default 0 */
NSBackgroundColorAttributeName; /* NSColor, default nil: no background */
-> NSAttachmentAttributeName; /* NSTextAttachment, default nil */
NSLigatureAttributeName; /* int, default 1: default ligatures, 0: no ligatures, 2: all ligatures */
NSBaselineOffsetAttributeName; /* float, in points; offset from baseline, default 0 */
NSKernAttributeName; /* float, amount to modify default kerning, if 0, kerning off */
#endif

View file

@ -1,38 +1,11 @@
/* /*
NSTextView.h * GNUTextView.h
*/
NSTextView is an NSText subclass that displays the glyphs laid // GNUTextView is a NSText subclass that displays the glyphs laid out in one NSTextContainer.
out in one NSTextContainer.
Copyright (C) 1996 Free Software Foundation, Inc. #import <AppKit/NSText.h>
#import <AppKit/NSTextAttachment.h>
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into GNUstep gui
by Felipe A. Rodriguez <far@ix.netcom.com>
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _GNUstep_H_NSTextView
#define _GNUstep_H_NSTextView
#include <AppKit/NSText.h>
#include <AppKit/NSTextAttachment.h>
#include <AppKit/NSRulerView.h> #include <AppKit/NSRulerView.h>
#include <AppKit/NSRulerMarker.h> #include <AppKit/NSRulerMarker.h>
@ -41,16 +14,19 @@
@class NSLayoutManager; @class NSLayoutManager;
//@interface NSTextView : NSText <NSTextInput> //@interface NSTextView : NSText <NSTextInput>
@interface NSTextView : NSText @interface NSTextView : NSText
{ NSTextContainer *textContainer; {
NSColor *insertionPointColor; NSTextContainer *textContainer;
BOOL smartInsertDeleteEnabled; NSColor *insertionPointColor;
NSSelectionAffinity selectionAffinity; BOOL smartInsertDeleteEnabled;
NSSelectionGranularity selectionGranularity; NSSelectionAffinity selectionAffinity;
NSSize textContainerInset; NSSelectionGranularity selectionGranularity;
NSPoint textContainerOrigin; NSSize textContainerInset;
NSLayoutManager *layoutManager; NSPoint textContainerOrigin;
NSTextStorage *textStorage; NSLayoutManager *layoutManager;
NSTextStorage *textStorage;
} }
/**************************** Initializing ****************************/ /**************************** Initializing ****************************/
@ -150,7 +126,7 @@
@interface NSTextView (NSSharing) @interface NSTextView (NSSharing)
// The methods in this category deal with settings that need to be shared by all the NSTextViews of a single NSLayoutManager. Many of these methods are overrides of NSText or NSResponder methods. // The methods in this category deal with settings that need to be shared by all the GNUTextViews of a single NSLayoutManager. Many of these methods are overrides of NSText or NSResponder methods.
/*************************** Selected/Marked range ***************************/ /*************************** Selected/Marked range ***************************/
@ -172,7 +148,7 @@
- (void)setMarkedTextAttributes:(NSDictionary *)attributeDictionary; - (void)setMarkedTextAttributes:(NSDictionary *)attributeDictionary;
- (NSDictionary *)markedTextAttributes; - (NSDictionary *)markedTextAttributes;
/*************************** Other NSTextView methods ***************************/ /*************************** Other GNUTextView methods ***************************/
- (void)setRulerVisible:(BOOL)flag; - (void)setRulerVisible:(BOOL)flag;
- (BOOL)usesRuler; - (BOOL)usesRuler;
@ -192,28 +168,28 @@
/*************************** NSText methods ***************************/ /*************************** NSText methods ***************************/
//- (BOOL)isSelectable; - (BOOL)isSelectable;
//- (void)setSelectable:(BOOL)flag; - (void)setSelectable:(BOOL)flag;
//- (BOOL)isEditable; - (BOOL)isEditable;
//- (void)setEditable:(BOOL)flag; - (void)setEditable:(BOOL)flag;
//- (BOOL)isRichText; - (BOOL)isRichText;
//- (void)setRichText:(BOOL)flag; - (void)setRichText:(BOOL)flag;
//- (BOOL)importsGraphics; - (BOOL)importsGraphics;
//- (void)setImportsGraphics:(BOOL)flag; - (void)setImportsGraphics:(BOOL)flag;
//- (id)delegate; - (id)delegate;
//- (void)setDelegate:(id)anObject; - (void)setDelegate:(id)anObject;
//- (BOOL)isFieldEditor; - (BOOL)isFieldEditor;
//- (void)setFieldEditor:(BOOL)flag; - (void)setFieldEditor:(BOOL)flag;
//- (BOOL)usesFontPanel; - (BOOL)usesFontPanel;
//- (void)setUsesFontPanel:(BOOL)flag; - (void)setUsesFontPanel:(BOOL)flag;
//- (BOOL)isRulerVisible; - (BOOL)isRulerVisible;
//- (void)setBackgroundColor:(NSColor *)color; - (void)setBackgroundColor:(NSColor *)color;
//- (NSColor *)backgroundColor; - (NSColor *)backgroundColor;
//- (void)setDrawsBackground:(BOOL)flag; - (void)setDrawsBackground:(BOOL)flag;
//- (BOOL)drawsBackground; - (BOOL)drawsBackground;
//- (NSRange)selectedRange; - (NSRange)selectedRange;
//- (void)setSelectedRange:(NSRange)charRange; - (void)setSelectedRange:(NSRange)charRange;
/*************************** NSResponder methods ***************************/ /*************************** NSResponder methods ***************************/
@ -238,7 +214,8 @@
- (void)textView:(NSTextView *)textView doubleClickedOnCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame; - (void)textView:(NSTextView *)textView doubleClickedOnCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame;
// Delegate only. // Delegate only.
- (void)textView:(NSTextView *)view draggedCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)rect event:(NSEvent *)event; // Delegate only - (void)textView:(NSTextView *)view draggedCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)rect event:(NSEvent *)event;
// Delegate only
- (NSRange)textView:(NSTextView *)textView willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange toCharacterRange:(NSRange)newSelectedCharRange; - (NSRange)textView:(NSTextView *)textView willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange toCharacterRange:(NSRange)newSelectedCharRange;
// Delegate only. // Delegate only.
@ -258,5 +235,3 @@ extern NSString *NSTextViewWillChangeNotifyingTextViewNotification;
extern NSString *NSTextViewDidChangeSelectionNotification; extern NSString *NSTextViewDidChangeSelectionNotification;
// NSOldSelectedCharacterRange -> NSValue with old range. // NSOldSelectedCharacterRange -> NSValue with old range.
#endif /* _GNUstep_H_NSTextView */

View file

@ -451,16 +451,21 @@ static Class imageClass;
(int)bRect.size.width, (int)bRect.size.width,
(int)bRect.size.height); (int)bRect.size.height);
bRect.origin.x -= 2;
bRect.size.width += 2;
[textObject setDelegate: anObject]; [textObject setDelegate: anObject];
[textObject setFrame: bRect]; [textObject setFrame: bRect];
[[NSColor redColor] set]; NSEraseRect(aRect);
NSRectFill(aRect);
// NSEraseRect(aRect);
[textObject setText: [self stringValue]]; [textObject setText: [self stringValue]];
[[[controlView window] contentView] addSubview: textObject]; [[[controlView window] contentView] addSubview: textObject];
if ([theEvent type] == NSLeftMouseDown)
[textObject mouseDown:theEvent];
[textObject display]; [textObject display];
[controlView unlockFocus]; [controlView unlockFocus];
} }

File diff suppressed because it is too large Load diff

View file

@ -1,29 +1,8 @@
/* /*
NSTextView.m * NSTextView.h
*/
Copyright (C) 1996 Free Software Foundation, Inc. // classes needed are: NSRulerView NSTextContainer NSLayoutManager
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into GNUstep gui
by Felipe A. Rodriguez <far@ix.netcom.com>
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <AppKit/NSTextView.h> #include <AppKit/NSTextView.h>
#include <AppKit/NSRulerView.h> #include <AppKit/NSRulerView.h>
@ -34,8 +13,6 @@
#include <AppKit/NSLayoutManager.h> #include <AppKit/NSLayoutManager.h>
#include <AppKit/NSTextStorage.h> #include <AppKit/NSTextStorage.h>
// classes needed are: NSRulerView NSTextContainer NSLayoutManager
@implementation NSTextView @implementation NSTextView
/**************************** Initializing ****************************/ /**************************** Initializing ****************************/
@ -56,14 +33,11 @@
// container may be nil // container may be nil
- initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer *)container - initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer *)container
{ { if(container) [self setTextContainer: container];
// self=[super initWithFrame:frameRect];
[super initWithFrame:frameRect];
if(container) [self setTextContainer: container];
else // set up a new container else // set up a new container
{ {
} }
self=[super initWithFrame:frameRect];
return self; return self;
} }
@ -113,13 +87,11 @@ if(container) [self setTextContainer: container];
/************************* Key binding entry-point *************************/ /************************* Key binding entry-point *************************/
// This method is the funnel point for text insertion after keys pass through the key binder. // This method is the funnel point for text insertion after keys pass through the key binder.
#ifdef DEBUGG #ifdef DEBUGG
-(void) insertText:(NSString*) insertString -(void) insertText:(NSString*) insertString
{ {
[super insertText: insertString];
} }
#endif /* DEBUGG */ #endif
/*************************** Sizing methods ***************************/ /*************************** Sizing methods ***************************/
@ -204,7 +176,6 @@ if(container) [self setTextContainer: container];
-(void) setNeedsDisplayInRect:(NSRect)rect avoidAdditionalLayout:(BOOL)fla -(void) setNeedsDisplayInRect:(NSRect)rect avoidAdditionalLayout:(BOOL)fla
{ {
} }
#ifdef DEBUGG #ifdef DEBUGG
-(BOOL)shouldDrawInsertionPoint -(BOOL)shouldDrawInsertionPoint
{ {
@ -212,8 +183,7 @@ if(container) [self setTextContainer: container];
-(void) drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag -(void) drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag
{ {
} }
#endif /* DEBUGG */ #endif
/*************************** Especially for subclassers ***************************/ /*************************** Especially for subclassers ***************************/
-(void) updateRuler -(void) updateRuler
@ -230,17 +200,14 @@ if(container) [self setTextContainer: container];
if([self importsGraphics]) [ret addObject:NSRTFDPboardType]; if([self importsGraphics]) [ret addObject:NSRTFDPboardType];
return ret; return ret;
} }
#ifdef DEBUGG #ifdef DEBUGG
- (void)updateDragTypeRegistration - (void)updateDragTypeRegistration
{ {
} }
- (NSRange)selectionRangeForProposedRange:(NSRange)proposedCharRange granularity:(NSSelectionGranularity)granularity - (NSRange)selectionRangeForProposedRange:(NSRange)proposedCharRange granularity:(NSSelectionGranularity)granularity
{ {}
} #endif
#endif /* DEBUGG */
@end @end
@implementation NSTextView (NSSharing) @implementation NSTextView (NSSharing)
@ -286,7 +253,7 @@ if(container) [self setTextContainer: container];
{ {
} }
/*************************** Other NSTextView methods ***************************/ /*************************** Other GNUTextView methods ***************************/
-(void) setRulerVisible:(BOOL)flag -(void) setRulerVisible:(BOOL)flag
{ {
@ -332,7 +299,6 @@ if(container) [self setTextContainer: container];
/*************************** NSResponder methods ***************************/ /*************************** NSResponder methods ***************************/
#ifdef DEBUGG #ifdef DEBUGG
-(BOOL) resignFirstResponder -(BOOL) resignFirstResponder
{ return YES; { return YES;
@ -340,8 +306,7 @@ if(container) [self setTextContainer: container];
-(BOOL) becomeFirstResponder -(BOOL) becomeFirstResponder
{ return YES; { return YES;
} }
#endif /* DEBUGG */ #endif
/*************************** Smart copy/paste/delete support ***************************/ /*************************** Smart copy/paste/delete support ***************************/
-(BOOL)smartInsertDeleteEnabled {return smartInsertDeleteEnabled;} -(BOOL)smartInsertDeleteEnabled {return smartInsertDeleteEnabled;}
@ -357,19 +322,18 @@ if(container) [self setTextContainer: container];
- (void) setDelegate: (id) anObject - (void) setDelegate: (id) anObject
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[super setDelegate: anObject]; [super setDelegate: anObject];
#define SET_DELEGATE_NOTIFICATION(notif_name) \ #define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([delegate respondsToSelector: @selector(textView##notif_name:)]) \ if ([delegate respondsToSelector: @selector(textView##notif_name:)]) \
[nc addObserver: delegate \ [nc addObserver: delegate \
selector: @selector(textView##notif_name:) \ selector: @selector(textView##notif_name:) \
name: NSTextView##notif_name##Notification \ name: NSTextView##notif_name##Notification \
object: self] object: self]
SET_DELEGATE_NOTIFICATION(DidChangeSelection); SET_DELEGATE_NOTIFICATION(DidChangeSelection);
SET_DELEGATE_NOTIFICATION(WillChangeNotifyingTextView); SET_DELEGATE_NOTIFICATION(WillChangeNotifyingTextView);
} }
@end @end