From d30b789d67869daa3eab1bd67aa9a01013ecfd70 Mon Sep 17 00:00:00 2001 From: ozone10 Date: Tue, 14 Feb 2023 19:15:51 +0100 Subject: [PATCH] Add support for non-printing char in main Search Result dock window ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/13020#issuecomment-1430034599 Close #13128 --- PowerEditor/src/NppBigSwitch.cpp | 11 +++++++-- PowerEditor/src/NppCommands.cpp | 4 ++++ .../src/ScintillaComponent/FindReplaceDlg.cpp | 21 +++++++++++++++- .../src/ScintillaComponent/FindReplaceDlg.h | 24 +++++++++++++++++++ .../ScintillaComponent/ScintillaEditView.h | 4 ++-- 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index ad6c37496..e9a042344 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1762,6 +1762,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa const bool isShown = nppParam.getSVP()._npcShow; _mainEditView.showNpc(isShown); _subEditView.showNpc(isShown); + _findReplaceDlg.updateFinderScintillaForNpc(); return TRUE; } @@ -2939,8 +2940,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_NPCFORMCHANGED: { - _mainEditView.setNPC(); - _subEditView.setNPC(); + NppParameters& nppParam = NppParameters::getInstance(); + const bool isShown = nppParam.getSVP()._npcShow; + if (isShown) + { + _mainEditView.setNPC(); + _subEditView.setNPC(); + _findReplaceDlg.updateFinderScintillaForNpc(true); + } return TRUE; } diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index fa968b50a..4bacf7f7d 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2368,6 +2368,8 @@ void Notepad_plus::command(int id) setCheckMenuItem(IDM_VIEW_ALL_CHARACTERS, allChecked); _toolBar.setCheck(IDM_VIEW_ALL_CHARACTERS, allChecked); + _findReplaceDlg.updateFinderScintillaForNpc(); + break; } @@ -2393,6 +2395,8 @@ void Notepad_plus::command(int id) svp1._eolShow = isChecked; svp1._npcShow = isChecked; + _findReplaceDlg.updateFinderScintillaForNpc(); + break; } diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index fedbb48b2..1d8877e69 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -3074,8 +3074,11 @@ void FindReplaceDlg::findAllIn(InWhat op) _pFinder->_scintView.showMargin(ScintillaEditView::_SC_MARGE_SYMBOL, false); _pFinder->_scintView.setMakerStyle(FOLDER_STYLE_SIMPLE); + NppDarkMode::setBorder(_pFinder->_scintView.getHSelf()); + _pFinder->_scintView.display(); _pFinder->setFinderStyle(); + _pFinder->setFinderStyleForNpc(); _pFinder->display(false); ::UpdateWindow(_hParent); @@ -3207,7 +3210,9 @@ Finder * FindReplaceDlg::createFinder() pFinder->_scintView.display(); ::UpdateWindow(_hParent); + NppDarkMode::setBorder(pFinder->_scintView.getHSelf()); pFinder->setFinderStyle(); + pFinder->setFinderStyleForNpc(); // Send the address of _MarkingsStruct to the lexer char ptrword[sizeof(void*) * 2 + 1]; @@ -4770,7 +4775,7 @@ void Finder::setFinderStyle() // Set global styles for the finder _scintView.performGlobalStyles(); - NppDarkMode::setBorder(_scintView.getHSelf()); + NppDarkMode::setDarkScrollBar(_scintView.getHSelf()); // Set current line background color for the finder const TCHAR * lexerName = ScintillaEditView::_langNameInfoArray[L_SEARCHRESULT]._langName; @@ -4822,6 +4827,20 @@ void Finder::setFinderStyle() _scintView.setMakerStyle(svp._folderStyle == FOLDER_STYLE_NONE ? FOLDER_STYLE_BOX : svp._folderStyle); } +void Finder::setFinderStyleForNpc(bool onlyColor) +{ + NppParameters& nppParam = NppParameters::getInstance(); + const bool isShown = nppParam.getSVP()._npcShow; + if (!onlyColor) + { + _scintView.showNpc(isShown, true); + } + else if (isShown) + { + _scintView.setNPC(); + } +} + intptr_t CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h index 9d038fcc8..674ff5700 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h @@ -125,6 +125,7 @@ public: void addSearchHitCount(int count, int countSearched, bool isMatchLines, bool searchedEntireNotSelection); const char* foundLine(FoundInfo fi, SearchResultMarkingLine mi, const TCHAR* foundline, size_t totalLineNumber); void setFinderStyle(); + void setFinderStyleForNpc(bool onlyColor = false); void removeAll(); void openAll(); void wrapLongLinesToggle(); @@ -352,6 +353,29 @@ public : if (_pFinder && _pFinder->isCreated()) { _pFinder->setFinderStyle(); + + if (!_findersOfFinder.empty()) + { + for (const auto& finder : _findersOfFinder) + { + finder->setFinderStyle(); + } + } + } + }; + + void updateFinderScintillaForNpc(bool onlyColor = false) { + if (_pFinder && _pFinder->isCreated()) + { + _pFinder->setFinderStyleForNpc(onlyColor); + + if (!_findersOfFinder.empty()) + { + for (const auto& finder : _findersOfFinder) + { + finder->setFinderStyleForNpc(); + } + } } }; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index 3afca465a..7112ba7bb 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -409,7 +409,7 @@ public: return (execute(SCI_GETVIEWEOL) != 0); }; - void showNpc(bool willBeShowed = true) { + void showNpc(bool willBeShowed = true, bool isSearchResult = false) { auto& svp = NppParameters::getInstance().getSVP(); if (willBeShowed) { @@ -429,7 +429,7 @@ public: execute(SCI_CLEARALLREPRESENTATIONS); // SCI_CLEARALLREPRESENTATIONS will also reset CRLF - if (svp._eolMode != svp.roundedRectangleText) + if (!isSearchResult && svp._eolMode != svp.roundedRectangleText) { setCRLF(); }