Add MarkAll Preference settings for case and word

Fix #9751 #5148, close #9796
pull/9802/head
Scott Sumner 2021-04-24 16:56:06 -04:00 committed by Don HO
parent a0177e8d05
commit 0dbdef320f
8 changed files with 100 additions and 28 deletions

View File

@ -912,8 +912,12 @@ You can define several column markers by using white space to separate the diffe
</Language>
<Highlighting title="Highlighting">
<Item id="6351" name="Mark All"/>
<Item id="6352" name="Match case"/>
<Item id="6353" name="Match whole word only"/>
<Item id="6333" name="Smart Highlighting"/>
<Item id="6326" name="Enable"/>
<Item id="6354" name="Matching"/>
<Item id="6332" name="Match case"/>
<Item id="6338" name="Match whole word only"/>
<Item id="6339" name="Use Find dialog settings"/>

View File

@ -1257,19 +1257,22 @@ void Notepad_plus::command(int id)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT5;
const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR text2Find[strSize];
TCHAR text2Find2[strSize];
TCHAR selectedText[strSize];
TCHAR wordOnCaret[strSize];
_pEditView->getGenericSelectedText(text2Find, strSize, false);
_pEditView->getGenericWordOnCaretPos(text2Find2, strSize);
_pEditView->getGenericSelectedText(selectedText, strSize, false);
_pEditView->getGenericWordOnCaretPos(wordOnCaret, strSize);
if (text2Find[0] == '\0')
if (selectedText[0] == '\0')
{
_findReplaceDlg.markAll(text2Find2, styleID, true);
if (lstrlen(wordOnCaret) > 0)
{
_findReplaceDlg.markAll(wordOnCaret, styleID, true);
}
}
else
{
_findReplaceDlg.markAll(text2Find, styleID, lstrlen(text2Find) == lstrlen(text2Find2));
_findReplaceDlg.markAll(selectedText, styleID, lstrlen(selectedText) == lstrlen(wordOnCaret));
}
}
break;

View File

@ -4401,6 +4401,27 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
}
}
}
// <GUIConfig name="MarkAll" matchCase="yes" wholeWordOnly="yes" </GUIConfig>
else if (!lstrcmp(nm, TEXT("MarkAll")))
{
const TCHAR* val = element->Attribute(TEXT("matchCase"));
if (val)
{
if (lstrcmp(val, TEXT("yes")) == 0)
_nppGUI._markAllCaseSensitive = true;
else if (!lstrcmp(val, TEXT("no")))
_nppGUI._markAllCaseSensitive = false;
}
val = element->Attribute(TEXT("wholeWordOnly"));
if (val)
{
if (lstrcmp(val, TEXT("yes")) == 0)
_nppGUI._markAllWordOnly = true;
else if (!lstrcmp(val, TEXT("no")))
_nppGUI._markAllWordOnly = false;
}
}
// <GUIConfig name="SmartHighLight" matchCase="yes" wholeWordOnly="yes" useFindSettings="no">yes</GUIConfig>
else if (!lstrcmp(nm, TEXT("SmartHighLight")))
{
@ -6323,6 +6344,14 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("searchEngineCustom"), _nppGUI._searchEngineCustom);
}
// <GUIConfig name="MarkAll" matchCase="no" wholeWordOnly="yes" </GUIConfig>
{
TiXmlElement* GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("MarkAll"));
GUIConfigElement->SetAttribute(TEXT("matchCase"), _nppGUI._markAllCaseSensitive ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("wholeWordOnly"), _nppGUI._markAllWordOnly ? TEXT("yes") : TEXT("no"));
}
// <GUIConfig name="SmartHighLight" matchCase="no" wholeWordOnly="yes" useFindSettings="no" onAnotherView="no">yes</GUIConfig>
{
TiXmlElement *GUIConfigElement = insertGUIConfigBoolNode(newGUIRoot, TEXT("SmartHighLight"), _nppGUI._enableSmartHilite);

View File

@ -840,6 +840,9 @@ struct NppGUI final
bool _smartHiliteUseFindSettings = false;
bool _smartHiliteOnAnotherView = false;
bool _markAllCaseSensitive = false;
bool _markAllWordOnly = true;
bool _disableSmartHiliteTmp = false;
bool _enableTagsMatchHilite = true;
bool _enableTagAttrsHilite = true;

View File

@ -2021,14 +2021,18 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl
int FindReplaceDlg::markAll(const TCHAR *txt2find, int styleID, bool isWholeWordSelected)
{
FindOption opt;
opt._isMatchCase = _options._isMatchCase;
// if whole word is selected for being colorized, isWholeWord option in Find/Replace dialog will be checked
// otherwise this option is false, because user may want to find the words contain the parts to search
opt._isWholeWord = isWholeWordSelected?_options._isWholeWord:false;
opt._str2Search = txt2find;
const NppGUI& nppGUI = NppParameters::getInstance().getNppGUI();
FindOption markAllOpt;
int nbFound = processAll(ProcessMarkAllExt, &opt, true, NULL, styleID);
markAllOpt._isMatchCase = nppGUI._markAllCaseSensitive;
// if whole word is selected for being colorized, isWholeWord setting in Preferences will be checked
// otherwise this option is false, because user may want to find the words contain the parts to search
markAllOpt._isWholeWord = isWholeWordSelected ? nppGUI._markAllWordOnly : false;
markAllOpt._str2Search = txt2find;
int nbFound = processAll(ProcessMarkAllExt, &markAllOpt, true, NULL, styleID);
return nbFound;
}

View File

@ -222,17 +222,20 @@ IDD_PREFERENCE_SUB_HIGHLIGHTING DIALOGEX 0, 0, 455, 185
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Smart Highlighting",IDC_SMARTHILITING_STATIC,147,21,155,81,BS_CENTER
CONTROL "Enable",IDC_CHECK_ENABLSMARTHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,155,31,142,10
CONTROL "Match case",IDC_CHECK_SMARTHILITECASESENSITIVE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,155,45,142,10
CONTROL "Match whole word only",IDC_CHECK_SMARTHILITEWHOLEWORDONLY, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,155,58,142,10
CONTROL "Use Find dialog settings",IDC_CHECK_SMARTHILITEUSEFINDSETTINGS, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,155,72,142,10
CONTROL "Highlight another view",IDC_CHECK_SMARTHILITEANOTHERRVIEW, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,155,86,142,10
GROUPBOX "Highlight Matching Tags",IDC_TAGMATCHEDHILITE_STATIC,147,110,155,55,BS_CENTER
CONTROL "Enable",IDC_CHECK_ENABLTAGSMATCHHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,155,120,140,10
CONTROL "Highlight tag attributes",IDC_CHECK_ENABLTAGATTRHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,155,134,140,10
CONTROL "Highlight comment/php/asp zone",IDC_CHECK_HIGHLITENONEHTMLZONE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,155,148,140,10
GROUPBOX "Mark All",IDC_MARKALL_STATIC,62,29,155,45,BS_CENTER
CONTROL "Match case",IDC_CHECK_MARKALLCASESENSITIVE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,70,42,142,10
CONTROL "Match whole word only",IDC_CHECK_MARKALLWHOLEWORDONLY,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,70,55,142,10
GROUPBOX "Smart Highlighting",IDC_SMARTHILITING_STATIC,226,29,172,108,BS_CENTER
CONTROL "Enable",IDC_CHECK_ENABLSMARTHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,234,39,142,10
CONTROL "Highlight another view",IDC_CHECK_SMARTHILITEANOTHERRVIEW,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,234,55,142,10
GROUPBOX "Matching", IDC_SMARTHILITEMATCHING_STATIC,233,74,155,55,BS_CENTER
CONTROL "Match case",IDC_CHECK_SMARTHILITECASESENSITIVE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,241,86,142,10
CONTROL "Match whole word only",IDC_CHECK_SMARTHILITEWHOLEWORDONLY,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,241,99,142,10
CONTROL "Use Find dialog settings",IDC_CHECK_SMARTHILITEUSEFINDSETTINGS,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,241,113,142,10
GROUPBOX "Highlight Matching Tags",IDC_TAGMATCHEDHILITE_STATIC,62,82,155,55,BS_CENTER
CONTROL "Enable",IDC_CHECK_ENABLTAGSMATCHHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,71,92,140,10
CONTROL "Highlight tag attributes",IDC_CHECK_ENABLTAGATTRHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,71,106,140,10
CONTROL "Highlight comment/php/asp zone",IDC_CHECK_HIGHLITENONEHTMLZONE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,71,120,140,10
END

View File

@ -2143,6 +2143,9 @@ INT_PTR CALLBACK HighlightingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
{
case WM_INITDIALOG :
{
::SendDlgItemMessage(_hSelf, IDC_CHECK_MARKALLCASESENSITIVE, BM_SETCHECK, nppGUI._markAllCaseSensitive, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_MARKALLWHOLEWORDONLY, BM_SETCHECK, nppGUI._markAllWordOnly, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLSMARTHILITE, BM_SETCHECK, nppGUI._enableSmartHilite, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SMARTHILITECASESENSITIVE, BM_SETCHECK, nppGUI._smartHiliteCaseSensitive, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SMARTHILITEWHOLEWORDONLY, BM_SETCHECK, nppGUI._smartHiliteWordOnly, 0);
@ -2171,7 +2174,23 @@ INT_PTR CALLBACK HighlightingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
case WM_COMMAND :
{
switch (wParam)
{
{
case IDC_CHECK_MARKALLCASESENSITIVE:
{
nppGUI._markAllCaseSensitive = isCheckedOrNot(IDC_CHECK_MARKALLCASESENSITIVE);
HWND grandParent = ::GetParent(_hParent);
::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATOR, 0, 0);
return TRUE;
}
case IDC_CHECK_MARKALLWHOLEWORDONLY:
{
nppGUI._markAllWordOnly = isCheckedOrNot(IDC_CHECK_MARKALLWHOLEWORDONLY);
HWND grandParent = ::GetParent(_hParent);
::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATOR, 0, 0);
return TRUE;
}
case IDC_CHECK_ENABLSMARTHILITE:
{
nppGUI._enableSmartHilite = !nppGUI._enableSmartHilite;
@ -2201,6 +2220,7 @@ INT_PTR CALLBACK HighlightingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATOR, 0, 0);
return TRUE;
}
case IDC_CHECK_SMARTHILITEWHOLEWORDONLY:
{
nppGUI._smartHiliteWordOnly = isCheckedOrNot(IDC_CHECK_SMARTHILITEWHOLEWORDONLY);
@ -2213,6 +2233,7 @@ INT_PTR CALLBACK HighlightingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATOR, 0, 0);
return TRUE;
}
case IDC_CHECK_SMARTHILITEUSEFINDSETTINGS:
{
nppGUI._smartHiliteUseFindSettings = isCheckedOrNot(IDC_CHECK_SMARTHILITEUSEFINDSETTINGS);
@ -2227,6 +2248,7 @@ INT_PTR CALLBACK HighlightingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATOR, 0, 0);
return TRUE;
}
case IDC_CHECK_SMARTHILITEANOTHERRVIEW:
{
nppGUI._smartHiliteOnAnotherView = isCheckedOrNot(IDC_CHECK_SMARTHILITEANOTHERRVIEW);

View File

@ -203,15 +203,19 @@
#define IDC_CHECK_REMEMBEREDITVIEWPERFILE (IDD_PREFERENCE_SUB_MISC + 41)
#define IDC_REMEMBEREDITVIEWPERFILE_STATIC (IDD_PREFERENCE_SUB_MISC + 42)
#define IDC_EDIT_REMEMBEREDITVIEWPERFILE (IDD_PREFERENCE_SUB_MISC + 43)
#define IDC_DOCUMENTPEEK_STATIC (IDD_PREFERENCE_SUB_MISC + 44)
#define IDC_CHECK_ENABLEDOCPEEKER (IDD_PREFERENCE_SUB_MISC + 45)
#define IDC_CHECK_ENABLEDOCPEEKONMAP (IDD_PREFERENCE_SUB_MISC + 46)
#define IDC_COMBO_FILEUPDATECHOICE (IDD_PREFERENCE_SUB_MISC + 47)
#define IDC_CHECK_DIRECTWRITE_ENABLE (IDD_PREFERENCE_SUB_MISC + 49)
#define IDC_CHECK_CLICKABLELINK_FULLBOXMODE (IDD_PREFERENCE_SUB_MISC + 50)
#define IDC_MARKALL_STATIC (IDD_PREFERENCE_SUB_MISC + 51)
#define IDC_CHECK_MARKALLCASESENSITIVE (IDD_PREFERENCE_SUB_MISC + 52)
#define IDC_CHECK_MARKALLWHOLEWORDONLY (IDD_PREFERENCE_SUB_MISC + 53)
#define IDC_SMARTHILITEMATCHING_STATIC (IDD_PREFERENCE_SUB_MISC + 54)
#define IDC_CHECK_MUTE_SOUNDS (IDD_PREFERENCE_SUB_MISC + 60)
#define IDD_PREFERENCE_SUB_NEWDOCUMENT 6400 //(IDD_PREFERENCE_BOX + 400)
#define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 1)
#define IDC_RADIO_F_WIN (IDD_PREFERENCE_SUB_NEWDOCUMENT + 2)