Class BeanShell
- java.lang.Object
-
- org.gjt.sp.jedit.BeanShell
-
public class BeanShell extends java.lang.ObjectBeanShell is jEdit's extension language.When run from jEdit, BeanShell code has access to the following predefined variables:
view- the currently activeView.editPane- the currently activeEditPane.textArea- the edit pane'sJEditTextArea.buffer- the edit pane'sBuffer.wm- the view'sDockableWindowManager.scriptPath- the path name of the currently executing BeanShell script.
-
-
Constructor Summary
Constructors Constructor Description BeanShell()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object_eval(View view, NameSpace namespace, java.lang.String command)Evaluates the specified BeanShell expression.static void_runScript(View view, java.lang.String path, java.io.Reader in, boolean ownNamespace)Runs a BeanShell script.static void_runScript(View view, java.lang.String path, java.io.Reader in, NameSpace namespace)Runs a BeanShell script.static BshMethodcacheBlock(java.lang.String id, java.lang.String code, boolean namespace)Caches a block of code, returning a handle that can be passed to runCachedBlock().static java.lang.Objecteval(View view, NameSpace namespace, java.lang.String command)Evaluates the specified BeanShell expression.static voidevalSelection(View view, JEditTextArea textArea)Evaluates the text selected in the specified text area.static NameSpacegetNameSpace()static booleanisScriptRunning()static java.lang.ObjectrunCachedBlock(BshMethod method, View view, NameSpace namespace)Runs a cached block of code in the specified namespace.static voidrunScript(View view, java.lang.String path, java.io.Reader in, boolean ownNamespace)Runs a BeanShell script.static voidrunScript(View view, java.lang.String path, java.io.Reader in, NameSpace namespace)Runs a BeanShell script.static voidshowEvaluateDialog(View view)Prompts for a BeanShell expression to evaluate.static voidshowEvaluateLinesDialog(View view)Evaluates the specified script for each selected line.
-
-
-
Method Detail
-
evalSelection
public static void evalSelection(View view, JEditTextArea textArea)
Evaluates the text selected in the specified text area.- Parameters:
view- The viewtextArea- The text area- Since:
- jEdit 2.7pre2
-
showEvaluateDialog
public static void showEvaluateDialog(View view)
Prompts for a BeanShell expression to evaluate.- Parameters:
view- the View- Since:
- jEdit 2.7pre2
-
showEvaluateLinesDialog
public static void showEvaluateLinesDialog(View view)
Evaluates the specified script for each selected line.- Parameters:
view- The view- Since:
- jEdit 4.0pre1
-
runScript
public static void runScript(View view, java.lang.String path, java.io.Reader in, boolean ownNamespace)
Runs a BeanShell script. Errors are shown in a dialog box.If the
inparameter is non-null, the script is read from that stream; otherwise it is read from the file identified bypath.The
scriptPathBeanShell variable is set to the path name of the script.- Parameters:
view- The view. Within the script, references tobuffer,textAreaandeditPaneare determined with reference to this parameter.path- The script file's VFS path.in- The reader to read the script from, ornull.ownNamespace- If set tofalse, methods and variables defined in the script will be available to all future uses of BeanShell; if set totrue, they will be lost as soon as the script finishes executing. jEdit uses a value offalsewhen running startup scripts, and a value oftruewhen running all other macros.- Since:
- jEdit 4.0pre7
-
runScript
public static void runScript(View view, java.lang.String path, java.io.Reader in, NameSpace namespace)
Runs a BeanShell script. Errors are shown in a dialog box.If the
inparameter is non-null, the script is read from that stream; otherwise it is read from the file identified bypath.The
scriptPathBeanShell variable is set to the path name of the script.- Parameters:
view- The view. Within the script, references tobuffer,textAreaandeditPaneare determined with reference to this parameter.path- The script file's VFS path.in- The reader to read the script from, ornull.namespace- The namespace to run the script in.- Since:
- jEdit 4.2pre5
-
_runScript
public static void _runScript(View view, java.lang.String path, java.io.Reader in, boolean ownNamespace) throws java.lang.Exception
Runs a BeanShell script. Errors are passed to the caller.If the
inparameter is non-null, the script is read from that stream; otherwise it is read from the file identified bypath.The
scriptPathBeanShell variable is set to the path name of the script.- Parameters:
view- The view. Within the script, references tobuffer,textAreaandeditPaneare determined with reference to this parameter.path- The script file's VFS path.in- The reader to read the script from, ornull.ownNamespace- If set tofalse, methods and variables defined in the script will be available to all future uses of BeanShell; if set totrue, they will be lost as soon as the script finishes executing. jEdit uses a value offalsewhen running startup scripts, and a value oftruewhen running all other macros.- Throws:
java.lang.Exception- instances are thrown when various BeanShell errors occur- Since:
- jEdit 4.0pre7
-
_runScript
public static void _runScript(View view, java.lang.String path, java.io.Reader in, NameSpace namespace) throws java.lang.Exception
Runs a BeanShell script. Errors are passed to the caller.If the
inparameter is non-null, the script is read from that stream; otherwise it is read from the file identified bypath.The
scriptPathBeanShell variable is set to the path name of the script.- Parameters:
view- The view. Within the script, references tobuffer,textAreaandeditPaneare determined with reference to this parameter.path- The script file's VFS path.in- The reader to read the script from, ornull.namespace- The namespace to run the script in.- Throws:
java.lang.Exception- instances are thrown when various BeanShell errors occur- Since:
- jEdit 4.2pre5
-
eval
public static java.lang.Object eval(View view, NameSpace namespace, java.lang.String command)
Evaluates the specified BeanShell expression. Errors are reported in a dialog box.- Parameters:
view- The view. Within the script, references tobuffer,textAreaandeditPaneare determined with reference to this parameter.namespace- The namespacecommand- The expression- Returns:
- an object
- Since:
- jEdit 4.0pre8
-
_eval
public static java.lang.Object _eval(View view, NameSpace namespace, java.lang.String command) throws java.lang.Exception
Evaluates the specified BeanShell expression. Unlikeeval(), this method passes any exceptions to the caller.- Parameters:
view- The view. Within the script, references tobuffer,textAreaandeditPaneare determined with reference to this parameter.namespace- The namespacecommand- The expression- Returns:
- the object
- Throws:
java.lang.Exception- instances are thrown when various BeanShell errors occur- Since:
- jEdit 3.2pre7
-
cacheBlock
public static BshMethod cacheBlock(java.lang.String id, java.lang.String code, boolean namespace) throws java.lang.Exception
Caches a block of code, returning a handle that can be passed to runCachedBlock().- Parameters:
id- An identifier. If null, a unique identifier is generatedcode- The codenamespace- If true, the namespace will be set- Returns:
- a bsh method
- Throws:
java.lang.Exception- instances are thrown when various BeanShell errors occur- Since:
- jEdit 4.1pre1
-
runCachedBlock
public static java.lang.Object runCachedBlock(BshMethod method, View view, NameSpace namespace) throws java.lang.Exception
Runs a cached block of code in the specified namespace. Faster than evaluating the block each time.- Parameters:
method- The method instance returned by cacheBlock()view- The viewnamespace- The namespace to run the code in- Returns:
- an object
- Throws:
java.lang.Exception- instances are thrown when various BeanShell errors occur- Since:
- jEdit 4.1pre1
-
isScriptRunning
public static boolean isScriptRunning()
- Returns:
- if a BeanShell script or macro is currently running.
- Since:
- jEdit 2.7pre2
-
getNameSpace
public static NameSpace getNameSpace()
- Returns:
- the global namespace.
- Since:
- jEdit 3.2pre5
-
-