Sort Preferences->New Document->Default language combobox

Fix #10513
pull/10507/head^2
Don HO 3 years ago
parent 1c9009e9b2
commit 36d13f3ad8

@ -174,7 +174,7 @@ BEGIN
CONTROL "",IDC_RADIO_OTHERCP,"Button",BS_AUTORADIOBUTTON,242,126,10,10
COMBOBOX IDC_COMBO_OTHERCP,257,125,100,140,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Default language :",IDC_DEFAULTLANG_STATIC,16,130,77,8
COMBOBOX IDC_COMBO_DEFAULTLANG,98,128,100,140,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO_DEFAULTLANG,98,128,100,140,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
END

@ -1911,28 +1911,41 @@ INT_PTR CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPA
::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, (ID2Check == IDC_RADIO_UTF8SANSBOM && ndds._openAnsiAsUtf8)?BST_CHECKED:BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), ID2Check == IDC_RADIO_UTF8SANSBOM);
size_t index = 0;
for (int i = L_TEXT ; i < nppParam.L_END ; ++i)
for (int i = L_TEXT + 1 ; i < nppParam.L_END ; ++i) // Skip L_TEXT
{
LangType lt = static_cast<LangType>(i);
str.clear();
if (static_cast<LangType>(i) != L_USER)
if (lt != L_USER && lt != L_JS)
{
int cmdID = nppParam.langTypeToCommandID(static_cast<LangType>(i));
int cmdID = nppParam.langTypeToCommandID(lt);
if ((cmdID != -1))
{
getNameStrFromCmd(cmdID, str);
if (str.length() > 0)
{
_langList.push_back(LangID_Name(static_cast<LangType>(i), str));
::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
if (ndds._lang == i)
index = _langList.size() - 1;
size_t index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_SETITEMDATA, index, lt);
}
}
}
}
::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_SETCURSEL, index, 0);
// Insert L_TEXT to the 1st position
int normalTextCmdID = nppParam.langTypeToCommandID(L_TEXT);
getNameStrFromCmd(normalTextCmdID, str);
::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_INSERTSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
// Set chosen language
LangType l = L_TEXT;
size_t cbCount = ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_GETCOUNT, 0, 0);
size_t j = 0;
for (; j < cbCount; ++j)
{
l = static_cast<LangType>(::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_GETITEMDATA, j, 0));
if (ndds._lang == l)
break;
}
::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_SETCURSEL, j, 0);
}
case WM_CTLCOLORLISTBOX:
@ -2038,7 +2051,7 @@ INT_PTR CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPA
if (LOWORD(wParam) == IDC_COMBO_DEFAULTLANG)
{
auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_GETCURSEL, 0, 0);
ndds._lang = _langList[index]._id;
ndds._lang = static_cast<LangType>(::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_GETITEMDATA, index, 0));
return TRUE;
}
else if (LOWORD(wParam) == IDC_COMBO_OTHERCP)

@ -99,7 +99,6 @@ public :
NewDocumentSubDlg() = default;
private :
std::vector<LangID_Name> _langList;
void makeOpenAnsiAsUtf8(bool doIt){
if (!doIt)
::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, BST_UNCHECKED, 0);
@ -128,7 +127,6 @@ public :
private :
URLCtrl _nbHistoryVal;
URLCtrl _customLenVal;
std::vector<LangID_Name> _langList;
void setCustomLen(int val);
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
};

Loading…
Cancel
Save