4
String class with attributes
6
Copyright (C) 1997,1999 Free Software Foundation, Inc.
8
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
10
Rewrite by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
13
This file is part of GNUStep-base
15
This library is free software; you can redistribute it and/or
16
modify it under the terms of the GNU Library General Public
17
License as published by the Free Software Foundation; either
18
version 2 of the License, or (at your option) any later version.
20
This library is distributed in the hope that it will be useful,
21
but WITHOUT ANY WARRANTY; without even the implied warranty of
22
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
Library General Public License for more details.
25
If you are interested in a warranty or support for this source code,
26
contact Scott Christley <scottc@net-community.com> for more information.
28
You should have received a copy of the GNU Library General Public
29
License along with this library; if not, write to the Free
30
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
33
/* Warning - [-initWithString:attributes:] is the designated initialiser,
34
* but it doesn't provide any way to perform the function of the
35
* [-initWithAttributedString:] initialiser.
36
* In order to work youd this, the string argument of the
37
* designated initialiser has been overloaded such that it
38
* is expected to accept an NSAttributedString here instead of
39
* a string. If you create an NSAttributedString subclass, you
40
* must make sure that your implementation of the initialiser
41
* copes with either an NSString or an NSAttributedString.
42
* If it receives an NSAttributedString, it should ignore the
43
* attributes argument and use the values from the string.
47
#ifndef _NSXKit_H_NSAttributedString
48
#define _NSXKit_H_NSAttributedString
50
#ifndef STRICT_OPENSTEP
51
#include <Foundation/NSString.h>
52
#include <Foundation/NSDictionary.h>
53
#include <Foundation/NSArray.h>
54
#include <Foundation/NSCoder.h>
56
@interface NSAttributedString : NSObject <NSCoding, NSCopying, NSMutableCopying>
60
//Creating an NSAttributedString
61
- (id) initWithString: (NSString*)aString;
62
- (id) initWithAttributedString: (NSAttributedString*)attributedString;
63
- (id) initWithString: (NSString*)aString attributes: (NSDictionary*)attributes;
65
//Retrieving character information
66
- (unsigned int) length;
67
- (NSString*) string; //Primitive method!
69
//Retrieving attribute information
70
- (NSDictionary*) attributesAtIndex: (unsigned int)index
71
effectiveRange: (NSRange*)aRange; //Primitive method!
72
- (NSDictionary*) attributesAtIndex: (unsigned int)index
73
longestEffectiveRange: (NSRange*)aRange
74
inRange: (NSRange)rangeLimit;
75
- (id) attribute: (NSString*)attributeName
76
atIndex: (unsigned int)index
77
effectiveRange: (NSRange*)aRange;
78
- (id) attribute: (NSString*)attributeName atIndex: (unsigned int)index
79
longestEffectiveRange: (NSRange*)aRange inRange: (NSRange)rangeLimit;
81
//Comparing attributed strings
82
- (BOOL) isEqualToAttributedString: (NSAttributedString*)otherString;
84
//Extracting a substring
85
- (NSAttributedString*) attributedSubstringFromRange: (NSRange)aRange;
89
* Synonym for attributedSubstringFromRange: - for consistency with NSString
91
- (NSAttributedString*) attributedSubstringWithRange: (NSRange)aRange;
94
@end //NSAttributedString
97
@interface NSMutableAttributedString : NSAttributedString
101
//Retrieving character information
102
- (NSMutableString*) mutableString;
104
//Changing characters
105
- (void) deleteCharactersInRange: (NSRange)aRange;
107
//Changing attributes
108
- (void) setAttributes: (NSDictionary*)attributes
109
range: (NSRange)aRange; //Primitive method!
110
- (void) addAttribute: (NSString*)name value: (id)value range: (NSRange)aRange;
111
- (void) addAttributes: (NSDictionary*)attributes range: (NSRange)aRange;
112
- (void) removeAttribute: (NSString*)name range: (NSRange)aRange;
114
//Changing characters and attributes
115
- (void) appendAttributedString: (NSAttributedString*)attributedString;
116
- (void) insertAttributedString: (NSAttributedString*)attributedString
117
atIndex: (unsigned int)index;
118
- (void) replaceCharactersInRange: (NSRange)aRange
119
withAttributedString: (NSAttributedString*)attributedString;
120
- (void) replaceCharactersInRange: (NSRange)aRange
121
withString: (NSString*)aString; //Primitive method!
122
- (void) setAttributedString: (NSAttributedString*)attributedString;
125
- (void) beginEditing;
128
@end //NSMutableAttributedString
130
#endif //STRICT_OPENSTEP
132
#endif //_NSXKit_H_NSAttributedString