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
This commit is contained in:
ozone10 2023-02-14 19:15:51 +01:00 committed by Don Ho
parent 278f694f3a
commit d30b789d67
5 changed files with 59 additions and 5 deletions

View File

@ -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;
}
@ -2938,9 +2939,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
}
case NPPM_INTERNAL_NPCFORMCHANGED:
{
NppParameters& nppParam = NppParameters::getInstance();
const bool isShown = nppParam.getSVP()._npcShow;
if (isShown)
{
_mainEditView.setNPC();
_subEditView.setNPC();
_findReplaceDlg.updateFinderScintillaForNpc(true);
}
return TRUE;
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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();
}
}
}
};

View File

@ -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();
}