Revision: 16385
http://sourceforge.net/p/skim-app/code/16385
Author: hofman
Date: 2026-06-17 09:02:19 +0000 (Wed, 17 Jun 2026)
Log Message:
-----------
no separate function to gather link templates
Modified Paths:
--------------
trunk/SKTemplateTag.m
Modified: trunk/SKTemplateTag.m
===================================================================
--- trunk/SKTemplateTag.m 2026-06-10 16:44:44 UTC (rev 16384)
+++ trunk/SKTemplateTag.m 2026-06-17 09:02:19 UTC (rev 16385)
@@ -39,7 +39,7 @@
#import "SKTemplateTag.h"
#import "SKTemplateParser.h"
-static inline SKAttributeTemplate *copyTemplateForLink(id aLink, NSRange
range) {
+static inline SKAttributeTemplate *templateForLink(id aLink, NSRange range) {
SKAttributeTemplate *linkTemplate = nil;
Class aClass = [aLink class];
if ([aLink isKindOfClass:[NSURL class]])
@@ -52,20 +52,6 @@
return linkTemplate;
}
-static inline NSArray
*copyTemplatesForLinksFromAttributedString(NSAttributedString *attrString) {
- NSMutableArray *templates = [[NSMutableArray alloc] init];
-
- [attrString enumerateAttribute:NSLinkAttributeName inRange:NSMakeRange(0,
[attrString length]) options:0 usingBlock:^(id aLink, NSRange range, BOOL
*stop) {
- SKAttributeTemplate *linkTemplate = copyTemplateForLink(aLink, range);
- if (linkTemplate) {
- [templates addObject:linkTemplate];
- }
- }];
- if ([templates count] == 0)
- templates = nil;
- return templates;
-}
-
@implementation SKTemplateTag
@dynamic type;
@@ -108,7 +94,7 @@
- (SKAttributeTemplate *)linkTemplate {
if (linkTemplate == nil)
- linkTemplate = copyTemplateForLink([attributes
objectForKey:NSLinkAttributeName], NSMakeRange(0, 0)) ?: [[SKAttributeTemplate
alloc] init];
+ linkTemplate = templateForLink([attributes
objectForKey:NSLinkAttributeName], NSMakeRange(0, 0)) ?: [[SKAttributeTemplate
alloc] init];
return [linkTemplate template] ? linkTemplate : nil;
}
@@ -268,8 +254,15 @@
- (SKTemplateTagType)type { return SKTemplateTagText; }
- (NSArray *)linkTemplates {
- if (linkTemplates == nil)
- linkTemplates =
copyTemplatesForLinksFromAttributedString(attributedText) ?: [[NSArray alloc]
init];
+ if (linkTemplates == nil) {
+ NSMutableArray *templates = [[NSMutableArray alloc] init];
+ [attributedText enumerateAttribute:NSLinkAttributeName
inRange:NSMakeRange(0, [attributedText length]) options:0 usingBlock:^(id
aLink, NSRange range, BOOL *stop) {
+ SKAttributeTemplate *linkTemplate = templateForLink(aLink, range);
+ if (linkTemplate)
+ [templates addObject:linkTemplate];
+ }];
+ linkTemplates = [templates copy];
+ }
return [linkTemplates count] ? linkTemplates : nil;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit