3 * \file AppleScriptProxy.cpp
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Benjamin Piwowarski
9 * Full author contact details are available in file CREDITS.
13 #include "AppleScript.h"
15 #include "DispatchResult.h"
16 #include "FuncRequest.h"
18 #include "LyXAction.h"
20 #include "frontends/Application.h"
22 #include "support/docstring.h"
23 #include "support/debug.h"
30 extern "C" LyXFunctionResult applescript_execute_command(const char *cmd, const char *arg) {
31 LYXERR(Debug::ACTION, "Running command [" << cmd << "] with arguments [" << arg << "]");
32 FuncRequest fr(lyxaction.lookupFunc(cmd), from_utf8(arg));
33 fr.setOrigin(FuncRequest::LYXSERVER);
35 theApp()->dispatch(fr, dr);
37 string const rval = to_utf8(dr.message());
38 char *cstr = (char*) malloc((rval.size()+1)*sizeof(rval[0]));
39 strcpy (cstr, rval.c_str());
42 LyXFunctionResult result;
43 result.code = dr.error() ? -1 : 0;
44 result.message = cstr;