3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Benjamin Piwowarski
8 * Full author contact details are available in file CREDITS.
11 #import <Cocoa/Cocoa.h>
12 #include "AppleScript.h"
16 @interface LyxCommand : NSScriptCommand {
18 - (id)performDefaultImplementation;
21 @implementation LyxCommand
22 - (id)performDefaultImplementation {
23 // Get the command and argument
24 NSDictionary * theArguments = [self evaluatedArguments];
26 NSString * directParameter = [self directParameter];
27 NSString *arg = [theArguments objectForKey: @"arg"];
30 // Execute the command
31 LyXFunctionResult result = applescript_execute_command([directParameter UTF8String], [arg UTF8String]);
33 // Construct the result record
34 NSString *message = [NSString stringWithCString:result.message encoding:NSUTF8StringEncoding];
37 if (result.code != 0) {
38 NSScriptCommand* c = [NSScriptCommand currentCommand];
39 [c setScriptErrorNumber:result.code];
40 [c setScriptErrorString:message];
49 /// Needed by AppleScript in order to discover LyxCommand
50 void setupApplescript() {