Source Editing

Basic Editor Function

The XOTclIDE editor is based on a Tk Text widget. The following functions are available.

Cut Text

Key Accelerator Control-x

Copy Text

Key Accelerator Control-c

Paste Text

Key Accelerator Control-v

Undo

Key Accelerator Control-z available only with Tcl8.4

To see other accelerators see the Tk Text Widget documentation. text widget manual.

Standard text find and replace dialogs are available in menu Edit. To search for text in many methods use the menu in Browser Component Browser Method->Search Text (F4).

Code Completion

It works like file name competition in bash (Unix Shell) or code completion in typed program language IDEs. The user can type the first character of token than press Tab or Control-Space. XOTclIDE tries to complete the token depending on its context. If many alternative completions are available a pop-down window list will be displayed.

Figure 3.2. Code Completion

Code Completion

The following language tokens can be completed

Tcl Core-Commands

commands like: lappend list foreach

Tcl Core-Commands parameters

for example string length|match|range

Defined Tcl Procedures

all procedures known from info procs

Defined XOTcl Classes and Object

all XOTcl Classes and Object in every namespace.

local class methods

all methods (including methods derived from other classes) found by $instance info instprocs

visible variables

variables defined per set append instvar foreach ... or method parameters. Just type $ and press the Tab key

Navigation in Sources

The Method menu in the Component Browser offers some additional help functions for browsing XOTcl/Tcl methods. You can return to the last shown method by Functions “Back Method ( Alt-Left )” or “Forward Method ( Alt-Right )” just like from your HTML browser.

Spawn View opens a new editor window with the same contents as the current edit area.

Syntax highlighting

XOTclIDE implements two kinds of syntax highlighting:

Simple syntax highlighting

is based on regular expression patterns. It highlights only "", substitution and # comments.

Parser-based syntax highlighting

This syntax highlighting gives a truer result. It highlights Tcl core-commands, variables, comments, "", substitution and XOTcl key-words.

Figure 3.3. Syntax Highlighting

Syntax Highlighting

Checking parentheses

Finding opening or closing parentheses can be hard work in understanding some Tcl methods. Double-click on [{" or ]}" and XOTclIDE will find the corresponding opening or closing parenthesis for you and select it.

Figure 3.4. Checking Parenthesis

Checking Parenthesis

Automatic Indenting

XOTclIDE tries to set the same indent in a newly inserted line as in the last line. If the last character before a new line is an opening parenthesis { then in the new line the indenting will be increased by four and a matching closing parenthesis will be inserted.

foreach a $list {here cursor

After a new line you will see this code

foreach a $list {
here cursor
}

Evaluate Tcl Scripts in Editor

This is a very powerful function. It lets you evaluate Tcl scripts as in the Tclshell console but is more flexible. Simply select a string and evaluate it with the pop-down menu or key-accelerator. Now you will notice that in Tcl everything is a string. It is also the easiest and fastest way to program in XOTcl/Tcl.

Figure 3.5. Evaluate Scripts

Evaluate Scripts

The Menu “Print it” corresponds to the Tcl eval command. You can also use Control-q.

Figure 3.6. Substitute Scripts

Substitute Scripts

Menu “Substitute it” corresponds to the subst Tcl command.

Figure 3.7. Inspect Script Evaluation

Inspect Script Evaluation

Menu “Inspect it” evaluates the selected text and launches an inspector on the returned value if it is a XOTcl object. You can also use Control-g. If the result of the last operation is an XOTcl Object then it will be displayed in an Object inspector.

You can use Workspaces (see menu System->Workspace ) to evaluate short Tcl scripts.