From 9244cd09430c82ecff805ea862c9133d5cb56ded Mon Sep 17 00:00:00 2001 From: Alan Kilborn Date: Wed, 15 May 2024 07:53:57 -0400 Subject: [PATCH] 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 --- .../MISC/PluginsManager/Notepad_plus_msgs.h | 21 +++++++++++++ PowerEditor/src/NppBigSwitch.cpp | 30 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index 346457648..3a5d571b1 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -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 // 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 #define VAR_NOT_RECOGNIZED 0 diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 799052317..0bef97e96 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -2953,6 +2953,36 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return _pluginsManager.allocateIndicator(static_cast(wParam), reinterpret_cast(lParam)); } + case NPPM_GETTABCOLORID: + { + const auto view = static_cast(wParam); + auto tabIndex = static_cast(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(pDt->nbItem()))) + { + colorId = pDt->getIndividualTabColour(tabIndex); + } + + return colorId; + } + case NPPM_GETBOOKMARKID: { return MARK_BOOKMARK;