-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathETTextStorage.m
38 lines (36 loc) · 1.02 KB
/
ETTextStorage.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import <EtoileFoundation/EtoileFoundation.h>
#import "EtoileText.h"
@implementation ETTextStorage
@synthesize text,style;
- (NSString*)string
{
return [text stringValue];
}
- (NSDictionary*)attributesAtIndex: (NSUInteger)anIndex
effectiveRange: (NSRangePointer)range
{
// FIXME: This collects the style for intermediate nodes redundantly. We
// should probably have a caching mechanism, or this will perform very
// badly on deep trees.
NSUInteger end = [text buildStyleFromIndex: anIndex
withStyleBuilder: style];
if (NULL != range)
{
range->location = anIndex;
range->length = end - anIndex;
}
return [style style];
}
- (void)replaceCharactersInRange: (NSRange)aRange
withString: (NSString*)aString
{
[text replaceCharactersInRange: aRange
withString: aString];
}
- (void)setAttributes: (NSDictionary*)attributes
range: (NSRange)aRange
{
[text setCustomAttributes: attributes
range: aRange];
}
@end