Updated 2011-07-07 09:18:42 by dkf

dzach 25-Sep-2005: Deep Console v0.1.2 [1] is a proof of a concept that sprang from What's wrong with the tree widgets?, which could see interesting implementations in tcl authoring tools. It is based on D. Richard Hipp's Tree widget. Here is one incarnation, in the body of the standard tk console. Another (better) candidate might be tkinspect:

The purpose:

  • Enhance the standard Tk console to include a visual way to explore user defined proc structures in depth.
  • Enhance editing by providing one-click editing and referrers to procs.
  • Provide in-place viewing and editing of user procs.

The looks:

The enhanced console looks like this:

Usage:

There are three panes in Deep Console: The proc tree, the proc editor and the console. The tree is initially not populated, since the user might just want to run some console commands and populating the tree for a large application may take some seconds. To populate the tree just press <F2>.

The tree

  • The icons represent user proc definitions
  • The icons represent user command invocations or references.
  • The end of a proc is marked with a thicker horizontal line.
  • Clicking on a proc or command icon, or double clicking on a proc name, reveals this proc's contents, in terms of proc names, in the tree pane.
  • Clicking on a tree proc name, displays that proc in the editor's pane, where the referenced user procs are highlighted.
  • Pressing <F2> refreshes the tree pane, resetting the tree to its collapsed form.

The proc editor

  • Pressing <Control-Down> while the text cursor is on (or next to) a highlighted user proc, brings up a view of it for inspection or editing (in-place editing) without leaving the editor pane. <Control-Up> will hide the view.
  • Pressing <Control-r> while a proc is selected in the tree pane, marks referrers to this procedure in red in the tree pane. Pressing <Esc>, or expanding a new proc in the tree pane clears referrers marks.
  • Pressing <Control-s> in the editor or view panes saves the contents of the editor pane, by evaluating them in the console interpreter. Syntax errors are alerted by the interpreter.
  • Pressing <Control-Return> in the editor or view panes, saves the contents as with <Control-s> and refreshes the tree pane. This can be used to insert newly written procs into the tree.
  • Commands can be executed in a sequence, if they are entered in the edit (or view) pane. Pressing <Control-s> or <Control-Return> executes the lines entered in the console interpreter.

The code

The tcl source code for the Deep Console can be found here [2]. If you replace your existing: your_tcl_installation_dir/lib/tk8.4/console.tcl (for tcl/tk 8.4 installations) it will appear instead of the standard tk console.

Feel free to change it to taste.

Example

To use Deep Console, after you have replaced your standard tk console as described above, here is a small demo. Save it in a file e.g. test.tcl and run with wish (it doesn't work by pasting in tkcon):
 package req Tk
 console show
 proc test1 {} {
        test2
 }
 proc test2 {} {
        test3
 }
 proc test3 {} {
        puts "Deep Console"
 }

History

v0.1.2: Corrected evaluation of proc script. When saving, evaluation was done in console's, instead of user's, space.

A similar concept was used for a debugger with syntax highlighting using ctext. IT also displays a tree of procs and variables with the possibility to edit procs at runtime.

dzach I wish I had seen this before. The deep browsing idea could be easily applied there too. Very cool.