mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Updates to AppleScript support, and documentaoin for it.
This commit is contained in:
parent
3046aa0411
commit
908c92e831
@ -12,27 +12,12 @@
|
||||
-->
|
||||
|
||||
|
||||
<!-- 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">
|
||||
|
||||
|
||||
<!-- use XInclude to include the standard suite -->
|
||||
<!-- <xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef" xpointer="xpointer(/dictionary/suite)"/> -->
|
||||
|
||||
|
||||
<!-- our special scripting suite for this example -->
|
||||
<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"/>
|
||||
@ -45,7 +30,7 @@
|
||||
<cocoa key="arg"/>
|
||||
</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>
|
||||
|
||||
</suite>
|
||||
|
@ -131,11 +131,12 @@ End
|
||||
\papercolumns 1
|
||||
\papersides 2
|
||||
\paperpagestyle headings
|
||||
\tracking_changes false
|
||||
\tracking_changes true
|
||||
\output_changes false
|
||||
\html_math_output 0
|
||||
\html_css_as_file 0
|
||||
\html_be_strict true
|
||||
\author -1762856967 "Benjamin Piwowarski"
|
||||
\end_header
|
||||
|
||||
\begin_body
|
||||
@ -5507,6 +5508,91 @@ read a <~/.lyxpipe.out
|
||||
\end_inset
|
||||
|
||||
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
|
||||
|
||||
\begin_layout Section
|
||||
|
@ -34,8 +34,14 @@
|
||||
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;
|
||||
if (result.code != 0) {
|
||||
NSScriptCommand* c = [NSScriptCommand currentCommand];
|
||||
[c setScriptErrorNumber:result.code];
|
||||
[c setScriptErrorString:message];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user