|
|
|
@ -25,7 +25,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool DocTabView::_hideTabBarStatus = false;
|
|
|
|
|
|
|
|
|
|
//向标签视图添加新的缓冲区,首先检查缓冲区是否有效(不是无效的缓冲区),然后检查是否已经存在相同的缓冲区。如果缓冲区有效且尚未存在,则将其添加到标签页视图中,并更新父窗口的大小。
|
|
|
|
|
void DocTabView::addBuffer(BufferID buffer)
|
|
|
|
|
{
|
|
|
|
|
if (buffer == BUFFER_INVALID) //valid only
|
|
|
|
@ -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,14 +77,14 @@ bool DocTabView::activateBuffer(BufferID buffer)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前激活的缓冲区。
|
|
|
|
|
BufferID DocTabView::activeBuffer()
|
|
|
|
|
{
|
|
|
|
|
int index = getCurrentTabIndex();
|
|
|
|
|
return getBufferByIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//遍历所有标签页,根据文件名查找匹配的缓冲区,找到则返回其ID,否则返回BUFFER_INVALID。
|
|
|
|
|
BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) //-1 if not found, something else otherwise
|
|
|
|
|
{
|
|
|
|
|
TCITEM tie{};
|
|
|
|
@ -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,7 +129,7 @@ BufferID DocTabView::getBufferByIndex(size_t index)
|
|
|
|
|
return reinterpret_cast<BufferID>(tie.lParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据mask中的标志位,更新与缓冲区相关的信息,例如文件名变化、只读状态变化等。
|
|
|
|
|
void DocTabView::bufferUpdated(Buffer * buffer, int mask)
|
|
|
|
|
{
|
|
|
|
|
int index = getIndexByBuffer(buffer->getID());
|
|
|
|
@ -183,7 +183,7 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask)
|
|
|
|
|
*out = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast<LPARAM>(&tie));
|
|
|
|
|
|
|
|
|
|
// send WM_SIZE only when change tab
|
|
|
|
@ -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,7 +208,7 @@ void DocTabView::setBuffer(size_t index, BufferID id)
|
|
|
|
|
::SendMessage(_hParent, WM_SIZE, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据隐藏/显示标签栏状态,调整标签页视图和文本编辑器视图的大小,并根据需要发送消息以更新可点击链接。
|
|
|
|
|
void DocTabView::reSizeTo(RECT & rc)
|
|
|
|
|
{
|
|
|
|
|
int borderWidth = ((NppParameters::getInstance()).getSVP())._borderWidth;
|
|
|
|
|