示例#1
0
bool wxExViMacros::Playback(wxExEx* ex, const std::string& macro, int repeat)
{
  if (!IsRecordedMacro(macro))
  {
    wxLogStatus(_("Unknown macro") + ": "  +  macro);
    return false;
  }
  
  if (m_IsPlayback && macro == m_Macro)
  {
    wxLogStatus(_("Already playing back"));
    return false;
  }

  if (repeat <= 0)
  {
    return false;
  }
  
  ex->GetSTC()->BeginUndoAction();
  
  bool stop = false;
  
  if (!m_IsPlayback && !m_IsRecording)
  {
    m_Macro = macro;
    wxExFrame::StatusText(m_Macro, "PaneMacro");
  }
  
  m_IsPlayback = true;
  
  wxBusyCursor wait;
    
  AskForInput();
  
  const auto& macro_commands(m_Macros[macro]);
  
  for (int i = 0; i < repeat && !stop; i++)
  {
    for (auto& it : macro_commands)
    { 
      stop = !ex->Command(it);
      
      if (stop)
      {
        wxLogStatus(_("Macro aborted at '") + it + "'");
        break;
      }
    }
  }

  ex->GetSTC()->EndUndoAction();

  if (!stop)
  {
    wxLogStatus(_("Macro played back"));
    m_Macro = macro; // might be overridden by expanded variable
    wxExFrame::StatusText(m_Macro, "PaneMacro");
  }
  
  m_IsPlayback = false;
  
  return !stop;
}
示例#2
0
bool wxExViMacros::Playback(wxExEx* ex, const wxString& macro, int repeat)
{
  if (!IsRecordedMacro(macro))
  {
    wxLogStatus(_("Unknown macro") + ": "  +  macro);
    return false;
  }
  
  if (m_IsPlayback && macro == m_Macro)
  {
    wxLogStatus(_("Already playing back"));
    return false;
  }

  if (repeat <= 0)
  {
    return false;
  }
  
  ex->GetSTC()->BeginUndoAction();
  
  bool stop = false;
  
  if (!m_IsPlayback && !m_IsRecording)
  {
    m_Macro = macro;
    wxExFrame::StatusText(m_Macro, "PaneMacro");
  }
  
  m_IsPlayback = true;
  
  wxBusyCursor wait;
    
  AskForInput();
  
  for (int i = 0; i < repeat; i++)
  {
    for (
      std::vector<wxString>::const_iterator it = m_Macros[macro].begin();
      it != m_Macros[macro].end() && !stop;
      ++it)
    { 
      stop = !ex->Command(*it);
      
      if (stop)
      {
        wxLogStatus(_("Macro aborted at '") + *it + "'");
      }
    }
  }

  ex->GetSTC()->EndUndoAction();

  if (!stop)
  {
    wxLogStatus(_("Macro played back"));
  }
  
  m_IsPlayback = false;
  
  return !stop;
}