Add plugin commands NPPM_GETTABCOLORID

No NPPM_SETTABCOLORID though. Plugins can use NPPM_MENUCOMMAND to set current tab color with the desired tab color ID.

Fix #15115, close #15142
pull/15166/head
Alan Kilborn 2024-05-15 07:53:57 -04:00 committed by Don Ho
parent fb086bbcda
commit 9244cd0943
2 changed files with 51 additions and 0 deletions

View File

@ -964,6 +964,27 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
// if isAllocatedSuccessful is TRUE, and value of idBegin is 7 // if isAllocatedSuccessful is TRUE, and value of idBegin is 7
// then indicator ID 7 is preserved by Notepad++, and it is safe to be used by the plugin. // then indicator ID 7 is preserved by Notepad++, and it is safe to be used by the plugin.
#define NPPM_GETTABCOLORID (NPPMSG + 114)
// int NPPM_GETTABCOLORID (int view, int tabIndex)
// Get the tab color id with given view and tab index.
//
// wParam[in]: VIEW
// Here's the values for the view:
// MAIN_VIEW 0
// SUB_VIEW 1
// active -1
//
// lParam[in]: TABINDEX
// Zero-based, i.e., use 0 for first tab, 1 for second tab, etc.; use -1 for active tab
//
// Return tab color id
// tab color id contains the following values:
// -1 (no color)
// 0 (yellow)
// 1 (green)
// 2 (blue)
// 3 (orange)
// 4 (pink)
// For RUNCOMMAND_USER // For RUNCOMMAND_USER
#define VAR_NOT_RECOGNIZED 0 #define VAR_NOT_RECOGNIZED 0

View File

@ -2953,6 +2953,36 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return _pluginsManager.allocateIndicator(static_cast<int32_t>(wParam), reinterpret_cast<int *>(lParam)); return _pluginsManager.allocateIndicator(static_cast<int32_t>(wParam), reinterpret_cast<int *>(lParam));
} }
case NPPM_GETTABCOLORID:
{
const auto view = static_cast<int>(wParam);
auto tabIndex = static_cast<int>(lParam);
auto colorId = -1; // no color (or unknown)
auto pDt = _pDocTab; // active view
if (view == MAIN_VIEW)
{
pDt = &_mainDocTab;
}
else if (view == SUB_VIEW)
{
pDt = &_subDocTab;
}
if (tabIndex == -1)
{
tabIndex = pDt->getCurrentTabIndex();
}
if ((tabIndex >= 0) && (tabIndex < static_cast<int>(pDt->nbItem())))
{
colorId = pDt->getIndividualTabColour(tabIndex);
}
return colorId;
}
case NPPM_GETBOOKMARKID: case NPPM_GETBOOKMARKID:
{ {
return MARK_BOOKMARK; return MARK_BOOKMARK;