PageRenderTime 73ms CodeModel.GetById 36ms app.highlight 1ms RepoModel.GetById 34ms app.codeStats 1ms


XML | 99 lines | 80 code | 12 blank | 7 comment | 0 complexity | e3dbcf7dbf3ada5fd85bff57a43c81ed MD5 | raw file
 1<!-- jEdit 3.2 Macro Guide, (C) 2001 John Gellene                -->
 2<!-- Revised Tue Jun 19 18:02:08 EDT 2001 @959 /Internet Time/   -->
 3<!--                                                             -->
 4<!-- jEdit buffer-local properties:                              -->
 5<!-- :indentSize=1:noTabs=yes:maxLineLen=72:tabSize=2:           -->
 6<!--                                                             -->
 7<!-- This file cover the introductory section of the macro guide -->
 9<chapter id="macro-basics"><title>Introducing BeanShell</title>
11  <para>
12   Here is how BeanShell's author, Pat Niemeyer, describes his creation:
13  </para>
15  <blockquote>
16   <para>
17    <quote>BeanShell is a small, free, embeddable, Java source
18    interpreter with object scripting language features, written in
19    Java. BeanShell executes standard Java statements and
20    expressions, in addition to obvious scripting commands and
21    syntax. BeanShell supports scripted objects as simple method
22    closures like those in Perl and JavaScript.</quote>
23   </para>
24  </blockquote>
26  <para>
27   As you might gather from this short quote, BeanShell is very similar to
28   Java and is designed to be easy for Java programmers to learn. If you
29   know how to program in Java, you already know how to write BeanShell
30   macros. Nonetheless, the premise of this guide is that you should not
31   have to know anything about Java to begin writing your own macros for
32   jEdit.
33  </para>
35  <para>
36   If you are not a Java programmer, you will have to learn a
37   little about Java classes and syntax, but that's not a bad thing.
38   You will also have to learn a little (but not too much) about
39   some of the classes that are defined and used by the jEdit
40   program itself. That is in fact the major strength of using
41   BeanShell with a program written in Java: it allows the user to
42   customize the program's behavior by employing the same interfaces
43   designed and used by the program's developer. Thus, BeanShell can
44   turn a well-designed application into a powerful toolkit.
45  </para>
47  <para>
48   This guide focuses on using BeanShell in macros. If you are interested
49   in learning more about BeanShell generally, consult the <ulink
50   url="">BeanShell web site</ulink>. Information
51   on how to run and organize macros, whether included with the jEdit
52   installation or written by you, can be found in
53   <xref linkend="using-macros"/>.
54  </para>
56 <sect1 id="single-macros"><title>Single Execution Macros</title>
57  <para>
58   There are two ways jEdit lets you use BeanShell quickly on a
59   <quote>one time only</quote> basis. You will find both of them in the
60   <guimenu>Utilities</guimenu> menu.
61  </para>
63  <para>
64   <guimenu>Utilities</guimenu>&gt;<guimenuitem>Evaluate BeanShell
65   Expression</guimenuitem> causes jEdit to display a text input dialog
66   that asks you to type a single line of BeanShell commands. You can type
67   more than one BeanShell statement so long as each of them ends with a
68   semicolon. If BeanShell successfully interprets your input, a message
69   box will appear with the return value of the last statement. You can do
70   the same thing using the BeanShell interpreter provided with the
71   <application>Console</application> plugin; the return value will appear
72   in the output window.
73  </para>
75  <para>
76   <guimenu>Utilities</guimenu>&gt;<guimenuitem>Evaluate Selection</guimenuitem>
77   evaluates the selected text as a BeanShell script and
78   replaces the selected text with the return value of the last BeanShell
79   statement.
80  </para>
82  <para>
83    Using <guimenuitem>Evaluate Selection</guimenuitem> is an
84    easy way to do arithmetic calculations inline while editing. BeanShell
85    uses numbers and arithmetic operations in an ordinary, intuitive way.
86  </para>
88  <informalexample>
89   <para>
90    Try typing an expression like <userinput>(3745*856)+74</userinput>
91    in the buffer, select it, and choose
92    <guimenu>Utilities</guimenu>&gt;<guimenuitem>Evaluate
93    Selection</guimenuitem>. The selected text will be replaced by the
94    answer, <userinput>3205794</userinput>.
95   </para>
96  </informalexample>
97 </sect1>