Sort languages alphabetically in Style Configurator

Fix #11337, close #11508
This commit is contained in:
Don Ho 2022-04-09 16:58:54 +02:00
parent ad39c68611
commit 2474cbeafd
2 changed files with 26 additions and 15 deletions

View File

@ -1758,9 +1758,9 @@ void NppParameters::getLangKeywordsFromXmlTree()
} }
void NppParameters::getExternalLexerFromXmlTree(TiXmlDocument *doc) void NppParameters::getExternalLexerFromXmlTree(TiXmlDocument* externalLexerDoc)
{ {
TiXmlNode *root = doc->FirstChild(TEXT("NotepadPlus")); TiXmlNode *root = externalLexerDoc->FirstChild(TEXT("NotepadPlus"));
if (!root) return; if (!root) return;
feedKeyWordsParameters(root); feedKeyWordsParameters(root);
feedStylerArray(root); feedStylerArray(root);
@ -3678,6 +3678,8 @@ bool NppParameters::feedStylerArray(TiXmlNode *node)
} }
} }
_lexerStylerVect.sort();
// The global styles for all lexers // The global styles for all lexers
TiXmlNode *globalStyleRoot = node->FirstChildElement(TEXT("GlobalStyles")); TiXmlNode *globalStyleRoot = node->FirstChildElement(TEXT("GlobalStyles"));
if (!globalStyleRoot) return false; if (!globalStyleRoot) return false;

View File

@ -506,7 +506,11 @@ private :
generic_string _lexerUserExt; generic_string _lexerUserExt;
}; };
struct SortLexersInAlphabeticalOrder {
bool operator() (LexerStyler& l, LexerStyler& r) {
return lstrcmp(l.getLexerDesc(), r.getLexerDesc()) < 0;
}
};
struct LexerStylerArray struct LexerStylerArray
{ {
@ -531,8 +535,13 @@ struct LexerStylerArray
} }
return nullptr; return nullptr;
}; };
void addLexerStyler(const TCHAR *lexerName, const TCHAR *lexerDesc, const TCHAR *lexerUserExt, TiXmlNode *lexerNode); void addLexerStyler(const TCHAR *lexerName, const TCHAR *lexerDesc, const TCHAR *lexerUserExt, TiXmlNode *lexerNode);
void sort() {
std::sort(_lexerStylerVect.begin(), _lexerStylerVect.end(), SortLexersInAlphabeticalOrder());
};
private : private :
std::vector<LexerStyler> _lexerStylerVect; std::vector<LexerStyler> _lexerStylerVect;
}; };
@ -1413,7 +1422,7 @@ public:
bool ExternalLangHasRoom() const {return _nbExternalLang < NB_MAX_EXTERNAL_LANG;}; bool ExternalLangHasRoom() const {return _nbExternalLang < NB_MAX_EXTERNAL_LANG;};
void getExternalLexerFromXmlTree(TiXmlDocument *doc); void getExternalLexerFromXmlTree(TiXmlDocument* externalLexerDoc);
std::vector<TiXmlDocument *> * getExternalLexerDoc() { return &_pXmlExternalLexerDoc; }; std::vector<TiXmlDocument *> * getExternalLexerDoc() { return &_pXmlExternalLexerDoc; };
void writeDefaultUDL(); void writeDefaultUDL();
@ -1674,19 +1683,19 @@ private:
NppParameters& operator=(NppParameters&&) = delete; NppParameters& operator=(NppParameters&&) = delete;
TiXmlDocument *_pXmlDoc = nullptr; TiXmlDocument *_pXmlDoc = nullptr; // langs.xml
TiXmlDocument *_pXmlUserDoc = nullptr; TiXmlDocument *_pXmlUserDoc = nullptr; // config.xml
TiXmlDocument *_pXmlUserStylerDoc = nullptr; TiXmlDocument *_pXmlUserStylerDoc = nullptr; // stylers.xml
TiXmlDocument *_pXmlUserLangDoc = nullptr; TiXmlDocument *_pXmlUserLangDoc = nullptr; // userDefineLang.xml
std::vector<UdlXmlFileState> _pXmlUserLangsDoc; std::vector<UdlXmlFileState> _pXmlUserLangsDoc; // userDefineLang customized XMLs
TiXmlDocument *_pXmlToolIconsDoc = nullptr; TiXmlDocument *_pXmlToolIconsDoc = nullptr; // toolbarIcons.xml
TiXmlDocument *_pXmlShortcutDoc = nullptr; TiXmlDocument *_pXmlShortcutDoc = nullptr; // shortcuts.xml
TiXmlDocument *_pXmlBlacklistDoc = nullptr; TiXmlDocument *_pXmlBlacklistDoc = nullptr; // not implemented
TiXmlDocumentA *_pXmlNativeLangDocA = nullptr; TiXmlDocumentA *_pXmlNativeLangDocA = nullptr; // nativeLang.xml
TiXmlDocumentA *_pXmlContextMenuDocA = nullptr; TiXmlDocumentA *_pXmlContextMenuDocA = nullptr; // contextMenu.xml
std::vector<TiXmlDocument *> _pXmlExternalLexerDoc; std::vector<TiXmlDocument *> _pXmlExternalLexerDoc; // External lexer plugins' XMLs
NppGUI _nppGUI; NppGUI _nppGUI;
ScintillaViewParams _svp; ScintillaViewParams _svp;