[MODIFY] Chang file switcher behaviour while clonning a document on the other view.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@785 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
5d8355de60
commit
c508aa94ef
@ -191,8 +191,9 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
||||
// returned value : TRUE if tab bar is hidden, otherwise FALSE
|
||||
|
||||
#define NPPM_GETPOSFROMBUFFERID (NPPMSG + 57)
|
||||
// INT NPPM_GETPOSFROMBUFFERID(INT bufferID, 0)
|
||||
// INT NPPM_GETPOSFROMBUFFERID(INT bufferID, INT priorityView)
|
||||
// Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing
|
||||
// if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly
|
||||
//
|
||||
// VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
|
||||
// Here's the values for the view :
|
||||
|
@ -2657,7 +2657,7 @@ void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose)
|
||||
activateBuffer(id, whichOne); //activate. DocTab already activated but not a problem
|
||||
MainFileManager->closeBuffer(idToClose, viewToOpen); //delete the buffer
|
||||
if (_pFileSwitcherPanel)
|
||||
_pFileSwitcherPanel->closeItem((int)idToClose);
|
||||
_pFileSwitcherPanel->closeItem((int)idToClose, whichOne);
|
||||
} else {
|
||||
tabToOpen->addBuffer(id);
|
||||
}
|
||||
@ -4219,7 +4219,7 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
|
||||
|
||||
if (_pFileSwitcherPanel)
|
||||
{
|
||||
_pFileSwitcherPanel->activateItem((int)bufid);
|
||||
_pFileSwitcherPanel->activateItem((int)bufid, currentView());
|
||||
}
|
||||
|
||||
_linkTriggered = true;
|
||||
|
@ -1277,17 +1277,35 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
{
|
||||
int i;
|
||||
|
||||
if ((i = _mainDocTab.getIndexByBuffer((BufferID)wParam)) != -1)
|
||||
if (lParam == SUB_VIEW)
|
||||
{
|
||||
long view = MAIN_VIEW;
|
||||
view <<= 30;
|
||||
return view|i;
|
||||
if ((i = _subDocTab.getIndexByBuffer((BufferID)wParam)) != -1)
|
||||
{
|
||||
long view = SUB_VIEW;
|
||||
view <<= 30;
|
||||
return view|i;
|
||||
}
|
||||
if ((i = _mainDocTab.getIndexByBuffer((BufferID)wParam)) != -1)
|
||||
{
|
||||
long view = MAIN_VIEW;
|
||||
view <<= 30;
|
||||
return view|i;
|
||||
}
|
||||
}
|
||||
if ((i = _subDocTab.getIndexByBuffer((BufferID)wParam)) != -1)
|
||||
else
|
||||
{
|
||||
long view = SUB_VIEW;
|
||||
view <<= 30;
|
||||
return view|i;
|
||||
if ((i = _mainDocTab.getIndexByBuffer((BufferID)wParam)) != -1)
|
||||
{
|
||||
long view = MAIN_VIEW;
|
||||
view <<= 30;
|
||||
return view|i;
|
||||
}
|
||||
if ((i = _subDocTab.getIndexByBuffer((BufferID)wParam)) != -1)
|
||||
{
|
||||
long view = SUB_VIEW;
|
||||
view <<= 30;
|
||||
return view|i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi
|
||||
scnN.nmhdr.code = NPPN_FILEOPENED;
|
||||
_pluginsManager.notify(&scnN);
|
||||
if (_pFileSwitcherPanel)
|
||||
_pFileSwitcherPanel->newItem((int)buf);
|
||||
_pFileSwitcherPanel->newItem((int)buf, currentView());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -336,11 +336,12 @@ void Notepad_plus::doClose(BufferID id, int whichOne) {
|
||||
// if the same buffer ID is not found then remove the entry from File Switcher Pannel
|
||||
if (_pFileSwitcherPanel)
|
||||
{
|
||||
if (::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0) == -1)
|
||||
_pFileSwitcherPanel->closeItem((int)id);
|
||||
//int posInfo = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0);
|
||||
|
||||
_pFileSwitcherPanel->closeItem((int)id, whichOne);
|
||||
|
||||
if (hiddenBufferID != -1)
|
||||
_pFileSwitcherPanel->closeItem((int)hiddenBufferID);
|
||||
_pFileSwitcherPanel->closeItem((int)hiddenBufferID, whichOne);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -56,6 +56,7 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||
int i = lpnmitem->iItem;
|
||||
if (i == -1)
|
||||
return TRUE;
|
||||
|
||||
activateDoc(i);
|
||||
|
||||
// Redirect NM_RCLICK message to Notepad_plus handle
|
||||
@ -109,8 +110,9 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||
|
||||
void VerticalFileSwitcher::activateDoc(int i) const
|
||||
{
|
||||
int bufferID = _fileListView.getBufferIDFromIndex(i);
|
||||
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, bufferID, 0);
|
||||
int view = MAIN_VIEW;
|
||||
int bufferID = _fileListView.getBufferInfoFromIndex(i, view);
|
||||
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, bufferID, view);
|
||||
int view2set = docPosInfo >> 30;
|
||||
int index2Switch = (docPosInfo << 2) >> 2 ;
|
||||
|
||||
|
@ -48,16 +48,16 @@ public:
|
||||
//Activate document in scintilla by using the internal index
|
||||
void activateDoc(int i) const;
|
||||
|
||||
int newItem(int bufferID){
|
||||
return _fileListView.newItem(bufferID);
|
||||
int newItem(int bufferID, int iView){
|
||||
return _fileListView.newItem(bufferID, iView);
|
||||
};
|
||||
|
||||
int closeItem(int bufferID){
|
||||
return _fileListView.closeItem(bufferID);
|
||||
int closeItem(int bufferID, int iView){
|
||||
return _fileListView.closeItem(bufferID, iView);
|
||||
};
|
||||
|
||||
void activateItem(int bufferID) {
|
||||
_fileListView.activateItem(bufferID);
|
||||
void activateItem(int bufferID, int iView) {
|
||||
_fileListView.activateItem(bufferID, iView);
|
||||
};
|
||||
|
||||
void setItemIconStatus(int bufferID) {
|
||||
|
@ -103,24 +103,25 @@ void VerticalFileSwitcherListView::initList()
|
||||
}
|
||||
}
|
||||
|
||||
int VerticalFileSwitcherListView::getBufferIDFromIndex(int index) const {
|
||||
int VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view) const {
|
||||
if (index < 0 || index >= int(_taskListInfo._tlfsLst.size()))
|
||||
return -1;
|
||||
view = _taskListInfo._tlfsLst[index]._iView;
|
||||
return int(_taskListInfo._tlfsLst[index]._bufID);
|
||||
}
|
||||
|
||||
int VerticalFileSwitcherListView::newItem(int bufferID)
|
||||
int VerticalFileSwitcherListView::newItem(int bufferID, int iView)
|
||||
{
|
||||
int i = find(bufferID);
|
||||
int i = find(bufferID, iView);
|
||||
if (i == -1)
|
||||
{
|
||||
i = add(bufferID);
|
||||
i = add(bufferID, iView);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
|
||||
{
|
||||
int i = find(bufferID);
|
||||
int i = find(bufferID, MAIN_VIEW);
|
||||
if (i != -1)
|
||||
{
|
||||
Buffer *buf = (Buffer *)bufferID;
|
||||
@ -136,30 +137,30 @@ void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
|
||||
}
|
||||
}
|
||||
|
||||
int VerticalFileSwitcherListView::closeItem(int bufferID)
|
||||
int VerticalFileSwitcherListView::closeItem(int bufferID, int iView)
|
||||
{
|
||||
int i = find(bufferID);
|
||||
int i = find(bufferID, iView);
|
||||
if (i != -1)
|
||||
remove(i);
|
||||
return i;
|
||||
}
|
||||
|
||||
void VerticalFileSwitcherListView::activateItem(int bufferID)
|
||||
void VerticalFileSwitcherListView::activateItem(int bufferID, int iView)
|
||||
{
|
||||
int i = find(bufferID);
|
||||
int i = find(bufferID, iView);
|
||||
if (i == -1)
|
||||
{
|
||||
newItem(bufferID);
|
||||
newItem(bufferID, iView);
|
||||
}
|
||||
ListView_SetItemState(_hSelf, i, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
||||
}
|
||||
|
||||
int VerticalFileSwitcherListView::add(int bufferID)
|
||||
int VerticalFileSwitcherListView::add(int bufferID, int iView)
|
||||
{
|
||||
int index = int(_taskListInfo._tlfsLst.size());
|
||||
const TCHAR *fn = ((Buffer *)bufferID)->getFileName();
|
||||
|
||||
_taskListInfo._tlfsLst.push_back(TaskLstFnStatus(0, 0, fn, 0, (void *)bufferID));
|
||||
_taskListInfo._tlfsLst.push_back(TaskLstFnStatus(iView, 0, fn, 0, (void *)bufferID));
|
||||
|
||||
LVITEM item;
|
||||
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
||||
@ -180,13 +181,14 @@ void VerticalFileSwitcherListView::remove(int index)
|
||||
ListView_DeleteItem(_hSelf, index);
|
||||
}
|
||||
|
||||
int VerticalFileSwitcherListView::find(int bufferID) const
|
||||
int VerticalFileSwitcherListView::find(int bufferID, int iView) const
|
||||
{
|
||||
bool found = false;
|
||||
size_t i = 0;
|
||||
for (; i < _taskListInfo._tlfsLst.size() ; i++)
|
||||
{
|
||||
if (_taskListInfo._tlfsLst[i]._bufID == (void *)bufferID)
|
||||
if (_taskListInfo._tlfsLst[i]._bufID == (void *)bufferID &&
|
||||
_taskListInfo._tlfsLst[i]._iView == iView)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
@ -30,13 +30,13 @@ public:
|
||||
virtual void init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst);
|
||||
virtual void destroy();
|
||||
void initList();
|
||||
int getBufferIDFromIndex(int index) const;
|
||||
int getBufferInfoFromIndex(int index, int & view) const;
|
||||
void setBgColour(int i) {
|
||||
ListView_SetItemState(_hSelf, i, LVIS_SELECTED|LVIS_FOCUSED, 0xFF);
|
||||
}
|
||||
int newItem(int bufferID);
|
||||
int closeItem(int bufferID);
|
||||
void activateItem(int bufferID);
|
||||
int newItem(int bufferID, int iView);
|
||||
int closeItem(int bufferID, int iView);
|
||||
void activateItem(int bufferID, int iView);
|
||||
void setItemIconStatus(int bufferID);
|
||||
|
||||
protected:
|
||||
@ -49,8 +49,8 @@ protected:
|
||||
return (((VerticalFileSwitcherListView *)(::GetWindowLongPtr(hwnd, GWL_USERDATA)))->runProc(hwnd, Message, wParam, lParam));
|
||||
};
|
||||
|
||||
int find(int bufferID) const;
|
||||
int add(int bufferID);
|
||||
int find(int bufferID, int iView) const;
|
||||
int add(int bufferID, int iView);
|
||||
void remove(int index);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user