]> git.lyx.org Git - lyx.git/blob - src/support/AppleScriptProxy.cpp
Update Win installer for new dictionary links. Untested.
[lyx.git] / src / support / AppleScriptProxy.cpp
1 // -*- C++ -*-
2 /**
3  * \file AppleScriptProxy.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Benjamin Piwowarski
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11 #include <config.h>
12
13 #include "AppleScript.h"
14
15 #include "DispatchResult.h"
16 #include "FuncRequest.h"
17 #include "LyX.h"
18 #include "LyXAction.h"
19
20 #include "frontends/Application.h"
21
22 #include "support/docstring.h"
23 #include "support/debug.h"
24
25 #include <stdlib.h>
26
27 using namespace std;
28 using namespace lyx;
29
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);
34         DispatchResult dr;
35         theApp()->dispatch(fr, dr);
36
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());
40
41         // Returns the result
42         LyXFunctionResult result;
43         result.code = dr.error() ? -1 : 0;
44         result.message = cstr;
45
46         return result;
47 }
48