Antiklop (revision 1.0)

Description

Antiklop is an inspector for Tcl/Tk programs. It allows interactive viewing and editing of single variables, arrays, procedures, windows, menus and bindings. Call to antiklop can be used as a breakpoint. In this case it can inspect local variables or execute your code at any of the stack frames. Antiklop can not communicate with other interpreters.

Command line

package require antiklop
This loads the package (see Tcl manual for details on packages).

::antiklop::popup
Bring the interface to front.

::antiklop::trap ?message?
Trap the program and start internal 'event loop'. In this case the procedure will exit when you press the blinking 'Release' button. Until this, any code you execute in the console, will be executed at the selected stack frame. Message (string) will be appended in square brackets to the trapped procedure name in title bar; default is 'trap'.

::antiklop::configure -bgerror boolean
Pop up on background errors instead of default 'bgerror'. This option is equivalent to selecting/unselecting the 'bgerror' checkbox (see below).

::antiklop::echo message
Write message to antiklop console. Newline character will be appended to the end of string. Antiklop will popup.

Interactive controls

(see screenshots under Linux and Windows for the reference)

control type description
bgerror checkbox Pop up on background errors instead of default 'bgerror'. If this checkbox is selected, original bgerror (if exists) is replaced with a new one that calls antiklop::trap. When some background error happen and bgerror is called, original stack that caused the error is already destroyed, so you can not inspect local variables :-( You only can see the stack trace saved by Tcl into 'errorInfo' global variable (and inspect other globals, of course). Unselecting the checkbox restores original handler.
Release button Terminate 'event loop' inside the trap procedure to allow the program to proceed (old grab, if any, will be restored). Enabled only if antiklop is holding the program.
Execute button Feed the entire text from console window to Tcl. It will be executed in highlighted namespace or stack level. If the current line is commented out, antiklop will uncomment it after confirmation. Output will be appended to the end of display. Note: to execute a single line, use <Shift-Return> keyboard shortcut.
Usage of other controls is quite straightforward: choose the item type with menus and edit the patterns if needed (* is default). Click on item in a listbox to query it.

Bugs

There are minor bugs related with auto commenting/uncommenting text in the console, relevant for console text execution, but not for browsing:
multiline variables and options are not properly commented out (in fact only the first line is commented out), whatch what you execute !
auto-uncomment of current line checks for '#' only the first symbol of the line, where antiklop always puts it.

Acknowledgments

Tcl/Tk provides excellent debug possibilities. Antiklop is just my attempt to make a handy interface for them.
This project was inspired by examples from the Tk book by Brent Welch and "tkinspect" program by Sam Shen.

Author contact information

Victor Safronov <safronov@academ.kaluga.su>