PageRenderTime 139ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

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

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