From octave-graphics-request at bevo dot che dot wisc dot edu Fri Aug 25 13:32:37 2000 Subject: VTK for octave From: "John W. Eaton" To: Kai Habel Cc: octave-graphics at bevo dot che dot wisc dot edu Date: Fri, 25 Aug 2000 13:30:49 -0500 (CDT) On 25-Aug-2000, Kai Habel wrote: | The first problem one gets is, the vtk function has its own loop and | waits for inputs (mouse or keyboard), so as long as the vtk window is | open the octave input is blocked. | I don't know how to solve this kind of problems. Could we merge the vtk | loop into octave's? Anyone with more insight? Here is an example (using Tk) that shows how to handle keyboard input with readline while also handling GUI events. The idea is that you register a function with readline to process events and also tell the GUI toolkit to not do anything with keyboard input. I think most toolkits allow you to do something similar. jwe // Compiled with: // // g++ -o foo tkHelloWorld.c \ // -ltk4.2 -ltcl7.6 -lX11 -lreadline -ldl -lieee -lm -lc // // and with the necessary -I and -L options to find the include and // library files. #include #include #include #include #include extern "C" void do_nothing (ClientData, int) { } extern "C" int event_hook () { return Tcl_DoOneEvent (TCL_ALL_EVENTS); } extern "C" void rl_deprep_terminal (void); void clean_up_and_exit (ClientData) { rl_deprep_terminal (); cout << "\n"; exit (0); } int main (int argc, char **argv) { rl_event_hook = event_hook; int retval = 0; Tcl_CreateExitHandler (clean_up_and_exit, 0); Tcl_Interp *interp = Tcl_CreateInterp (); Tcl_Init (interp); if (Tk_Init (interp) == TCL_ERROR) { cerr << interp->result << "\n"; retval = 1; } else { Tk_CreateFileHandler (0, TK_READABLE, do_nothing, 0); bool done = false; while (! done) { char *line = readline ("tk> "); if (line) { if (*line) { add_history (line); Tcl_Eval (interp, line); } } else done = true; } } Tcl_DeleteInterp (interp); return retval; }