mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-22 21:34:58 +02:00
Add pref setting to allow Replace to stop after replacement
Fix #4437, close #9801
This commit is contained in:
parent
f249fc5902
commit
a0177e8d05
@ -959,6 +959,7 @@ You can define several column markers by using white space to separate the diffe
|
|||||||
<Item id="6902" name="Use monospaced font in Find dialog (Need to restart Notepad++)"/>
|
<Item id="6902" name="Use monospaced font in Find dialog (Need to restart Notepad++)"/>
|
||||||
<Item id="6903" name="Find dialog remains open after search that outputs to results window"/>
|
<Item id="6903" name="Find dialog remains open after search that outputs to results window"/>
|
||||||
<Item id="6904" name="Confirm Replace All in All Opened Documents"/>
|
<Item id="6904" name="Confirm Replace All in All Opened Documents"/>
|
||||||
|
<Item id="6905" name="Replace: Don't move to the following occurrence"/>
|
||||||
</Searching>
|
</Searching>
|
||||||
|
|
||||||
<RecentFilesHistory title="Recent Files History">
|
<RecentFilesHistory title="Recent Files History">
|
||||||
@ -1358,6 +1359,7 @@ Find in all files except exe, obj && log:
|
|||||||
<find-status-replace-end-reached value="Replace: Replaced the 1st occurrence from the top. The end of document has been reached"/>
|
<find-status-replace-end-reached value="Replace: Replaced the 1st occurrence from the top. The end of document has been reached"/>
|
||||||
<find-status-replace-top-reached value="Replace: Replaced the 1st occurrence from the bottom. The begin of document has been reached"/>
|
<find-status-replace-top-reached value="Replace: Replaced the 1st occurrence from the bottom. The begin of document has been reached"/>
|
||||||
<find-status-replaced-next-found value="Replace: 1 occurrence was replaced. The next occurrence found."/>
|
<find-status-replaced-next-found value="Replace: 1 occurrence was replaced. The next occurrence found."/>
|
||||||
|
<find-status-replaced-without-continuing value="Replace: 1 occurrence was replaced."/>
|
||||||
<find-status-replaced-next-not-found value="Replace: 1 occurrence was replaced. No more occurrences were found."/>
|
<find-status-replaced-next-not-found value="Replace: 1 occurrence was replaced. No more occurrences were found."/>
|
||||||
<find-status-replace-not-found value="Replace: no occurrence was found"/>
|
<find-status-replace-not-found value="Replace: no occurrence was found"/>
|
||||||
<find-status-replace-readonly value="Replace: Cannot replace text. The current document is read only"/>
|
<find-status-replace-readonly value="Replace: Cannot replace text. The current document is read only"/>
|
||||||
|
@ -5284,6 +5284,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
|||||||
const TCHAR* optConfirmReplaceOpenDocs = element->Attribute(TEXT("confirmReplaceInAllOpenDocs"));
|
const TCHAR* optConfirmReplaceOpenDocs = element->Attribute(TEXT("confirmReplaceInAllOpenDocs"));
|
||||||
if (optConfirmReplaceOpenDocs)
|
if (optConfirmReplaceOpenDocs)
|
||||||
_nppGUI._confirmReplaceInAllOpenDocs = (lstrcmp(optConfirmReplaceOpenDocs, TEXT("yes")) == 0);
|
_nppGUI._confirmReplaceInAllOpenDocs = (lstrcmp(optConfirmReplaceOpenDocs, TEXT("yes")) == 0);
|
||||||
|
|
||||||
|
const TCHAR* optReplaceStopsWithoutFindingNext = element->Attribute(TEXT("replaceStopsWithoutFindingNext"));
|
||||||
|
if (optReplaceStopsWithoutFindingNext)
|
||||||
|
_nppGUI._replaceStopsWithoutFindingNext = (lstrcmp(optReplaceStopsWithoutFindingNext, TEXT("yes")) == 0);
|
||||||
}
|
}
|
||||||
else if (!lstrcmp(nm, TEXT("MISC")))
|
else if (!lstrcmp(nm, TEXT("MISC")))
|
||||||
{
|
{
|
||||||
@ -6299,7 +6303,7 @@ void NppParameters::createXmlTreeFromGUIParams()
|
|||||||
GUIConfigElement->SetAttribute(TEXT("muteSounds"), _nppGUI._muteSounds ? TEXT("yes") : TEXT("no"));
|
GUIConfigElement->SetAttribute(TEXT("muteSounds"), _nppGUI._muteSounds ? TEXT("yes") : TEXT("no"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// <GUIConfig name="Searching" "monospacedFontFindDlg"="no" stopFillingFindField="no" findDlgAlwaysVisible="no" confirmReplaceOpenDocs="yes" confirmMacroReplaceOpenDocs="yes" confirmReplaceInFiles="yes" confirmMacroReplaceInFiles="yes" />
|
// <GUIConfig name="Searching" "monospacedFontFindDlg"="no" stopFillingFindField="no" findDlgAlwaysVisible="no" confirmReplaceOpenDocs="yes" confirmMacroReplaceOpenDocs="yes" confirmReplaceInFiles="yes" confirmMacroReplaceInFiles="yes" replaceStopsWithoutFindingNext="no"/>
|
||||||
{
|
{
|
||||||
TiXmlElement* GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
TiXmlElement* GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
||||||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("Searching"));
|
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("Searching"));
|
||||||
@ -6308,6 +6312,7 @@ void NppParameters::createXmlTreeFromGUIParams()
|
|||||||
GUIConfigElement->SetAttribute(TEXT("stopFillingFindField"), _nppGUI._stopFillingFindField ? TEXT("yes") : TEXT("no"));
|
GUIConfigElement->SetAttribute(TEXT("stopFillingFindField"), _nppGUI._stopFillingFindField ? TEXT("yes") : TEXT("no"));
|
||||||
GUIConfigElement->SetAttribute(TEXT("findDlgAlwaysVisible"), _nppGUI._findDlgAlwaysVisible ? TEXT("yes") : TEXT("no"));
|
GUIConfigElement->SetAttribute(TEXT("findDlgAlwaysVisible"), _nppGUI._findDlgAlwaysVisible ? TEXT("yes") : TEXT("no"));
|
||||||
GUIConfigElement->SetAttribute(TEXT("confirmReplaceInAllOpenDocs"), _nppGUI._confirmReplaceInAllOpenDocs ? TEXT("yes") : TEXT("no"));
|
GUIConfigElement->SetAttribute(TEXT("confirmReplaceInAllOpenDocs"), _nppGUI._confirmReplaceInAllOpenDocs ? TEXT("yes") : TEXT("no"));
|
||||||
|
GUIConfigElement->SetAttribute(TEXT("replaceStopsWithoutFindingNext"), _nppGUI._replaceStopsWithoutFindingNext ? TEXT("yes") : TEXT("no"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// <GUIConfig name="searchEngine" searchEngineChoice="2" searchEngineCustom="" />
|
// <GUIConfig name="searchEngine" searchEngineChoice="2" searchEngineCustom="" />
|
||||||
|
@ -853,6 +853,7 @@ struct NppGUI final
|
|||||||
bool _monospacedFontFindDlg = false;
|
bool _monospacedFontFindDlg = false;
|
||||||
bool _findDlgAlwaysVisible = false;
|
bool _findDlgAlwaysVisible = false;
|
||||||
bool _confirmReplaceInAllOpenDocs = true;
|
bool _confirmReplaceInAllOpenDocs = true;
|
||||||
|
bool _replaceStopsWithoutFindingNext = false;
|
||||||
bool _muteSounds = false;
|
bool _muteSounds = false;
|
||||||
writeTechnologyEngine _writeTechnologyEngine = defaultTechnology;
|
writeTechnologyEngine _writeTechnologyEngine = defaultTechnology;
|
||||||
bool _isWordCharDefault = true;
|
bool _isWordCharDefault = true;
|
||||||
|
@ -1969,29 +1969,41 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl
|
|||||||
}
|
}
|
||||||
(*_ppEditView)->execute(SCI_SETSEL, start + replacedLen, start + replacedLen);
|
(*_ppEditView)->execute(SCI_SETSEL, start + replacedLen, start + replacedLen);
|
||||||
|
|
||||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||||
// Do the next find
|
|
||||||
moreMatches = processFindNext(txt2find, &replaceOptions, &status, FINDNEXTTYPE_REPLACENEXT);
|
|
||||||
|
|
||||||
if (status == FSEndReached)
|
NppParameters& nppParam = NppParameters::getInstance();
|
||||||
|
const NppGUI& nppGui = nppParam.getNppGUI();
|
||||||
|
|
||||||
|
if (nppGui._replaceStopsWithoutFindingNext)
|
||||||
{
|
{
|
||||||
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replace-end-reached", TEXT("Replace: Replaced the 1st occurrence from the top. The end of document has been reached."));
|
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replaced-without-continuing", TEXT("Replace: 1 occurrence was replaced."));
|
||||||
setStatusbarMessage(msg, FSEndReached);
|
setStatusbarMessage(msg, FSMessage);
|
||||||
}
|
|
||||||
else if (status == FSTopReached)
|
|
||||||
{
|
|
||||||
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replace-top-reached", TEXT("Replace: Replaced the 1st occurrence from the bottom. The begin of document has been reached."));
|
|
||||||
setStatusbarMessage(msg, FSTopReached);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
generic_string msg;
|
// Do the next find
|
||||||
if (moreMatches)
|
moreMatches = processFindNext(txt2find, &replaceOptions, &status, FINDNEXTTYPE_REPLACENEXT);
|
||||||
msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replaced-next-found", TEXT("Replace: 1 occurrence was replaced. The next occurrence found."));
|
|
||||||
else
|
|
||||||
msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replaced-next-not-found", TEXT("Replace: 1 occurrence was replaced. No more occurrences were found."));
|
|
||||||
|
|
||||||
setStatusbarMessage(msg, FSMessage);
|
if (status == FSEndReached)
|
||||||
|
{
|
||||||
|
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replace-end-reached", TEXT("Replace: Replaced the 1st occurrence from the top. The end of document has been reached."));
|
||||||
|
setStatusbarMessage(msg, FSEndReached);
|
||||||
|
}
|
||||||
|
else if (status == FSTopReached)
|
||||||
|
{
|
||||||
|
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replace-top-reached", TEXT("Replace: Replaced the 1st occurrence from the bottom. The begin of document has been reached."));
|
||||||
|
setStatusbarMessage(msg, FSTopReached);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
generic_string msg;
|
||||||
|
if (moreMatches)
|
||||||
|
msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replaced-next-found", TEXT("Replace: 1 occurrence was replaced. The next occurrence found."));
|
||||||
|
else
|
||||||
|
msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replaced-next-not-found", TEXT("Replace: 1 occurrence was replaced. No more occurrences were found."));
|
||||||
|
|
||||||
|
setStatusbarMessage(msg, FSMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,8 @@ BEGIN
|
|||||||
CONTROL "Use Monospaced font in Find dialog (Need to restart Notepad++)",IDC_CHECK_MONOSPACEDFONT_FINDDLG, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,25,350,10
|
CONTROL "Use Monospaced font in Find dialog (Need to restart Notepad++)",IDC_CHECK_MONOSPACEDFONT_FINDDLG, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,25,350,10
|
||||||
CONTROL "Find dialog remains open after search that outputs to results window",IDC_CHECK_FINDDLG_ALWAYS_VISIBLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,40,350,10
|
CONTROL "Find dialog remains open after search that outputs to results window",IDC_CHECK_FINDDLG_ALWAYS_VISIBLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,40,350,10
|
||||||
CONTROL "Confirm Replace All in All Opened Documents",IDC_CHECK_CONFIRMREPLOPENDOCS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,55,350,10
|
CONTROL "Confirm Replace All in All Opened Documents",IDC_CHECK_CONFIRMREPLOPENDOCS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,55,350,10
|
||||||
END
|
CONTROL "Replace: Don't move to the following occurrence", IDC_CHECK_REPLACEANDSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 70, 350, 10
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
IDD_PREFERENCE_SUB_BACKUP DIALOGEX 0, 0, 455, 185
|
IDD_PREFERENCE_SUB_BACKUP DIALOGEX 0, 0, 455, 185
|
||||||
|
@ -3704,6 +3704,7 @@ INT_PTR CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_MONOSPACEDFONT_FINDDLG, BM_SETCHECK, nppGUI._monospacedFontFindDlg, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_MONOSPACEDFONT_FINDDLG, BM_SETCHECK, nppGUI._monospacedFontFindDlg, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_FINDDLG_ALWAYS_VISIBLE, BM_SETCHECK, nppGUI._findDlgAlwaysVisible, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_FINDDLG_ALWAYS_VISIBLE, BM_SETCHECK, nppGUI._findDlgAlwaysVisible, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_CONFIRMREPLOPENDOCS, BM_SETCHECK, nppGUI._confirmReplaceInAllOpenDocs, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_CONFIRMREPLOPENDOCS, BM_SETCHECK, nppGUI._confirmReplaceInAllOpenDocs, 0);
|
||||||
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_REPLACEANDSTOP, BM_SETCHECK, nppGUI._replaceStopsWithoutFindingNext, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3739,6 +3740,13 @@ INT_PTR CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDC_CHECK_REPLACEANDSTOP:
|
||||||
|
{
|
||||||
|
nppGUI._replaceStopsWithoutFindingNext = isCheckedOrNot(IDC_CHECK_REPLACEANDSTOP);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -361,6 +361,7 @@
|
|||||||
#define IDC_CHECK_MONOSPACEDFONT_FINDDLG (IDD_PREFERENCE_SUB_SEARCHING + 2)
|
#define IDC_CHECK_MONOSPACEDFONT_FINDDLG (IDD_PREFERENCE_SUB_SEARCHING + 2)
|
||||||
#define IDC_CHECK_FINDDLG_ALWAYS_VISIBLE (IDD_PREFERENCE_SUB_SEARCHING + 3)
|
#define IDC_CHECK_FINDDLG_ALWAYS_VISIBLE (IDD_PREFERENCE_SUB_SEARCHING + 3)
|
||||||
#define IDC_CHECK_CONFIRMREPLOPENDOCS (IDD_PREFERENCE_SUB_SEARCHING + 4)
|
#define IDC_CHECK_CONFIRMREPLOPENDOCS (IDD_PREFERENCE_SUB_SEARCHING + 4)
|
||||||
|
#define IDC_CHECK_REPLACEANDSTOP (IDD_PREFERENCE_SUB_SEARCHING + 5)
|
||||||
|
|
||||||
#define IDD_PREFERENCE_SUB_DARKMODE 7100 //(IDD_PREFERENCE_BOX + 1100)
|
#define IDD_PREFERENCE_SUB_DARKMODE 7100 //(IDD_PREFERENCE_BOX + 1100)
|
||||||
#define IDC_CHECK_DARKMODE_ENABLE (IDD_PREFERENCE_SUB_DARKMODE + 1)
|
#define IDC_CHECK_DARKMODE_ENABLE (IDD_PREFERENCE_SUB_DARKMODE + 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user