x64 issue, replace int for bufferid by bufferid itself, otherwise x64 crashes as bufferid aka buffer * differs from int under x64
This commit is contained in:
parent
581c7b2a72
commit
edfa987f4e
@ -228,13 +228,13 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
|||||||
// allocate fullFilePath with the return values + 1, then call it again to get full path file name
|
// allocate fullFilePath with the return values + 1, then call it again to get full path file name
|
||||||
|
|
||||||
#define NPPM_GETBUFFERIDFROMPOS (NPPMSG + 59)
|
#define NPPM_GETBUFFERIDFROMPOS (NPPMSG + 59)
|
||||||
// INT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView)
|
// LRESULT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView)
|
||||||
// wParam: Position of document
|
// wParam: Position of document
|
||||||
// lParam: View to use, 0 = Main, 1 = Secondary
|
// lParam: View to use, 0 = Main, 1 = Secondary
|
||||||
// Returns 0 if invalid
|
// Returns 0 if invalid
|
||||||
|
|
||||||
#define NPPM_GETCURRENTBUFFERID (NPPMSG + 60)
|
#define NPPM_GETCURRENTBUFFERID (NPPMSG + 60)
|
||||||
// INT NPPM_GETCURRENTBUFFERID(0, 0)
|
// LRESULT NPPM_GETCURRENTBUFFERID(0, 0)
|
||||||
// Returns active Buffer
|
// Returns active Buffer
|
||||||
|
|
||||||
#define NPPM_RELOADBUFFERID (NPPMSG + 61)
|
#define NPPM_RELOADBUFFERID (NPPMSG + 61)
|
||||||
|
@ -3197,7 +3197,7 @@ void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose)
|
|||||||
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 (_pFileSwitcherPanel)
|
||||||
_pFileSwitcherPanel->closeItem((int)idToClose, whichOne);
|
_pFileSwitcherPanel->closeItem(idToClose, whichOne);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -4730,7 +4730,7 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_pFileSwitcherPanel)
|
if (_pFileSwitcherPanel)
|
||||||
_pFileSwitcherPanel->setItemIconStatus((int)buffer);
|
_pFileSwitcherPanel->setItemIconStatus(buffer);
|
||||||
|
|
||||||
if (!mainActive && !subActive)
|
if (!mainActive && !subActive)
|
||||||
{
|
{
|
||||||
@ -4830,7 +4830,7 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
|
|||||||
|
|
||||||
if (_pFileSwitcherPanel)
|
if (_pFileSwitcherPanel)
|
||||||
{
|
{
|
||||||
_pFileSwitcherPanel->activateItem((int)bufid, currentView());
|
_pFileSwitcherPanel->activateItem(bufid, currentView());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible())
|
if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible())
|
||||||
|
@ -101,7 +101,7 @@ void Notepad_plus::command(int id)
|
|||||||
if (id == IDM_FILESWITCHER_FILESCLOSEOTHERS)
|
if (id == IDM_FILESWITCHER_FILESCLOSEOTHERS)
|
||||||
{
|
{
|
||||||
// Get current buffer and its view
|
// Get current buffer and its view
|
||||||
_pFileSwitcherPanel->activateItem(int(_pEditView->getCurrentBufferID()), currentView());
|
_pFileSwitcherPanel->activateItem(_pEditView->getCurrentBufferID(), currentView());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -244,7 +244,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isRecursive, bool isRe
|
|||||||
scnN.nmhdr.code = NPPN_FILEOPENED;
|
scnN.nmhdr.code = NPPN_FILEOPENED;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
if (_pFileSwitcherPanel)
|
if (_pFileSwitcherPanel)
|
||||||
_pFileSwitcherPanel->newItem((int)buf, currentView());
|
_pFileSwitcherPanel->newItem(buf, currentView());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -449,14 +449,14 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
|
|||||||
|
|
||||||
//Do all the works
|
//Do all the works
|
||||||
bool isBufRemoved = removeBufferFromView(id, whichOne);
|
bool isBufRemoved = removeBufferFromView(id, whichOne);
|
||||||
int hiddenBufferID = -1;
|
BufferID hiddenBufferID = BUFFER_INVALID;
|
||||||
if (nrDocs == 1 && canHideView(whichOne))
|
if (nrDocs == 1 && canHideView(whichOne))
|
||||||
{ //close the view if both visible
|
{ //close the view if both visible
|
||||||
hideView(whichOne);
|
hideView(whichOne);
|
||||||
|
|
||||||
// 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 = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETBUFFERIDFROMPOS, 0, whichOne);
|
hiddenBufferID = reinterpret_cast<BufferID>(::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETBUFFERIDFROMPOS, 0, whichOne));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify plugins that current file is closed
|
// Notify plugins that current file is closed
|
||||||
@ -466,15 +466,15 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
|
|||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
|
||||||
// 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 Pannel
|
// if the same buffer ID is not found then remove the entry from File Switcher Panel
|
||||||
if (_pFileSwitcherPanel)
|
if (_pFileSwitcherPanel)
|
||||||
{
|
{
|
||||||
//int posInfo = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0);
|
//int posInfo = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0);
|
||||||
|
|
||||||
_pFileSwitcherPanel->closeItem((int)id, whichOne);
|
_pFileSwitcherPanel->closeItem(id, whichOne);
|
||||||
|
|
||||||
if (hiddenBufferID != -1)
|
if (hiddenBufferID != BUFFER_INVALID)
|
||||||
_pFileSwitcherPanel->closeItem((int)hiddenBufferID, whichOne);
|
_pFileSwitcherPanel->closeItem(hiddenBufferID, whichOne);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command(IDM_VIEW_REFRESHTABAR);
|
command(IDM_VIEW_REFRESHTABAR);
|
||||||
|
@ -205,15 +205,15 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||||||
void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const
|
void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const
|
||||||
{
|
{
|
||||||
int view = tlfs->_iView;
|
int view = tlfs->_iView;
|
||||||
int bufferID = (int)tlfs->_bufID;
|
BufferID bufferID = static_cast<BufferID>(tlfs->_bufID);
|
||||||
|
|
||||||
int currentView = ::SendMessage(_hParent, NPPM_GETCURRENTVIEW, 0, 0);
|
int currentView = ::SendMessage(_hParent, NPPM_GETCURRENTVIEW, 0, 0);
|
||||||
int currentBufID = ::SendMessage(_hParent, NPPM_GETCURRENTBUFFERID, 0, 0);
|
BufferID currentBufID = reinterpret_cast<BufferID>(::SendMessage(_hParent, NPPM_GETCURRENTBUFFERID, 0, 0));
|
||||||
|
|
||||||
if (bufferID == currentBufID && view == currentView)
|
if (bufferID == currentBufID && view == currentView)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, bufferID, view);
|
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, (WPARAM)bufferID, view);
|
||||||
int view2set = docPosInfo >> 30;
|
int view2set = docPosInfo >> 30;
|
||||||
int index2Switch = (docPosInfo << 2) >> 2 ;
|
int index2Switch = (docPosInfo << 2) >> 2 ;
|
||||||
|
|
||||||
|
@ -55,19 +55,19 @@ 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;
|
||||||
|
|
||||||
int newItem(int bufferID, int iView){
|
int newItem(BufferID bufferID, int iView){
|
||||||
return _fileListView.newItem(bufferID, iView);
|
return _fileListView.newItem(bufferID, iView);
|
||||||
};
|
};
|
||||||
|
|
||||||
int closeItem(int bufferID, int iView){
|
int closeItem(BufferID bufferID, int iView){
|
||||||
return _fileListView.closeItem(bufferID, iView);
|
return _fileListView.closeItem(bufferID, iView);
|
||||||
};
|
};
|
||||||
|
|
||||||
void activateItem(int bufferID, int iView) {
|
void activateItem(BufferID bufferID, int iView) {
|
||||||
_fileListView.activateItem(bufferID, iView);
|
_fileListView.activateItem(bufferID, iView);
|
||||||
};
|
};
|
||||||
|
|
||||||
void setItemIconStatus(int bufferID) {
|
void setItemIconStatus(BufferID bufferID) {
|
||||||
_fileListView.setItemIconStatus(bufferID) ;
|
_fileListView.setItemIconStatus(bufferID) ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -157,11 +157,11 @@ void VerticalFileSwitcherListView::reload()
|
|||||||
initList();
|
initList();
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view) const
|
BufferID VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view) const
|
||||||
{
|
{
|
||||||
int nbItem = ListView_GetItemCount(_hSelf);
|
int nbItem = ListView_GetItemCount(_hSelf);
|
||||||
if (index < 0 || index >= nbItem)
|
if (index < 0 || index >= nbItem)
|
||||||
return -1;
|
return BUFFER_INVALID;
|
||||||
|
|
||||||
LVITEM item;
|
LVITEM item;
|
||||||
item.mask = LVIF_PARAM;
|
item.mask = LVIF_PARAM;
|
||||||
@ -170,10 +170,10 @@ int VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view)
|
|||||||
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
||||||
|
|
||||||
view = tlfs->_iView;
|
view = tlfs->_iView;
|
||||||
return int(tlfs->_bufID);
|
return static_cast<BufferID>(tlfs->_bufID);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerticalFileSwitcherListView::newItem(int bufferID, int iView)
|
int VerticalFileSwitcherListView::newItem(BufferID bufferID, int iView)
|
||||||
{
|
{
|
||||||
int i = find(bufferID, iView);
|
int i = find(bufferID, iView);
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
@ -183,7 +183,7 @@ int VerticalFileSwitcherListView::newItem(int bufferID, int iView)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
|
void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID)
|
||||||
{
|
{
|
||||||
Buffer *buf = (Buffer *)bufferID;
|
Buffer *buf = (Buffer *)bufferID;
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
|
|||||||
item.iItem = i;
|
item.iItem = i;
|
||||||
ListView_GetItem(_hSelf, &item);
|
ListView_GetItem(_hSelf, &item);
|
||||||
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)(item.lParam);
|
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)(item.lParam);
|
||||||
if (int(tlfs->_bufID) == bufferID)
|
if (tlfs->_bufID == bufferID)
|
||||||
{
|
{
|
||||||
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
||||||
ListView_SetItem(_hSelf, &item);
|
ListView_SetItem(_hSelf, &item);
|
||||||
@ -236,7 +236,7 @@ generic_string VerticalFileSwitcherListView::getFullFilePath(size_t i) const
|
|||||||
return tlfs->_fn;
|
return tlfs->_fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerticalFileSwitcherListView::closeItem(int bufferID, int iView)
|
int VerticalFileSwitcherListView::closeItem(BufferID bufferID, int iView)
|
||||||
{
|
{
|
||||||
int i = find(bufferID, iView);
|
int i = find(bufferID, iView);
|
||||||
if (i != -1)
|
if (i != -1)
|
||||||
@ -244,7 +244,7 @@ int VerticalFileSwitcherListView::closeItem(int bufferID, int iView)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerticalFileSwitcherListView::activateItem(int bufferID, int iView)
|
void VerticalFileSwitcherListView::activateItem(BufferID bufferID, int iView)
|
||||||
{
|
{
|
||||||
// Clean all selection
|
// Clean all selection
|
||||||
int nbItem = ListView_GetItemCount(_hSelf);
|
int nbItem = ListView_GetItemCount(_hSelf);
|
||||||
@ -255,7 +255,7 @@ void VerticalFileSwitcherListView::activateItem(int bufferID, int iView)
|
|||||||
ListView_SetItemState(_hSelf, i, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
ListView_SetItemState(_hSelf, i, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerticalFileSwitcherListView::add(int bufferID, int iView)
|
int VerticalFileSwitcherListView::add(BufferID bufferID, int iView)
|
||||||
{
|
{
|
||||||
int index = ListView_GetItemCount(_hSelf);
|
int index = ListView_GetItemCount(_hSelf);
|
||||||
Buffer *buf = (Buffer *)bufferID;
|
Buffer *buf = (Buffer *)bufferID;
|
||||||
@ -311,7 +311,7 @@ void VerticalFileSwitcherListView::removeAll()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerticalFileSwitcherListView::find(int bufferID, int iView) const
|
int VerticalFileSwitcherListView::find(BufferID bufferID, int iView) const
|
||||||
{
|
{
|
||||||
LVITEM item;
|
LVITEM item;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -323,7 +323,7 @@ int VerticalFileSwitcherListView::find(int bufferID, int iView) const
|
|||||||
item.iItem = i;
|
item.iItem = i;
|
||||||
ListView_GetItem(_hSelf, &item);
|
ListView_GetItem(_hSelf, &item);
|
||||||
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
||||||
if (int(tlfs->_bufID) == bufferID && tlfs->_iView == iView)
|
if (tlfs->_bufID == bufferID && tlfs->_iView == iView)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@ -374,7 +374,7 @@ std::vector<SwitcherFileInfo> VerticalFileSwitcherListView::getSelectedFiles(boo
|
|||||||
ListView_GetItem(_hSelf, &item);
|
ListView_GetItem(_hSelf, &item);
|
||||||
|
|
||||||
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
|
||||||
files.push_back(SwitcherFileInfo(int(tlfs->_bufID), tlfs->_iView));
|
files.push_back(SwitcherFileInfo(static_cast<BufferID>(tlfs->_bufID), tlfs->_iView));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,13 +32,16 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "TaskListDlg.h"
|
#include "TaskListDlg.h"
|
||||||
|
|
||||||
|
class Buffer;
|
||||||
|
typedef Buffer * BufferID; //each buffer has unique ID by which it can be retrieved
|
||||||
|
|
||||||
#define SORT_DIRECTION_UP 0
|
#define SORT_DIRECTION_UP 0
|
||||||
#define SORT_DIRECTION_DOWN 1
|
#define SORT_DIRECTION_DOWN 1
|
||||||
|
|
||||||
struct SwitcherFileInfo {
|
struct SwitcherFileInfo {
|
||||||
int _bufID;
|
BufferID _bufID;
|
||||||
int _iView;
|
int _iView;
|
||||||
SwitcherFileInfo(int buf, int view): _bufID(buf), _iView(view){};
|
SwitcherFileInfo(BufferID buf, int view) : _bufID(buf), _iView(view){};
|
||||||
};
|
};
|
||||||
|
|
||||||
class VerticalFileSwitcherListView : public Window
|
class VerticalFileSwitcherListView : public Window
|
||||||
@ -50,14 +53,14 @@ public:
|
|||||||
virtual void init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst);
|
virtual void init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst);
|
||||||
virtual void destroy();
|
virtual void destroy();
|
||||||
void initList();
|
void initList();
|
||||||
int getBufferInfoFromIndex(int index, int & view) const;
|
BufferID getBufferInfoFromIndex(int index, int & view) const;
|
||||||
void setBgColour(int i) {
|
void setBgColour(int i) {
|
||||||
ListView_SetItemState(_hSelf, i, LVIS_SELECTED|LVIS_FOCUSED, 0xFF);
|
ListView_SetItemState(_hSelf, i, LVIS_SELECTED|LVIS_FOCUSED, 0xFF);
|
||||||
}
|
}
|
||||||
int newItem(int bufferID, int iView);
|
int newItem(BufferID bufferID, int iView);
|
||||||
int closeItem(int bufferID, int iView);
|
int closeItem(BufferID bufferID, int iView);
|
||||||
void activateItem(int bufferID, int iView);
|
void activateItem(BufferID bufferID, int iView);
|
||||||
void setItemIconStatus(int bufferID);
|
void setItemIconStatus(BufferID bufferID);
|
||||||
generic_string getFullFilePath(size_t i) const;
|
generic_string getFullFilePath(size_t i) const;
|
||||||
|
|
||||||
void insertColumn(const TCHAR *name, int width, int index);
|
void insertColumn(const TCHAR *name, int width, int index);
|
||||||
@ -92,8 +95,8 @@ protected:
|
|||||||
return (((VerticalFileSwitcherListView *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)))->runProc(hwnd, Message, wParam, lParam));
|
return (((VerticalFileSwitcherListView *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)))->runProc(hwnd, Message, wParam, lParam));
|
||||||
};
|
};
|
||||||
|
|
||||||
int find(int bufferID, int iView) const;
|
int find(BufferID bufferID, int iView) const;
|
||||||
int add(int bufferID, int iView);
|
int add(BufferID bufferID, int iView);
|
||||||
void remove(int index);
|
void remove(int index);
|
||||||
void removeAll();
|
void removeAll();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user