diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 5b486b631..246920312 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1317,6 +1317,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } + case NPPM_INTERNAL_CLOSEDOC: + { + // Close a document without switching to it + int whichView = ((wParam != MAIN_VIEW) && (wParam != SUB_VIEW)) ? currentView() : static_cast(wParam); + int index = static_cast(lParam); + + // Gotta switch to correct view to get the correct buffer ID + switchEditViewTo(whichView); + + // Close the document + fileClose(_pDocTab->getBufferByIndex(index), whichView); + + return TRUE; + } + // ADD_ZERO_PADDING == TRUE // // version | HIWORD | LOWORD diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp index 81d8681f0..166c4ebba 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp @@ -89,6 +89,41 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, return TRUE; } + case WM_PARENTNOTIFY: + { + switch ( wParam ) + { + case WM_MBUTTONDOWN: + { + // Get item ID under cursor + LVHITTESTINFO hitInfo{}; + hitInfo.pt.x = GET_X_LPARAM(lParam); + hitInfo.pt.y = GET_Y_LPARAM(lParam); + + ::ClientToScreen(getHSelf(), &hitInfo.pt); + ::ScreenToClient(_fileListView.getHSelf(), &hitInfo.pt); + ListView_HitTest(_fileListView.getHSelf(), &hitInfo); + + if (hitInfo.iItem != -1) + { + // Get the actual item info from the ID + LVITEM item{}; + item.mask = LVIF_PARAM; + item.iItem = hitInfo.iItem; + ListView_GetItem(_fileListView.getHSelf(), &item); + TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; + + // Close the document + closeDoc(tlfs); + + return TRUE; + } + } + } + + break; + } + case WM_NOTIFY: { switch (reinterpret_cast(lParam)->code) @@ -351,11 +386,23 @@ void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const int docPosInfo = static_cast(::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, reinterpret_cast(bufferID), view)); int view2set = docPosInfo >> 30; - int index2Switch = (docPosInfo << 2) >> 2 ; + int index2Switch = (docPosInfo << 2) >> 2; ::SendMessage(_hParent, NPPM_ACTIVATEDOC, view2set, index2Switch); } +void VerticalFileSwitcher::closeDoc(TaskLstFnStatus *tlfs) const +{ + int view = tlfs->_iView; + BufferID bufferID = static_cast(tlfs->_bufID); + + int docPosInfo = static_cast(::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, reinterpret_cast(bufferID), view)); + int view2set = docPosInfo >> 30; + int index2Switch = (docPosInfo << 2) >> 2; + + ::SendMessage(_hParent, NPPM_INTERNAL_CLOSEDOC, view2set, index2Switch); +} + int VerticalFileSwitcher::setHeaderOrder(int columnIndex) { HWND hListView = _fileListView.getHSelf(); diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h index 8f432795d..ce898bace 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h @@ -47,6 +47,8 @@ public: //Activate document in scintilla by using the internal index void activateDoc(TaskLstFnStatus *tlfs) const; + void closeDoc(TaskLstFnStatus *tlfs) const; + int newItem(BufferID bufferID, int iView){ return _fileListView.newItem(bufferID, iView); }; diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 709aea64c..b04fd9489 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -648,6 +648,7 @@ #define NPPM_INTERNAL_SETNPC (NOTEPADPLUS_USER_INTERNAL + 72) #define NPPM_INTERNAL_NPCFORMCHANGED (NOTEPADPLUS_USER_INTERNAL + 73) #define NPPM_INTERNAL_NPCLAUNCHSTYLECONF (NOTEPADPLUS_USER_INTERNAL + 74) + #define NPPM_INTERNAL_CLOSEDOC (NOTEPADPLUS_USER_INTERNAL + 75) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000)