luaforwindows/SciTE/docs/SciTEDirector.html

442 lines
19 KiB
HTML
Executable File

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="SciTE" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
SciTE Director Interface
</title>
<style type="text/css">
table {
border: 1px solid black;
border-collapse: collapse;
}
td {
border: 1px solid black;
padding: 1px 5px 1px 5px;
}
.S0 {
color: #808080;
}
.S1 {
font-family: Comic Sans MS;
color: #007F00;
font-size: 9pt;
}
.S2 {
font-family: Comic Sans MS;
color: #007F00;
font-size: 9pt;
}
.S3 {
font-family: Comic Sans MS;
color: #3F703F;
font-size: 9pt;
}
.S4 {
color: #007F7F;
}
.S5 {
font-weight: bold;
color: #00007F;
}
.S6 {
color: #7F007F;
}
.S7 {
color: #7F007F;
}
.S8 {
color: #804080;
}
.S9 {
color: #7F7F00;
}
.S10 {
font-weight: bold;
color: #000000;
}
.S12 {
font-family: Courier New;
color: #000000;
background: #E0C0E0;
font-size: 10pt;
}
.S13 {
font-family: Courier New;
color: #007F00;
background: #E0FFE0;
font-size: 10pt;
}
.S14 {
font-family: Courier New;
color: #3F7F3F;
background: #E0F0FF;
font-size: 10pt;
}
.S15 {
font-family: Comic Sans MS;
color: #3F703F;
font-size: 9pt;
}
SPAN {
font-family: Verdana;
font-size: 10pt;
}
.example {
color: #00A000;
font-weight: bold;
}
DIV.example {
background: #F7FCF7;
border: 1px solid #C0D7C0;
margin: 0.3em 3em;
padding: 0.3em 0.6em;
font-size: 80%;
}
DIV.highlighted {
background: #F7FCF7;
border: 1px solid #C0D7C0;
margin: 0.3em 3em;
padding: 0.3em 0.6em;
font-size: 80%;
}
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table bgcolor="#000000" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<img src="SciTEIco.png" border="3" height="64" width="64" alt="Scintilla icon" />
</td>
<td>
<a href="index.html" style="color:white;text-decoration:none"><font size="5">
SciTE Director Interface</font></a>
</td>
</tr>
</table>
<h3>
Purpose.
</h3>
<p>Software development does not occur only at the single file level handled by SciTE.
A developer will generally work on a group of related files together in the context of one
project. Project manager functionality could be added to SciTE as it has to other editors
but this would impose a particular view of how projects are to be managed including the
format of project files. Instead, SciTE has an interface that can be used by project
managers or similar applications to control SciTE. Any application that controls SciTE is
referred to as a "Director".</p>
<p>The current Director interface only works on Windows. In the future, it should be
possible to replace the low level interface and so make this interface available on other
platforms.</p>
<p>There is currently one director application,
<a href="http://llt.chez.tiscali.fr/">Filerx</a>, available.</p>
<p>This interface is implemented on top of the
<a href="SciTEExtension.html">SciTE Extension Interface</a>, in the
file scite\win32\DirectorExtension.cxx.</p>
<h3>
Direct connection, broadcasting and explicit return addresses.
</h3>
<p>One application at a time is <i>the director</i> of SciTE,
controlling SciTE as it wishes. To support other communications techniques
applications may broadcast to all active director interfaces. When doing so,
each message should contain an explicit return address where replies to the
broadcast message will be sent.
</p>
<h3>
Low level interface on Windows.
</h3>
<p>The Windows WM_COPYDATA message is used to transfer data between
SciTE and a Director. The messages are sent between windows created by the two
applications. SciTE uses a window that has no other purpose than to receive these
messages.
The lpData and cbData fields of the COPYDATASTRUCT
are used to transfer a string between the two processes, with cbData holding the length
of the string pointed to by lpData. The string does not have to be terminated with '\0'.
The dwData should be 0.</p>
<p>Before messages can be sent from one application to the other, the window handle
of the window to receive the message must be found. This is normally transferred when
starting the other application as a command line parameter. Either application may
start the other. SciTE makes its window handle available in the WindowID
property and accepts a director.hwnd property as the window handle to which it
sends data.</p>
<p>As an example of communicating the window handle, to install Filerx in the Tools
menu of SciTE these properties could be used:</p>
<div class="example">
command.name.0.*=Project Editor<br/>
command.0.*="C:\os\scite\bin\filerx.exe" "$(FileDir)" "$(WindowID)"<br/>
command.subsystem.0.*=2
</div>
<p>In the opposite direction, Filerx can start up SciTE with a command line that
specifies its window handle as well as the file it wants edited:</p>
<div class="example">
SciTE -director.hwnd=937846 c:\os\scite\src\SciTEBase.cxx
</div>
<p>Once one application has the window handle of the other application, it should send
its window handle to the other application using an identity message as described later.
Then both sides are able to send messages.</p>
<p>To broadcast a message on Windows, the set of active director
interfaces can be found by broadcasting the "SciTEDirectorInterface"
message and seeing which windows reply with the same value as that message.
Example broadcast code:</p>
<div class="highlighted">
<SPAN class=S0></SPAN><SPAN class=S5>unsigned</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>int</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>SDI</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>::</SPAN><SPAN class=S11>RegisterWindowMessage</SPAN><SPAN class=S10>(</SPAN><SPAN class=S0></SPAN><SPAN class=S6>"SciTEDirectorInterface"</SPAN><SPAN class=S10>);</SPAN><SPAN class=S0><BR>
</SPAN><SPAN class=S11>HWND</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>w</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>::</SPAN><SPAN class=S11>GetWindow</SPAN><SPAN class=S10>(::</SPAN><SPAN class=S11>GetDesktopWindow</SPAN><SPAN class=S10>(),</SPAN><SPAN class=S0></SPAN><SPAN class=S11>GW_CHILD</SPAN><SPAN class=S10>);</SPAN><SPAN class=S0><BR>
</SPAN><SPAN class=S5>while</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>w</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>{</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>DWORD</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>res</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>0</SPAN><SPAN class=S10>;</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S2>//&nbsp;Need&nbsp;time&nbsp;out&nbsp;to&nbsp;avoid&nbsp;hung&nbsp;applications</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S10>::</SPAN><SPAN class=S11>SendMessageTimeout</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>w</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>SDI</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>0</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>0</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>SMTO_NORMAL</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>1000</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>&amp;</SPAN><SPAN class=S11>res</SPAN><SPAN class=S10>);</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>if</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>res</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>==</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>static_cast</SPAN><SPAN class=S10>&lt;</SPAN><SPAN class=S11>DWORD</SPAN><SPAN class=S10>&gt;(</SPAN><SPAN class=S11>SDI</SPAN><SPAN class=S10>))</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>{</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S2>//&nbsp;Replied&nbsp;with&nbsp;same&nbsp;SDI&nbsp;code&nbsp;so&nbsp;should</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S2>//&nbsp;understand&nbsp;SDI's&nbsp;version&nbsp;of&nbsp;WM_COPYDATA</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S10>::</SPAN><SPAN class=S11>SendMessage</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>w</SPAN><SPAN class=S10>,</SPAN><SPAN class=S11>WM_COPYDATA</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>UINT</SPAN><SPAN class=S10>)</SPAN><SPAN class=S11>m_hWnd</SPAN><SPAN class=S10>,(</SPAN><SPAN class=S5>long</SPAN><SPAN class=S10>)&amp;</SPAN><SPAN class=S11>cds</SPAN><SPAN class=S10>);</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S10>}</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>w</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>::</SPAN><SPAN class=S11>GetWindow</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>w</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>GW_HWNDNEXT</SPAN><SPAN class=S10>);</SPAN><SPAN class=S0><BR>
</SPAN><SPAN class=S10>}</SPAN><SPAN class=S0><BR>
</SPAN>
</div>
<p>To advertise that a top level window supports the Director interface:</p>
<div class="highlighted">
<SPAN class=S0></SPAN><SPAN class=S11>LRESULT</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>PASCAL</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>DirectorExtension_WndProc</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>HWND</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>hWnd</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>UINT</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>iMessage</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>WPARAM</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>wParam</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>LPARAM</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>lParam</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>{</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>unsigned</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>int</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>SDI</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>::</SPAN><SPAN class=S11>RegisterWindowMessage</SPAN><SPAN class=S10>(</SPAN><SPAN class=S6>"SciTEDirectorInterface"</SPAN><SPAN class=S10>);</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>if</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>iMessage</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>==</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>SDI</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>{</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>return</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>SDI</SPAN><SPAN class=S10>;</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S10>}</SPAN><SPAN class=S0><BR>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>return</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>::</SPAN><SPAN class=S11>DefWindowProc</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>hWnd</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>iMessage</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>wParam</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0></SPAN><SPAN class=S11>lParam</SPAN><SPAN class=S10>);</SPAN><SPAN class=S0><BR>
</SPAN><SPAN class=S10>}</SPAN><BR>
</div>
<h3>
Low level interface on GTK+.
</h3>
<p>This is not yet implemented.
The proposed design uses an input fifo for each application supporting the director
interface located in /tmp with a name using a pattern such as
"/tmp/SciTE&lt;PID&gt;.director".
This allows enumerating all active director interfaces and also opening
a specific interface when the fifo name has been communicated through some
other means such as a command line argument or an identity: command.</p>
<h3>
High level interface.
</h3>
<p>Messages use C style escapes to represent control characters and
ensure that only visible characters are transmitted apart from the use
of '\n' to separate messages.</p>
<p>The string transmitted by the low level interface contains an optional
return address surrounded by ':' characters, an action, a ':' character and
an optional argument. The argument is often a file path. The ':' must be present even if there
is no argument. For example, SciTE understands the message</p>
<div class="example">
open:c:\\os\\scintilla\\include\\Scintilla.iface
</div>
<p>as a command to open the file "c:\os\scintilla\include\Scintilla.iface" just as if the user
had performed this operation.</p>
<p>If the first character of the message is a ':' then up to the next ':' is a return
address, so SciTE will reply to the message</p>
<div class="example">
:73658:askfilename:
</div>
<p>by sending the filename being edited to the return address 73658
rather than to its director.</p>
<h4>The actions understood by SciTE are:</h4>
<table border="1">
<tr>
<td>askfilename:</td>
<td>Return the name of the file being edited.</td>
</tr>
<tr>
<td>askproperty:&lt;key&gt;</td>
<td>Return the value of a property.</td>
</tr>
<tr>
<td>close:</td>
<td>Close the current file.</td>
</tr>
<tr>
<td>closing:</td>
<td>Director is closing - SciTE closes if it was started by the director.</td>
</tr>
<tr>
<td>currentmacro:&lt;string&gt;</td>
<td>Set the current macro to name.</td>
</tr>
<tr>
<td>cwd:</td>
<td>Change the working directory.</td>
</tr>
<tr>
<td>enumproperties:dyn|local|user|base|embed</td>
<td>Enumerate all the properties in the argument set.</td>
</tr>
<tr>
<td>exportashtml:&lt;path&gt;</td>
<td>Save the document in HTML format as the indicated file.</td>
</tr>
<tr>
<td>exportasrtf:&lt;path&gt;</td>
<td>Save the document in RTF format as the indicated file.</td>
</tr>
<tr>
<td>exportaspdf:&lt;path&gt;</td>
<td>Save the document in PDF format as the indicated file.</td>
</tr>
<tr>
<td>exportaslatex:&lt;path&gt;</td>
<td>Save the document in LaTeX format as the indicated file.</td>
</tr>
<tr>
<td>exportasxml:&lt;path&gt;</td>
<td>Save the document in XML format as the indicated file.</td>
</tr>
<tr>
<td>extender:&lt;command&gt;</td>
<td>Call the extension interface with the given command.</td>
</tr>
<tr>
<td>find:&lt;string&gt;</td>
<td>Search for a string, select and show it.</td>
</tr>
<tr>
<td>focus:&lt;timeStamp&gt;</td>
<td>On GTK+ bring this SciTE window to the front.
The timeStamp is from the window manager and ensures that windows are only
activated because of a user command.
Has no effect on Windows as applications on Windows can only donate focus, not take focus.</td>
</tr>
<tr>
<td>goto:&lt;lineNumber&gt;[,&lt;columnNumber&gt;]</td>
<td>Move caret to a particular line and make it visible.<br>
If there is a column number then select the word at that column number
or move the caret there if no word is present.</td>
</tr>
<tr>
<td>identity:&lt;hwndDirector&gt;</td>
<td>Sets the director window handle to which SciTE sends messages.
The argument is in decimal.</td>
</tr>
<tr>
<td>insert:&lt;value&gt;</td>
<td>Display the value in the editor pane replacing the selection.</td>
</tr>
<tr>
<td>loadsession:&lt;path&gt;</td>
<td>Load a session as given by the indicated file.</td>
</tr>
<tr>
<td>macrocommand:&lt;command&gt;</td>
<td>Execute a macro command.
See the SciTE source code for the syntax of the
command argument.</td>
</tr>
<tr>
<td>macroenable:&lt;enable&gt;</td>
<td>If enable, display menu commands in SciTE for recording
and playing macros.</td>
</tr>
<tr>
<td>macrolist:&lt;list&gt;</td>
<td>Display a list for the user to choose from.</td>
</tr>
<tr>
<td>menucommand:&lt;cmd&gt;</td>
<td>Execute a menu command based on numeric ID.</td>
</tr>
<tr>
<td>open:&lt;path&gt;</td>
<td>Open the indicated file.</td>
</tr>
<tr>
<td>output:&lt;value&gt;</td>
<td>Display the value in the output pane replacing the selection.</td>
</tr>
<tr>
<td>property:&lt;key&gt;=&lt;value&gt;</td>
<td>Set a property to a value.</td>
</tr>
<tr>
<td>quit:</td>
<td>Shut down SciTE.</td>
</tr>
<tr>
<td>reloadproperties:</td>
<td>Reload properties from files.</td>
</tr>
<tr>
<td>replaceall:&lt;search&gt;\000&lt;replace&gt;</td>
<td>Replace all instances of he search string in the
document with the replace string.</td>
</tr>
<tr>
<td>saveas:&lt;path&gt;</td>
<td>Save the document as the indicated file.</td>
</tr>
<tr>
<td>savesession:&lt;path&gt;</td>
<td>Save a session as given by the indicated file.</td>
</tr>
</table>
<h4>The actions sent by SciTE are:</h4>
<table border="1">
<tr>
<td>closed:&lt;path&gt;</td>
<td>SciTE has closed the indicated file.</td>
</tr>
<tr>
<td>closing:</td>
<td>SciTE is closing.</td>
</tr>
<tr>
<td>dyn|local|user|base|embed:&lt;key&gt;=&lt;value&gt;</td>
<td>Set a property in a set to a value.</td>
</tr>
<tr>
<td>filename:&lt;path&gt;</td>
<td>The file being edited is path.
This is the reply to the askfilename: command.</td>
</tr>
<tr>
<td>identity:&lt;hwndSciTEReceiving&gt;</td>
<td>SciTE indicates to the director the window handle to which it should send
messages. The argument is in decimal.</td>
</tr>
<tr>
<td>macro:getlist</td>
<td>Retrieve the list of available macros which will be
returned by the macrolist command.</td>
</tr>
<tr>
<td>macro:record:&lt;details&gt;</td>
<td>Start recording a macro.
See the SciTE source code for the syntax of the
details argument.</td>
</tr>
<tr>
<td>macro:run:&lt;macroName&gt;</td>
<td>Run the named macro.</td>
</tr>
<tr>
<td>macro:stoprecord</td>
<td>Stop recording a macro.</td>
</tr>
<tr>
<td>opened:&lt;path&gt;</td>
<td>SciTE has opened the indicated file.</td>
</tr>
<tr>
<td>switched:&lt;path&gt;</td>
<td>SciTE has switched buffers to the indicated file.</td>
</tr>
<tr>
<td>saved:&lt;path&gt;</td>
<td>SciTE has saved the indicated file.</td>
</tr>
</table>
<p>In the future, more actions will be defined. Applications should ignore any
actions that they do not understand.</p>
</body>
</html>