-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPDAnnotatedTextStorage.m
53 lines (41 loc) · 1.69 KB
/
PDAnnotatedTextStorage.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// PDAnnotatedTextStorage.m
// SproutedInterface
//
// Created by Philip Dow on 5/24/07.
// Copyright Sprouted. All rights reserved.
// Inquiries should be directed to [email protected]
//
#import <SproutedInterface/PDAnnotatedTextStorage.h>
#define MarkerAttributeName NSToolTipAttributeName
@implementation PDAnnotatedTextStorage
-(BOOL)hasBookmarkAtIndex:(unsigned)index inTextView:(NSTextView*)textView
{
//NSRange paragraphRange =
//[textView selectionRangeForProposedRange:NSMakeRange(index, 1) granularity:NSSelectByParagraph];
//NSLog(@"%@ %s - %i, %i", [self className], _cmd, NSMaxRange(paragraphRange) -1);
//id attribute = [self attribute:MarkerAttributeName atIndex:NSMaxRange(paragraphRange) -1 effectiveRange:NULL];
id attribute = [self attribute:MarkerAttributeName atIndex:index effectiveRange:NULL];
if( attribute != NULL )
return YES;
else
return NO;
}
-(BOOL)hasBookmarkAtIndex:(unsigned)index inTextView:(NSTextView*)textView effectiveRange:(NSRangePointer)aRange
{
//NSRange paragraphRange =
//[textView selectionRangeForProposedRange:NSMakeRange(index, 1) granularity:NSSelectByParagraph];
//NSLog(@"%@ %s - %i, %i", [self className], _cmd, NSMaxRange(paragraphRange) -1);
id attribute = [self attribute:MarkerAttributeName atIndex:index effectiveRange:aRange];
if( attribute != NULL )
return YES;
else
return NO;
}
-(void)setBookmarkAtIndex:(unsigned)index flag:(BOOL)flag inTextView:(NSTextView*)textView
{
NSRange paragraphRange =
[textView selectionRangeForProposedRange:NSMakeRange(index, 1) granularity:NSSelectByParagraph];
[self addAttribute:MarkerAttributeName value:@"My Comment" range:NSMakeRange(NSMaxRange(paragraphRange)-1,1)];
}
@end