mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-20 12:24:49 +02:00
Add middle mouse click ability to close doc in Document List
Documents are closed on middle mouse click down. Fix #12949, close #13015
This commit is contained in:
parent
0d9b16634d
commit
94b83158dc
@ -1317,6 +1317,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case NPPM_INTERNAL_CLOSEDOC:
|
||||||
|
{
|
||||||
|
// Close a document without switching to it
|
||||||
|
int whichView = ((wParam != MAIN_VIEW) && (wParam != SUB_VIEW)) ? currentView() : static_cast<int32_t>(wParam);
|
||||||
|
int index = static_cast<int32_t>(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
|
// ADD_ZERO_PADDING == TRUE
|
||||||
//
|
//
|
||||||
// version | HIWORD | LOWORD
|
// version | HIWORD | LOWORD
|
||||||
|
@ -89,6 +89,41 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
|
|||||||
return TRUE;
|
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:
|
case WM_NOTIFY:
|
||||||
{
|
{
|
||||||
switch (reinterpret_cast<LPNMHDR>(lParam)->code)
|
switch (reinterpret_cast<LPNMHDR>(lParam)->code)
|
||||||
@ -351,11 +386,23 @@ void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const
|
|||||||
|
|
||||||
int docPosInfo = static_cast<int32_t>(::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, reinterpret_cast<WPARAM>(bufferID), view));
|
int docPosInfo = static_cast<int32_t>(::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, reinterpret_cast<WPARAM>(bufferID), view));
|
||||||
int view2set = docPosInfo >> 30;
|
int view2set = docPosInfo >> 30;
|
||||||
int index2Switch = (docPosInfo << 2) >> 2 ;
|
int index2Switch = (docPosInfo << 2) >> 2;
|
||||||
|
|
||||||
::SendMessage(_hParent, NPPM_ACTIVATEDOC, view2set, index2Switch);
|
::SendMessage(_hParent, NPPM_ACTIVATEDOC, view2set, index2Switch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VerticalFileSwitcher::closeDoc(TaskLstFnStatus *tlfs) const
|
||||||
|
{
|
||||||
|
int view = tlfs->_iView;
|
||||||
|
BufferID bufferID = static_cast<BufferID>(tlfs->_bufID);
|
||||||
|
|
||||||
|
int docPosInfo = static_cast<int32_t>(::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, reinterpret_cast<WPARAM>(bufferID), view));
|
||||||
|
int view2set = docPosInfo >> 30;
|
||||||
|
int index2Switch = (docPosInfo << 2) >> 2;
|
||||||
|
|
||||||
|
::SendMessage(_hParent, NPPM_INTERNAL_CLOSEDOC, view2set, index2Switch);
|
||||||
|
}
|
||||||
|
|
||||||
int VerticalFileSwitcher::setHeaderOrder(int columnIndex)
|
int VerticalFileSwitcher::setHeaderOrder(int columnIndex)
|
||||||
{
|
{
|
||||||
HWND hListView = _fileListView.getHSelf();
|
HWND hListView = _fileListView.getHSelf();
|
||||||
|
@ -47,6 +47,8 @@ public:
|
|||||||
//Activate document in scintilla by using the internal index
|
//Activate document in scintilla by using the internal index
|
||||||
void activateDoc(TaskLstFnStatus *tlfs) const;
|
void activateDoc(TaskLstFnStatus *tlfs) const;
|
||||||
|
|
||||||
|
void closeDoc(TaskLstFnStatus *tlfs) const;
|
||||||
|
|
||||||
int newItem(BufferID bufferID, int iView){
|
int newItem(BufferID bufferID, int iView){
|
||||||
return _fileListView.newItem(bufferID, iView);
|
return _fileListView.newItem(bufferID, iView);
|
||||||
};
|
};
|
||||||
|
@ -648,6 +648,7 @@
|
|||||||
#define NPPM_INTERNAL_SETNPC (NOTEPADPLUS_USER_INTERNAL + 72)
|
#define NPPM_INTERNAL_SETNPC (NOTEPADPLUS_USER_INTERNAL + 72)
|
||||||
#define NPPM_INTERNAL_NPCFORMCHANGED (NOTEPADPLUS_USER_INTERNAL + 73)
|
#define NPPM_INTERNAL_NPCFORMCHANGED (NOTEPADPLUS_USER_INTERNAL + 73)
|
||||||
#define NPPM_INTERNAL_NPCLAUNCHSTYLECONF (NOTEPADPLUS_USER_INTERNAL + 74)
|
#define NPPM_INTERNAL_NPCLAUNCHSTYLECONF (NOTEPADPLUS_USER_INTERNAL + 74)
|
||||||
|
#define NPPM_INTERNAL_CLOSEDOC (NOTEPADPLUS_USER_INTERNAL + 75)
|
||||||
|
|
||||||
// See Notepad_plus_msgs.h
|
// See Notepad_plus_msgs.h
|
||||||
//#define NOTEPADPLUS_USER (WM_USER + 1000)
|
//#define NOTEPADPLUS_USER (WM_USER + 1000)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user