Example #1
0
bool wxExViMacros::LoadDocument()
{
  wxXmlDocument doc;
  
  if (!Load(doc))
  {
    return false;
  }
  
  // If modified is true, then you did not save previous
  // recordings.
  // We assume that this is your choice, so we reset the member.
  m_IsModified = false;
  
  m_Abbreviations.clear();
  m_Macros.clear();
  m_Variables.clear();
  
  wxXmlNode* child = doc.GetRoot()->GetChildren();
  
  while (child)
  {
    if (child->GetName() == "abbreviation")
    {
      ParseNodeAbbreviation(child);
    }
    else if (child->GetName() == "macro")
    {
      ParseNodeMacro(child);
    }
    else if (child->GetName() == "variable")
    {
      ParseNodeVariable(child);
    }
      
    child = child->GetNext();
  }
  
  return true;
}
Example #2
0
bool wxExLexers::Read()
{
  // This test is to prevent showing an error if the lexers file does not exist,
  // as this is not required.
  if (!m_FileName.FileExists())
  {
    return false;
  } 

  wxXmlDocument doc;

  if (!doc.Load(m_FileName.GetFullPath()))
  {
    return false;
  }
  
  Initialize();
  
  // Even if no theme is chosen,
  // read all lexers, to be able to select other themes again.

  wxXmlNode* child = doc.GetRoot()->GetChildren();

  while (child)
  {
    if (child->GetName() == "macro")
    {
      ParseNodeMacro(child);
    }
    else if (child->GetName() == "global")
    {
      ParseNodeGlobal(child);
    }
    else if (child->GetName() == "lexer")
    {
      const wxExLexer lexer(child);
      
      if (lexer.IsOk())
      {
        m_Lexers.insert(std::make_pair(lexer.GetDisplayLexer(), lexer));
      }
    }

    child = child->GetNext();
  }

  // Check config, but do not create one.
  wxConfigBase* config = wxConfigBase::Get(false);

  if (config != NULL)
  {
    if (!config->Exists(_("In files")))
    {
      config->Write(_("In files"), GetLexerExtensions());
    }

    if (!config->Exists(_("Add what")))
    {
      config->Write(_("Add what"), GetLexerExtensions());
    }
  }
  
  return true;
}