/// This is the function which actually obeys one command. Rather than applying /// the command directly, an event containing a reference to the command is sent /// to the main (GUI) thread. This is because having more than one thread access /// the GUI at a time causes problems with wxwidgets. int ExecCommand2(wxString *pIn, wxString *pOut) { { CommandBuilder builder(*pIn); if (builder.WasValid()) { AudacityProject *project = GetActiveProject(); OldStyleCommandPointer cmd = builder.GetCommand(); AppCommandEvent ev; ev.SetCommand(cmd); AudacityApp & App = wxGetApp(); App.OnReceiveCommand(ev); *pOut = wxEmptyString; } else { *pOut = wxT("Syntax error!\n"); *pOut += builder.GetErrorMessage() + wxT("\n"); } } // Wait until all responses from the command have been received. // The last response is signalled by an empty line. wxString msg = ScriptCommandRelay::ReceiveResponse().GetMessage(); while (msg != wxT("\n")) { //wxLogDebug( "Msg: %s", msg ); *pOut += msg + wxT("\n"); msg = ScriptCommandRelay::ReceiveResponse().GetMessage(); } return 0; }
/// Send a command to a project, to be applied in that context. void ScriptCommandRelay::PostCommand(AudacityProject *project, const OldStyleCommandPointer &cmd) { wxASSERT(project != NULL); wxASSERT(cmd != NULL); AppCommandEvent ev; ev.SetCommand(cmd); project->GetEventHandler()->AddPendingEvent(ev); }
/// Send a command to a project, to be applied in that context. void ScriptCommandRelay::PostCommand(AudacityProject *project, Command *cmd) { wxASSERT(project != NULL); wxASSERT(cmd != NULL); AppCommandEvent ev; ev.SetCommand(cmd); projectGetEventHandler()ct->AddPendingEvent(ev); }