diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index b2f12fdb2..b83b9e077 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -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 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 7c5c58ef6..a79e15713 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -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(i); str.clear(); - if (static_cast(i) != L_USER) + if (lt != L_USER && lt != L_JS) { - int cmdID = nppParam.langTypeToCommandID(static_cast(i)); + int cmdID = nppParam.langTypeToCommandID(lt); if ((cmdID != -1)) { getNameStrFromCmd(cmdID, str); if (str.length() > 0) { - _langList.push_back(LangID_Name(static_cast(i), str)); - ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_ADDSTRING, 0, reinterpret_cast(str.c_str())); - if (ndds._lang == i) - index = _langList.size() - 1; + size_t index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_ADDSTRING, 0, reinterpret_cast(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(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(::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(::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_GETITEMDATA, index, 0)); return TRUE; } else if (LOWORD(wParam) == IDC_COMBO_OTHERCP) diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 746d32178..f051b23cb 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -99,7 +99,6 @@ public : NewDocumentSubDlg() = default; private : - std::vector _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 _langList; void setCustomLen(int val); INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); };