Add word-wrap option to find-results context menu

Close #8624, close #8681
This commit is contained in:
Scott Sumner 2020-08-07 15:38:21 -04:00 committed by Don HO
parent 7c28a120d9
commit 3a2edb99c4
6 changed files with 61 additions and 0 deletions

View File

@ -1253,6 +1253,7 @@ Find in all files except exe, obj && log:
<finder-select-all value="Select all"/>
<finder-clear-all value="Clear all"/>
<finder-open-all value="Open all"/>
<finder-wrap-long-lines value="Word wrap long lines"/>
<common-ok value="OK"/>
<common-cancel value="Cancel"/>
<common-name value="Name: "/>

View File

@ -4563,6 +4563,15 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
}
}
else if (!lstrcmp(nm, TEXT("FinderConfig")))
{
const TCHAR* val = element->Attribute(TEXT("wrappedLines"));
if (val)
{
_nppGUI._finderLinesAreCurrentlyWrapped = (!lstrcmp(val, TEXT("yes")));
}
}
else if (!lstrcmp(nm, TEXT("NewDocDefaultSettings")))
{
int i;
@ -5648,6 +5657,14 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("bottom"), _nppGUI._findWindowPos.bottom);
}
// <GUIConfig name="FinderConfig" wrappedLines="no" />
{
TiXmlElement* GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("FinderConfig"));
const TCHAR* pStr = _nppGUI._finderLinesAreCurrentlyWrapped ? TEXT("yes") : TEXT("no");
GUIConfigElement->SetAttribute(TEXT("wrappedLines"), pStr);
}
// <GUIConfig name="noUpdate" intervalDays="15" nextUpdateDate="20161022">no</GUIConfig>
{
TiXmlElement *element = insertGUIConfigBoolNode(newGUIRoot, TEXT("noUpdate"), !_nppGUI._autoUpdateOpt._doAutoUpdate);

View File

@ -803,6 +803,8 @@ struct NppGUI final
int _tabSize = 4;
bool _tabReplacedBySpace = false;
bool _finderLinesAreCurrentlyWrapped = false;
int _fileAutoDetection = cdEnabledNew;
bool _checkHistoryFiles = false;

View File

@ -2346,6 +2346,13 @@ void FindReplaceDlg::findAllIn(InWhat op)
_pFinder->_scintView.execute(SCI_SETUSETABS, true);
_pFinder->_scintView.execute(SCI_SETTABWIDTH, 4);
NppParameters& nppParam = NppParameters::getInstance();
NppGUI& nppGUI = const_cast<NppGUI&>(nppParam.getNppGUI());
_pFinder->_longLinesAreWrapped = nppGUI._finderLinesAreCurrentlyWrapped;
_pFinder->_scintView.wrap(_pFinder->_longLinesAreWrapped);
_pFinder->_scintView.setWrapMode(LINEWRAP_INDENT);
_pFinder->_scintView.showWrapSymbol(true);
// allow user to start selecting as a stream block, then switch to a column block by adding Alt keypress
_pFinder->_scintView.execute(SCI_SETMOUSESELECTIONRECTANGULARSWITCH, true);
@ -2454,6 +2461,12 @@ Finder * FindReplaceDlg::createFinder()
pFinder->_scintView.execute(SCI_SETUSETABS, true);
pFinder->_scintView.execute(SCI_SETTABWIDTH, 4);
// inherit setting from current state of main finder:
pFinder->_longLinesAreWrapped = _pFinder->_longLinesAreWrapped;
pFinder->_scintView.wrap(pFinder->_longLinesAreWrapped);
pFinder->_scintView.setWrapMode(LINEWRAP_INDENT);
pFinder->_scintView.showWrapSymbol(true);
// allow user to start selecting as a stream block, then switch to a column block by adding Alt keypress
pFinder->_scintView.execute(SCI_SETMOUSESELECTIONRECTANGULARSWITCH, true);
@ -3447,6 +3460,20 @@ void Finder::openAll()
}
}
void Finder::wrapLongLinesToggle()
{
_longLinesAreWrapped = !_longLinesAreWrapped;
_scintView.wrap(_longLinesAreWrapped);
if (!_canBeVolatiled)
{
// only remember this setting from the original finder
NppParameters& nppParam = NppParameters::getInstance();
NppGUI& nppGUI = const_cast<NppGUI&>(nppParam.getNppGUI());
nppGUI._finderLinesAreCurrentlyWrapped = _longLinesAreWrapped;
}
}
bool Finder::isLineActualSearchResult(const generic_string & s) const
{
const auto firstColon = s.find(TEXT("\tLine "));
@ -3678,6 +3705,12 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
}
case NPPM_INTERNAL_SCINTILLAFINDERWRAP:
{
wrapLongLinesToggle();
return TRUE;
}
default :
{
return FALSE;
@ -3704,6 +3737,7 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
generic_string selectAll = pNativeSpeaker->getLocalizedStrFromID("finder-select-all", TEXT("Select all"));
generic_string clearAll = pNativeSpeaker->getLocalizedStrFromID("finder-clear-all", TEXT("Clear all"));
generic_string openAll = pNativeSpeaker->getLocalizedStrFromID("finder-open-all", TEXT("Open all"));
generic_string wrapLongLines = pNativeSpeaker->getLocalizedStrFromID("finder-wrap-long-lines", TEXT("Word wrap long lines"));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_FINDINFINDERDLG, findInFinder));
if (_canBeVolatiled)
@ -3717,9 +3751,13 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERCLEARALL, clearAll));
tmp.push_back(MenuItemUnit(0, TEXT("Separator")));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFEROPENALL, openAll));
tmp.push_back(MenuItemUnit(0, TEXT("Separator")));
tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINDERWRAP, wrapLongLines));
scintillaContextmenu.create(_hSelf, tmp);
scintillaContextmenu.checkItem(NPPM_INTERNAL_SCINTILLAFINDERWRAP, _longLinesAreWrapped);
scintillaContextmenu.display(p);
return TRUE;
}

View File

@ -130,6 +130,7 @@ public:
void setFinderStyle();
void removeAll();
void openAll();
void wrapLongLinesToggle();
void copy();
void beginNewFilesSearch();
void finishFilesSearch(int count, int searchedCount, bool isMatchLines, bool searchedEntireNotSelection);
@ -166,6 +167,7 @@ private:
bool _canBeVolatiled = true;
bool _longLinesAreWrapped = false;
void setFinderReadOnly(bool isReadOnly) {
_scintView.execute(SCI_SETREADONLY, isReadOnly);

View File

@ -444,6 +444,7 @@
#define NPPM_INTERNAL_EDGEBACKGROUND (NOTEPADPLUS_USER_INTERNAL + 50)
#define NPPM_INTERNAL_EDGEMULTISETSIZE (NOTEPADPLUS_USER_INTERNAL + 51)
#define NPPM_INTERNAL_UPDATECLICKABLELINKS (NOTEPADPLUS_USER_INTERNAL + 52)
#define NPPM_INTERNAL_SCINTILLAFINDERWRAP (NOTEPADPLUS_USER_INTERNAL + 53)
// See Notepad_plus_msgs.h
//#define NOTEPADPLUS_USER (WM_USER + 1000)