Revision: 14930
          http://sourceforge.net/p/skim-app/code/14930
Author:   hofman
Date:     2025-03-01 18:15:29 +0000 (Sat, 01 Mar 2025)
Log Message:
-----------
macro to get number of sub text storages

Modified Paths:
--------------
    trunk/PDFSelection_SKExtensions.m

Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m   2025-03-01 18:10:23 UTC (rev 14929)
+++ trunk/PDFSelection_SKExtensions.m   2025-03-01 18:15:29 UTC (rev 14930)
@@ -269,6 +269,7 @@
 #define CHARACTERS_KEY @"characters"
 
 #define SUB_TEXT_STORAGES (subTextStorages ?: (subTextStorages = [textStorage 
valueForKey:key]))
+#define SUB_TEXT_STORAGES_COUNT ([key isEqualToString:CHARACTERS_KEY] ? 
[textStorage length] : [SUB_TEXT_STORAGES count])
 
 static NSArray 
*characterRangesAndContainersForSpecifier(NSScriptObjectSpecifier *specifier, 
BOOL continuous, BOOL continuousContainers) {
     if ([specifier isKindOfClass:[NSScriptObjectSpecifier class]] == NO)
@@ -310,10 +311,7 @@
                 if ([specifier isKindOfClass:[NSPropertySpecifier class]]) {
                     // this should be the full range of characters, words, or 
paragraphs
                     NSRange range = NSMakeRange(0, 0);
-                    if ([key isEqualToString:@"character"])
-                        range.length = [textStorage length];
-                    else
-                        range.length = [SUB_TEXT_STORAGES count];
+                    range.length = SUB_TEXT_STORAGES_COUNT;
                     if (range.length)
                         [tmpRanges addPointer:&range];
                 } else if ([specifier isKindOfClass:[NSRangeSpecifier class]]) 
{
@@ -334,10 +332,7 @@
                             indices = [endSpec 
indicesOfObjectsByEvaluatingWithContainer:textStorage count:&count];
                             endIndex = count > 0 ? indices[count - 1] : -1;
                         } else {
-                            if ([key isEqualToString:@"character"])
-                                endIndex = [textStorage length] - 1;
-                            else
-                                endIndex = [SUB_TEXT_STORAGES count] - 1;
+                            endIndex = SUB_TEXT_STORAGES_COUNT - 1;
                         }
                         if (startIndex >= 0 && endIndex >= 0) {
                             NSRange range = NSMakeRange(MIN(startIndex, 
endIndex), MAX(startIndex, endIndex) + 1 - MIN(startIndex, endIndex));
@@ -349,10 +344,7 @@
                     indices = [specifier 
indicesOfObjectsByEvaluatingWithContainer:textStorage count:&count];
                     NSRange range = NSMakeRange(0, 0);
                     if (count == -1) {
-                        if ([key isEqualToString:@"character"])
-                            range.length = [textStorage length];
-                        else
-                            range.length = [SUB_TEXT_STORAGES count];
+                        range.length = SUB_TEXT_STORAGES_COUNT;
                     } else if (count > 0) {
                         for (i = 0; i < count; i++) {
                             NSUInteger idx = indices[i];

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

Reply via email to