1997-09-01 21:59:51 +00:00
|
|
|
/*
|
|
|
|
NSAttributedString.h
|
|
|
|
|
|
|
|
String class with attributes
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
Copyright (C) 1997,1999 Free Software Foundation, Inc.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
|
1997-11-21 18:19:29 +00:00
|
|
|
Date: November 1997
|
1999-04-09 17:07:21 +00:00
|
|
|
Rewrite by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Date: April 1999
|
1997-09-01 21:59:51 +00:00
|
|
|
|
1997-11-21 18:19:29 +00:00
|
|
|
This file is part of GNUStep-base
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1997-09-01 21:59:51 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
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
|
2019-12-09 23:36:00 +00:00
|
|
|
Lesser General Public License for more details.
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
If you are interested in a warranty or support for this source code,
|
|
|
|
contact Scott Christley <scottc@net-community.com> for more information.
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1997-09-01 21:59:51 +00:00
|
|
|
License along with this library; if not, write to the Free
|
2006-09-13 10:20:49 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2019-12-09 23:36:00 +00:00
|
|
|
Boston, MA 02110 USA.
|
1997-09-01 21:59:51 +00:00
|
|
|
*/
|
|
|
|
|
1999-04-09 17:07:21 +00:00
|
|
|
/* Warning - [-initWithString:attributes:] is the designated initialiser,
|
|
|
|
* but it doesn't provide any way to perform the function of the
|
|
|
|
* [-initWithAttributedString:] initialiser.
|
|
|
|
* In order to work youd this, the string argument of the
|
|
|
|
* designated initialiser has been overloaded such that it
|
|
|
|
* is expected to accept an NSAttributedString here instead of
|
|
|
|
* a string. If you create an NSAttributedString subclass, you
|
|
|
|
* must make sure that your implementation of the initialiser
|
|
|
|
* copes with either an NSString or an NSAttributedString.
|
|
|
|
* If it receives an NSAttributedString, it should ignore the
|
|
|
|
* attributes argument and use the values from the string.
|
|
|
|
*/
|
1997-11-21 18:19:29 +00:00
|
|
|
|
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#ifndef __NSAttributedString_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSAttributedString_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
2006-09-13 10:20:49 +00:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
1997-09-01 21:59:51 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
|
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSCoder.h>
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
@interface NSAttributedString : NSObject <NSCoding, NSCopying, NSMutableCopying>
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//Creating an NSAttributedString
|
1999-09-16 07:21:34 +00:00
|
|
|
- (id) initWithString: (NSString*)aString;
|
|
|
|
- (id) initWithAttributedString: (NSAttributedString*)attributedString;
|
|
|
|
- (id) initWithString: (NSString*)aString attributes: (NSDictionary*)attributes;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
//Retrieving character information
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) length;
|
2010-02-08 17:52:36 +00:00
|
|
|
/** Returns the string content of the receiver.<br />
|
|
|
|
* NB. this is actually a proxy to the internal content (which may change)
|
2018-03-15 14:09:14 +00:00
|
|
|
* so if you need an immutable instance you should copy the returned value,
|
|
|
|
* not just retain it.
|
2010-02-08 17:52:36 +00:00
|
|
|
*/
|
1999-09-16 07:21:34 +00:00
|
|
|
- (NSString*) string; //Primitive method!
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
//Retrieving attribute information
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSDictionary*) attributesAtIndex: (NSUInteger)index
|
1999-09-16 07:21:34 +00:00
|
|
|
effectiveRange: (NSRange*)aRange; //Primitive method!
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSDictionary*) attributesAtIndex: (NSUInteger)index
|
1999-09-16 07:21:34 +00:00
|
|
|
longestEffectiveRange: (NSRange*)aRange
|
|
|
|
inRange: (NSRange)rangeLimit;
|
|
|
|
- (id) attribute: (NSString*)attributeName
|
2009-02-23 20:42:32 +00:00
|
|
|
atIndex: (NSUInteger)index
|
1999-09-16 07:21:34 +00:00
|
|
|
effectiveRange: (NSRange*)aRange;
|
2009-02-23 20:42:32 +00:00
|
|
|
- (id) attribute: (NSString*)attributeName atIndex: (NSUInteger)index
|
1999-09-16 07:21:34 +00:00
|
|
|
longestEffectiveRange: (NSRange*)aRange inRange: (NSRange)rangeLimit;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
//Comparing attributed strings
|
1999-09-16 07:21:34 +00:00
|
|
|
- (BOOL) isEqualToAttributedString: (NSAttributedString*)otherString;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
//Extracting a substring
|
1999-09-16 07:21:34 +00:00
|
|
|
- (NSAttributedString*) attributedSubstringFromRange: (NSRange)aRange;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
@end //NSAttributedString
|
|
|
|
|
|
|
|
|
|
|
|
@interface NSMutableAttributedString : NSAttributedString
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//Retrieving character information
|
1999-09-16 07:21:34 +00:00
|
|
|
- (NSMutableString*) mutableString;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
//Changing characters
|
1999-09-16 07:21:34 +00:00
|
|
|
- (void) deleteCharactersInRange: (NSRange)aRange;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
//Changing attributes
|
1999-09-16 07:21:34 +00:00
|
|
|
- (void) setAttributes: (NSDictionary*)attributes
|
|
|
|
range: (NSRange)aRange; //Primitive method!
|
|
|
|
- (void) addAttribute: (NSString*)name value: (id)value range: (NSRange)aRange;
|
|
|
|
- (void) addAttributes: (NSDictionary*)attributes range: (NSRange)aRange;
|
|
|
|
- (void) removeAttribute: (NSString*)name range: (NSRange)aRange;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
//Changing characters and attributes
|
1999-09-16 07:21:34 +00:00
|
|
|
- (void) appendAttributedString: (NSAttributedString*)attributedString;
|
|
|
|
- (void) insertAttributedString: (NSAttributedString*)attributedString
|
2009-02-23 20:42:32 +00:00
|
|
|
atIndex: (NSUInteger)index;
|
1999-09-16 07:21:34 +00:00
|
|
|
- (void) replaceCharactersInRange: (NSRange)aRange
|
|
|
|
withAttributedString: (NSAttributedString*)attributedString;
|
|
|
|
- (void) replaceCharactersInRange: (NSRange)aRange
|
|
|
|
withString: (NSString*)aString; //Primitive method!
|
|
|
|
- (void) setAttributedString: (NSAttributedString*)attributedString;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
//Grouping changes
|
1999-09-16 07:21:34 +00:00
|
|
|
- (void) beginEditing;
|
|
|
|
- (void) endEditing;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
@end //NSMutableAttributedString
|
|
|
|
|
2020-08-02 12:14:07 +00:00
|
|
|
typedef NSString* NSAttributedStringKey;
|
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#endif /* GS_API_MACOSX */
|
1998-11-10 20:16:33 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-02-20 17:16:23 +00:00
|
|
|
#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL)
|
2010-02-18 11:40:58 +00:00
|
|
|
#import <GNUstepBase/NSAttributedString+GNUstepBase.h>
|
|
|
|
#endif
|
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#endif /* __NSAttributedString_h_GNUSTEP_BASE_INCLUDE */
|
1997-09-01 21:59:51 +00:00
|
|
|
|