Legal Notice
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no "Invariant Sections", "Front-Cover Texts" or "Back-Cover Texts", each as defined in the license. A copy of the license can be found in the file COPYING.DOC.txt included with jEdit.
Table of Contents
This plugins embedds a Jython Interpreter (Jython is an implementation of Python integrated with Java) into jEdit. It allows the user to run Jython commands as usual, and integrates with jEdit by easily running and importing the current buffer. Jython can also be used to customise jEdit in the same way as BeanShell does, with macros and plugins now being possible to be written in Jython. As a primarly example most of the plugin itself is built in such a fashion
The interpreter can be opened by selecting Plugins > Jython Interpreter. The interpreter window can be set to dock into the view in Utilities > Global Options > Docking. The interpreter is not loaded until runtime, this reduces the memory requirements until the interpreter is really needed. This behaviour can be modified by selecting Load interpreter at startup in the options window. Also if any plugin or macro is run it will load the interpreter in case it is not already running. You also have the About for JythonInterpreter and the Check jython version... which will verify if you have the correct jython version in your classpath
The interpreter window has a text area for entering commands and as output area. On top there is a toolbar for fast access to commands.
The text area behaves much like the original Jython Interpreter. Previously entered strings can be recalled with the CTRL+UP and CTR+DOWN keys. This can be optionally set to UP/DOWN in the Options dialog box
The interpreter is based on Jython 2.1 and tested on Sun's JDK 1.3.1 and Sun's JDK 1.4, jEdit 4.0.4, in Linux. Since the way of loading modules the plugin won't work unless the jython version is 2.1 or hight, this due that the plugin needs the ability to load modules zipped in jar files
Since version 0.6 JythonInterpreter features a toolbar which make easy to execute several operations:
The available buttons are:
Run current buffer:
It will run the current selected buffer. It will ask you if you want to save the file if the file is unsaved. The output will go to the text area
Run current buffer to another buffer:
Same as before, but the output will appear in another buffer.
Import current buffer.
It will import the current buffer.
Edit JythonPath.
Opens a dialog box which allows you to edit the JythonPath. You can add/remove/edit entries as well as moving them up and down
Browse Path.
It opens the Path Browser, which allows you to easily open python files. It doesn't yet works with compressed python files
Save session: .
Exports the current interactive session to a new buffer
Restart and clean session: .
Restarts the interpreter and cleans the session
Check buffer with tabnanny: .
Checks the current buffer with tabnnany to find indentation problems
About: .
Opens the about dialog box
The Interpreter is based on the Jython's Interactive Console, so all commands available there are available here as well.
The current buffer object is always available as a Jython object called buffer. This makes very easy to run the currently edited file as execfile(buffer.getPath())
If the projectviewer plugin is installed, the path of the current project will be added to the jython class path so that any java classes in the current project can be used within the interpreter.
The same variables normally available at BeanShell are available in Jython, namely:
buffer.
editPane.
textArea.
view.
The interpreter is running on it's own independent thread and the current task will be "attempted" to be stopped by the stop button
Pressing restart will clear completly the interpreter. Notice that the startup scripts will be loaded again.
The JythonInterpreter plugin includes a python parser adapted for the SideKick parser. To use it just open a python file and the sidekick plugin window.
In version 0.9.1 there were errrors in the loading part unless the Autoload ALL JARs options was checked.
Several options have been added and can be Found at Utilities Global Options Plugins Jython Interpreter
The options are:
Load Interpreter at the begining:
If selected the interpreter will be loaded automatically at startup, instead of waiting for the first command.
Autoload plugins' JARS:
If selected the interpreter will add all the jars from plugins to the cache and system path making them avaiable for scripting.
Autosave before run/import.
If set files will be automatically saved when run or import.
Confirm save before run/import.
If set and the autosave option is not set, it will ask if you want to save the file before run/import. Disable if you don't want to be bugged
Save JythonPath on modification.
If set the path will be saved locally if you modify it by the PathEditor dialog box. In this way the next time the interpreter is used it will use the complete path
Override default registry: .
Allows to use custom values for the Jython registry. Notice that empty values won't be set as empty. The loading of custom properties after Jython has started for the first time has no effect, so changes will be valid the next time jEdit is run. For details about registr refer to The Jython Registry
Since version 0.8 JythohInterpreter uses the MacroHandler mechanism avaiable as jEdit 4.0pre6 and avobe. This means that jython macros can be executed and treated exactly like BeanShell macros. Macros have access to the 4 standard variables view, buffer, textArea and editPane
To make a macro just create a python file (Don't forget the py extension) and put it in a macros dir
Aditionally you can script all other plugins. To do that enable loading the plugins jar option. That will cause the interpreter to include all jars in your .jedit/jars dir and you can use that to do plugins scripting.
Finally the utils module has a new BufferList class. This class is a wrapper around a buffer but which acts as a jython list, where every element on the list is a buffer line. For instance a code like this would print the whole Buffer to the console.
def f(): from utils import BufferList b = BufferList(buffer) for l in b: print l f() |
Run it directly in the interpreter window it would print itself.
You can use all the range of list standard functions like BufferList(buffer)[0:2:] to get all buffer's even lines and so on.
Jython Plugins can be built by creating a normal plugin and adding .py files to the plugin's jar. Of course you also need to add the dependency on JythonInterpreter 0.5 or higher. When your plugin needs to execute something you call the JythonExecutor.executePlugin(pluginName, dir, module, function) or JythonExecutor.executePlugin(pluginName, dir, module, function, args)
Where:
As an example the Plugin itself intializes with a call execPlugin("jython.JythonPlugin", "jython", "init", "_start");
Add syntax coloring to the interpreter
Add auto tabbing
Improve path browser
Option to profile programs
Debugger
Version 0.9.6 requires jEdit 4.2pre11, SideKick 0.3, ErrorList 1.3.2
Includes an updated version of Jython 2.1 that works on JDK 1.5.
Added optional dependency on ProjectViewer.
buffer, editPane, textArea, and view are now locals in macros.
__name__ is set to "__main__" for macros.
Version 0.9.5 requires jEdit 4.2pre, SideKick 0.1, ErrorList 1.3.1
Converted option panes to Java.
Fixed bugs in executing python startup scripts.
"jython" directory no longer created or used in jEdit home directory. Use a startup script instead if you wish to have a script executed when jEdit is starting.
Traceback displayed when there's an error executing a macro.
Removed old macro execution method: "_execMacro".
Removed support for executing user's "jython\jedit.py" on startup.
Added AWT error handler to catch jython exception using AWT.
Fixed bugs in path handler. Now it can also load one path and mutiple jars at the same time. It uses jEdit VFS.
Added button to invoke tabnanny
If project list is installed its classpath is added to the interpreter
Compatible with jEdit 4.2pre7
Version 0.9.2 requires jEdit 4.0pre6, SideKick 0.1
Fixed bug where PythonParser wouldn't work if "Autoload Plugin JARS" wasn't set to `true` (default setting is false). Now SideKick.jar is always imported.
Version 0.9.1 requires jEdit 4.0pre6, SideKick 0.1
Integrated Python parser for SideKick plugin.
Fixed label properties used for option panes.
Version 0.9 requires jEdit 4.0.6
Fixed bugs #606782, #536885, #524056
Added option to uset UP/DOWN for history navigation
Added option to reuse the export to file
Added option for the export to file to remember the original source file. When export to is pressed it will use again the original source file
Removed all old Console dependencies
Added option pane to define colors and font
Version 0.8 requires jEdit 4.0.6
Updated to jEdit 4.0.6 and uses the new Macro Handler API (Mike Dillon)
Removed custom namespace to ensure macro compability
Added option to autoload all plugins' jars
Added export session
Removed deprecated functions
Version 0.7 requires jEdit 3.2.2, the EditBus plugin 1.0.1.
Updated to jEdit 4.0.4 using new Dockables APi
Added jython.JythonDocker class to adapt to the new Dockables API
Improved caching of jars
Version 0.6.3 requires jEdit 3.2.2, the EditBus plugin 1.0.1.
Updated to jython 2.1.
Last version for jEdit 3.xx
Version 0.6 requires jEdit 3.2.2, the EditBus plugin 1.0.1.
Completely redesigned GUI, with a toolbar and a text area, direclty editable.
New implementation mostly in Jython
New run current buffer button
New run current buffer to another buffer button
New import current buffer button
New JythonPath editor
New PathBrowser
Improved error handling, including an Error button which allows to jump to the error source
Check jython version, which verify if the right version is in use
History moved to CTRL+UP and CTRL+DOWN keys
Documentation moved to DockBook
Version 0.5 requires jEdit 3.1final, the EditBus plugin 1.0.1.
Improved init.py.
Added output.
Completly rebuilt execPlugin mehtod, using jython 2.1a3 features. Old method is deprecated.
Fixed wrong location of the help file.
Removed Console dependency.
Added jython 2.1a3 bundle if you don't have jython already.
Version 0.4 requires Requires jEdit 3.1final, EditBus 1.0, and Console 2.6.
Improved init.py
Added execPlugin mehtod
Removed jython distribution for size issues
Version 0.3 requires Requires jEdit 3.1final, EditBus 1.0, and Console 2.6.
Added option to customize the jython registry
Added static method to execute macros
Added init method
Integrated jython distribution
Version 0.2 requires Requires jEdit 3.1final, EditBus 1.0, and Console 2.6.
Detects if jython is not available and displays a nicer message
Interpreter runs in its own thread
Stop enabled
Added restart
The namespace for shell variables can be customized
Added options pane
Version 0.1 requires Requires jEdit 3.1final, EditBus 1.0, and Console 2.6.
Initial release
Uses a modified Console.jar included in the distribution jar