jHepWork includes two consoles to run BeanShellhttp://www.beanshell.org/ and Jythonhttp://www.jython.org/ commands. Try help options to learn more about additional features which will allow you interactions with the OS.
JythonShell/BeanShell allow you to run an external program. Just type ``!'' in front of the program name you want to execute. Here are a few examples:
>>> !latex <file> # will execute latex for the file <file> >>> !make # will execute make file >>> !gv # will start gv (for linux/unix) >>> !ls # shows the current directory
Typing the file name with the extension ``.py'' will automatically execute it. You can use the command history (Key: Up and Down), Java and Python completion (Key: Ctrl + Space).
It is important to note that there are a several predefined variables available for the consoles. They have been exported by the scripts located in the ``macros/system'' directory: "sysjehep.py" (for Jython) "sysjehep.bsh" (for BeanShell).
For example, assume you are editing some file. The information about this file can be found by typing (in the JythonShell) the following commands:
>>> print DocName >>> print DocDir >>> print ClassPath >>> print fSep (a file separator) >>> print DicDir (a directory with dictionaries) >>> print DocMasterName >>> print DocMasterNameShort
You can also use methods of the Editor class (which holds the currently opened document) Try ``print Editor.DocDir()'', for example. You can access all the methods of the Editor static class by typing ``Editor.'' and then press [Ctrl]+[Space]. You will see all public methods associated with the current editor.
Analogously, you can print all such variables using the BeanShell commands (but using the BeanShell syntax).
JHepWork uses the following aliases:
[CLASSPATH] - java class path [FILE_SHORT] - returns the file name without the extension [FILE_SHORT_NODIR] - returns the file name without the extension & path [FILE] - returns the full name of the file including the path [FILE_NODIR] - returns the full name of the file excluding the path [DIR_FILE] - returns file directory [DIR_SYS] - returns system directory
Example: print [FILE] and you should see the name of the currently opened file Note: Such substitutions can be used in macros. For example, if your macro contains [FILE], it will be automatically replaced by the current file name
There is also a special command: ``run''. This is just a shortcut to the command python statement ``source([FILE])'', i.e. the currently edited file will be evaluated.
You can view all available methods by typing "obrowser"; This will open an object browser window with all objects. If you want to add some object, do this: obrowser.add(your object);
>>> obrowser >>> a=JLabel("OK") >>> obrowser.add(a)
Note: for jython, you can also use the code assist, see Sect. :autorefsubsection3.2. However, you cannot use the code assist for the BeanShell. In this case, you should use "obrowser".
The user can put macros to the ``macros/user'' directory. There are already several macros in the system directory. For example, one can replace a string with another string in the current text just by calling replace(String1, String2); In fact, the macros should be rather similar to jEdit macros, as long as you are using the textArea class.
Jython classpath is defined via the "sysjehep.py" module located in the "macros/system"i directory. This variable specifies the location of jython modules which can be visible for the "import" statement. The module "sysjehep.py" is loaded automatically every time you start jHepWork (or reload the Jython console). in this file you can specify the locations of the user modules. By default, every file which is put to the installation directory, or to "macros/system" or "macros/user" should be visible.