PageRenderTime 59ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/doc/users-guide/launcher-guide.xml

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