#include "editorviewhelper.h" #include #include #include #include #include "ILexer.h" #include "Lexilla.h" const QMultiMap languages_group = std::visit([]() -> QMultiMap { int lexerCount = GetLexerCount(); char buffer[114]; QMultiMap map; for (int i = 0; i < lexerCount; i++) { GetLexerName(i, buffer, 114); QString lexerName(buffer); map.insert(lexerName.at(0).toLower(), lexerName); } return map; }); std::list LexerGroupActionMenu::groups() { QList keys = languages_group.keys(); std::list keysLst(keys.constBegin(), keys.constEnd()); keysLst.unique(); return keysLst; } QString LexerGroupActionMenu::displayName(const QString &lexerName) { static const QHash displayNameMap { {"cpp", "C++"}, {"cmake", "CMake"}, {"hypertext", "HTML"}, {"powershell", "PowerShell"} }; return displayNameMap.value(lexerName, lexerName); } void LexerGroupActionMenu::slotAboutToShow() { if (!m_group) { m_group = new QActionGroup(menu()); } else { return; } for (const QString & name : languages_group.values(m_languageGroup)) { QAction *a = menu()->addAction(displayName(name), this, [this, name](){ emit lexerSelected(name); }); a->setActionGroup(m_group); } }