Revision: 12577
          http://sourceforge.net/p/skim-app/code/12577
Author:   hofman
Date:     2021-11-27 14:54:01 +0000 (Sat, 27 Nov 2021)
Log Message:
-----------
Define TeX line as a class rather than a value type, so it can work with JXA. 
Typed and implemented as an integer NSNumber.

Modified Paths:
--------------
    trunk/NSNumber_SKExtensions.h
    trunk/NSNumber_SKExtensions.m
    trunk/Skim.sdef

Modified: trunk/NSNumber_SKExtensions.h
===================================================================
--- trunk/NSNumber_SKExtensions.h       2021-11-24 10:22:33 UTC (rev 12576)
+++ trunk/NSNumber_SKExtensions.h       2021-11-27 14:54:01 UTC (rev 12577)
@@ -48,7 +48,11 @@
 - (NSString *)alphaCounterValue;
 - (NSString *)greekCounterValue;
 
-+ (NSNumber *)scriptingTexLineWithDescriptor:(NSAppleEventDescriptor 
*)descriptor;
-- (NSAppleEventDescriptor *)scriptingTexLineDescriptor;
+@end
 
+@interface NSObject (SKExtensions)
+
+- (NSUInteger)countOfTexLines;
+- (id)objectInTexLinesAtIndex:(NSUInteger)idx;
+
 @end

Modified: trunk/NSNumber_SKExtensions.m
===================================================================
--- trunk/NSNumber_SKExtensions.m       2021-11-24 10:22:33 UTC (rev 12576)
+++ trunk/NSNumber_SKExtensions.m       2021-11-27 14:54:01 UTC (rev 12577)
@@ -112,19 +112,16 @@
     return string;
 }
 
-+ (NSNumber *)scriptingTexLineWithDescriptor:(NSAppleEventDescriptor 
*)descriptor {
-    if ([descriptor descriptorType] != typeObjectSpecifier || [[descriptor 
descriptorForKeyword:keyAEDesiredClass] typeCodeValue]!= 'Line')
-        return nil;
-    NSInteger i = [[descriptor descriptorForKeyword:keyAEKeyData] int32Value];
-    return [NSNumber numberWithInteger:MAX(0, i - 1)];
+@end
+
+@implementation NSObject (SKExtensions)
+
+- (NSUInteger)countOfTexLines {
+    return NSNotFound;
 }
 
-- (NSAppleEventDescriptor *)scriptingTexLineDescriptor {
-    AEDesc desc;
-    if (noErr == CreateObjSpecifier('Line', (AEDesc *)[[NSAppleEventDescriptor 
nullDescriptor] aeDesc], formAbsolutePosition, (AEDesc 
*)[[NSAppleEventDescriptor descriptorWithInt32:[self intValue] + 1] aeDesc], 
YES, &desc)) {
-        return [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&desc] 
autorelease];
-    }
-    return nil;
+- (id)objectInTexLinesAtIndex:(NSUInteger)idx {
+    return [NSNumber numberWithUnsignedInteger:idx];
 }
 
 @end

Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef     2021-11-24 10:22:33 UTC (rev 12576)
+++ trunk/Skim.sdef     2021-11-27 14:54:01 UTC (rev 12577)
@@ -836,6 +836,15 @@
             </direct-parameter>
         </command>
 
+        <class-extension extends="item" hidden="yes"
+            description="A scriptable object.">
+            <cocoa class="NSObject"/>
+            <element type="TeX line" access="r"
+                description="TeX lines.">
+                <cocoa key="texLines"/>
+            </element>
+        </class-extension>
+
         <class-extension extends="application"
             description="Skim's top level scripting object.">
             <cocoa class="SKApplication"/>
@@ -1326,6 +1335,11 @@
             <type type="point" list="yes"/>
         </class>
 
+        <class name="TeX line" plural="TeX lines" code="Line">
+            <cocoa class="NSNumber"/>
+            <type type="integer"/>
+        </class>
+
         <record-type name="PDF view settings" code="VSet">
             <property name="scale factor" code="SclF" type="real"
                 description="The scale factor of the PDF.">
@@ -1613,10 +1627,6 @@
             <cocoa class="NSData"/>
         </value-type>
 
-        <value-type name="TeX line" code="Line">
-            <cocoa class="NSNumber"/>
-        </value-type>
-
         <enumeration name="standard color" code="ClrE" inline="0">
             <enumerator name="red" code="Red "
                 description="Red color."/>

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to