LexerConf::Ptr_t ColoursAndFontsManager::CopyTheme(const wxString& lexerName, const wxString& themeName, const wxString& sourceTheme) { LexerConf::Ptr_t sourceLexer = GetLexer(lexerName, sourceTheme); CHECK_PTR_RET_NULL(sourceLexer); wxXmlNode* sourceLexerXml = sourceLexer->ToXml(); LexerConf::Ptr_t newLexer(new LexerConf()); newLexer->FromXml(sourceLexerXml); // Update the theme name newLexer->SetThemeName(themeName); // Add it return DoAddLexer(newLexer->ToXml()); }
void ColoursAndFontsManager::Save(LexerConf::Ptr_t lexer) { wxXmlDocument doc; doc.SetRoot(lexer->ToXml()); wxString filename; wxString themeName = lexer->GetThemeName().Lower(); themeName.Replace(" ", "_"); themeName.Replace("::", "_"); themeName.Replace("(", "_"); themeName.Replace(")", "_"); themeName.Replace(":", "_"); themeName.Replace(",", "_"); themeName.Replace(".", "_"); themeName.Replace(";", "_"); filename << "lexer_" << lexer->GetName().Lower() << "_" << themeName << ".xml"; wxFileName xmlFile(clStandardPaths::Get().GetUserDataDir(), filename); xmlFile.AppendDir("lexers"); ::SaveXmlToFile(&doc, xmlFile.GetFullPath()); }