Table of Contents
tclreadline - gnu readline
for the tcl scripting language
- ::tclreadline::readline
command [options ]
-
The tclreadline package makes
the gnu readline available to the scripting language tcl. The primary purpose
of the package is to facilitate the interactive script development by
the means of word and file name completion as well as history expansion
(well known from shells like bash).
Additionally tclreadline can also
be used for tcl scripts which want to use a shell like input interface.
In this case the ::tclreadline::readline read command has to be called
explicitly.
The advantage of tclreadline is that it uses the callback
handler mechanism of the gnu readline while it processes tcl events. This
way X events from a wish gui will processed as well as events from the
tclreadline line interface.
tclreadline is basically a shared
library and a few tcl scripts which are accessed with the tcl package
require command. Therefore tclreadline should work with all common extensions
like blt, itcl, itk, tix ... .
If you want to use
tclreadline as a line interface for developing tcl scripts, you probably
don't have to read this section. In this case the only thing you should
do is to modify your .tclshrc according to the section FILES .
For the
functionality of the GNU readline you should refer to the readline's documentation.
The following list will give all commands, which are currently implemented
in the shared lib (e.g. libtclreadline1.0.so). Additional commands were introduced
in a startup script tclreadlineSetup.tcl , which lives in the tclreadline
installation directory. (typically something like /usr/local/lib/tclreadline
..) These commands are primarily for internal use and not documented here.
Note that all commands reside in the namespace ::tclreadline:: .
- ::tclreadline::readline add string
- adds a string to the completer.
If the string contains white spaces, each of the words will be completed
consecutively when hitting <Tab>. Example:
::tclreadline::readline
add "button pathName ?options?"
typing but<Tab> will complete to button.
Hitting <Tab> again will complete to "button pathName". ...
- ::tclreadline::readline
complete string
- returns 1 if string is a complete tcl command and
0 otherwise.
- ::tclreadline::readline customcompleter [string ]
- Register
the proc string as custom completer. This proc is called with exactly
four arguments each time completion takes place: the word to complete
("text"), the "start" and "end" positions of this word in the line entered
so far, and this line ("line"). The custom completion script should return
an array of strings which is a list of completions for "text". If there
are no completions, it should return an empty string "". The first entry
in the returned list is the substitution for "text". The remaining entries
are the possible completions. If the custom completio