PageRenderTime 45ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/www/tags/NOV_07_2009/htdocs/FAQ/macros.html

#
HTML | 71 lines | 71 code | 0 blank | 0 comment | 0 complexity | 34f96a4d2dacf470ac2997ef064a5314 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. <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Macros</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="jEdit Frequently Asked Questions"><link rel="up" href="index.html" title="jEdit Frequently Asked Questions"><link rel="prev" href="usage.html" title="Usage Questions"><link rel="next" href="plugins.html" title="Plugin Questions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Macros</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="usage.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="plugins.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="macros"></a>Macros</h2></div></div></div><p>This section deals with questions on writing and running
  2. macros.</p><div class="qandaset"><dl><dt>1. <a href="macros.html#macro-using">Using macros</a></dt><dd><dl><dt>Q: <a href="macros.html#id2552818">Where can I get macro's from?</a></dt><dt>Q: <a href="macros.html#id2553445">I just wrote a new macro for myself. Where should I
  3. save the file?</a></dt><dt>Q: <a href="macros.html#id2553519">Do I have to use the .bsh file
  4. extension when I save one of my own macro scripts?</a></dt><dt>Q: <a href="macros.html#id2553589">How can I store the result of a macro so that the next
  5. time I run it the macro can retrieve the value?</a></dt><dt>Q: <a href="macros.html#id2553659">In a macro I'd like to exec an external program (e.g.
  6. jmk, javac) and capture its output to a buffer. I'd also
  7. like to see this output as the external program runs or be
  8. able to interact with the program. So when I exec, what
  9. happens to System.in/out/err of the exec'd program?</a></dt></dl></dd></dl><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h4 class="title"><a name="macro-using"></a>1. Using macros</h4></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>Q: <a href="macros.html#id2552818">Where can I get macro's from?</a></dt><dt>Q: <a href="macros.html#id2553445">I just wrote a new macro for myself. Where should I
  10. save the file?</a></dt><dt>Q: <a href="macros.html#id2553519">Do I have to use the .bsh file
  11. extension when I save one of my own macro scripts?</a></dt><dt>Q: <a href="macros.html#id2553589">How can I store the result of a macro so that the next
  12. time I run it the macro can retrieve the value?</a></dt><dt>Q: <a href="macros.html#id2553659">In a macro I'd like to exec an external program (e.g.
  13. jmk, javac) and capture its output to a buffer. I'd also
  14. like to see this output as the external program runs or be
  15. able to interact with the program. So when I exec, what
  16. happens to System.in/out/err of the exec'd program?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="id2552818"></a><a name="macro-getting"></a><p><b>Q:</b></p></td><td align="left" valign="top"><p>Where can I get macro's from?</p></td></tr><tr class="answer"><td align="left" valign="top"><p><b>A:</b></p></td><td align="left" valign="top"><p>There is a plugin available called MacroManager that
  17. will provide a similar interface to jEdit's plugin manager
  18. for installing new macros. The plugin downloads the macros
  19. from the jEdit Community site, so an internet connection is
  20. necessary.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2553445"></a><a name="macro-new-store"></a><p><b>Q:</b></p></td><td align="left" valign="top"><p>I just wrote a new macro for myself. Where should I
  21. save the file?</p></td></tr><tr class="answer"><td align="left" valign="top"><p><b>A:</b></p></td><td align="left" valign="top"><p>There is a <code class="filename">macros</code> directory in
  22. your user settings directory. If you store your macro there
  23. it will appear in jEdit's <span class="guimenu"><strong>Macros</strong></span> menu
  24. under the name you have given to the macro's source code
  25. file. The <code class="filename">.bsh</code> will be deleted in the
  26. macro entry, and underscore characters will be converted to
  27. whitespace, so that the file
  28. <code class="filename">My_New_Macro.bsh</code> will be displayed as
  29. <span class="guimenuitem"><strong>My New Macro</strong></span>.</p><p>You can create additional subdirectories in the
  30. <code class="filename">macros</code>to organize your personal macros
  31. by category. Each subdirectory will correspond to a submenu
  32. under the application's <span class="guimenu"><strong>Macros</strong></span> menu. This
  33. is helpful to reduce the screen space used to display the
  34. macros menu at any one time.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2553519"></a><a name="macro-new-ext"></a><p><b>Q:</b></p></td><td align="left" valign="top"><p>Do I have to use the <code class="filename">.bsh</code> file
  35. extension when I save one of my own macro scripts?</p></td></tr><tr class="answer"><td align="left" valign="top"><p><b>A:</b></p></td><td align="left" valign="top"><p>You need the <code class="filename">.bsh</code> extension in
  36. order for jEdit to detect and display the name of the macro
  37. in its <span class="guimenu"><strong>Macros</strong></span> menu. The macro must also
  38. be in the <code class="filename">macros</code> directory of either
  39. the jEdit installation directory or the user settings
  40. directory.</p><p>You do not need the extension to run a macro, however.
  41. By selecting <span class="guimenu"><strong>Macros</strong></span>&gt;<span class="guimenuitem"><strong>Run
  42. Other Macro...</strong></span>, you can choose any file to be
  43. run as a macro. While in a macro, you can call
  44. <strong class="userinput"><code>source("full_path")</code></strong> to do the same
  45. thing.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2553589"></a><a name="macro-temp"></a><p><b>Q:</b></p></td><td align="left" valign="top"><p>How can I store the result of a macro so that the next
  46. time I run it the macro can retrieve the value?</p></td></tr><tr class="answer"><td align="left" valign="top"><p><b>A:</b></p></td><td align="left" valign="top"><p>You can use either
  47. <strong class="userinput"><code>jEdit.setProperty(String, String)</code></strong> or
  48. <strong class="userinput"><code>jEdit.setTemporaryProperty(String,
  49. String)</code></strong>. Both methods take
  50. <code class="classname">String</code> values for the name of the
  51. property and its value. If you use
  52. <strong class="userinput"><code>setProperty()</code></strong>, the property will
  53. remain in jEdit's property store permanently, so if you only
  54. need the value during the course of a single editing
  55. session, use
  56. <strong class="userinput"><code>setTemporaryProperty()</code></strong>.</p><p>To ensure that your value can be stored regardless of
  57. its type, use the following syntax:</p><pre class="programlisting">jEdit.setTemporaryProperty("myValueName", myValue.toString());</pre><p>
  58. and remember to convert the &#8220;<span class="quote">myValueName</span>&#8221;
  59. property back to its intended type when you retrieve
  60. it.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2553659"></a><a name="macro-exec"></a><p><b>Q:</b></p></td><td align="left" valign="top"><p>In a macro I'd like to exec an external program (e.g.
  61. jmk, javac) and capture its output to a buffer. I'd also
  62. like to see this output as the external program runs or be
  63. able to interact with the program. So when I exec, what
  64. happens to System.in/out/err of the exec'd program?</p></td></tr><tr class="answer"><td align="left" valign="top"><p><b>A:</b></p></td><td align="left" valign="top"><p>Use the <code class="filename">runInSystemShell()</code> or the
  65. <code class="filename">runCommandToBuffer()</code> script methods
  66. that come bundled with the Console plugin. The help
  67. documentation for Console provides details on these methods.
  68. Currently the Console's System shell is not interactive
  69. during execution of a command, but it does receive and
  70. display the standard output and error streams of the
  71. external process.</p></td></tr></tbody></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="usage.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="plugins.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Usage Questions </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Plugin Questions</td></tr></table></div></body></html>