NSLog(@"Filling rects!");
///////
NSLayoutManager* LM = [[NSLayoutManager alloc] init];
NSAttributedString* AS = [self attributedStringValue];
NSTextStorage* TS = [[NSTextStorage alloc] initWithAttributedString:AS];
[TS setAttributedString:AS];
[LM setTextStorage:TS];
[TS addLayoutManager:LM];
NSTextContainer* TC = [[NSTextContainer alloc] initWithContainerSize:[self frame].size];
[LM addTextContainer:TC];
NSUInteger rectCount = 0;
NSRectArray linkRect = [LM rectArrayForCharacterRange:NSMakeRange(0, 2)
withinSelectedCharacterRange:NSMakeRange(0, 0)
inTextContainer:TC
rectCount:&rectCount];
activeURLRects.clear();
for(size_t i = 0; i < rectCount; ++i)
{
cout << "Rect:\n";
cout << "\t" << linkRect[i].size.width << " , " << linkRect[i].size.height << endl;
activeURLRects.push_back(linkRect[i]);
}
///////
for(size_t i = 0; i < activeURLRects.size(); ++i)
{
NSRect rect = activeURLRects[i];
NSColor* color = [NSColor colorWithDeviceRed:0.0 green:1.0 blue:0.0 alpha:0.3];
[color set];
NSRectFill(rect);
}