diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 94acda793..aebeab525 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -3,7 +3,7 @@ The comments are here for explanation, it's not necessary to translate them. --> - +
@@ -1349,6 +1349,8 @@ Continue?"/> + + diff --git a/PowerEditor/installer/nativeLang/german.xml b/PowerEditor/installer/nativeLang/german.xml index f1e2bf003..d1e66da6b 100644 --- a/PowerEditor/installer/nativeLang/german.xml +++ b/PowerEditor/installer/nativeLang/german.xml @@ -12,7 +12,7 @@ --> - +
@@ -1357,6 +1357,8 @@ Fortsetzen?"/> + + diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 4a5089ae0..7080fbc5a 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -367,10 +367,12 @@ IDI_FUNCLIST_ROOT BITMAP "icons/project_file.bmp" IDI_FUNCLIST_NODE BITMAP "icons/funcList_node.bmp" IDI_FUNCLIST_LEAF BITMAP "icons/funcList_leaf.bmp" -IDI_FUNCLIST_SORTBUTTON BITMAP "icons/funclstSort.bmp" -IDI_FUNCLIST_RELOADBUTTON BITMAP "icons/funclstReload.bmp" -IDI_FUNCLIST_SORTBUTTON_DM BITMAP "icons/darkMode/panels/funclstSort.bmp" -IDI_FUNCLIST_RELOADBUTTON_DM BITMAP "icons/darkMode/panels/funclstReload.bmp" +IDI_FUNCLIST_SORTBUTTON BITMAP "icons/funclstSort.bmp" +IDI_FUNCLIST_RELOADBUTTON BITMAP "icons/funclstReload.bmp" +IDI_FUNCLIST_PREFERENCEBUTTON BITMAP "icons/funclstPreferences.bmp" +IDI_FUNCLIST_SORTBUTTON_DM BITMAP "icons/darkMode/panels/funclstSort.bmp" +IDI_FUNCLIST_RELOADBUTTON_DM BITMAP "icons/darkMode/panels/funclstReload.bmp" +IDI_FUNCLIST_PREFERENCEBUTTON_DM BITMAP "icons/darkMode/panels/funclstPreferences.bmp" IDI_GET_INFO_FROM_TOOLTIP ICON "icons/MoreOnTooltip.ico" diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 9785f450e..7ded6ebea 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5503,6 +5503,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (optDocPeekOnMap) _nppGUI._isDocPeekOnMap = (lstrcmp(optDocPeekOnMap, TEXT("yes")) == 0); + const TCHAR* optSortFunctionList = element->Attribute(TEXT("sortFunctionList")); + if (optSortFunctionList) + _nppGUI._shouldSortFunctionList = (lstrcmp(optSortFunctionList, TEXT("yes")) == 0); + const TCHAR* saveDlgExtFilterToAllTypes = element->Attribute(TEXT("saveDlgExtFilterToAllTypes")); if (saveDlgExtFilterToAllTypes) _nppGUI._setSaveDlgExtFiltToAllTypes = (lstrcmp(saveDlgExtFilterToAllTypes, TEXT("yes")) == 0); @@ -6564,6 +6568,7 @@ void NppParameters::createXmlTreeFromGUIParams() GUIConfigElement->SetAttribute(TEXT("isFolderDroppedOpenFiles"), _nppGUI._isFolderDroppedOpenFiles ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("docPeekOnTab"), _nppGUI._isDocPeekOnTab ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("docPeekOnMap"), _nppGUI._isDocPeekOnMap ? TEXT("yes") : TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("sortFunctionList"), _nppGUI._shouldSortFunctionList ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("saveDlgExtFilterToAllTypes"), _nppGUI._setSaveDlgExtFiltToAllTypes ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("muteSounds"), _nppGUI._muteSounds ? TEXT("yes") : TEXT("no")); } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 491f161a6..9e62e3f02 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -859,6 +859,9 @@ struct NppGUI final bool _isDocPeekOnTab = false; bool _isDocPeekOnMap = false; + // function list should be sorted by default on new file open + bool _shouldSortFunctionList = false; + DarkModeConf _darkmode; }; diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index e623cc7b5..29c068b7a 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -27,8 +27,7 @@ using namespace std; #define INDEX_NODE 1 #define INDEX_LEAF 2 -#define FL_SORTLOCALNODENAME "SortTip" -#define FL_RELOADLOCALNODENAME "ReloadTip" +#define FL_PREFERENCES_INITIALSORT_ID 1 FunctionListPanel::~FunctionListPanel() { @@ -394,7 +393,8 @@ void FunctionListPanel::reload() if (!previousParams) { ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, reinterpret_cast(TEXT(""))); - setSort(false); + setSort(NppParameters::getInstance().getNppGUI()._shouldSortFunctionList); + sortOrUnsort(); _treeView.expand(root); } else @@ -420,6 +420,32 @@ void FunctionListPanel::reload() } } +void FunctionListPanel::initPreferencesMenu() +{ + NativeLangSpeaker* pNativeSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + + generic_string shouldSortFunctionListStr = pNativeSpeaker->getAttrNameStr(TEXT("Sort functions (A to Z) by default"), FL_FUCTIONLISTROOTNODE, FL_PREFERENCE_INITIALSORT); + + _hPreferencesMenu = ::CreatePopupMenu(); + ::InsertMenu(_hPreferencesMenu, 0, MF_BYCOMMAND, FL_PREFERENCES_INITIALSORT_ID, shouldSortFunctionListStr.c_str()); + ::CheckMenuItem(_hPreferencesMenu, FL_PREFERENCES_INITIALSORT_ID, MF_BYCOMMAND | (nppGUI._shouldSortFunctionList ? MF_CHECKED : MF_UNCHECKED)); +} + +void FunctionListPanel::showPreferencesMenu() +{ + RECT rectToolbar; + RECT rectPreferencesButton; + ::GetWindowRect(_hToolbarMenu, &rectToolbar); + ::SendMessage(_hToolbarMenu, TB_GETRECT, IDC_PREFERENCEBUTTON_FUNCLIST, (LPARAM)&rectPreferencesButton); + + ::TrackPopupMenu(_hPreferencesMenu, + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + rectToolbar.left + rectPreferencesButton.left, + rectToolbar.top + rectPreferencesButton.bottom, + 0, _hSelf, NULL); +} + void FunctionListPanel::markEntry() { LONG lineNr = static_cast((*_ppEditView)->getCurrentLineNumber()); @@ -570,6 +596,10 @@ void FunctionListPanel::notified(LPNMHDR notification) { wcscpy_s(lpttt->szText, _reloadTipStr.c_str()); } + else if (notification->idFrom == IDC_PREFERENCEBUTTON_FUNCLIST) + { + wcscpy_s(lpttt->szText, _preferenceTipStr.c_str()); + } } else if (notification->hwndFrom == _treeView.getHSelf() || notification->hwndFrom == this->_treeViewSearchResult.getHSelf()) { @@ -638,7 +668,6 @@ void FunctionListPanel::searchFuncAndSwitchView() { TCHAR text2search[MAX_PATH] ; ::SendMessage(_hSearchEdit, WM_GETTEXT, MAX_PATH, reinterpret_cast(text2search)); - bool doSort = shouldSort(); if (text2search[0] == '\0') { @@ -669,8 +698,11 @@ void FunctionListPanel::searchFuncAndSwitchView() ::InvalidateRect(_hSearchEdit, NULL, TRUE); } - if (doSort) + // restore selected sorting + if (shouldSort()) _pTreeView->sort(_pTreeView->getRoot(), true); + else + _pTreeView->customSorting(_pTreeView->getRoot(), categorySortFunc, 0, true); } static WNDPROC oldFunclstToolbarProc = NULL; @@ -788,6 +820,8 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP case WM_INITDIALOG : { + FunctionListPanel::initPreferencesMenu(); + NppParameters& nppParams = NppParameters::getInstance(); int editWidth = nppParams._dpiManager.scaleX(100); @@ -809,9 +843,9 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP ::SendMessage(_hToolbarMenu, TB_SETBITMAPSIZE, 0, MAKELPARAM(iconSizeDyn, iconSizeDyn)); TBADDBITMAP addbmp = { 0, 0 }; - const int nbIcons = 2; - int iconIDs[nbIcons] = { IDI_FUNCLIST_SORTBUTTON, IDI_FUNCLIST_RELOADBUTTON }; - int iconDarkModeIDs[nbIcons] = { IDI_FUNCLIST_SORTBUTTON_DM, IDI_FUNCLIST_RELOADBUTTON_DM }; + const int nbIcons = 3; + int iconIDs[nbIcons] = { IDI_FUNCLIST_SORTBUTTON, IDI_FUNCLIST_RELOADBUTTON, IDI_FUNCLIST_PREFERENCEBUTTON }; + int iconDarkModeIDs[nbIcons] = { IDI_FUNCLIST_SORTBUTTON_DM, IDI_FUNCLIST_RELOADBUTTON_DM, IDI_FUNCLIST_PREFERENCEBUTTON_DM }; for (size_t i = 0; i < nbIcons; ++i) { int icoID = NppDarkMode::isEnabled() ? iconDarkModeIDs[i] : iconIDs[i]; @@ -841,6 +875,12 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP tbButtons[2].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; tbButtons[2].iString = reinterpret_cast(TEXT("")); + tbButtons[3].idCommand = IDC_PREFERENCEBUTTON_FUNCLIST; + tbButtons[3].iBitmap = 2; + tbButtons[3].fsState = TBSTATE_ENABLED; + tbButtons[3].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; + tbButtons[3].iString = reinterpret_cast(TEXT("")); + ::SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); ::SendMessage(_hToolbarMenu, TB_SETBUTTONSIZE, 0, MAKELONG(nppParams._dpiManager.scaleX(16), nppParams._dpiManager.scaleY(16))); ::SendMessage(_hToolbarMenu, TB_ADDBUTTONS, sizeof(tbButtons) / sizeof(TBBUTTON), reinterpret_cast(&tbButtons)); @@ -852,6 +892,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP NativeLangSpeaker *pNativeSpeaker = nppParams.getNativeLangSpeaker(); _sortTipStr = pNativeSpeaker->getAttrNameStr(_sortTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_SORTLOCALNODENAME); _reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME); + _preferenceTipStr = pNativeSpeaker->getAttrNameStr(_preferenceTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_PREFERENCESLOCALNODENAME); _hSearchEdit = CreateWindowEx(0, L"Edit", NULL, WS_CHILD | WS_BORDER | WS_VISIBLE | ES_AUTOVSCROLL, @@ -892,6 +933,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP case WM_DESTROY: _treeView.destroy(); _treeViewSearchResult.destroy(); + ::DestroyMenu(_hPreferencesMenu); ::DestroyWindow(_hToolbarMenu); break; @@ -930,6 +972,20 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP reload(); } return TRUE; + + case IDC_PREFERENCEBUTTON_FUNCLIST: + { + showPreferencesMenu(); + } + return TRUE; + + case FL_PREFERENCES_INITIALSORT_ID: + { + bool& shouldSortFunctionList = NppParameters::getInstance().getNppGUI()._shouldSortFunctionList; + shouldSortFunctionList = !shouldSortFunctionList; + ::CheckMenuItem(_hPreferencesMenu, FL_PREFERENCES_INITIALSORT_ID, MF_BYCOMMAND | (shouldSortFunctionList ? MF_CHECKED : MF_UNCHECKED)); + } + return TRUE; } } break; diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h index 550bcb028..ee5c3be6b 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h @@ -24,6 +24,12 @@ #define FL_PANELTITLE TEXT("Function List") #define FL_FUCTIONLISTROOTNODE "FunctionList" +#define FL_SORTLOCALNODENAME "SortTip" +#define FL_RELOADLOCALNODENAME "ReloadTip" +#define FL_PREFERENCESLOCALNODENAME "PreferencesTip" + +#define FL_PREFERENCE_INITIALSORT "PreferencesInitialSort" + class ScintillaEditView; /* @@ -98,6 +104,7 @@ public: protected: virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + HMENU _hPreferencesMenu = NULL; private: HWND _hToolbarMenu = nullptr; @@ -114,6 +121,7 @@ private: generic_string _sortTipStr = TEXT("Sort"); generic_string _reloadTipStr = TEXT("Reload"); + generic_string _preferenceTipStr = TEXT("Preferences"); std::vector _foundFuncInfos; @@ -134,5 +142,7 @@ private: bool shouldSort(); void setSort(bool isEnabled); void findMarkEntry(HTREEITEM htItem, LONG line); + void initPreferencesMenu(); + void showPreferencesMenu(); }; diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel_rc.h b/PowerEditor/src/WinControls/FunctionList/functionListPanel_rc.h index a6125aa7b..8d01f310b 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel_rc.h +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel_rc.h @@ -23,4 +23,5 @@ #define IDC_SEARCHFIELD_FUNCLIST (IDD_FUNCLIST_PANEL + 3) #define IDC_RELOADBUTTON_FUNCLIST (IDD_FUNCLIST_PANEL + 4) #define IDC_SORTBUTTON_FUNCLIST (IDD_FUNCLIST_PANEL + 5) +#define IDC_PREFERENCEBUTTON_FUNCLIST (IDD_FUNCLIST_PANEL + 6) diff --git a/PowerEditor/src/icons/darkMode/panels/funclstPreferences.bmp b/PowerEditor/src/icons/darkMode/panels/funclstPreferences.bmp new file mode 100644 index 000000000..405c756fd Binary files /dev/null and b/PowerEditor/src/icons/darkMode/panels/funclstPreferences.bmp differ diff --git a/PowerEditor/src/icons/funclstPreferences.bmp b/PowerEditor/src/icons/funclstPreferences.bmp new file mode 100644 index 000000000..f0e7103db Binary files /dev/null and b/PowerEditor/src/icons/funclstPreferences.bmp differ diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 660e1fc91..0488b86bd 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -280,10 +280,12 @@ #define IDI_FUNCLIST_NODE 621 #define IDI_FUNCLIST_LEAF 622 -#define IDI_FUNCLIST_SORTBUTTON 631 -#define IDI_FUNCLIST_RELOADBUTTON 632 -#define IDI_FUNCLIST_SORTBUTTON_DM 633 -#define IDI_FUNCLIST_RELOADBUTTON_DM 634 +#define IDI_FUNCLIST_SORTBUTTON 631 +#define IDI_FUNCLIST_RELOADBUTTON 632 +#define IDI_FUNCLIST_PREFERENCEBUTTON 633 +#define IDI_FUNCLIST_SORTBUTTON_DM 634 +#define IDI_FUNCLIST_RELOADBUTTON_DM 635 +#define IDI_FUNCLIST_PREFERENCEBUTTON_DM 636