02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Tornado</strong> 2.0<br />

User’s Guide<br />

– A button, akin to the button, to launch a dedicated window that<br />

monitors the value where this points.<br />

The Tcl primitive catch is used in the second button definition in order to avoid<br />

propagating error conditions (for instance, if the buttons are pressed with no code<br />

loaded) from GDB back to the controlling CrossWind session. This does not<br />

prevent GDB from issuing the appropriate error messages to the command panel.<br />

Example 7-1<br />

Buttons for C++ this Pointer<br />

# Make a nice gap before new buttons<br />

toolBarItemCreate " " space<br />

# BUTTON: "t" Print C++ "this" value.<br />

toolBarItemCreate " t " button {<br />

ttySend "print this\n"<br />

}<br />

# BUTTON: "t*" Launch "inspect" window on current C++ class (*this)<br />

toolBarItemCreate " t*" button {<br />

catch {downtcl gdb display/W *this}<br />

}<br />

Tcl: A List Command for the File Menu<br />

Example 7-2 illustrates how to add extensions to the CrossWind graphical<br />

interface with a simple enhancement: adding a menu command to list the<br />

displayed program source centered on a particular line.<br />

In Example 7-2, the procedure xwindList uses downtcl to run the GDB list<br />

command. To tie this into the graphical interface, the example adds a new<br />

command List from… to the File menu. The new command displays a form<br />

(described in the dialogCreate call) to collect input specifying an argument to the<br />

list command. When input is complete, the form in turn runs xwindList, through<br />

a call-back attached to its OK button. Figure 7-14 shows the new menu command<br />

and form defined here (and the Example 7-3 menu command).<br />

Example 7-2<br />

List Command<br />

# FORM: a form to prompt for list argument<br />

# (part of "List from..." command addition to "File" menu)<br />

dialogCreate "List from?" -size 290 100 {<br />

{text "line spec:" -hspan}<br />

276

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!