PageRenderTime 50ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/doc/users-guide/launcher-guide.xml

#
XML | 537 lines | 474 code | 54 blank | 9 comment | 0 complexity | d24070dadf23fc314a02223e08f2d89c MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- :xml.root=users-guide.xml: -->
  3. <appendix id="launcher-guide">
  4. <title>jEditLauncher for Windows</title>
  5. <!-- jEdit buffer-local properties: -->
  6. <!-- :tabSize=2:indentSize=1:noTabs=true:maxLineLen=72: -->
  7. <!-- jEditLauncher 4.0 (R2) Quick Guide -->
  8. <!-- Copyright (C) 2001, 2002 John Gellene -->
  9. <!-- $Id: launcher-guide.xml 16181 2009-09-08 19:26:57Z ezust $
  10. -->
  11. <section id="launcher-intro">
  12. <title>Introduction</title>
  13. <para>The jEditLauncher package is a set of lightweight components for
  14. running jEdit under the Windows group of operating systems. The package
  15. is designed to run on Windows 95, Windows 98, Windows Me, Windows NT
  16. (versions 4.0 and greater), Windows 2000 and Windows XP.</para>
  17. <para>While jEdit does not make available a component-type interface, it
  18. does contains an <quote>EditServer</quote> that listens on a socket for
  19. requests to load scripts written in the BeanShell scripting language.
  20. When the server activates, it writes the server port number and a
  21. pseudo-random, numeric authorization key to a text file. By default, the
  22. file is named <filename>server</filename> and is located in the settings
  23. directory (see <xref linkend="settings-directory" />).</para>
  24. <para>The jEditLauncher component locates and reads this file, opens a
  25. socket and attempts to connect to the indicated port. If successful, it
  26. transmits the appropriate BeanShell script to the server. If
  27. unsuccessful, it attempts to start jEdit and repeats the socket
  28. transmission once it can obtain the port and key information. The
  29. component will abandon the effort to connect roughly twenty seconds
  30. after it launches the application.</para>
  31. </section>
  32. <section id="launcher-starting">
  33. <title>Starting jEdit</title>
  34. <para>The main component of the jEditLauncher package is a client
  35. application entitled <command>jedit.exe</command>. It may be executed
  36. either from either Windows Explorer, a shortcut icon or the command
  37. line. It uses the jEditLauncher COM component to open files in jEdit
  38. that are listed as command line parameters. It supports Windows and UNC
  39. file specifications as well as wild cards. If called without parameters,
  40. it will launch jEdit. If jEdit is already running<!-- and has an active
  41. EditServer -->, it will simply open a new, empty buffer.</para>
  42. <para><command>jedit.exe</command> supports five command-line options.
  43. Except for the <userinput>/1</userinput> option, if any of these options
  44. are invoked correctly, the application will not load files or execute
  45. jEdit.</para>
  46. <itemizedlist>
  47. <listitem>
  48. <para>The option <userinput>/h</userinput> causes a window to be
  49. displayed with a brief description of the application and its
  50. various options.</para>
  51. </listitem>
  52. <listitem>
  53. <para>The option <userinput>/p</userinput> will activate a
  54. dialog window displaying the command-line parameters to be used
  55. when calling jEdit. This option can also be triggered by
  56. selecting <guilabel>Set jEdit Parameters</guilabel> from the
  57. <guilabel>jEdit</guilabel> section of the Windows Programs menu,
  58. or by running the utility program
  59. <command>jedinit.exe</command></para>
  60. <para>Using the dialog, you can change parameters specifying the
  61. executable for the Java application loader (either
  62. <filename>java.exe</filename> or
  63. <filename>javaw.exe</filename>), the location of the jEdit
  64. archive file, <filename>jedit.jar</filename>, and command line
  65. options for both. <itemizedlist>
  66. <listitem>
  67. <para>The input fields for Java options and jEdit
  68. options are separate. If you insert an option in the
  69. wrong place it will not be properly executed.</para>
  70. </listitem>
  71. <listitem>
  72. <para>If the <userinput>-jar</userinput> option is
  73. not used with the Java application loader the
  74. principal jEdit class of
  75. <classname>org.gjt.sp.jedit.jEdit</classname> is set
  76. as fixed data.</para>
  77. </listitem>
  78. <listitem>
  79. <para>The working directory for the Java
  80. interpreter's process can also be specified.</para>
  81. </listitem>
  82. </itemizedlist> A read-only window at the bottom of the
  83. dialog displays the full command line that jEditLauncher will
  84. invoke.</para>
  85. <para>Before committing changes to the command line parameters,
  86. <command>jedit.exe</command> validates the paths for the Java
  87. and jEdit targets as well as the working directory. It will
  88. complain if the paths are invalid. It will not validate command
  89. line options, but it will warn you if it finds the
  90. <userinput>-noserver</userinput> option used for jEdit, since
  91. this will deactivate the edit server and make it impossible for
  92. jEditLauncher to open files.</para>
  93. <para>Note that due to the design of
  94. <application>jEditLauncher</application>, platform-independent
  95. command line options handled by jEdit itself (such as
  96. <userinput>-background</userinput> and
  97. <userinput>-norestore</userinput>) must be entered in the
  98. <quote>Set jEdit Parameters</quote> dialog box, and cannot be
  99. specified on the <command>jedit.exe</command> command line
  100. directly. For information about platform-independent command
  101. line options, see <xref linkend="cli-usage" />.</para>
  102. </listitem>
  103. <listitem>
  104. <para>The option <userinput>/1</userinput> is intended for use
  105. in circumstances where a single file name is passed to jEdit for
  106. opening, and quotation marks cannot be used to delimit file
  107. names containing whitespace. The launcher reads the entire
  108. command line following the <userinput>/1</userinput> options as
  109. a single file path, regardless of the presence of whitespace,
  110. and passes the resulting string as a single file name parameter
  111. to jEdit.</para>
  112. <para>This option allows jEdit to be used with version 5 or
  113. greater of Internet Explorer as an alternate text editor or as
  114. the target of the <guimenuitem>View Source</guimenuitem>
  115. command. Included with the jEditLauncher distribution is a file
  116. named <filename>jEdit_IE.reg.txt</filename> containing an
  117. example of a Window registry file that you can use to register
  118. jEdit as a HTML editor with Internet Explorer. Instructions for
  119. the file's use are included in the text.</para>
  120. <para>The use of the <userinput>/1</userinput> option with
  121. multiple file names or other parameters will lead to program
  122. errors or unpredictable results.</para>
  123. </listitem>
  124. <listitem>
  125. <para>The option <userinput>/i</userinput> is not mentioned in
  126. the help window for <filename>jedit.exe</filename>. It is
  127. intended primarily to be used in conjunction with jEdit's Java
  128. installer, but it can also be used to install or reinstall
  129. jEditLauncher manually. When accompanied by a second parameter
  130. specifying the directory where your preferred Java interpreter
  131. is located, jEditLauncher will install itself and set a
  132. reasonable initial set of command line parameters for executing
  133. jEdit. You can change these parameters later by running
  134. <filename>jedinit.exe</filename> or
  135. <filename>jedit.exe</filename> with the<userinput>/p</userinput>
  136. option.</para>
  137. </listitem>
  138. <listitem>
  139. <para>The option <userinput>/u</userinput> will cause
  140. jEditLauncher to be uninstalled by removing its registry
  141. entries. This option does not delete any jEditLauncher or jEdit
  142. files.</para>
  143. </listitem>
  144. </itemizedlist>
  145. </section>
  146. <section id="launcher-menu">
  147. <title>The Context Menu Handler</title>
  148. <para>The jEditLauncher package also implements a context menu handler
  149. for the Windows shell. It is intended to be be installed as a handler
  150. available for any file. When you right-click on a file or shortcut icon,
  151. the context menu that appears will include an item displaying the jEdit
  152. icon and captioned <guilabel>Open with jEdit</guilabel>. If the file has
  153. an extension, another item will appear captioned <guilabel>Open *.XXX
  154. with jEdit</guilabel>, where XXX is the extension of the selected file.
  155. Clicking this item will cause jEdit to load all files with the same
  156. extension in the same directory as the selected file. Multiple file
  157. selections are also supported; in this circumstance only the
  158. <guilabel>Open with jEdit</guilabel> item appears.</para>
  159. <para>If a single file with a <filename>.bsh</filename> extension is
  160. selected, the menu will also contain an item captioned <guilabel>Run
  161. script in jEdit</guilabel>. Selecting this item will cause jEditLauncher
  162. to run the selected file as a BeanShell script.</para>
  163. <para>If exactly two files are selected, the menu will contain an entry
  164. for <guilabel>Show diff in jEdit</guilabel>. Selecting this item will
  165. load the two files in jEdit and have them displayed side-by-side with
  166. their differences highlighted by the <application>JDiff</application>
  167. plugin. The file selected first will be treated as the base for
  168. comparison purposes. If the plugin is not installed, an error message
  169. will be displayed in jEdit. See <xref linkend="using-plugins" /> for
  170. more information about installing plugins.</para>
  171. </section>
  172. <!-- open section -->
  173. <section id="launcher-jedidiff">
  174. <title>Using jEdit and jEditLauncher as a Diff Utility</title>
  175. <para>As noted above, you can create a graphical diff display comparing
  176. the contents of two text files by selecting the two files in an Explorer
  177. window, right-clicking to produce a context menu, and selecting the
  178. <guimenuitem>Show diff in jEdit</guimenuitem> menu item. The utility
  179. <filename>jedidiff.exe</filename> allows you to perform this operation
  180. from a command line. The command takes the two files to be compared as
  181. parameters; they should be delimited by quotation marks if their paths
  182. contain whitespace.</para>
  183. </section>
  184. <section id="launcher-uninstall">
  185. <title>Uninstalling jEdit and jEditLauncher</title>
  186. <para></para>
  187. <para>There are three ways to uninstall jEdit and jEditLauncher.</para>
  188. <itemizedlist>
  189. <listitem>
  190. <para>First, you can run <filename>unlaunch.exe</filename> in
  191. the jEdit installation directory.</para>
  192. </listitem>
  193. <listitem>
  194. <para>Second, you can choose <guilabel>Uninstall
  195. jEdit</guilabel> from the <guilabel>jEdit</guilabel> section of
  196. the Programs menu. <!-- This will
  197. uninstall the <quote>primary</quote> version of jEdit (and will
  198. designate a new primary version if any versions remain). --></para>
  199. </listitem>
  200. <listitem>
  201. <para>Third, you can choose the uninstall option for jEdit in
  202. the Control Panel's Add/Remove Programs applet. <!-- This allows you to specify
  203. unambiguously the version of jEdit that you wish to remove. --></para>
  204. </listitem>
  205. </itemizedlist>
  206. <para>Each of these options will deactivate jEditLauncher and delete all
  207. files in jEdit's installation directory. As a safeguard, jEditLauncher
  208. displays a warning window and requires the user to confirm an uninstall
  209. operation. Because the user's settings directory can be set and changed
  210. from one jEdit session to another, user settings files must be deleted
  211. manually.</para>
  212. <para>To deactivate jEditLauncher without deleting any files, run
  213. <filename>jedit /u</filename> from any command prompt where the jEdit
  214. installation directory is in the search path. This will remove the
  215. entries for jEditLauncher from the Windows registry. It will also
  216. disable the context menu handler and the automatic launching and
  217. scripting capabilities. The package can reactivated by executing
  218. <command>jedit.exe</command> again, and jEdit can be started in the same
  219. manner as any other Java application on your system.</para>
  220. </section>
  221. <section id="launcher-interface">
  222. <title>The jEditLauncher Interface</title>
  223. <para>The core of the jEditLauncher package is a COM component that can
  224. communicate with the EditServer, or open jEdit if it is not running or
  225. is otherwise refusing a connection. The component supports both Windows
  226. and UNC file specifications, including wild cards. It will resolve
  227. shortcut links to identify and transmit the name of the underlying
  228. file.</para>
  229. <para>Because it is implemented with a <quote>dual interface</quote>,
  230. the functions of jEditLauncher are available to scripting languages in
  231. the Windows environment such as VBScript, JScript, Perl (using the
  232. Win32::OLE package) and Python (using the win32com.client
  233. package).</para>
  234. <para>The scriptable interface consists of two read-only properties and
  235. six functions:</para>
  236. <para><emphasis>Properties</emphasis></para>
  237. <itemizedlist>
  238. <listitem>
  239. <para><varname>ServerPort</varname> - a read-only property that
  240. returns the port number found in jEdit's server file; the value
  241. is not tested for authenticity. It returns zero if the server
  242. information file cannot be located.</para>
  243. </listitem>
  244. <listitem>
  245. <para><varname>ServerKey</varname> - a read-only property that
  246. returns the numeric authorization key found in jEdit's server
  247. file; the value is not tested for authenticity. It returns zero
  248. if the server information file cannot be located.</para>
  249. </listitem>
  250. </itemizedlist>
  251. <para><emphasis>Functions</emphasis></para>
  252. <itemizedlist>
  253. <listitem>
  254. <para><function>OpenFile</function> - a method that takes a
  255. single file name (with or without wild card characters) as a
  256. parameter.</para>
  257. </listitem>
  258. <listitem>
  259. <para><function>OpenFiles</function> - this method takes an
  260. array of file names (with or without wild card characters) as a
  261. parameter. The form of the array is that which is used for
  262. arrays in the scripting environment. In JScript, for example the
  263. data type of the <classname>VARIANT</classname> holding the
  264. array is <classname>VT_DISPATCH</classname>; in VBScript, it is
  265. <classname>VT_ARRAY | VT_VARIANT</classname>, with array members
  266. having data type <classname>VT_BSTR</classname>.</para>
  267. </listitem>
  268. <listitem>
  269. <para><function>Launch</function> - this method with no
  270. parameters attempts to open jEdit without loading additional
  271. files.</para>
  272. </listitem>
  273. <listitem>
  274. <para><function>RunScript</function> - this method takes a file
  275. name or full file path as a parameter and runs the referenced
  276. file as a BeanShell script in jEdit. The predefined variables
  277. <varname>view</varname>, <varname>editPane</varname>,
  278. <varname>textArea</varname> and <varname>buffer</varname> are
  279. available to the script. If more than one view is open, the
  280. variable are initialized with reference to the earliest opened
  281. view. If no path is given for the file it will use the working
  282. directory of the calling process.</para>
  283. </listitem>
  284. <listitem>
  285. <para><function>EvalScript</function> - this method takes a
  286. string as a parameter containing one or more BeanShell
  287. statements and runs the script in jEdit's BeanShell interpreter.
  288. The predefined variables are available on the same basis as in
  289. <function>RunScript</function>.</para>
  290. </listitem>
  291. <listitem>
  292. <para><function>RunDiff</function> - this method takes two
  293. strings representing file names as parameters. If the
  294. <application>JDiff</application> plugin is installed, this
  295. method will activate the JDiff plugin and display the two files
  296. in the plugin's graphical <quote>dual diff</quote> format. The
  297. first parameter is treated as the base for display purposes. If
  298. the <application>JDiff</application> plugin is not installed, a
  299. error message box will be displayed in jEdit.</para>
  300. </listitem>
  301. </itemizedlist>
  302. </section>
  303. <section id="launcher-examples">
  304. <title>Scripting Examples</title>
  305. <para>Here are some brief examples of scripts using jEditLauncher. The
  306. first two will run under Windows Script Host, which is either installed
  307. or available for download for 32-bit Windows operating systems. The next
  308. example is written in Perl and requires the Win32::OLE package. The last
  309. is written in Python and requires the win32gui and win32com.client
  310. extensions.</para>
  311. <para>If Windows Script Host is installed, you can run the first two
  312. scripts by typing the name of the file containing the script at a
  313. command prompt. In jEdit's <application>Console</application> plugin,
  314. you can type <userinput>cmd /c
  315. <replaceable>script_path</replaceable></userinput> or <userinput>wscript
  316. <replaceable>script_path</replaceable></userinput>.</para>
  317. <informalexample>
  318. <programlisting>' Example VBScript using jEditLauncher interface
  319. dim launcher
  320. set launcher = CreateObject("JEdit.JEditLauncher")
  321. a = Array("I:\Source Code Files\shellext\jeditshell\*.h", _
  322. "I:\Source Code Files\shellext\jeditshell\*.cpp")
  323. MsgBox "The server authorization code is " + _
  324. FormatNumber(launcher.ServerKey, 0, 0, 0, 0) + ".", _
  325. vbOKOnly + vbInformation, "jEditLauncher"
  326. launcher.openFiles(a)
  327. myScript = "jEdit.newFile(view); textArea.setSelectedText(" _
  328. &amp; CHR(34) _
  329. &amp; "Welcome to jEditLauncher." _
  330. &amp; CHR(34) &amp; ");"
  331. launcher.evalScript(myScript)</programlisting>
  332. </informalexample>
  333. <informalexample>
  334. <programlisting>/* Example JScript using jEditLauncher interface
  335. * Note: in contrast to VBScript, JScript does not
  336. * directly support message boxes outside a browser window
  337. */
  338. var launcher = WScript.createObject("JEdit.JEditLauncher");
  339. var a = new Array("I:\\weather.html", "I:\\test.txt");
  340. b = "I:\\*.pl";
  341. launcher.openFiles(a);
  342. launcher.openFile(b);
  343. c = "G:\\Program Files\\jEdit\\macros\\Misc"
  344. + "\\Properties\\System_properties.bsh";
  345. launcher.runScript(c);</programlisting>
  346. </informalexample>
  347. <informalexample>
  348. <programlisting># Example Perl script using jEditLauncher interface
  349. use Win32::OLE;
  350. $launcher = Win32::OLE-&gt;new('JEdit.JEditLauncher') ||
  351. die "JEditLauncher: not found !\n";
  352. @files = ();
  353. foreach $entry (@ARGV) {
  354. @new = glob($entry);
  355. push(@files,@new);
  356. }
  357. $launcher-&gt;openFiles(\@files);
  358. my($script) = "Macros.message(view, \"I found "
  359. .(scalar @files)." files.\");";
  360. $launcher-&gt;evalScript($script);</programlisting>
  361. </informalexample>
  362. <informalexample>
  363. <programlisting># Example Python script using jEditLauncher interface
  364. import win32gui
  365. import win32com.client
  366. o = win32com.client.Dispatch("JEdit.JEditLauncher")
  367. port = o.ServerPort
  368. if port == 0:
  369. port = "inactive. We will now launch jEdit"
  370. win32gui.MessageBox(0, "The server port is %s." % port,
  371. "jEditLauncher", 0)
  372. path = "C:\\WINNT\\Profiles\\Administrator\\Desktop\\"
  373. o.RunDiff(path + "Search.bsh", path + "Search2.bsh")
  374. </programlisting>
  375. </informalexample>
  376. </section>
  377. <!-- open section -->
  378. <section id="launcher-logging">
  379. <title>jEditLauncher Logging</title>
  380. <para>The jEditLauncher package has a logging facility that is separate
  381. from jEdit's Activity Log to provide a record of events occurring
  382. outside the Java virtual machine environment in which jEdit operates.
  383. The logging facility maintains two log files:
  384. <filename>jelaunch.log</filename> for events relating to starting jEdit,
  385. loading files and running scripts, and <filename>install.log</filename>
  386. for jEditLauncher installation activity. Both files are maintained in
  387. the directory in which jEdit is installed. They are cumulative from
  388. session to session, but may be manually deleted at any time without
  389. affecting program execution.</para>
  390. </section>
  391. <!-- <section id="launcher-install"><title>Standalone Installation</title>
  392. <para>
  393. Installation of jEditLauncher occurs as part of the installation of the
  394. jEdit package for Windows. If a full jEdit installation fails, you can
  395. install jEditLauncher by placing the following files in the same
  396. directory as <filename>jedit.jar</filename>, the archive containing the
  397. Java application:
  398. </para>
  399. <itemizedlist>
  400. <listitem>
  401. <para>
  402. <filename>jedit.exe</filename>
  403. </para>
  404. </listitem>
  405. <listitem>
  406. <para>
  407. <filename>jedinit.exe</filename>
  408. </para>
  409. </listitem>
  410. <listitem>
  411. <para>
  412. <filename>jeshlstb.dll</filename>
  413. </para>
  414. </listitem>
  415. <listitem>
  416. <para>
  417. <filename>jedinstl.dll</filename>
  418. </para>
  419. </listitem>
  420. <listitem>
  421. <para>
  422. <filename>jeditsvr.exe</filename>
  423. </para>
  424. </listitem>
  425. <listitem>
  426. <para>
  427. <filename>jeservps.dll</filename>
  428. </para>
  429. </listitem>
  430. <listitem>
  431. <para>
  432. <filename>unlaunch.exe</filename>
  433. </para>
  434. </listitem>
  435. </itemizedlist>
  436. <para>
  437. Anytime <filename>jedit.exe</filename> is executed (either directly or
  438. indirectly through a call to <filename>jedinit.exe</filename>),
  439. jEditLauncher checks to see if it is properly installed. If it is not,
  440. it will offer to install itself. If you agree, you will then be asked to
  441. supply the path to a Java interpreter. The directory you choose should
  442. contain <filename>javaw.exe</filename>, which the installer uses as a
  443. default; you can change the interpreter later with a call to
  444. <filename>jedinit.exe</filename>.
  445. </para>
  446. </section> -->
  447. <section id="launcher-legalnotice">
  448. <title>Legal Notice</title>
  449. <para>All source code and software distributed as the jEditLauncher
  450. package in which the author holds the copyright is made available under
  451. the GNU General Public License (<quote>GPL</quote>). A copy of the GPL
  452. is included in the file <filename>COPYING.txt</filename> included with
  453. jEdit.</para>
  454. <para>Notwithstanding the terms of the General Public License, the
  455. author grants permission to compile and link object code generated by
  456. the compilation of this program with object code and libraries that are
  457. not subject to the GNU General Public License, provided that the
  458. executable output of such compilation shall be distributed with source
  459. code on substantially the same basis as the jEditLauncher package of
  460. which this source code and software is a part. By way of example, a
  461. distribution would satisfy this condition if it included a working
  462. Makefile for any freely available make utility that runs on the Windows
  463. family of operating systems. This condition does not require a licensee
  464. of this software to distribute any proprietary software (including
  465. header files and libraries) that is licensed under terms prohibiting or
  466. limiting redistribution to third parties.</para>
  467. <para>The purpose of this specific permission is to allow a user to link
  468. files contained or generated by the source code with library and other
  469. files licensed to the user by Microsoft or other parties, whether or not
  470. that license conforms to the requirements of the GPL. This permission
  471. should not be construed to expand the terms of any license for any
  472. source code or other materials used in the creation of
  473. jEditLauncher.</para>
  474. </section>
  475. </appendix>