mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Updates to AppleScript support, and documentaoin for it.
This commit is contained in:
parent
3046aa0411
commit
908c92e831
@ -12,43 +12,28 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
<!-- declare the namespace for using XInclude so we can include the standard suite -->
|
<!-- declare the namespace for using XInclude so we can include the standard suite -->
|
||||||
<dictionary xmlns:xi="http://www.w3.org/2003/XInclude">
|
<dictionary xmlns:xi="http://www.w3.org/2003/XInclude">
|
||||||
|
|
||||||
|
<!-- our special scripting suite for this example -->
|
||||||
<!-- use XInclude to include the standard suite -->
|
<suite name="Lyx" code="LYX " description="LyX scripting facilities.">
|
||||||
<!-- <xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef" xpointer="xpointer(/dictionary/suite)"/> -->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- our special scripting suite for this example -->
|
<command name="run" code="SLyxComm" description="run a simple command with one parameter">
|
||||||
<suite name="Lyx" code="LYX " description="LyX scripting facilities.">
|
|
||||||
|
|
||||||
<record-type name="LyX return value" code="LyxR">
|
|
||||||
<property name="code" code="code" type="integer"
|
|
||||||
description="Error code (0 in case of success).">
|
|
||||||
<cocoa key="code"/>
|
|
||||||
</property>
|
|
||||||
<property name="message" code="mess" type="text"
|
|
||||||
description="The returned message.">
|
|
||||||
<cocoa key="message"/>
|
|
||||||
</property>
|
|
||||||
</record-type>
|
|
||||||
|
|
||||||
<command name="run" code="SLyxComm" description="run a simple command with one parameter">
|
|
||||||
<cocoa class="LyxCommand"/>
|
<cocoa class="LyxCommand"/>
|
||||||
|
|
||||||
<direct-parameter description="The command to be executed.">
|
<direct-parameter description="The command to be executed.">
|
||||||
<type type="text" list="no"/>
|
<type type="text" list="no"/>
|
||||||
</direct-parameter>
|
</direct-parameter>
|
||||||
|
|
||||||
<parameter name="with argument" code="args" type="text">
|
<parameter name="with argument" code="args" type="text">
|
||||||
<cocoa key="arg"/>
|
<cocoa key="arg"/>
|
||||||
</parameter>
|
</parameter>
|
||||||
|
|
||||||
<result type="LyX return value" description="Contains a code (0 for success) and the message returned by LyX"/>
|
<result type="text" description="The message returned by LyX"/>
|
||||||
</command>
|
</command>
|
||||||
|
|
||||||
</suite>
|
</suite>
|
||||||
|
|
||||||
|
|
||||||
</dictionary>
|
</dictionary>
|
@ -131,11 +131,12 @@ End
|
|||||||
\papercolumns 1
|
\papercolumns 1
|
||||||
\papersides 2
|
\papersides 2
|
||||||
\paperpagestyle headings
|
\paperpagestyle headings
|
||||||
\tracking_changes false
|
\tracking_changes true
|
||||||
\output_changes false
|
\output_changes false
|
||||||
\html_math_output 0
|
\html_math_output 0
|
||||||
\html_css_as_file 0
|
\html_css_as_file 0
|
||||||
\html_be_strict true
|
\html_be_strict true
|
||||||
|
\author -1762856967 "Benjamin Piwowarski"
|
||||||
\end_header
|
\end_header
|
||||||
|
|
||||||
\begin_body
|
\begin_body
|
||||||
@ -5507,6 +5508,91 @@ read a <~/.lyxpipe.out
|
|||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
echo $a
|
echo $a
|
||||||
|
\change_inserted -1762856967 1393941760
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Subsection
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
AppleScript (Mac OS X)
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
Since LyX 2.1, LyX supports basic interactions with AppleScript for normal
|
||||||
|
communication through the command run.
|
||||||
|
This command takes a direct argument (the
|
||||||
|
\series bold
|
||||||
|
function
|
||||||
|
\series default
|
||||||
|
to perform) and an optional argument.
|
||||||
|
It either returns the output of the function or triggers an error with
|
||||||
|
the error message and code.
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
Example:
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
tell application "LyX"
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
try
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
-- Stores the current file name into f
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
set f to (run "server-get-filename" with argument "")
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
on error the error_message number the error_number
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
display dialog "Error: " & the error_number & ".
|
||||||
|
" ¬
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
& the error_message buttons {"OK"} default button 1
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
end try
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout LyX-Code
|
||||||
|
|
||||||
|
\change_inserted -1762856967 1393941776
|
||||||
|
end tell
|
||||||
|
\change_unchanged
|
||||||
|
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Section
|
\begin_layout Section
|
||||||
|
@ -34,8 +34,14 @@
|
|||||||
NSString *message = [NSString stringWithCString:result.message encoding:NSUTF8StringEncoding];
|
NSString *message = [NSString stringWithCString:result.message encoding:NSUTF8StringEncoding];
|
||||||
free(result.message);
|
free(result.message);
|
||||||
|
|
||||||
NSDictionary *objcResult = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:result.code], @"code", message, @"message", nil];
|
if (result.code != 0) {
|
||||||
return objcResult;
|
NSScriptCommand* c = [NSScriptCommand currentCommand];
|
||||||
|
[c setScriptErrorNumber:result.code];
|
||||||
|
[c setScriptErrorString:message];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user