[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
|
// returned value : TRUE if tab bar is hidden, otherwise FALSE
|
||||||
|
|
||||||
#define NPPM_GETPOSFROMBUFFERID (NPPMSG + 57)
|
#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
|
// 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)
|
// VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
|
||||||
// Here's the values for the view :
|
// 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
|
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);
|
_pFileSwitcherPanel->closeItem((int)idToClose, whichOne);
|
||||||
} else {
|
} else {
|
||||||
tabToOpen->addBuffer(id);
|
tabToOpen->addBuffer(id);
|
||||||
}
|
}
|
||||||
@ -4219,7 +4219,7 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
|
|||||||
|
|
||||||
if (_pFileSwitcherPanel)
|
if (_pFileSwitcherPanel)
|
||||||
{
|
{
|
||||||
_pFileSwitcherPanel->activateItem((int)bufid);
|
_pFileSwitcherPanel->activateItem((int)bufid, currentView());
|
||||||
}
|
}
|
||||||
|
|
||||||
_linkTriggered = true;
|
_linkTriggered = true;
|
||||||
|
@ -1277,6 +1277,23 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (lParam == SUB_VIEW)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if ((i = _mainDocTab.getIndexByBuffer((BufferID)wParam)) != -1)
|
if ((i = _mainDocTab.getIndexByBuffer((BufferID)wParam)) != -1)
|
||||||
{
|
{
|
||||||
long view = MAIN_VIEW;
|
long view = MAIN_VIEW;
|
||||||
@ -1289,6 +1306,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
view <<= 30;
|
view <<= 30;
|
||||||
return view|i;
|
return view|i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi
|
|||||||
scnN.nmhdr.code = NPPN_FILEOPENED;
|
scnN.nmhdr.code = NPPN_FILEOPENED;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
if (_pFileSwitcherPanel)
|
if (_pFileSwitcherPanel)
|
||||||
_pFileSwitcherPanel->newItem((int)buf);
|
_pFileSwitcherPanel->newItem((int)buf, currentView());
|
||||||
}
|
}
|
||||||
else
|
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 the same buffer ID is not found then remove the entry from File Switcher Pannel
|
||||||
if (_pFileSwitcherPanel)
|
if (_pFileSwitcherPanel)
|
||||||
{
|
{
|
||||||
if (::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0) == -1)
|
//int posInfo = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0);
|
||||||
_pFileSwitcherPanel->closeItem((int)id);
|
|
||||||
|
_pFileSwitcherPanel->closeItem((int)id, whichOne);
|
||||||
|
|
||||||
if (hiddenBufferID != -1)
|
if (hiddenBufferID != -1)
|
||||||
_pFileSwitcherPanel->closeItem((int)hiddenBufferID);
|
_pFileSwitcherPanel->closeItem((int)hiddenBufferID, whichOne);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -56,6 +56,7 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||||||
int i = lpnmitem->iItem;
|
int i = lpnmitem->iItem;
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
activateDoc(i);
|
activateDoc(i);
|
||||||
|
|
||||||
// Redirect NM_RCLICK message to Notepad_plus handle
|
// 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
|
void VerticalFileSwitcher::activateDoc(int i) const
|
||||||
{
|
{
|
||||||
int bufferID = _fileListView.getBufferIDFromIndex(i);
|
int view = MAIN_VIEW;
|
||||||
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, bufferID, 0);
|
int bufferID = _fileListView.getBufferInfoFromIndex(i, view);
|
||||||
|
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, bufferID, view);
|
||||||
int view2set = docPosInfo >> 30;
|
int view2set = docPosInfo >> 30;
|
||||||
int index2Switch = (docPosInfo << 2) >> 2 ;
|
int index2Switch = (docPosInfo << 2) >> 2 ;
|
||||||
|
|
||||||
|
@ -48,16 +48,16 @@ public:
|
|||||||
//Activate document in scintilla by using the internal index
|
//Activate document in scintilla by using the internal index
|
||||||
void activateDoc(int i) const;
|
void activateDoc(int i) const;
|
||||||
|
|
||||||
int newItem(int bufferID){
|
int newItem(int bufferID, int iView){
|
||||||
return _fileListView.newItem(bufferID);
|
return _fileListView.newItem(bufferID, iView);
|
||||||
};
|
};
|
||||||
|
|
||||||
int closeItem(int bufferID){
|
int closeItem(int bufferID, int iView){
|
||||||
return _fileListView.closeItem(bufferID);
|
return _fileListView.closeItem(bufferID, iView);
|
||||||
};
|
};
|
||||||
|
|
||||||
void activateItem(int bufferID) {
|
void activateItem(int bufferID, int iView) {
|
||||||
_fileListView.activateItem(bufferID);
|
_fileListView.activateItem(bufferID, iView);
|
||||||
};
|
};
|
||||||
|
|
||||||
void setItemIconStatus(int bufferID) {
|
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()))
|
if (index < 0 || index >= int(_taskListInfo._tlfsLst.size()))
|
||||||
return -1;
|
return -1;
|
||||||
|
view = _taskListInfo._tlfsLst[index]._iView;
|
||||||
return int(_taskListInfo._tlfsLst[index]._bufID);
|
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)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
i = add(bufferID);
|
i = add(bufferID, iView);
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
|
void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
|
||||||
{
|
{
|
||||||
int i = find(bufferID);
|
int i = find(bufferID, MAIN_VIEW);
|
||||||
if (i != -1)
|
if (i != -1)
|
||||||
{
|
{
|
||||||
Buffer *buf = (Buffer *)bufferID;
|
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)
|
if (i != -1)
|
||||||
remove(i);
|
remove(i);
|
||||||
return 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)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
newItem(bufferID);
|
newItem(bufferID, 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 VerticalFileSwitcherListView::add(int bufferID, int iView)
|
||||||
{
|
{
|
||||||
int index = int(_taskListInfo._tlfsLst.size());
|
int index = int(_taskListInfo._tlfsLst.size());
|
||||||
const TCHAR *fn = ((Buffer *)bufferID)->getFileName();
|
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;
|
LVITEM item;
|
||||||
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
item.mask = LVIF_TEXT | LVIF_IMAGE;
|
||||||
@ -180,13 +181,14 @@ void VerticalFileSwitcherListView::remove(int index)
|
|||||||
ListView_DeleteItem(_hSelf, index);
|
ListView_DeleteItem(_hSelf, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerticalFileSwitcherListView::find(int bufferID) const
|
int VerticalFileSwitcherListView::find(int bufferID, int iView) const
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (; i < _taskListInfo._tlfsLst.size() ; i++)
|
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;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -30,13 +30,13 @@ 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 getBufferIDFromIndex(int index) const;
|
int 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 newItem(int bufferID, int iView);
|
||||||
int closeItem(int bufferID);
|
int closeItem(int bufferID, int iView);
|
||||||
void activateItem(int bufferID);
|
void activateItem(int bufferID, int iView);
|
||||||
void setItemIconStatus(int bufferID);
|
void setItemIconStatus(int bufferID);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -49,8 +49,8 @@ protected:
|
|||||||
return (((VerticalFileSwitcherListView *)(::GetWindowLongPtr(hwnd, GWL_USERDATA)))->runProc(hwnd, Message, wParam, lParam));
|
return (((VerticalFileSwitcherListView *)(::GetWindowLongPtr(hwnd, GWL_USERDATA)))->runProc(hwnd, Message, wParam, lParam));
|
||||||
};
|
};
|
||||||
|
|
||||||
int find(int bufferID) const;
|
int find(int bufferID, int iView) const;
|
||||||
int add(int bufferID);
|
int add(int bufferID, int iView);
|
||||||
void remove(int index);
|
void remove(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user