Code Browser plugin | (March 31 2012) |
Table of Contents
The Code Browser plugin contains a buffer switcher and a code browser within a split pane. The buffer switcher can be hidden by moving the divider all the way up, or by clicking the small up-handle. The code browser simplifies navigating source code of any programming language supported by the Exuberant C Tags program.
The buffer switcher displays the file name of each buffer, and as much of the end of each path as can be fit. The selcted buffer is shown in bold. The file name colors are taken from the File System Browser (See > > ). The path of 'dirty' buffers is displayed in in dark red, others in dark gray. Operation of the buffer switcher is straight forward: A mouse click selects a buffer, and a control-click closes a buffer. While the mouse is ofer a buffer switcher entry a tooltip shows the entire path for this entry.
The code browser requires Exuberant C Tags version 5.5 or later. You can find it at http://ctags.sourceforge.net. NOTE: The standard ctags program found on many systems is NOT sufficient!!!
The path of the ctags program needs to be
set in the Plugin Options for the Code Browser plugin. A typical choice on
Unix-like systems is /usr/local/bin/ctags
, and on windows
systems c:\Apps\ctags51\ctags.exe
.
Once the ctags path is set, the code browser plugin will parse a file whenever a buffer displaying the file is selected, or when the current buffer is saved. Please note that only the file on disk is parsed, not the in-memory contents of the buffer.
Simply click on any function, variable declaration etc. displayed in the code browser, and the buffer will be positioned accordingly. As regular expressions are used, code browser will be able to find definitions even in modified files as long as the line on which the definition occured was not changed. Tooltips show the contents of the line, which depending on language and style may include more information.
Right-clicking on any function, variable declaration etc. will bring up a context menu with these choices:
: Inserts the selected term in the current text view.
: Perform a hypersearch with this term.
: Copies the selected term to the paste board.
: Appends the selected term to the pasteboard.
The
menu button above the Code Browser section lets you select a few options:: When checked, buffers are parsed automatically when saved or when you switch to another buffer. When un-checked, buffers will only be parsed when you click on the button. That can be helpful when you work with extremely large files, where parsing requires some time.
: When checked, all listed tags will be sorted.
: When checked, any section in the code you jump to will be unfolded automatically.
: After selecting a tag the dock is automatically closed
The ctags program supports many languages, but chances are you might work with a language or file type not supported by ctags. While support built into ctags is the most elegant solution, you can also create some simple regular expression based support for languages not directly supported by ctags.
The following chapter gives some examples. The lines shown need to be added
to one of the files ctags reads during startup. On unix-like systems that
could be ~/.ctags
, and on windows systems that could be a
file ctags.cnf
in the jEdit directory. Please read the
ctags documentation for more info.
Here is an example for contents of the ctags configuration file mentioned in the previous chapter. The example add simple support for XML files and HTML files (note that HTML is now supported natively in ctags):
--langdef=xml --langmap=xml:.xml --regex-xml=/<([^ \t]+)[ \t]*(id|name)[ \t]*=[ \t]*\"([^\"]+)/\1 \3/Named Tags/i --langdef=html --langmap=html:.htm.html --regex-html=/<a[ \t]+href[ \t]*=[ \t]*\"([^\"]+)/\1/HRefs/i --regex-html=/<img[ \t]+src[ \t]*=[ \t]*\"([^\"]+)/\1/Images/i --regex-html=/<h([1-6])[^>]*>([^<]*)/\2 (\1)/Headers/i
The --langdef lines define the name of the language, the --langmap lines define the extensions of files for this language, and the --regex-html lines define the regular expressions describing the items of a language you want to see in Code Browser. For more info please see the ctags documentation.
build.xml
files would normally be governed by the
xml entries listed in the previous chapter. ctags does
not allow one entry for *.xml
and another for
build.xml
. Code Browser helps out here; Code Browser
forces the language used by ctags to ant when
the file to be parsed is named build.xml
.
--langdef=ant --regex-ant=/<property[ \t]*name[ \t]*=[ \t]*\"([^\"]+)/\1/Properties/i --regex-ant=/<target[ \t]*name[ \t]*=[ \t]*\"([^\"]+)/\1/Targets/i --regex-ant=/<path[ \t]*id[ \t]*=[ \t]*\"([^\"]+)/\1/Paths/i --regex-ant=/<taskdef[ \t]*id[ \t]*=[ \t]*\"([^\"]+)/\1/Taskdefs/i --regex-ant=/<typedef[ \t]*id[ \t]*=[ \t]*\"([^\"]+)/\1/Typedefs/i
Q: I am working on a (shell|perl|python|whatever) script, but CodeBrowser isn't showing anything.
A: Ctags parses files without extensions (like many scripts) only if the executable flag is set AND the magic #!/path/to/interpreter first line can be found. So make sure both those conitions are met, or add a known extension to the script.
Q: Is there support for ActionScript?
A: Check www.ubergeek.tv/jack/hack.php
Feel free to do with the files of this project whatever you want. If they make you filthy rich you should send some bucks my way though.
BITart and Gerd Knops make no warranties, representations or commitments with regard to the contents of this software. BITart and Gerd Knops specifically disclaim any and all warranties, wether express, implied or statutory, including, but not limited to, any warranty of merchantability or fitness for a particular purpose, and non-infringement. Under no circumstances will BITart or Gerd Knops be liable for loss of data, special, incidental or consequential damages out of the use of this software, even if those damages were forseeable, or BITart or Gerd Knops was informed of their potential.
You can write to:
Gerd Knops <gerti-codebrowser@bitart.com>
The jEdit-users mailing-list
<jedit-users@lists.sourceforge.net>
The jEdit-devel mailing-list
<jedit-devel@lists.sourceforge.net>
Version 1.4.3. Requires JDK 1.4, jEdit 4.3pre5, ExuberantCtags 5.5.
Fixes for change in regexp/search API
Sends new CaretChanging editbus message for the benefit of Navigator.
Version 1.4.2. Requires JDK 1.3, jEdit 4.3, ExuberantCtags 5.5.
Works with jedit 4.3 API and plugin dynamic loading.
Version 1.4.0. Requires JDK 1.3, jEdit 4.1, ExuberantCtags 5.5.
Behavior improved when multiple tags with identical names are found: if you select the n-th one, then CodeBrowser will jump to the n-th occurance in the code.
New
Menu.Moved
and buttons into new Menu.New option
: When checked and you jump to a folded section of the code that section will be unfolded automaticallyNew option
: When checked the dock will automatically close after a tag was selectedCleaned up UI
Cleaned up code
Version 1.3.1. Requires JDK 1.3, jEdit 4.1, ExuberantCtags 5.5.
Updated for jEdit 4.2
Version 1.3.0. Requires JDK 1.3, jEdit 4.1, ExuberantCtags 5.5.
Compatible with all languages supported now or in future by ExuberantCtags
No longer requires internal tables to determine programming language
No longer requires internal tables to translate single letter 'kind' to description
Methods, functions etc. now listed with signature
Version 1.2.1. Requires JDK 1.3, jEdit 4.
Context menu for items in CodeBrowser (Rudi Widmann)
Version 1.2.0. Requires JDK 1.3, jEdit 4. Code contributed by Rudi Widmann:
Manual parsing mode
Cache parse results
Do not parse when docked but not visible
Focus textarea after selecting element in parse tree
Version 1.1.1. Requires JDK 1.3, jEdit 4.
Should now work with all kinds of remote files
Version 1.1.0. Requires JDK 1.3, jEdit 4.
Added support for FTP plugin
Version 1.0.0. Requires JDK 1.3, jEdit 4.
Minor bugfixes
First release to plugin central
Version 0.9.2. Requires JDK 1.3, jEdit 4.
Improved documentation
Now handles multiple/split views better
BufferSwitcher now uses colors from File System Browser
Version 0.9.1. Requires JDK 1.3, jEdit 4.
Regex bugfix
Version 0.9.0. Requires JDK 1.3, jEdit 4.
First beta test version