LexerConf::Ptr_t EclipseTextThemeImporter::Import(const wxFileName& eclipseXmlFile)
{
    LexerConf::Ptr_t lexer = InitializeImport(eclipseXmlFile, "text", 1);
    CHECK_PTR_RET_NULL(lexer);
    
    AddProperty(lexer, "0", "Default", m_foreground.colour, m_background.colour);
    AddCommonProperties(lexer);
    FinalizeImport(lexer);
    return lexer;
}
LexerConf::Ptr_t EclipsePHPThemeImporter::Import(const wxFileName& eclipseXmlFile)
{
    LexerConf::Ptr_t lexer = InitializeImport(eclipseXmlFile, "php", 4);
    CHECK_PTR_RET_NULL(lexer);

    // PHP can also be found in a file which contains HTML and JavaScript
    // so we define them all here

    // HTML
    AddProperty(lexer, wxSTC_H_DEFAULT, "HTML Default", m_foreground.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_TAG, "HTML Tag", m_variable.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_TAGUNKNOWN, "Unknown HTML Tag", m_variable.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_ATTRIBUTE, "HTML Attribute", m_klass.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_ATTRIBUTEUNKNOWN, "Unknown HTML Attribute", m_klass.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_NUMBER, "HTML Number", m_number.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_DOUBLESTRING, "HTML Double String", m_string.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_SINGLESTRING, "HTML Single String", m_string.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_OTHER, "HTML Other", m_foreground.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_COMMENT, "HTML Comment", m_multiLineComment.colour, m_background.colour);
    AddProperty(lexer, wxSTC_H_ENTITY, "HTML Entity", m_foreground.colour, m_background.colour);

    // Embedded JavaScript
    AddProperty(lexer, wxSTC_HJ_START, "JS Start", m_foreground.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_DEFAULT, "JS Default", m_foreground.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_COMMENT, "JS Comment", m_singleLineComment.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_COMMENTLINE, "JS MultiLine Comment", m_multiLineComment.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_COMMENTDOC, "JS Doc Comment", m_multiLineComment.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_NUMBER, "JS Number", m_number.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_WORD, "JS Word", m_foreground.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_KEYWORD, "JS Keyword", m_keyword.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_DOUBLESTRING, "JS Double String", m_string.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_SINGLESTRING, "JS Single String", m_string.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_SYMBOLS, "JS Symbols", m_foreground.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_STRINGEOL, "JS String EOL", m_string.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HJ_REGEX, "JS Regex", m_klass.colour, m_background.colour);

    // PHP
    AddProperty(lexer, wxSTC_HPHP_COMPLEX_VARIABLE, "PHP Complex Variable", m_variable.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_DEFAULT, "PHP Default", m_foreground.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_HSTRING, "PHP Heredoc String", m_string.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_SIMPLESTRING, "PHP String", m_string.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_WORD, "PHP Word", m_keyword.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_NUMBER, "PHP Number", m_number.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_VARIABLE, "PHP Variable", m_variable.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_COMMENTLINE, "PHP Comment", m_singleLineComment.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_COMMENT, "PHP Multiline Comment", m_multiLineComment.colour, m_background.colour);
    AddProperty(lexer, wxSTC_HPHP_HSTRING_VARIABLE, "PHP Heredoc Variable", m_variable.colour, m_background.colour);
    FinalizeImport(lexer);
    return lexer;
}
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);

    JSONElement json = sourceLexer->ToJSON();
    LexerConf::Ptr_t newLexer(new LexerConf());
    newLexer->FromJSON(json);

    // Update the theme name
    newLexer->SetThemeName(themeName);

    // Add it
    return DoAddLexer(newLexer->ToJSON());
}
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());
}
LexerConf::Ptr_t EclipseCSSThemeImporter::Import(const wxFileName& eclipseXmlFile)
{
    LexerConf::Ptr_t lexer = InitializeImport(eclipseXmlFile, "css", wxSTC_LEX_CSS);
    CHECK_PTR_RET_NULL(lexer);

    // Set error colour
    wxColour defaultBg(m_background.colour);
    bool isDark = DrawingUtils::IsDark(defaultBg);
    wxString errorColour = "RED";
    if(isDark) {
        errorColour = "PINK";
    }
    wxString operatorColour = isDark ? "WHITE" : "BLACK";

    /// Lexical states for SCLEX_CSS
    // Convert to CodeLite's XML properties
    AddProperty(lexer, "0", "Default", m_foreground.colour, m_background.colour);
    AddProperty(lexer, "1", "Tag", m_foreground.colour, m_background.colour);
    AddProperty(lexer, "2", "Class", m_klass.colour, m_background.colour);
    AddProperty(lexer, "3", "Pseudo Class", m_klass.colour, m_background.colour);
    AddProperty(lexer, "4", "Unknown Pseudo Class", m_klass.colour, m_background.colour);
    AddProperty(lexer, "5", "Operator", operatorColour, m_background.colour);
    AddProperty(lexer, "6", "Identifier", m_variable.colour, m_background.colour);
    AddProperty(lexer, "7", "Unknown Identifier", m_variable.colour, m_background.colour);
    AddProperty(lexer, "8", "Value", m_foreground.colour, m_background.colour);
    AddProperty(lexer, "9", "Comment", m_multiLineComment.colour, m_background.colour);
    AddProperty(lexer, "10", "ID", m_variable.colour, m_background.colour);
    AddProperty(lexer, "11", "Important", m_foreground.colour, m_background.colour);
    AddProperty(lexer, "12", "Directive", m_klass.colour, m_background.colour);
    AddProperty(lexer, "13", "String", m_string.colour, m_background.colour);
    AddProperty(lexer, "14", "Double String", m_string.colour, m_background.colour);
    AddProperty(lexer, "15", "Identifier 2", m_variable.colour, m_background.colour);
    AddProperty(lexer, "16", "Attribute", m_foreground.colour, m_background.colour);
    AddProperty(lexer, "17", "Identifier 3", m_variable.colour, m_background.colour);
    AddProperty(lexer, "18", "Pseudo Element", m_foreground.colour, m_background.colour);
    AddProperty(lexer, "19", "Extended Identifier", m_variable.colour, m_background.colour);
    AddProperty(lexer, "20", "Extended Pseudo Class", m_foreground.colour, m_background.colour);
    AddProperty(lexer, "21", "Extended Pseudo Element", m_foreground.colour, m_background.colour);
    AddProperty(lexer, "22", "Media", m_klass.colour, m_background.colour);
    AddProperty(lexer, "23", "Variable", m_variable.colour, m_background.colour);
    FinalizeImport(lexer);
    return lexer;
}
LexerConf::Ptr_t EclipseJavaScriptThemeImporter::Import(const wxFileName& eclipseXmlFile)
{
    LexerConf::Ptr_t lexer = InitializeImport(eclipseXmlFile, "javascript", 3);
    CHECK_PTR_RET_NULL(lexer);

    // Covnert to codelite's XML properties
    AddProperty(lexer, wxSTC_C_DEFAULT, "Default", m_foreground.colour, m_background.colour);
    AddProperty(lexer,
                wxSTC_C_COMMENT,
                "Block comment",
                m_multiLineComment.colour,
                m_background.colour,
                m_multiLineComment.isBold,
                m_multiLineComment.isItalic);
    AddProperty(lexer,
                wxSTC_C_COMMENTLINE,
                "Single line comment",
                m_singleLineComment.colour,
                m_background.colour,
                m_singleLineComment.isBold,
                m_singleLineComment.isItalic);
    AddProperty(lexer,
                wxSTC_C_COMMENTDOC,
                "Doxygen block comment",
                m_javadoc.colour,
                m_background.colour,
                m_javadoc.isBold,
                m_javadoc.isItalic);
    AddProperty(
        lexer, wxSTC_C_NUMBER, "Number", m_number.colour, m_background.colour, m_number.isBold, m_number.isItalic);
    AddProperty(lexer,
                wxSTC_C_WORD,
                "JavaScript keyword",
                m_keyword.colour,
                m_background.colour,
                m_keyword.isBold,
                m_keyword.isItalic);
    AddProperty(
        lexer, wxSTC_C_STRING, "String", m_string.colour, m_background.colour, m_string.isBold, m_string.isItalic);
    AddProperty(lexer,
                wxSTC_C_CHARACTER,
                "Character",
                m_string.colour,
                m_background.colour,
                m_string.isBold,
                m_string.isItalic);
    AddProperty(lexer, wxSTC_C_OPERATOR, "Operator", m_foreground.colour, m_background.colour);
    AddProperty(lexer, wxSTC_C_IDENTIFIER, "Identifier", m_foreground.colour, m_background.colour);
    AddProperty(lexer,
                wxSTC_C_STRINGEOL,
                "Open String",
                m_string.colour,
                m_background.colour,
                m_string.isBold,
                m_string.isItalic);
    AddProperty(lexer,
                wxSTC_C_COMMENTLINEDOC,
                "Doxygen single line comment",
                m_javadoc.colour,
                m_background.colour,
                m_javadoc.isBold,
                m_javadoc.isItalic);
    AddProperty(lexer,
                wxSTC_C_WORD2,
                "JavaScript functions",
                m_variable.colour,
                m_background.colour,
                m_javadoc.isBold,
                m_javadoc.isItalic);
    AddProperty(lexer,
                wxSTC_C_GLOBALCLASS,
                "JavaScript global classes",
                m_klass.colour,
                m_background.colour,
                m_javadoc.isBold,
                m_javadoc.isItalic);
    AddProperty(lexer,
                wxSTC_C_COMMENTDOCKEYWORD,
                "Doxygen keyword",
                m_javadocKeyword.colour,
                m_background.colour,
                m_javadocKeyword.isBold,
                m_javadocKeyword.isItalic);
    AddProperty(lexer,
                wxSTC_C_COMMENTDOCKEYWORDERROR,
                "Doxygen keyword error",
                m_javadocKeyword.colour,
                m_background.colour,
                m_javadocKeyword.isBold,
                m_javadocKeyword.isItalic);
    FinalizeImport(lexer);
    return lexer;
}