DOKK / manpages / debian 12 / tkcon / tkcon.1.en
tkcon(1) General Commands Manual tkcon(1)


tkcon - Tk console replacement

tkcon [{option value | tcl_script} ...]


TkCon is a replacement for the standard console that comes with Tk (on Windows/Mac, but also works on Unix). The console itself provides many more features than the standard console. TkCon works on all platforms where Tcl/Tk is available. It is meant primarily to aid one when working with the little details inside Tcl and Tk, giving Unix users the GUI console provided by default in the Mac and Windows Tk.

Except for -rcfile, command line arguments are handled after the TkCon resource file is sourced, but before the slave interpreter or the TkCon user interface is initialized.

-rcfile is handled right before it would be sourced, allowing you to specify any alternate file. Command line arguments are passed to each new console and will be evaluated by each. To prevent this from happening, you have to say

tkcon main set argv {}; tkcon main set argc 0

For these options, any unique substring is allowed.

Causes TkCon to stop evaluating arguments and set the remaining args to be argv/argc (with -- prepended). This carries over for any further consoles. This is meant only for wrapping TkCon around programs that require their own arguments.
Sets the requested color type to the specified color for tkcon. See tkconrc(5) for the recognized <color> names.
A Tcl script to eval in each main interpreter. This is evaluated after the resource file is loaded and the slave interpreter is created. Multiple -eval switches will be recognized (in order).
Sets the named slave that tkcon operates in. In general, this is only useful to set to "" (empty), indicating to tkcon to avoid the multi-interpreter model and operate in the main environment. When this is empty, any further arguments will be only used in the first tkcon console and not passed onto further new consoles. This is useful when using tkcon as a console for extended wish executables that don't load there commands into slave interpreters.
Sets the font that tkcon uses for its text windows. If this isn't a fixed width font, tkcon will override it.
Sets ::tkcon::OPT(nontcl) to TCL_BOOLEAN (see tkconrc(5)). Needed when attaching to non-Tcl interpreters.
Packages to automatically load into the slave interpreters (i.e. "Tk").
Specify an alternate tkcon resource file name.
Makes the named widget the root name of all consoles (i.e. .tkcon).
A Tcl script to eval in each slave interpreter. This will append the one specified in the tkcon resource file, if any.

Most of the bindings are the same as for the text widget. Some have been modified to make sure that the integrity of the console is maintained. Others have been added to enhance the usefulness of the console. Only the modified or new bindings are listed here.

Cut.
Copy.
Paste.
Insert (duh).
Goes up one level in the commands line history when cursor is on the prompt line, otherwise it moves through the buffer.
Goes down one level in the commands line history when cursor is on the last line of the buffer, otherwise it moves through the buffer.
Goes up one level in the commands line history.
Goes down one level in the commands line history.
Tries to expand file path names, then variable names, then proc names.
Tries to expand file path names.
Tries to expand procedure names. The procedure names will be those that are actually in the attached interpreter (unless nontcl is specified, in which case it always does the lookup in the default slave interpreter).
Tries to expand variable names (those returned by [info vars]). It's search behavior is like that for procedure names.
Evaluates the current command line if it is a complete command, otherwise it just goes to a new line.
Go to the beginning of the current command line.
Clear the entire console buffer.
Searches backwards in the history for any command that contains the string in the current command line. Repeatable to search farther back. The matching substring off the found command will blink.
As above, but searches forward (only useful if you searched too far back).
Transposes characters.
Clears the current command line.
Saves current command line in a buffer that can be retrieved with another Control-z. If the current command line is empty, then any saved command is retrieved without being overwritten, otherwise the current contents get swapped with what's in the saved command buffer.
Attaches console to the console's slave interpreter.
Attaches console to the console's master interpreter.
Attaches console to main TkCon interpreter.
Pops up the "About" dialog.
Creates a new console. Each console has separate state, including it's own widget hierarchy (it's a slave interpreter).
Close the current console OR Quit the program (depends on the value of ::tkcon::TKCON(slaveexit)).
Closes the current console. Closing the main console will exit the program (something has to control all the slaves...).

TkCon also has electric bracing (similar to that in emacs). It will highlight matching pairs of {}'s, []'s, ()'s and ""'s. For the first three, if there is no matching left element for the right, then it blinks the entire current command line. For the double quote, if there is no proper match then it just blinks the current double quote character. It does properly recognize most escaping (except escaped escapes), but does not look for commenting (why would you interactively put comments in?).

There are several new procedures introduced in TkCon to improve productivity and/or account for lost functionality in the Tcl environment that users are used to in native environments. There are also some redefined procedures. Here is a non-comprehensive list:

Simple alias mechanism. It will overwrite existing commands. When called without args, it returns current aliases. Note that TkCon makes some aliases for you (in slaves). Don't delete those.
Clears the text widget. Same as the <Control-l> binding, except this will accept a percentage of the buffer to clear (1-100, 100 default).
Cheap way to get directory listings. Uses glob style pattern matching.
The dump command provides a way for the user to spit out state information about the interpreter in a Tcl readable (and human readable) form. See dump(3tk) for details.
Concatenates the args and spits the result to the console (stdout).
Opens an editor with the data from arg. The optional type argument can be one of: proc, var or file. For proc or var, the arg may be a pattern.
Interactive debugging command. See idebug(3tk) for details.
Removes one or more items from a list and returns the new list. If -all is specified, it removes all instances of each item in the list. If -regexp or -glob is specified, it interprets each item in the items list as a regexp or glob pattern to match against.
Aliased to edit.
Aliased to dir -full.
Aliased to edit.
This command provides passive runtime debugging output for variables and commands. See observe(3tk) for details.
Redefined to put the output into TkCon.
Multi-purpose command. See tkcon(3tk) for details.
Convenience proc to update the "tclIndex" (controlled by -index switch) and/or "pkgIndex.tcl" (controlled by -package switch) file in the named directories based on the given pattern for files. It defaults to creating the "tclIndex" but not the "pkgIndex.tcl" file, with the directory defaulting to [pwd]. The extension defaults to *.tcl, with *.[info sharelibextension] added when -package is true.
unaliases command.
The what command will identify the word given in string in the Tcl environment and return a list of types that it was recognized as. Possible types are: alias, procedure, command, array variable, scalar variable, directory, file, widget, and executable. Used by procedures dump and which.
Like the which command of Unix shells, this will tell you if a particular command is known, and if so, whether it is internal or external to the interpreter. If it is an internal command and there is a slot in auto_index for it, it tells you the file that auto_index would load. This does not necessarily mean that that is where the file came from, but if it were not in the interpreter previously, then that is where the command was found.

There are several procedures that I use as helpers that some may find helpful in there coding (i.e. expanding pathnames). Feel free to lift them from the code (but do assign proper attribution).

Some examples of tkcon command line startup situations:

megawish /usr/bin/tkcon -exec "" -root .tkcon mainfile.tcl
Use tkcon as a console for your megawish application. You can avoid starting the line with megawish if that is the default wish that TkCon would use. The -root ensures that tkcon will not conflict with the application root window.
tkcon -font "Courier 12" -load Tk
Use the courier font for TkCon and always load Tk in slave interpreters at startup.
tkcon -rcfile ~/.wishrc -color-bg white
Use the ~/.wishrc file as the resource file, and a white background for TkCon's text widgets.

TkCon will search for a resource file in "~/.tkconrc". TkCon never sources the "~/.wishrc" file. The resource file is sourced by each new instance of the console. An example resource file is provided in tkconrc(5).

dump(3tk), idebug(3tk), observe(3tk), text(3tk), tkcon(3tk), tkconrc(5)

Tk, console

Copyright (c) Jeffrey Hobbs (jeff at hobbs.org)
2.5 TkCon