|
|
|
@ -25,14 +25,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool DocTabView::_hideTabBarStatus = false;
|
|
|
|
|
|
|
|
|
|
//向标签视图添加新的缓冲区,首先检查缓冲区是否有效(不是无效的缓冲区),然后检查是否已经存在相同的缓冲区。如果缓冲区有效且尚未存在,则将其添加到标签页视图中,并更新父窗口的大小。
|
|
|
|
|
void DocTabView::addBuffer(BufferID buffer)
|
|
|
|
|
{
|
|
|
|
|
if (buffer == BUFFER_INVALID) //valid only
|
|
|
|
|
return;
|
|
|
|
|
if (getIndexByBuffer(buffer) != -1) //no duplicates
|
|
|
|
|
return;
|
|
|
|
|
Buffer * buf = MainFileManager.getBufferByID(buffer);
|
|
|
|
|
Buffer* buf = MainFileManager.getBufferByID(buffer);
|
|
|
|
|
TCITEM tie{};
|
|
|
|
|
tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
|
|
|
|
|
|
|
|
|
@ -40,7 +40,7 @@ void DocTabView::addBuffer(BufferID buffer)
|
|
|
|
|
if (_hasImgLst)
|
|
|
|
|
index = 0;
|
|
|
|
|
tie.iImage = index;
|
|
|
|
|
tie.pszText = const_cast<TCHAR *>(buf->getFileName());
|
|
|
|
|
tie.pszText = const_cast<TCHAR*>(buf->getFileName());
|
|
|
|
|
tie.lParam = reinterpret_cast<LPARAM>(buffer);
|
|
|
|
|
::SendMessage(_hSelf, TCM_INSERTITEM, _nbItem++, reinterpret_cast<LPARAM>(&tie));
|
|
|
|
|
bufferUpdated(buf, BufferChangeMask);
|
|
|
|
@ -48,25 +48,25 @@ void DocTabView::addBuffer(BufferID buffer)
|
|
|
|
|
::SendMessage(_hParent, WM_SIZE, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//关闭指定的缓冲区,到要关闭的缓冲区的索引,然后从标签页视图中删除它,并通知父窗口进行调整。
|
|
|
|
|
void DocTabView::closeBuffer(BufferID buffer)
|
|
|
|
|
{
|
|
|
|
|
int indexToClose = getIndexByBuffer(buffer);
|
|
|
|
|
deletItemAt((size_t)indexToClose);
|
|
|
|
|
::SendMessage(_hParent, WM_SIZE, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//为特定的标签设置颜色。根据提供的缓冲区ID,设置该缓冲区在标签页中的颜色。
|
|
|
|
|
void DocTabView::setIndividualTabColour(BufferID bufferId, int colorId)
|
|
|
|
|
{
|
|
|
|
|
bufferId->setDocColorId(colorId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取特定标签的颜色,根据提供的标签索引,返回该标签的颜色。
|
|
|
|
|
int DocTabView::getIndividualTabColour(int tabIndex)
|
|
|
|
|
{
|
|
|
|
|
BufferID bufferId = getBufferByIndex(tabIndex);
|
|
|
|
|
return bufferId->getDocColorId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//激活特定的缓冲区,通过缓冲区的ID找到其索引位置并尝试激活该缓冲区,如果成功则返回true,否则返回false。
|
|
|
|
|
bool DocTabView::activateBuffer(BufferID buffer)
|
|
|
|
|
{
|
|
|
|
|
int indexToActivate = getIndexByBuffer(buffer);
|
|
|
|
@ -77,15 +77,15 @@ bool DocTabView::activateBuffer(BufferID buffer)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前激活的缓冲区。
|
|
|
|
|
BufferID DocTabView::activeBuffer()
|
|
|
|
|
{
|
|
|
|
|
int index = getCurrentTabIndex();
|
|
|
|
|
return getBufferByIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) //-1 if not found, something else otherwise
|
|
|
|
|
//遍历所有标签页,根据文件名查找匹配的缓冲区,找到则返回其ID,否则返回BUFFER_INVALID。
|
|
|
|
|
BufferID DocTabView::findBufferByName(const TCHAR* fullfilename) //-1 if not found, something else otherwise
|
|
|
|
|
{
|
|
|
|
|
TCITEM tie{};
|
|
|
|
|
tie.lParam = -1;
|
|
|
|
@ -94,7 +94,7 @@ BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) //-1 if not fo
|
|
|
|
|
{
|
|
|
|
|
::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
|
|
|
|
|
BufferID id = reinterpret_cast<BufferID>(tie.lParam);
|
|
|
|
|
Buffer * buf = MainFileManager.getBufferByID(id);
|
|
|
|
|
Buffer* buf = MainFileManager.getBufferByID(id);
|
|
|
|
|
if (OrdinalIgnoreCaseCompareStrings(fullfilename, buf->getFullPathName()) == 0)
|
|
|
|
|
{
|
|
|
|
|
return id;
|
|
|
|
@ -103,7 +103,7 @@ BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) //-1 if not fo
|
|
|
|
|
return BUFFER_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//通过缓冲区ID找到其在标签中的索引位置,如果不存在则返回 - 1。
|
|
|
|
|
int DocTabView::getIndexByBuffer(BufferID id)
|
|
|
|
|
{
|
|
|
|
|
TCITEM tie{};
|
|
|
|
@ -118,7 +118,7 @@ int DocTabView::getIndexByBuffer(BufferID id)
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//通过缓冲区ID找到其在标签中的索引位置,如果不存在则返回-1。
|
|
|
|
|
BufferID DocTabView::getBufferByIndex(size_t index)
|
|
|
|
|
{
|
|
|
|
|
TCITEM tie{};
|
|
|
|
@ -129,8 +129,8 @@ BufferID DocTabView::getBufferByIndex(size_t index)
|
|
|
|
|
return reinterpret_cast<BufferID>(tie.lParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DocTabView::bufferUpdated(Buffer * buffer, int mask)
|
|
|
|
|
//根据mask中的标志位,更新与缓冲区相关的信息,例如文件名变化、只读状态变化等。
|
|
|
|
|
void DocTabView::bufferUpdated(Buffer* buffer, int mask)
|
|
|
|
|
{
|
|
|
|
|
int index = getIndexByBuffer(buffer->getID());
|
|
|
|
|
if (index == -1)
|
|
|
|
@ -143,7 +143,7 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask)
|
|
|
|
|
if (mask & BufferChangeReadonly || mask & BufferChangeDirty)
|
|
|
|
|
{
|
|
|
|
|
tie.mask |= TCIF_IMAGE;
|
|
|
|
|
tie.iImage = buffer->isDirty()?UNSAVED_IMG_INDEX:SAVED_IMG_INDEX;
|
|
|
|
|
tie.iImage = buffer->isDirty() ? UNSAVED_IMG_INDEX : SAVED_IMG_INDEX;
|
|
|
|
|
if (buffer->isMonitoringOn())
|
|
|
|
|
{
|
|
|
|
|
tie.iImage = MONITORING_IMG_INDEX;
|
|
|
|
@ -171,15 +171,15 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask)
|
|
|
|
|
//Tab's caption must be encoded like this because otherwise tab control would make tab too small or too big for the text.
|
|
|
|
|
|
|
|
|
|
while (*in != 0)
|
|
|
|
|
if (*in == '&')
|
|
|
|
|
{
|
|
|
|
|
*out++ = '&';
|
|
|
|
|
*out++ = '&';
|
|
|
|
|
while (*(++in) == '&')
|
|
|
|
|
if (*in == '&')
|
|
|
|
|
{
|
|
|
|
|
*out++ = '&';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*out++ = *in++;
|
|
|
|
|
*out++ = '&';
|
|
|
|
|
while (*(++in) == '&')
|
|
|
|
|
*out++ = '&';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*out++ = *in++;
|
|
|
|
|
*out = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -192,7 +192,7 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask)
|
|
|
|
|
::SendMessage(_hParent, WM_SIZE, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据给定的索引设置相应的缓冲区ID,并更新标签显示的相关信息。
|
|
|
|
|
void DocTabView::setBuffer(size_t index, BufferID id)
|
|
|
|
|
{
|
|
|
|
|
if (index >= _nbItem)
|
|
|
|
@ -208,8 +208,8 @@ void DocTabView::setBuffer(size_t index, BufferID id)
|
|
|
|
|
::SendMessage(_hParent, WM_SIZE, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DocTabView::reSizeTo(RECT & rc)
|
|
|
|
|
//根据隐藏/显示标签栏状态,调整标签页视图和文本编辑器视图的大小,并根据需要发送消息以更新可点击链接。
|
|
|
|
|
void DocTabView::reSizeTo(RECT& rc)
|
|
|
|
|
{
|
|
|
|
|
int borderWidth = ((NppParameters::getInstance()).getSVP())._borderWidth;
|
|
|
|
|
if (_hideTabBarStatus)
|
|
|
|
@ -221,9 +221,9 @@ void DocTabView::reSizeTo(RECT & rc)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TabBar::reSizeTo(rc);
|
|
|
|
|
rc.left += borderWidth;
|
|
|
|
|
rc.left += borderWidth;
|
|
|
|
|
rc.right -= borderWidth * 2;
|
|
|
|
|
rc.top += borderWidth;
|
|
|
|
|
rc.top += borderWidth;
|
|
|
|
|
rc.bottom -= (borderWidth * 2);
|
|
|
|
|
_pView->reSizeTo(rc);
|
|
|
|
|
}
|
|
|
|
|