Enhanced Tk Console (TkCon) Docs: starting up


Top Level Documentation

Resource File:

TkCon will search for a resource file in "$env(HOME)/.tkconrc" (Unix), "$env(HOME)/tkcon.cfg" (Windows) or "$env(PREF_FOLDER)/tkcon.cfg" (Macintosh). On DOS machines, "$env(HOME)" usually refers to "C:\". TkCon never sources the "~/.wishrc" file. The resource file is sourced by each new instance of the console. An example resource file is provided below.

Command Line Arguments

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.

-argv (also --)
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.
-eval (also -main or -e)
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).
-nontcl TCL_BOOLEAN
Sets TKCON(nontcl) to TCL_BOOLEAN. Needed when attaching to non-Tcl interpreters.
-package package_name (also -load)
Packages to automatically load into the slave interpreters (ie - "Tk").
-rcfile filename
Specify an alternate TkCon resource file name.
-root widgetname
Makes the named widget the root name of all consoles (ie - .tkcon).
-slave tcl_script
A tcl script to eval in each slave interpreter. This will append the one specified in the TkCon resource file, if any.

Variables:

Certain variables in TkCon can be modified to suit your needs. It's easiest to do this in the resource file, but you can do it when time the program is running (and some can be changed via the Prefs menu). All these are part of the master interpreter's global array variable TKCON. You can 'tkcon set TKCON' when the program is running to check its state. Here is an explanation of certain variables you might change or use:
color,blink
The background color of the electric brace highlighting, if on. Defaults to yellow.
color,proc
The foreground color of a recognized proc, if command highlighting is on. Defaults to dark green.
color,prompt
The foreground color of the prompt as output in the console. This is also used as the color of disabled menu labels in several menus. Defaults to brown.
color,stdin
The foreground color of the stdin for the console. Defaults to black.
color,stdout
The foreground color of the stdout as output in the console. Defaults to blue.
color,stderr
The foreground color of stderr as output in the console. Defaults to red.

autoload
Packages to automatically load into the slave interpreter (ie - 'Tk'). This is a list. Defaults to {} (none).
blinktime
The amount of time (in millisecs) that braced sections should blink for. Defaults to 500 (.5 secs), must be at least 100.
blinkrange
Whether to blink the entire range for electric brace matching or to just blink the actual matching braces (respectively 1 or 0, defaults to 1).
calcmode
Whether to allow expr commands to be run at the command line without prefixing them with expr (just a convenience).
cols
Number of columns for the console to start out with. Defaults to 80.
dead
What to do with dead connected interpreters. If dead is leave, TkCon automatically exits the dead interpreter. If dead is ignore then it remains attached waiting for the interpreter to reappear. Otherwise TkCon will prompt you.
history
The size of the history list to keep. Defaults to 32.
library
The path to any tcl library directories (these are appended to the auto_path when the after the resource file is loaded in).
lightbrace
Whether to use the brace highlighting feature or not (respectively 1 or 0, defaults to 1).
lightcmd
Whether to use the command highlighting feature or not (respectively 1 or 0, defaults to 1).
maineval
A tcl script to execute in the main interpreter after the slave interpreter is created and the user interface is initialized.
nontcl
For those who might be using non-Tcl based Tk attachments, set this to 1. It prevents TkCon from trying to evaluate its own Tcl code in an attached interpreter. Also see my notes for non-Tcl based Tk interpreters.
prompt1
Like tcl_prompt1, except it doesn't require you use 'puts'. No equivalent for tcl_prompt2 is available (it's unnecessary IMHO).
Defaults to {([file tail [pwd]]) [history nextid] % }.
rcfile
Name of the resource file. $env(HOME) is prepended to this. Defaults to .tkconrc on Unix and tkcon.cfg otherwise.
rows
Number of rows for the console to start out with. Defaults to 24.
scollypos
Y scrollbar position. Valid values are left or right. Defaults to left.
showmenu
Show the menubar on startup (1 or 0, defaults to 1).
showmultiple
Show multiple matches for path/proc/var name expansion (1 or 0, defaults to 1).
slaveeval
A tcl script to execute in each slave interpreter right after it's created. This allows the user to have user defined info always available in a slave. Example:
	set tkCon(slaveeval) {
		proc foo args { puts $args }
		lappend auto_path .
	}
slaveexit
Allows the prevention of exit in slaves from exitting the entire application. If it is equal to exit, exit will exit as usual, otherwise it will just close down that interpreter (and any children). Defaults to close.
subhistory
Allow history substitution to occur (0 or 1, defaults to 1). The history list is maintained in a single interpreter per TkCon console instance. Thus you have history which can range over a series of attached interpreters.

An example TkCon resource file might look like:

######################################################
## My TkCon Resource File
 
# Use 'fixed' as my default font (only valid on unix)
set TKCON(maineval) {
    set tkcon font fixed
}
# Keep 50 commands in history
set TKCON(history) 50
# Use a pink prompt
set TKCON(color,prompt) pink
######################################################


Contact jeff.hobbs@acm.org with questions or see http://www.cs.uoregon.edu/~jhobbs