PageRenderTime 138ms CodeModel.GetById 132ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms


XML | 142 lines | 125 code | 12 blank | 5 comment | 0 complexity | a133bd90f14b577b460ee90214ad8f59 MD5 | raw file
  1<!-- jEdit buffer-local properties:                      -->
  2<!-- :indentSize=4:noTabs=false:maxLineLen=72:tabSize=4: -->
  3<!-- :xml.root=faq.xml:                                  -->
  5<!-- jEdit FAQ                                           -->
  6<!-- Copyright (C) 2003 John Gellene, Kris Kopicki       -->
  8<sect1 id="macros"><title>Macros</title>
 10  This section deals with questions on writing and running macros.
 13<qandaset defaultlabel="qanda">
 15<qandadiv id="macro-using"><title>Using macros</title>
 18	<question id="macro-getting">
 19		<para>
 20			Where can I get macro's from?
 21		</para>
 22	</question>
 23	<answer>
 24		<para>
 25			There is a plugin available called MacroManager that will provide a
 26			similar interface to jEdit's plugin manager for installing new macros.
 27			The plugin downloads the macros from the jEdit Community site, so an
 28			internet connection is necessary.
 29		</para>
 30	</answer>
 34  <question id="macro-new-store">
 35    <para>
 36      I just wrote a new macro for myself.  Where should I save the
 37      file?
 38    </para>
 39  </question>
 40  <answer>
 41    <para>
 42      There is a <filename>macros</filename> directory in your user
 43      settings directory. If you store your macro there it will appear in
 44      jEdit's <guimenu>Macros</guimenu> menu under the name you have
 45      given to the macro's source code file.  The
 46      <filename>.bsh</filename> will be deleted in the macro entry, and
 47      underscore characters will be converted to whitespace, so that the
 48      file <filename>My_New_Macro.bsh</filename> will be displayed as
 49      <guimenuitem>My New Macro</guimenuitem>.
 50    </para>
 51    <para>
 52      You can create additional subdirectories in the
 53      <filename>macros</filename>to organize your personal macros by
 54      category. Each subdirectory will correspond to a submenu
 55      under the application's <guimenu>Macros</guimenu> menu.  This is
 56      helpful to reduce the screen space used to display the macros menu
 57      at any one time.
 58    </para>
 59    </answer>
 63  <question id="macro-new-ext">
 64    <para>
 65      Do I have to use the <filename>.bsh</filename> file extension when
 66      I save one of my own macro scripts?
 67    </para>
 68  </question>
 69  <answer>
 70    <para>
 71      You need the <filename>.bsh</filename> extension in order for
 72      jEdit to detect and display the name of the macro in its
 73      <guimenu>Macros</guimenu> menu.  The macro must also be in the
 74      <filename>macros</filename> directory of either the jEdit
 75      installation directory or the user settings directory.
 76    </para>
 77    <para>
 78      You do not need the extension to run a macro, however.  By
 79      selecting <guimenu>Macros</guimenu>&gt;<guimenuitem>Run Other
 80      Macro...</guimenuitem>, you can choose any file to be run as a
 81      macro. While in a macro, you can
 82      call <userinput>source(&quot;full_path&quot;)</userinput>
 83      to do the same thing.
 84    </para>
 85  </answer>
 89  <question id="macro-temp">
 90    <para>
 91      How can I store the result of a macro so that the next time I run it
 92      the macro can retrieve the value?
 93    </para>
 94  </question>
 95  <answer>
 96    <para>
 97      You can use either <userinput>jEdit.setProperty(String,
 98      String)</userinput> or <userinput>jEdit.setTemporaryProperty(String,
 99      String)</userinput>. Both methods
100      take <classname>String</classname> values for the name of the
101      property and its value.  If you use
102      <userinput>setProperty()</userinput>, the property will remain in
103      jEdit's property store permanently, so if you only need the value
104      during the course of a single editing session, use
105      <userinput>setTemporaryProperty()</userinput>.
106    </para>
107    <para>
108      To ensure that your value can be stored regardless of its type,
109      use the following
110      syntax:<programlisting>jEdit.setTemporaryProperty("myValueName", myValue.toString());</programlisting>
111      and remember to convert the <quote>myValueName</quote> property
112      back to its intended type when you retrieve it.
113    </para>
114  </answer>
118	<question id="macro-exec">
119		<para>
120			In a macro I'd like to exec an external program (e.g. jmk, javac) and capture
121			its output to a buffer. I'd also like to see this output as the
122			external program runs or be able to interact with the program. So when I exec,
123			what happens to of the exec'd program?
124		</para>
125	</question>
126	<answer>
127		<para>
128			Use the <filename>runInSystemShell()</filename> or the
129			<filename>runCommandToBuffer()</filename> script methods that come
130			bundled with the Console plugin. The help documentation for Console provides
131			details on these methods. Currently the Console's System shell is not
132			interactive during execution of a command, but it does receive and display the
133			standard output and error streams of the external process.
134		</para>
135	</answer>