mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-16 16:18:22 +00:00
47 lines
1.2 KiB
Mathematica
47 lines
1.2 KiB
Mathematica
|
/**
|
||
|
* \file AppleScript.m
|
||
|
* This file is part of LyX, the document processor.
|
||
|
* Licence details can be found in the file COPYING.
|
||
|
*
|
||
|
* \author Benjamin Piwowarski
|
||
|
*
|
||
|
* Full author contact details are available in file CREDITS.
|
||
|
*/
|
||
|
|
||
|
#import <Cocoa/Cocoa.h>
|
||
|
#include "AppleScript.h"
|
||
|
|
||
|
|
||
|
|
||
|
@interface LyxCommand : NSScriptCommand {
|
||
|
}
|
||
|
- (id)performDefaultImplementation;
|
||
|
@end
|
||
|
|
||
|
@implementation LyxCommand
|
||
|
- (id)performDefaultImplementation {
|
||
|
// Get the command and argument
|
||
|
NSDictionary * theArguments = [self evaluatedArguments];
|
||
|
|
||
|
NSString * directParameter = [self directParameter];
|
||
|
NSString *arg = [theArguments objectForKey: @"arg"];
|
||
|
|
||
|
|
||
|
// Execute the command
|
||
|
LyXFunctionResult result = applescript_execute_command([directParameter UTF8String], [arg UTF8String]);
|
||
|
|
||
|
// Construct the result record
|
||
|
NSString *message = [NSString stringWithCString:result.message encoding:NSUTF8StringEncoding];
|
||
|
free(result.message);
|
||
|
|
||
|
NSDictionary *objcResult = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:result.code], @"code", message, @"message", nil];
|
||
|
return objcResult;
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
/// Needed by AppleScript in order to discover LyxCommand
|
||
|
void setupApplescript() {
|
||
|
}
|
||
|
|