,
tell document 1 of application "DocScript" to simple reset
( reset) ( 1 "DocScript" ). , [command directParameter], objectSpecifier .
, , Ted. () "select", " 5 1".
tell application "Ted"
select paragraph 5 of document 1
end tell
SDEF: Text Suite:
<suite name="Text Suite" code="????">
...
<class name="paragraph" code="cpar" inherits="item" >
...
<responds-to command="select">
<cocoa method="handleSelectCommand:"/>
</responds-to>
</class>
...
</suite>
"select" EVERY , : . , , , .
:
, , NSTextStorage, NSTextStorage .
@implementation NSTextStorage (Scriptability)
- (void) handleSelectCommand:(NSScriptCommand *)command
{
NSScriptObjectSpecifier *directParameter =[command directParameter];
NSScriptObjectSpecifier *container = [directParameter containerSpecifier];
TedDocument *document = [self extractDocument:container];
NSString *contents = document.textView.string;
NSRange selRange;
[self getRangeForSelectCommand:directParameter contents:contents range:&selRange];
[document.textView setSelectedRange:selRange];
}
@end
directParameter, , " 5 1 " ", . :
// , .
- (TedDocument *) extractDocument:(NSScriptObjectSpecifier *)container
{
if (container == nil)
{
NSLog(@"%@", @"ERROR: extractDocument received nil container reference");
return nil;
}
FourCharCode containerClass = [[container keyClassDescription] appleEventCode];
if (containerClass != 'docu')
{
return [self extractDocument:[container containerSpecifier]];
}
return [container objectsByEvaluatingSpecifier];
}