Example #1
0
/// 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;
}
Example #2
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);
}
Example #4
0
void CommandHandler::OnReceiveCommand(AppCommandEvent &event)
{
   // First retrieve the actual command from the event 'envelope'.
   Command *cmd = event.GetCommand();

   // Then apply it to current application & project.  Note that the
   // command may change the context - for example, switching to a
   // different project.
   cmd->Apply(*mCurrentContext);

   // Done with the command so delete it.
   delete cmd;

   // Redraw the project
   mCurrentContext->proj->RedrawProject();
}
Example #5
0
void CommandHandler::OnReceiveCommand(AppCommandEvent &event)
{
   // First retrieve the actual command from the event 'envelope'.
   CommandHolder cmd = event.GetCommand();

   // JKC: In case the user changed the project, let us track that.
   // This saves us the embarrassment (crash) of a NEW project
   // being opened, the old one closed and still trying to act
   // on the old one.
   SetProject( GetActiveProject() );
   // Then apply it to current application & project.  Note that the
   // command may change the context - for example, switching to a
   // different project.
   cmd->Apply(*mCurrentContext);

   // Redraw the project
   mCurrentContext->GetProject()->RedrawProject();
}