| | @@ -768,25 +768,37 @@ |
| 768 | 768 | Tcl_DecrRefCount(listPtr); |
| 769 | 769 | return rc; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | /* |
| 773 | | -** Run a Tcl script. If the script succeeds, start the main loop until |
| 774 | | -** there is no more work to be done or the script calls "exit". |
| 773 | +** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the |
| 774 | +** Tcl script succeeds, start a Tcl event loop until there are no more events |
| 775 | +** remaining to process -OR- the script calls [exit]. If the bWait argument |
| 776 | +** is zero, only process events that are already in the queue; otherwise, |
| 777 | +** process events until the script terminates the Tcl event loop. |
| 775 | 778 | */ |
| 776 | | -int runTclGui(Th_Interp *interp, void *pContext, const char *script){ |
| 779 | +int evaluateTclWithEvents( |
| 780 | + Th_Interp *interp, |
| 781 | + void *pContext, |
| 782 | + const char *zScript, |
| 783 | + int nScript, |
| 784 | + int bWait |
| 785 | +){ |
| 777 | 786 | struct TclContext *tclContext = (struct TclContext *)pContext; |
| 787 | + Tcl_Interp *tclInterp; |
| 778 | 788 | int rc; |
| 789 | + int flags = TCL_ALL_EVENTS; |
| 779 | 790 | |
| 780 | 791 | if( createTclInterp(interp, pContext)!=TH_OK ){ |
| 781 | 792 | return TH_ERROR; |
| 782 | 793 | } |
| 783 | | - rc = Tcl_EvalEx(tclContext->interp, script, -1, TCL_EVAL_GLOBAL); |
| 784 | | - if (rc == TCL_OK){ |
| 785 | | - while (Tcl_DoOneEvent(0)) { |
| 786 | | - /* do nothing */ |
| 787 | | - } |
| 794 | + tclInterp = tclContext->interp; |
| 795 | + rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); |
| 796 | + if( rc!=TCL_OK ) return rc; |
| 797 | + if( !bWait ) flags |= TCL_DONT_WAIT; |
| 798 | + while( Tcl_DoOneEvent(flags) ){ |
| 799 | + /* do nothing */ |
| 788 | 800 | } |
| 789 | 801 | return rc; |
| 790 | 802 | } |
| 791 | 803 | |
| 792 | 804 | /* |
| 793 | 805 | |