Skip to content

Commit b3de66c

Browse files
committed
Avoid column style reset on startup
1 parent 13cea5f commit b3de66c

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

src/MultiReplacePanel.cpp

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,7 +3034,7 @@ INT_PTR CALLBACK MultiReplace::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
30343034
initializeMarkerStyle();
30353035
initializeCtrlMap();
30363036
initializeFontStyles();
3037-
updateThemeAndColors();
3037+
applyThemePalette();
30383038
loadSettings();
30393039
updateTwoButtonsVisibility();
30403040
initializeListView();
@@ -8800,6 +8800,7 @@ void MultiReplace::showStatusMessage(const std::wstring& messageText, MessageSta
88008800
}
88018801
}
88028802

8803+
/*
88038804
void MultiReplace::updateThemeAndColors() {
88048805
// Check if Notepad++ is currently in dark mode
88058806
BOOL isDarkMode = (SendMessage(nppData._nppHandle, NPPM_ISDARKMODEENABLED, 0, 0) != 0);
@@ -8832,15 +8833,55 @@ void MultiReplace::updateThemeAndColors() {
88328833
break;
88338834
}
88348835
8835-
// This ensures column colors are also updated on theme change
8836-
initializeColumnStyles();
8836+
// This ensures column colors are also updated on theme change.
8837+
if (isColumnHighlighted)
8838+
initializeColumnStyles();
88378839
88388840
// Force the owner-drawn status control to repaint with the new colors
88398841
InvalidateRect(GetDlgItem(_hSelf, IDC_STATUS_MESSAGE), NULL, TRUE);
88408842
88418843
// draws the (?) Find Tooltip
88428844
InvalidateRect(GetDlgItem(_hSelf, IDC_FILTER_HELP), NULL, TRUE);
88438845
}
8846+
*/
8847+
8848+
void MultiReplace::applyThemePalette()
8849+
{
8850+
// Check if Notepad++ is currently in dark mode
8851+
BOOL isDarkMode = (SendMessage(nppData._nppHandle, NPPM_ISDARKMODEENABLED, 0, 0) != 0);
8852+
8853+
// Assign colours from the predefined palettes in the header file
8854+
if (isDarkMode) {
8855+
COLOR_SUCCESS = DMODE_SUCCESS;
8856+
COLOR_ERROR = DMODE_ERROR;
8857+
COLOR_INFO = DMODE_INFO;
8858+
_filterHelpColor = DMODE_FILTER_HELP;
8859+
}
8860+
else {
8861+
COLOR_SUCCESS = LMODE_SUCCESS;
8862+
COLOR_ERROR = LMODE_ERROR;
8863+
COLOR_INFO = LMODE_INFO;
8864+
_filterHelpColor = LMODE_FILTER_HELP;
8865+
}
8866+
8867+
// Update the active colour based on the last message status
8868+
switch (_lastMessageStatus) {
8869+
case MessageStatus::Success: _statusMessageColor = COLOR_SUCCESS; break;
8870+
case MessageStatus::Error: _statusMessageColor = COLOR_ERROR; break;
8871+
default: _statusMessageColor = COLOR_INFO; break;
8872+
}
8873+
8874+
// Repaint status control and "(?)" tooltip so they pick up the new palette
8875+
InvalidateRect(GetDlgItem(_hSelf, IDC_STATUS_MESSAGE), NULL, TRUE);
8876+
InvalidateRect(GetDlgItem(_hSelf, IDC_FILTER_HELP), NULL, TRUE);
8877+
}
8878+
8879+
void MultiReplace::refreshColumnStylesIfNeeded()
8880+
{
8881+
if (isColumnHighlighted) { // flag is managed by highlight/clear handlers
8882+
initializeColumnStyles();
8883+
}
8884+
}
88448885

88458886
std::wstring MultiReplace::getShortenedFilePath(const std::wstring& path, int maxLength, HDC hDC) {
88468887
bool hdcProvided = true;
@@ -10475,7 +10516,10 @@ void MultiReplace::onThemeChanged()
1047510516
{
1047610517
// Update all theme-related colors (status messages and columns)
1047710518
if (instance) {
10478-
instance->updateThemeAndColors();
10519+
{
10520+
instance->applyThemePalette(); // status colours, tooltip repaint
10521+
instance->refreshColumnStylesIfNeeded(); // guarded lexer reset
10522+
}
1047910523
}
1048010524
}
1048110525

src/MultiReplacePanel.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,9 @@ class MultiReplace : public StaticDialog
834834
void updateHeaderSelection();
835835
void updateHeaderSortDirection();
836836
void showStatusMessage(const std::wstring& messageText, MessageStatus status, bool isNotFound = false);
837-
void updateThemeAndColors();
837+
//void updateThemeAndColors();
838+
void applyThemePalette();
839+
void refreshColumnStylesIfNeeded();
838840
std::wstring getShortenedFilePath(const std::wstring& path, int maxLength, HDC hDC = nullptr);
839841
void displayResultCentered(size_t posStart, size_t posEnd, bool isDownwards);
840842
std::wstring getSelectedText();

0 commit comments

Comments
 (0)