Re: flow control question



On Tue, 21 Jul 2009, Dov Grobgeld wrote:

Here are two programs that implement through the text viewer
widget what you are asking for:

   - The Python console in gimp
   - GemTcl - a tcl interpreter

The way I set up the interaction is to listen to both the
key-press-event and the insert-text events of the text-viewer.
The key-press-event signals to the insert-event handler that it
is supposed to enter eval mode... and the insert-event catches
this before the newline is inserted into the buffer, runs the
eval and inserts the result into the buffer[.]

Thanks for the references.  That is pretty much what I have been
doing up till now.  What I really wanted that was new, though, was
a loop of precisely the form

while (get_a_command()) {
  respond
}

where get_a_command is a function, to which all the GUI apparatus
is subservient, that can be passed as a callback.  The reason is
that I want to enable the "hijacking" of get_a_command by a
debugger.  That is, if the user has set a breakpoint in a script
running in this sort of GUI console, the debugger can call
get_a_command and offer "next", "continue" and so on.  (The
debugger itself lives in a library that knows nothing about GTK.)

I've now been at least half successful in this.

Allin Cottrell





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]