Add "Switch to Document List" command for shortcut

Fix #9015
This commit is contained in:
Don Ho 2021-07-26 19:07:38 +02:00
parent 7c4a428e47
commit 7c82c523b6
8 changed files with 79 additions and 61 deletions

View File

@ -181,7 +181,7 @@ Notepad_plus::~Notepad_plus()
delete _pTrayIco; delete _pTrayIco;
delete _pAnsiCharPanel; delete _pAnsiCharPanel;
delete _pClipboardHistoryPanel; delete _pClipboardHistoryPanel;
delete _pFileSwitcherPanel; delete _pDocumentListPanel;
delete _pProjectPanel_1; delete _pProjectPanel_1;
delete _pProjectPanel_2; delete _pProjectPanel_2;
delete _pProjectPanel_3; delete _pProjectPanel_3;
@ -4025,8 +4025,8 @@ void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose)
tabToOpen->setBuffer(0, id); //index 0 since only one open tabToOpen->setBuffer(0, id); //index 0 since only one open
activateBuffer(id, whichOne); //activate. DocTab already activated but not a problem activateBuffer(id, whichOne); //activate. DocTab already activated but not a problem
MainFileManager.closeBuffer(idToClose, viewToOpen); //delete the buffer MainFileManager.closeBuffer(idToClose, viewToOpen); //delete the buffer
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
_pFileSwitcherPanel->closeItem(idToClose, whichOne); _pDocumentListPanel->closeItem(idToClose, whichOne);
} }
else else
{ {
@ -5907,8 +5907,8 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
} }
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
_pFileSwitcherPanel->setItemIconStatus(buffer); _pDocumentListPanel->setItemIconStatus(buffer);
if (!mainActive && !subActive) if (!mainActive && !subActive)
{ {
@ -6006,9 +6006,9 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
scnN.nmhdr.idFrom = (uptr_t)bufid; scnN.nmhdr.idFrom = (uptr_t)bufid;
_pluginsManager.notify(&scnN); _pluginsManager.notify(&scnN);
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
{ {
_pFileSwitcherPanel->activateItem(bufid, currentView()); _pDocumentListPanel->activateItem(bufid, currentView());
} }
if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible()) if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible())
@ -6540,19 +6540,19 @@ void Notepad_plus::launchClipboardHistoryPanel()
} }
void Notepad_plus::launchFileSwitcherPanel() void Notepad_plus::launchDocumentListPanel()
{ {
if (!_pFileSwitcherPanel) if (!_pDocumentListPanel)
{ {
_pFileSwitcherPanel = new VerticalFileSwitcher; _pDocumentListPanel = new VerticalFileSwitcher;
HIMAGELIST hImgLst = _docTabIconList.getHandle(); HIMAGELIST hImgLst = _docTabIconList.getHandle();
_pFileSwitcherPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst); _pDocumentListPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst);
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
bool isRTL = pNativeSpeaker->isRTL(); bool isRTL = pNativeSpeaker->isRTL();
tTbData data = {0}; tTbData data = {0};
_pFileSwitcherPanel->create(&data, isRTL); _pDocumentListPanel->create(&data, isRTL);
::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast<LPARAM>(_pFileSwitcherPanel->getHSelf())); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast<LPARAM>(_pDocumentListPanel->getHSelf()));
// define the default docking behaviour // define the default docking behaviour
data.uMask = DWS_DF_CONT_LEFT | DWS_ICONTAB; data.uMask = DWS_DF_CONT_LEFT | DWS_ICONTAB;
data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDR_DOCLIST_ICO), IMAGE_ICON, 14, 14, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT); data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDR_DOCLIST_ICO), IMAGE_ICON, 14, 14, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
@ -6575,10 +6575,10 @@ void Notepad_plus::launchFileSwitcherPanel()
COLORREF fgColor = (NppParameters::getInstance()).getCurrentDefaultFgColor(); COLORREF fgColor = (NppParameters::getInstance()).getCurrentDefaultFgColor();
COLORREF bgColor = (NppParameters::getInstance()).getCurrentDefaultBgColor(); COLORREF bgColor = (NppParameters::getInstance()).getCurrentDefaultBgColor();
_pFileSwitcherPanel->setBackgroundColor(bgColor); _pDocumentListPanel->setBackgroundColor(bgColor);
_pFileSwitcherPanel->setForegroundColor(fgColor); _pDocumentListPanel->setForegroundColor(fgColor);
} }
_pFileSwitcherPanel->display(); _pDocumentListPanel->display();
} }
@ -7555,9 +7555,9 @@ void Notepad_plus::refreshDarkMode()
{ {
::SendMessage(_pAnsiCharPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); ::SendMessage(_pAnsiCharPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
} }
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
{ {
::SendMessage(_pFileSwitcherPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); ::SendMessage(_pDocumentListPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
} }
if (_pClipboardHistoryPanel) if (_pClipboardHistoryPanel)

View File

@ -402,7 +402,7 @@ private:
AnsiCharPanel* _pAnsiCharPanel = nullptr; AnsiCharPanel* _pAnsiCharPanel = nullptr;
ClipboardHistoryPanel* _pClipboardHistoryPanel = nullptr; ClipboardHistoryPanel* _pClipboardHistoryPanel = nullptr;
VerticalFileSwitcher* _pFileSwitcherPanel = nullptr; VerticalFileSwitcher* _pDocumentListPanel = nullptr;
ProjectPanel* _pProjectPanel_1 = nullptr; ProjectPanel* _pProjectPanel_1 = nullptr;
ProjectPanel* _pProjectPanel_2 = nullptr; ProjectPanel* _pProjectPanel_2 = nullptr;
ProjectPanel* _pProjectPanel_3 = nullptr; ProjectPanel* _pProjectPanel_3 = nullptr;
@ -608,7 +608,7 @@ private:
void removeDuplicateLines(); void removeDuplicateLines();
void launchAnsiCharPanel(); void launchAnsiCharPanel();
void launchClipboardHistoryPanel(); void launchClipboardHistoryPanel();
void launchFileSwitcherPanel(); void launchDocumentListPanel();
void checkProjectMenuItem(); void checkProjectMenuItem();
void launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID); void launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID);
void launchDocMap(); void launchDocMap();

View File

@ -548,9 +548,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_INTERNAL_DOCORDERCHANGED : case NPPM_INTERNAL_DOCORDERCHANGED :
{ {
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
{ {
_pFileSwitcherPanel->updateTabOrder(); _pDocumentListPanel->updateTabOrder();
} }
BufferID id = _pEditView->getCurrentBufferID(); BufferID id = _pEditView->getCurrentBufferID();
@ -1811,10 +1811,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
_pAnsiCharPanel->setForegroundColor(style._fgColor); _pAnsiCharPanel->setForegroundColor(style._fgColor);
} }
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
{ {
_pFileSwitcherPanel->setBackgroundColor(style._bgColor); _pDocumentListPanel->setBackgroundColor(style._bgColor);
_pFileSwitcherPanel->setForegroundColor(style._fgColor); _pDocumentListPanel->setForegroundColor(style._fgColor);
} }
if (_pClipboardHistoryPanel) if (_pClipboardHistoryPanel)
@ -2444,9 +2444,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
NppGUI & nppGUI = nppParam.getNppGUI(); NppGUI & nppGUI = nppParam.getNppGUI();
nppGUI._fileSwitcherWithoutExtColumn = isOff == TRUE; nppGUI._fileSwitcherWithoutExtColumn = isOff == TRUE;
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
{ {
_pFileSwitcherPanel->reload(); _pDocumentListPanel->reload();
} }
// else nothing to do // else nothing to do
return TRUE; return TRUE;
@ -2465,22 +2465,22 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
BOOL toShow = static_cast<BOOL>(lParam); BOOL toShow = static_cast<BOOL>(lParam);
if (toShow) if (toShow)
{ {
if (!_pFileSwitcherPanel || !_pFileSwitcherPanel->isVisible()) if (!_pDocumentListPanel || !_pDocumentListPanel->isVisible())
launchFileSwitcherPanel(); launchDocumentListPanel();
} }
else else
{ {
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
_pFileSwitcherPanel->display(false); _pDocumentListPanel->display(false);
} }
return TRUE; return TRUE;
} }
case NPPM_ISDOCLISTSHOWN: case NPPM_ISDOCLISTSHOWN:
{ {
if (!_pFileSwitcherPanel) if (!_pDocumentListPanel)
return FALSE; return FALSE;
return _pFileSwitcherPanel->isVisible(); return _pDocumentListPanel->isVisible();
} }
// OLD BEHAVIOUR: // OLD BEHAVIOUR:

View File

@ -171,19 +171,19 @@ void Notepad_plus::command(int id)
fileReload(); fileReload();
break; break;
case IDM_FILESWITCHER_FILESCLOSE: case IDM_DOCLIST_FILESCLOSE:
case IDM_FILESWITCHER_FILESCLOSEOTHERS: case IDM_DOCLIST_FILESCLOSEOTHERS:
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
{ {
vector<SwitcherFileInfo> files = _pFileSwitcherPanel->getSelectedFiles(id == IDM_FILESWITCHER_FILESCLOSEOTHERS); vector<SwitcherFileInfo> files = _pDocumentListPanel->getSelectedFiles(id == IDM_DOCLIST_FILESCLOSEOTHERS);
for (size_t i = 0, len = files.size(); i < len; ++i) for (size_t i = 0, len = files.size(); i < len; ++i)
{ {
fileClose((BufferID)files[i]._bufID, files[i]._iView); fileClose((BufferID)files[i]._bufID, files[i]._iView);
} }
if (id == IDM_FILESWITCHER_FILESCLOSEOTHERS) if (id == IDM_DOCLIST_FILESCLOSEOTHERS)
{ {
// Get current buffer and its view // Get current buffer and its view
_pFileSwitcherPanel->activateItem(_pEditView->getCurrentBufferID(), currentView()); _pDocumentListPanel->activateItem(_pEditView->getCurrentBufferID(), currentView());
} }
} }
break; break;
@ -737,23 +737,39 @@ void Notepad_plus::command(int id)
} }
break; break;
case IDM_VIEW_SWITCHTO_DOCLIST:
{
if (_pDocumentListPanel && _pDocumentListPanel->isVisible())
{
_pDocumentListPanel->getFocus();
}
else
{
checkMenuItem(IDM_VIEW_DOCLIST, true);
_toolBar.setCheck(IDM_VIEW_DOCLIST, true);
launchDocumentListPanel();
_pDocumentListPanel->setClosed(false);
}
}
break;
case IDM_VIEW_DOCLIST: case IDM_VIEW_DOCLIST:
{ {
if (_pFileSwitcherPanel && (!_pFileSwitcherPanel->isClosed())) if (_pDocumentListPanel && (!_pDocumentListPanel->isClosed()))
{ {
_pFileSwitcherPanel->display(false); _pDocumentListPanel->display(false);
_pFileSwitcherPanel->setClosed(true); _pDocumentListPanel->setClosed(true);
checkMenuItem(IDM_VIEW_DOCLIST, false); checkMenuItem(IDM_VIEW_DOCLIST, false);
_toolBar.setCheck(IDM_VIEW_DOCLIST, false); _toolBar.setCheck(IDM_VIEW_DOCLIST, false);
} }
else else
{ {
launchFileSwitcherPanel(); launchDocumentListPanel();
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
{ {
checkMenuItem(IDM_VIEW_DOCLIST, true); checkMenuItem(IDM_VIEW_DOCLIST, true);
_toolBar.setCheck(IDM_VIEW_DOCLIST, true); _toolBar.setCheck(IDM_VIEW_DOCLIST, true);
_pFileSwitcherPanel->setClosed(false); _pDocumentListPanel->setClosed(false);
} }
} }
} }
@ -876,7 +892,7 @@ void Notepad_plus::command(int id)
} }
} }
break; break;
case IDM_VIEW_FUNC_LIST: case IDM_VIEW_FUNC_LIST:
{ {
if (_pFuncList && (!_pFuncList->isClosed())) if (_pFuncList && (!_pFuncList->isClosed()))

View File

@ -392,8 +392,8 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
// Notify plugins that current file is just opened // Notify plugins that current file is just opened
scnN.nmhdr.code = NPPN_FILEOPENED; scnN.nmhdr.code = NPPN_FILEOPENED;
_pluginsManager.notify(&scnN); _pluginsManager.notify(&scnN);
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
_pFileSwitcherPanel->newItem(buf, currentView()); _pDocumentListPanel->newItem(buf, currentView());
} }
else else
{ {
@ -728,8 +728,8 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
// if the current activated buffer is in this view, // if the current activated buffer is in this view,
// then get buffer ID to remove the entry from File Switcher Pannel // then get buffer ID to remove the entry from File Switcher Pannel
hiddenBufferID = reinterpret_cast<BufferID>(::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETBUFFERIDFROMPOS, 0, whichOne)); hiddenBufferID = reinterpret_cast<BufferID>(::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETBUFFERIDFROMPOS, 0, whichOne));
if (!isBufRemoved && hiddenBufferID != BUFFER_INVALID && _pFileSwitcherPanel) if (!isBufRemoved && hiddenBufferID != BUFFER_INVALID && _pDocumentListPanel)
_pFileSwitcherPanel->closeItem(hiddenBufferID, whichOne); _pDocumentListPanel->closeItem(hiddenBufferID, whichOne);
} }
// Notify plugins that current file is closed // Notify plugins that current file is closed
@ -740,12 +740,12 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
// The document could be clonned. // The document could be clonned.
// if the same buffer ID is not found then remove the entry from File Switcher Panel // if the same buffer ID is not found then remove the entry from File Switcher Panel
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
{ {
_pFileSwitcherPanel->closeItem(id, whichOne); _pDocumentListPanel->closeItem(id, whichOne);
if (hiddenBufferID != BUFFER_INVALID) if (hiddenBufferID != BUFFER_INVALID)
_pFileSwitcherPanel->closeItem(hiddenBufferID, whichOne); _pDocumentListPanel->closeItem(hiddenBufferID, whichOne);
} }
// Add to recent file only if file is removed and does not exist in any of the views // Add to recent file only if file is removed and does not exist in any of the views
@ -2223,8 +2223,8 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou
else if (canHideView(currentView())) else if (canHideView(currentView()))
hideView(currentView()); hideView(currentView());
if (_pFileSwitcherPanel) if (_pDocumentListPanel)
_pFileSwitcherPanel->reload(); _pDocumentListPanel->reload();
if (shouldLoadFileBrowser && !session._fileBrowserRoots.empty()) if (shouldLoadFileBrowser && !session._fileBrowserRoots.empty())
{ {

View File

@ -479,17 +479,17 @@ BOOL Notepad_plus::notify(SCNotification *notification)
} }
return TRUE; return TRUE;
} }
else if (_pFileSwitcherPanel && notification->nmhdr.hwndFrom == _pFileSwitcherPanel->getHSelf()) else if (_pDocumentListPanel && notification->nmhdr.hwndFrom == _pDocumentListPanel->getHSelf())
{ {
// Already switched, so do nothing here. // Already switched, so do nothing here.
if (_pFileSwitcherPanel->nbSelectedFiles() > 1) if (_pDocumentListPanel->nbSelectedFiles() > 1)
{ {
if (!_fileSwitcherMultiFilePopupMenu.isCreated()) if (!_fileSwitcherMultiFilePopupMenu.isCreated())
{ {
vector<MenuItemUnit> itemUnitArray; vector<MenuItemUnit> itemUnitArray;
itemUnitArray.push_back(MenuItemUnit(IDM_FILESWITCHER_FILESCLOSE, TEXT("Close Selected files"))); itemUnitArray.push_back(MenuItemUnit(IDM_DOCLIST_FILESCLOSE, TEXT("Close Selected files")));
itemUnitArray.push_back(MenuItemUnit(IDM_FILESWITCHER_FILESCLOSEOTHERS, TEXT("Close others files"))); itemUnitArray.push_back(MenuItemUnit(IDM_DOCLIST_FILESCLOSEOTHERS, TEXT("Close others files")));
_fileSwitcherMultiFilePopupMenu.create(_pPublicInterface->getHSelf(), itemUnitArray); _fileSwitcherMultiFilePopupMenu.create(_pPublicInterface->getHSelf(), itemUnitArray);
_nativeLangSpeaker.changeLangTabContextMenu(_fileSwitcherMultiFilePopupMenu.getMenuHandle()); _nativeLangSpeaker.changeLangTabContextMenu(_fileSwitcherMultiFilePopupMenu.getMenuHandle());

View File

@ -312,6 +312,7 @@ static const WinMenuKeyDefinition winKeyDefs[] =
{ VK_NULL, IDM_VIEW_SWITCHTO_PROJECT_PANEL_3, false, false, false, TEXT("Switch to Project Panel 3") }, { VK_NULL, IDM_VIEW_SWITCHTO_PROJECT_PANEL_3, false, false, false, TEXT("Switch to Project Panel 3") },
{ VK_NULL, IDM_VIEW_SWITCHTO_FILEBROWSER, false, false, false, TEXT("Switch to Folder as Workspace") }, { VK_NULL, IDM_VIEW_SWITCHTO_FILEBROWSER, false, false, false, TEXT("Switch to Folder as Workspace") },
{ VK_NULL, IDM_VIEW_SWITCHTO_FUNC_LIST, false, false, false, TEXT("Switch to Function List") }, { VK_NULL, IDM_VIEW_SWITCHTO_FUNC_LIST, false, false, false, TEXT("Switch to Function List") },
{ VK_NULL, IDM_VIEW_SWITCHTO_DOCLIST, false, false, false, TEXT("Switch to Document List") },
{ VK_NULL, IDM_VIEW_SYNSCROLLV, false, false, false, nullptr }, { VK_NULL, IDM_VIEW_SYNSCROLLV, false, false, false, nullptr },
{ VK_NULL, IDM_VIEW_SYNSCROLLH, false, false, false, nullptr }, { VK_NULL, IDM_VIEW_SYNSCROLLH, false, false, false, nullptr },
{ VK_R, IDM_EDIT_RTL, true, true, false, nullptr }, { VK_R, IDM_EDIT_RTL, true, true, false, nullptr },

View File

@ -244,8 +244,8 @@
#define IDM_SEARCH_MARKONEEXT5 (IDM_SEARCH + 66) #define IDM_SEARCH_MARKONEEXT5 (IDM_SEARCH + 66)
#define IDM_MISC (IDM + 3500) #define IDM_MISC (IDM + 3500)
#define IDM_FILESWITCHER_FILESCLOSE (IDM_MISC + 1) #define IDM_DOCLIST_FILESCLOSE (IDM_MISC + 1)
#define IDM_FILESWITCHER_FILESCLOSEOTHERS (IDM_MISC + 2) #define IDM_DOCLIST_FILESCLOSEOTHERS (IDM_MISC + 2)
#define IDM_VIEW (IDM + 4000) #define IDM_VIEW (IDM + 4000)
@ -356,6 +356,7 @@
#define IDM_VIEW_SWITCHTO_PROJECT_PANEL_3 (IDM_VIEW + 106) #define IDM_VIEW_SWITCHTO_PROJECT_PANEL_3 (IDM_VIEW + 106)
#define IDM_VIEW_SWITCHTO_FILEBROWSER (IDM_VIEW + 107) #define IDM_VIEW_SWITCHTO_FILEBROWSER (IDM_VIEW + 107)
#define IDM_VIEW_SWITCHTO_FUNC_LIST (IDM_VIEW + 108) #define IDM_VIEW_SWITCHTO_FUNC_LIST (IDM_VIEW + 108)
#define IDM_VIEW_SWITCHTO_DOCLIST (IDM_VIEW + 109)
#define IDM_VIEW_GOTO_ANOTHER_VIEW 10001 #define IDM_VIEW_GOTO_ANOTHER_VIEW 10001
#define IDM_VIEW_CLONE_TO_ANOTHER_VIEW 10002 #define IDM_VIEW_CLONE_TO_ANOTHER_VIEW 10002