Add "Sort By" commands under Window Menu
Add commands by name, path, type and by size for sorting under Window Menu. Fix #10393, close #11190
This commit is contained in:
parent
726ad7f580
commit
1c8b867395
|
@ -73,6 +73,7 @@ The comments are here for explanation, it's not necessary to translate them.
|
||||||
<Item subMenuId="settings-import" name="Import"/>
|
<Item subMenuId="settings-import" name="Import"/>
|
||||||
<Item subMenuId="tools-md5" name="MD5"/>
|
<Item subMenuId="tools-md5" name="MD5"/>
|
||||||
<Item subMenuId="tools-sha256" name="SHA-256"/>
|
<Item subMenuId="tools-sha256" name="SHA-256"/>
|
||||||
|
<Item subMenuId="window-sortby" name="Sort By"/>
|
||||||
</SubEntries>
|
</SubEntries>
|
||||||
|
|
||||||
<!-- all menu item -->
|
<!-- all menu item -->
|
||||||
|
@ -362,6 +363,15 @@ The comments are here for explanation, it's not necessary to translate them.
|
||||||
<Item id="42041" name="Empty Recent Files List"/>
|
<Item id="42041" name="Empty Recent Files List"/>
|
||||||
<Item id="48016" name="Modify Shortcut/Delete Macro..."/>
|
<Item id="48016" name="Modify Shortcut/Delete Macro..."/>
|
||||||
<Item id="48017" name="Modify Shortcut/Delete Command..."/>
|
<Item id="48017" name="Modify Shortcut/Delete Command..."/>
|
||||||
|
|
||||||
|
<Item id="11002" name="Name A to Z"/>
|
||||||
|
<Item id="11003" name="Name Z to A"/>
|
||||||
|
<Item id="11004" name="Path A to Z"/>
|
||||||
|
<Item id="11005" name="Path Z to A"/>
|
||||||
|
<Item id="11006" name="Type A to Z"/>
|
||||||
|
<Item id="11007" name="Type Z to A"/>
|
||||||
|
<Item id="11008" name="Size Smaller to Larger"/>
|
||||||
|
<Item id="11009" name="Size Larger to Smaller"/>
|
||||||
</Commands>
|
</Commands>
|
||||||
</Main>
|
</Main>
|
||||||
<Splitter>
|
<Splitter>
|
||||||
|
@ -635,6 +645,14 @@ The comments are here for explanation, it's not necessary to translate them.
|
||||||
<Item id="44107" name="Switch to Folder as Workspace"/>
|
<Item id="44107" name="Switch to Folder as Workspace"/>
|
||||||
<Item id="44109" name="Switch to Document List"/>
|
<Item id="44109" name="Switch to Document List"/>
|
||||||
<Item id="44108" name="Switch to Function List"/>
|
<Item id="44108" name="Switch to Function List"/>
|
||||||
|
<Item id="11002" name="Sort By Name A to Z"/>
|
||||||
|
<Item id="11003" name="Sort By Name Z to A"/>
|
||||||
|
<Item id="11004" name="Sort By Path A to Z"/>
|
||||||
|
<Item id="11005" name="Sort By Path Z to A"/>
|
||||||
|
<Item id="11006" name="Sort By Type A to Z"/>
|
||||||
|
<Item id="11007" name="Sort By Type Z to A"/>
|
||||||
|
<Item id="11008" name="Sort By Size Smaller to Larger"/>
|
||||||
|
<Item id="11009" name="Sort By Size Larger to Smaller"/>
|
||||||
</MainCommandNames>
|
</MainCommandNames>
|
||||||
</ShortcutMapper>
|
</ShortcutMapper>
|
||||||
<ShortcutMapperSubDialg title="Shortcut">
|
<ShortcutMapperSubDialg title="Shortcut">
|
||||||
|
|
|
@ -3555,6 +3555,77 @@ void Notepad_plus::command(int id)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDM_WINDOW_SORT_FN_ASC :
|
||||||
|
{
|
||||||
|
WindowsDlg windowsDlg;
|
||||||
|
windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
|
||||||
|
windowsDlg.sortFileNameASC();
|
||||||
|
windowsDlg.doSort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_WINDOW_SORT_FN_DSC :
|
||||||
|
{
|
||||||
|
WindowsDlg windowsDlg;
|
||||||
|
windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
|
||||||
|
windowsDlg.sortFileNameDSC();
|
||||||
|
windowsDlg.doSort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_WINDOW_SORT_FP_ASC :
|
||||||
|
{
|
||||||
|
WindowsDlg windowsDlg;
|
||||||
|
windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
|
||||||
|
windowsDlg.sortFilePathASC();
|
||||||
|
windowsDlg.doSort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_WINDOW_SORT_FP_DSC :
|
||||||
|
{
|
||||||
|
WindowsDlg windowsDlg;
|
||||||
|
windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
|
||||||
|
windowsDlg.sortFilePathDSC();
|
||||||
|
windowsDlg.doSort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_WINDOW_SORT_FT_ASC :
|
||||||
|
{
|
||||||
|
WindowsDlg windowsDlg;
|
||||||
|
windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
|
||||||
|
windowsDlg.sortFileTypeASC();
|
||||||
|
windowsDlg.doSort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_WINDOW_SORT_FT_DSC :
|
||||||
|
{
|
||||||
|
WindowsDlg windowsDlg;
|
||||||
|
windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
|
||||||
|
windowsDlg.sortFileTypeDSC();
|
||||||
|
windowsDlg.doSort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_WINDOW_SORT_FS_ASC :
|
||||||
|
{
|
||||||
|
WindowsDlg windowsDlg;
|
||||||
|
windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
|
||||||
|
windowsDlg.sortFileSizeASC();
|
||||||
|
windowsDlg.doSort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_WINDOW_SORT_FS_DSC :
|
||||||
|
{
|
||||||
|
WindowsDlg windowsDlg;
|
||||||
|
windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
|
||||||
|
windowsDlg.sortFileSizeDSC();
|
||||||
|
windowsDlg.doSort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case IDM_SYSTRAYPOPUP_NEWDOC:
|
case IDM_SYSTRAYPOPUP_NEWDOC:
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
#include "localization.h"
|
#include "localization.h"
|
||||||
#include "localizationString.h"
|
#include "localizationString.h"
|
||||||
#include "UserDefineDialog.h"
|
#include "UserDefineDialog.h"
|
||||||
|
#include "WindowsDlgRc.h"
|
||||||
|
|
||||||
#pragma warning(disable : 4996) // for GetVersionEx()
|
#pragma warning(disable : 4996) // for GetVersionEx()
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
namespace // anonymous namespace
|
namespace // anonymous namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -405,6 +405,15 @@ static const WinMenuKeyDefinition winKeyDefs[] =
|
||||||
|
|
||||||
{ VK_F5, IDM_EXECUTE, false, false, false, nullptr },
|
{ VK_F5, IDM_EXECUTE, false, false, false, nullptr },
|
||||||
|
|
||||||
|
{ VK_NULL, IDM_WINDOW_SORT_FN_ASC, false, false, false, nullptr },
|
||||||
|
{ VK_NULL, IDM_WINDOW_SORT_FN_DSC, false, false, false, nullptr },
|
||||||
|
{ VK_NULL, IDM_WINDOW_SORT_FP_ASC, false, false, false, nullptr },
|
||||||
|
{ VK_NULL, IDM_WINDOW_SORT_FP_DSC, false, false, false, nullptr },
|
||||||
|
{ VK_NULL, IDM_WINDOW_SORT_FT_ASC, false, false, false, nullptr },
|
||||||
|
{ VK_NULL, IDM_WINDOW_SORT_FT_DSC, false, false, false, nullptr },
|
||||||
|
{ VK_NULL, IDM_WINDOW_SORT_FS_ASC, false, false, false, nullptr },
|
||||||
|
{ VK_NULL, IDM_WINDOW_SORT_FS_DSC, false, false, false, nullptr },
|
||||||
|
|
||||||
{ VK_NULL, IDM_CMDLINEARGUMENTS, false, false, false, nullptr },
|
{ VK_NULL, IDM_CMDLINEARGUMENTS, false, false, false, nullptr },
|
||||||
{ VK_NULL, IDM_HOMESWEETHOME, false, false, false, nullptr },
|
{ VK_NULL, IDM_HOMESWEETHOME, false, false, false, nullptr },
|
||||||
{ VK_NULL, IDM_PROJECTPAGE, false, false, false, nullptr },
|
{ VK_NULL, IDM_PROJECTPAGE, false, false, false, nullptr },
|
||||||
|
|
|
@ -946,6 +946,110 @@ void WindowsDlg::doCount()
|
||||||
SetWindowText(_hSelf,msg.c_str());
|
SetWindowText(_hSelf,msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::doSort()
|
||||||
|
{
|
||||||
|
size_t count = (_pTab != NULL) ? _pTab->nbItem() : 0;
|
||||||
|
std::vector<UINT> items(count);
|
||||||
|
auto currrentTabIndex = _pTab->getCurrentTabIndex();
|
||||||
|
NMWINDLG nmdlg = {};
|
||||||
|
nmdlg.type = WDT_SORT;
|
||||||
|
nmdlg.hwndFrom = _hSelf;
|
||||||
|
nmdlg.curSel = currrentTabIndex;
|
||||||
|
nmdlg.code = WDN_NOTIFY;
|
||||||
|
nmdlg.nItems = static_cast<UINT>(count);
|
||||||
|
nmdlg.Items = items.data();
|
||||||
|
for (size_t i=0; i < count; ++i)
|
||||||
|
{
|
||||||
|
nmdlg.Items[i] = _idxMap[i];
|
||||||
|
}
|
||||||
|
SendMessage(_hParent, WDN_NOTIFY, 0, LPARAM(&nmdlg));
|
||||||
|
if (nmdlg.processed)
|
||||||
|
{
|
||||||
|
_idxMap.clear();
|
||||||
|
refreshMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
//After sorting, need to open the active tab before sorting
|
||||||
|
//This will be helpful when large number of documents are opened
|
||||||
|
__int64 newPosition = -1;
|
||||||
|
std::vector<int>::iterator it = std::find(_idxMap.begin(), _idxMap.end(), currrentTabIndex);
|
||||||
|
if (it != _idxMap.end())
|
||||||
|
{
|
||||||
|
newPosition = it - _idxMap.begin();
|
||||||
|
}
|
||||||
|
nmdlg.type = WDT_ACTIVATE;
|
||||||
|
nmdlg.curSel = static_cast<UINT>(newPosition);
|
||||||
|
nmdlg.hwndFrom = _hSelf;
|
||||||
|
nmdlg.code = WDN_NOTIFY;
|
||||||
|
SendMessage(_hParent, WDN_NOTIFY, 0, LPARAM(&nmdlg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sort(int columnID, bool reverseSort)
|
||||||
|
{
|
||||||
|
refreshMap();
|
||||||
|
_currentColumn = columnID;
|
||||||
|
_reverseSort = reverseSort;
|
||||||
|
stable_sort(_idxMap.begin(), _idxMap.end(), BufferEquivalent(_pTab, _currentColumn, _reverseSort));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sortFileNameASC()
|
||||||
|
{
|
||||||
|
sort(0, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sortFileNameDSC()
|
||||||
|
{
|
||||||
|
sort(0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sortFilePathASC()
|
||||||
|
{
|
||||||
|
sort(1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sortFilePathDSC()
|
||||||
|
{
|
||||||
|
sort(1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sortFileTypeASC()
|
||||||
|
{
|
||||||
|
sort(2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sortFileTypeDSC()
|
||||||
|
{
|
||||||
|
sort(2, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sortFileSizeASC()
|
||||||
|
{
|
||||||
|
sort(3, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::sortFileSizeDSC()
|
||||||
|
{
|
||||||
|
sort(3, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsDlg::refreshMap()
|
||||||
|
{
|
||||||
|
size_t count = (_pTab != NULL) ? _pTab->nbItem() : 0;
|
||||||
|
size_t oldSize = _idxMap.size();
|
||||||
|
if (count == oldSize)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (count != oldSize)
|
||||||
|
{
|
||||||
|
size_t lo = 0;
|
||||||
|
_idxMap.resize(count);
|
||||||
|
if (oldSize < count)
|
||||||
|
lo = oldSize;
|
||||||
|
for (size_t i = lo; i < count; ++i)
|
||||||
|
_idxMap[i] = int(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WindowsDlg::doSortToTabs()
|
void WindowsDlg::doSortToTabs()
|
||||||
{
|
{
|
||||||
int curSel = ListView_GetNextItem(_hList, -1, LVNI_SELECTED);
|
int curSel = ListView_GetNextItem(_hList, -1, LVNI_SELECTED);
|
||||||
|
|
|
@ -55,7 +55,17 @@ public :
|
||||||
WindowsDlg();
|
WindowsDlg();
|
||||||
int doDialog();
|
int doDialog();
|
||||||
virtual void init(HINSTANCE hInst, HWND parent, DocTabView *pTab);
|
virtual void init(HINSTANCE hInst, HWND parent, DocTabView *pTab);
|
||||||
|
void doSortToTabs();
|
||||||
|
void doSort();
|
||||||
|
void sort(int columnID, bool reverseSort);
|
||||||
|
void sortFileNameASC();
|
||||||
|
void sortFileNameDSC();
|
||||||
|
void sortFilePathASC();
|
||||||
|
void sortFilePathDSC();
|
||||||
|
void sortFileTypeASC();
|
||||||
|
void sortFileTypeDSC();
|
||||||
|
void sortFileSizeASC();
|
||||||
|
void sortFileSizeDSC();
|
||||||
void doRefresh(bool invalidate = false);
|
void doRefresh(bool invalidate = false);
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
|
@ -70,11 +80,11 @@ protected :
|
||||||
void resetSelection();
|
void resetSelection();
|
||||||
void doSave();
|
void doSave();
|
||||||
void doClose();
|
void doClose();
|
||||||
void doSortToTabs();
|
|
||||||
void updateButtonState();
|
void updateButtonState();
|
||||||
void activateCurrent();
|
void activateCurrent();
|
||||||
void doColumnSort();
|
void doColumnSort();
|
||||||
void doCount();
|
void doCount();
|
||||||
|
void refreshMap();
|
||||||
void putItemsToClipboard(bool isFullPath);
|
void putItemsToClipboard(bool isFullPath);
|
||||||
Buffer* getBuffer(int index) const;
|
Buffer* getBuffer(int index) const;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,19 @@ END
|
||||||
|
|
||||||
IDR_WINDOWS_MENU MENU
|
IDR_WINDOWS_MENU MENU
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "Recent Window", IDM_WINDOW_MRU_FIRST, GRAYED
|
POPUP "Sort By"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "Name A to Z", IDM_WINDOW_SORT_FN_ASC
|
||||||
|
MENUITEM "Name Z to A", IDM_WINDOW_SORT_FN_DSC
|
||||||
|
MENUITEM "Path A to Z", IDM_WINDOW_SORT_FP_ASC
|
||||||
|
MENUITEM "Path Z to A", IDM_WINDOW_SORT_FP_DSC
|
||||||
|
MENUITEM "Type A to Z", IDM_WINDOW_SORT_FT_ASC
|
||||||
|
MENUITEM "Type Z to A", IDM_WINDOW_SORT_FT_DSC
|
||||||
|
MENUITEM "Size Smaller to Larger", IDM_WINDOW_SORT_FS_ASC
|
||||||
|
MENUITEM "Size Larger to Smaller", IDM_WINDOW_SORT_FS_DSC
|
||||||
|
END
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Recent Window", IDM_WINDOW_MRU_FIRST, GRAYED
|
||||||
MENUITEM "&Windows...", IDM_WINDOW_WINDOWS
|
MENUITEM "&Windows...", IDM_WINDOW_WINDOWS
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,17 @@
|
||||||
#define IDC_WINDOWS_SORT (IDD_WINDOWS + 4)
|
#define IDC_WINDOWS_SORT (IDD_WINDOWS + 4)
|
||||||
|
|
||||||
#define IDR_WINDOWS_MENU 11000
|
#define IDR_WINDOWS_MENU 11000
|
||||||
#define IDM_WINDOW_WINDOWS (IDR_WINDOWS_MENU + 1)
|
#define IDM_WINDOW_WINDOWS (IDR_WINDOWS_MENU + 1)
|
||||||
#define IDM_WINDOW_MRU_FIRST (IDR_WINDOWS_MENU + 20)
|
#define IDM_WINDOW_SORT_FN_ASC (IDR_WINDOWS_MENU + 2)
|
||||||
#define IDM_WINDOW_MRU_LIMIT (IDR_WINDOWS_MENU + 29)
|
#define IDM_WINDOW_SORT_FN_DSC (IDR_WINDOWS_MENU + 3)
|
||||||
#define IDM_WINDOW_COPY_NAME (IDM_WINDOW_MRU_LIMIT + 1)
|
#define IDM_WINDOW_SORT_FP_ASC (IDR_WINDOWS_MENU + 4)
|
||||||
#define IDM_WINDOW_COPY_PATH (IDM_WINDOW_MRU_LIMIT + 2)
|
#define IDM_WINDOW_SORT_FP_DSC (IDR_WINDOWS_MENU + 5)
|
||||||
|
#define IDM_WINDOW_SORT_FT_ASC (IDR_WINDOWS_MENU + 6)
|
||||||
|
#define IDM_WINDOW_SORT_FT_DSC (IDR_WINDOWS_MENU + 7)
|
||||||
|
#define IDM_WINDOW_SORT_FS_ASC (IDR_WINDOWS_MENU + 8)
|
||||||
|
#define IDM_WINDOW_SORT_FS_DSC (IDR_WINDOWS_MENU + 9)
|
||||||
|
#define IDM_WINDOW_MRU_FIRST (IDR_WINDOWS_MENU + 20)
|
||||||
|
#define IDM_WINDOW_MRU_LIMIT (IDR_WINDOWS_MENU + 29)
|
||||||
|
#define IDM_WINDOW_COPY_NAME (IDM_WINDOW_MRU_LIMIT + 1)
|
||||||
|
#define IDM_WINDOW_COPY_PATH (IDM_WINDOW_MRU_LIMIT + 2)
|
||||||
|
|
||||||
|
|
|
@ -1221,7 +1221,9 @@ intptr_t CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPAR
|
||||||
CommandShortcut::CommandShortcut(const Shortcut& sc, long id) : Shortcut(sc), _id(id)
|
CommandShortcut::CommandShortcut(const Shortcut& sc, long id) : Shortcut(sc), _id(id)
|
||||||
{
|
{
|
||||||
_shortcutName = sc.getName();
|
_shortcutName = sc.getName();
|
||||||
if ( _id < IDM_EDIT)
|
if ( _id >= IDM_WINDOW_SORT_FN_ASC and _id <= IDM_WINDOW_SORT_FS_DSC)
|
||||||
|
_category = TEXT("Window");
|
||||||
|
else if ( _id < IDM_EDIT)
|
||||||
_category = TEXT("File");
|
_category = TEXT("File");
|
||||||
else if ( _id < IDM_SEARCH)
|
else if ( _id < IDM_SEARCH)
|
||||||
_category = TEXT("Edit");
|
_category = TEXT("Edit");
|
||||||
|
|
|
@ -97,6 +97,8 @@ MenuPosition menuPos[] = {
|
||||||
|
|
||||||
{ 7, 0, -1, "tools-md5" },
|
{ 7, 0, -1, "tools-md5" },
|
||||||
{ 7, 1, -1, "tools-sha256" },
|
{ 7, 1, -1, "tools-sha256" },
|
||||||
|
|
||||||
|
{ 11, 0, -1, "window-sortby"},
|
||||||
{ -1, -1, -1, "" } // End of array
|
{ -1, -1, -1, "" } // End of array
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -361,6 +363,14 @@ void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & plugin
|
||||||
if (nullptr == subMenuIdStr or nullptr == name)
|
if (nullptr == subMenuIdStr or nullptr == name)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!strcmp(subMenuIdStr, "window-sortby"))
|
||||||
|
{
|
||||||
|
generic_string sortTrans;
|
||||||
|
const wchar_t *nameW = wmc.char2wchar(name, _nativeLangEncoding);
|
||||||
|
sortTrans = nameW;
|
||||||
|
::ModifyMenu(menuHandle, 0, MF_BYPOSITION, 0, sortTrans.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
MenuPosition& menuPos = getMenuPosition(subMenuIdStr);
|
MenuPosition& menuPos = getMenuPosition(subMenuIdStr);
|
||||||
int x = menuPos._x;
|
int x = menuPos._x;
|
||||||
int y = menuPos._y;
|
int y = menuPos._y;
|
||||||
|
|
Loading…
Reference in New Issue