Sort language list in the Preferences dialog
Sort langlist before displaying using custom less than operator. Fix #14245, close #14443
This commit is contained in:
parent
ef8ad111e9
commit
bf37d4714f
|
@ -586,6 +586,14 @@ struct LangMenuItem final
|
||||||
|
|
||||||
LangMenuItem(LangType lt, int cmdID = 0, const std::wstring& langName = TEXT("")):
|
LangMenuItem(LangType lt, int cmdID = 0, const std::wstring& langName = TEXT("")):
|
||||||
_langType(lt), _cmdID(cmdID), _langName(langName){};
|
_langType(lt), _cmdID(cmdID), _langName(langName){};
|
||||||
|
|
||||||
|
bool operator<(const LangMenuItem& rhs)
|
||||||
|
{
|
||||||
|
std::wstring lhs_lang(this->_langName.length(), ' '), rhs_lang(rhs._langName.length(), ' ');
|
||||||
|
std::transform(this->_langName.begin(), this->_langName.end(), lhs_lang.begin(), towlower);
|
||||||
|
std::transform(rhs._langName.begin(), rhs._langName.end(), rhs_lang.begin(), towlower);
|
||||||
|
return lhs_lang < rhs_lang;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PrintSettings final {
|
struct PrintSettings final {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "lesDlgs.h"
|
#include "lesDlgs.h"
|
||||||
#include "EncodingMapper.h"
|
#include "EncodingMapper.h"
|
||||||
#include "localization.h"
|
#include "localization.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#define MyGetGValue(rgb) (LOBYTE((rgb)>>8))
|
#define MyGetGValue(rgb) (LOBYTE((rgb)>>8))
|
||||||
|
|
||||||
|
@ -2861,12 +2862,20 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||||
if (str.length() > 0)
|
if (str.length() > 0)
|
||||||
{
|
{
|
||||||
_langList.push_back(LangMenuItem(static_cast<LangType>(i), cmdID, str));
|
_langList.push_back(LangMenuItem(static_cast<LangType>(i), cmdID, str));
|
||||||
::SendDlgItemMessage(_hSelf, IDC_LIST_ENABLEDLANG, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::sort(_langList.begin(), _langList.end());
|
||||||
|
|
||||||
|
for (size_t i = 0, len = _langList.size(); i < len; ++i)
|
||||||
|
{
|
||||||
|
::SendDlgItemMessage(_hSelf, IDC_LIST_ENABLEDLANG, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(_langList[i]._langName.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(nppGUI._excludedLangList.begin(), nppGUI._excludedLangList.end());
|
||||||
|
|
||||||
for (size_t i = 0, len = nppGUI._excludedLangList.size(); i < len ; ++i)
|
for (size_t i = 0, len = nppGUI._excludedLangList.size(); i < len ; ++i)
|
||||||
{
|
{
|
||||||
::SendDlgItemMessage(_hSelf, IDC_LIST_DISABLEDLANG, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(nppGUI._excludedLangList[i]._langName.c_str()));
|
::SendDlgItemMessage(_hSelf, IDC_LIST_DISABLEDLANG, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(nppGUI._excludedLangList[i]._langName.c_str()));
|
||||||
|
|
Loading…
Reference in New Issue