Add option to turn off selecting text when Field dialog is invoked

Fix #11988, close #11989
pull/12054/head
doug1234 2022-08-05 23:53:25 -04:00 committed by Don Ho
parent 6a33bf6c4c
commit 9809e2fc2c
8 changed files with 56 additions and 20 deletions

View File

@ -1048,12 +1048,14 @@ You can define several column markers by using white space to separate the diffe
</Print>
<Searching title="Searching">
<Item id="6901" name="Don't fill find field in Find dialog with selected word"/>
<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="6904" name="Confirm Replace All in All Opened Documents"/>
<Item id="6905" name="Replace: Don't move to the following occurrence"/>
<Item id="6906" name="Search Result window: show only one entry per found line"/>
<Item id="6907" name="When Find Dialog is Invoked"/>
<Item id="6908" name="Fill Find Field with Selected Text"/>
<Item id="6909" name="Select Word Under Caret when Nothing Selected"/>
</Searching>
<RecentFilesHistory title="Recent Files History">

View File

@ -334,9 +334,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
const NppGUI & nppGui = nppParam.getNppGUI();
if (!nppGui._stopFillingFindField)
if (nppGui._fillFindFieldWithSelected)
{
_pEditView->getGenericSelectedText(str, strSize);
_pEditView->getGenericSelectedText(str, strSize, nppGui._fillFindFieldSelectCaret);
_findReplaceDlg.setSearchText(str);
}

View File

@ -1215,9 +1215,9 @@ void Notepad_plus::command(int id)
_findReplaceDlg.doDialog(dlgID, _nativeLangSpeaker.isRTL());
const NppGUI & nppGui = (NppParameters::getInstance()).getNppGUI();
if (!nppGui._stopFillingFindField)
if (nppGui._fillFindFieldWithSelected)
{
_pEditView->getGenericSelectedText(str, strSize);
_pEditView->getGenericSelectedText(str, strSize, nppGui._fillFindFieldSelectCaret);
_findReplaceDlg.setSearchText(str);
}

View File

@ -5477,9 +5477,21 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (optNameMonoFont)
_nppGUI._monospacedFontFindDlg = (lstrcmp(optNameMonoFont, TEXT("yes")) == 0);
//This is an option from previous versions of notepad++. It is handled for compatibility with older settings.
const TCHAR* optStopFillingFindField = element->Attribute(TEXT("stopFillingFindField"));
if (optStopFillingFindField)
_nppGUI._stopFillingFindField = (lstrcmp(optStopFillingFindField, TEXT("yes")) == 0);
if (optStopFillingFindField)
{
_nppGUI._fillFindFieldWithSelected = (lstrcmp(optStopFillingFindField, TEXT("no")) == 0);
_nppGUI._fillFindFieldSelectCaret = _nppGUI._fillFindFieldWithSelected;
}
const TCHAR* optFillFindFieldWithSelected = element->Attribute(TEXT("fillFindFieldWithSelected"));
if (optFillFindFieldWithSelected)
_nppGUI._fillFindFieldWithSelected = (lstrcmp(optFillFindFieldWithSelected, TEXT("yes")) == 0);
const TCHAR* optFillFindFieldSelectCaret = element->Attribute(TEXT("fillFindFieldSelectCaret"));
if (optFillFindFieldSelectCaret)
_nppGUI._fillFindFieldSelectCaret = (lstrcmp(optFillFindFieldSelectCaret, TEXT("yes")) == 0);
const TCHAR* optFindDlgAlwaysVisible = element->Attribute(TEXT("findDlgAlwaysVisible"));
if (optFindDlgAlwaysVisible)
@ -6680,7 +6692,8 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("Searching"));
GUIConfigElement->SetAttribute(TEXT("monospacedFontFindDlg"), _nppGUI._monospacedFontFindDlg ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("stopFillingFindField"), _nppGUI._stopFillingFindField ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("fillFindFieldWithSelected"), _nppGUI._fillFindFieldWithSelected ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("fillFindFieldSelectCaret"), _nppGUI._fillFindFieldSelectCaret ? 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("replaceStopsWithoutFindingNext"), _nppGUI._replaceStopsWithoutFindingNext ? TEXT("yes") : TEXT("no"));

View File

@ -799,7 +799,8 @@ struct NppGUI final
char _rightmostDelimiter = ')';
bool _delimiterSelectionOnEntireDocument = false;
bool _backSlashIsEscapeCharacterForSql = true;
bool _stopFillingFindField = false;
bool _fillFindFieldWithSelected = true;
bool _fillFindFieldSelectCaret = true;
bool _monospacedFontFindDlg = false;
bool _findDlgAlwaysVisible = false;
bool _confirmReplaceInAllOpenDocs = true;

View File

@ -322,13 +322,15 @@ IDD_PREFERENCE_SUB_SEARCHING DIALOGEX 0, 0, 455, 185
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "Don't fill find field in Find dialog with selected word", IDC_CHECK_STOPFILLINGFINDFIELD, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,10,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 "Confirm Replace All in All Opened Documents",IDC_CHECK_CONFIRMREPLOPENDOCS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,55,350,10
CONTROL "Replace: Don't move to the following occurrence", IDC_CHECK_REPLACEANDSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 70, 350, 10
CONTROL "Search Result window: show only one entry per found line", IDC_CHECK_SHOWONCEPERFOUNDLINE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 85, 350, 10
END
GROUPBOX "When Find Dialog is Invoked", IDD_FILL_FIND_FIELD_GRP_STATIC, 31, 4, 323, 43, BS_CENTER
CONTROL "Fill Find Field with Selected Text", IDC_CHECK_FILL_FIND_FIELD_WITH_SELECTED, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 16, 275, 10
CONTROL "Select Word Under Caret when Nothing Selected", IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 52, 31, 275, 10
CONTROL "Use Monospaced font in Find dialog (Need to restart Notepad++)", IDC_CHECK_MONOSPACEDFONT_FINDDLG, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 52, 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, 67, 350, 10
CONTROL "Confirm Replace All in All Opened Documents", IDC_CHECK_CONFIRMREPLOPENDOCS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 82, 350, 10
CONTROL "Replace: Don't move to the following occurrence", IDC_CHECK_REPLACEANDSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 97, 350, 10
CONTROL "Search Result window: show only one entry per found line", IDC_CHECK_SHOWONCEPERFOUNDLINE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 112, 350, 10
END
IDD_PREFERENCE_SUB_BACKUP DIALOGEX 0, 0, 455, 185

View File

@ -4950,9 +4950,11 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
case WM_INITDIALOG:
{
::SendDlgItemMessage(_hSelf, IDC_CHECK_STOPFILLINGFINDFIELD, BM_SETCHECK, nppGUI._stopFillingFindField, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILL_FIND_FIELD_WITH_SELECTED, BM_SETCHECK, nppGUI._fillFindFieldWithSelected, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET, BM_SETCHECK, nppGUI._fillFindFieldSelectCaret, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_MONOSPACEDFONT_FINDDLG, BM_SETCHECK, nppGUI._monospacedFontFindDlg, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_FINDDLG_ALWAYS_VISIBLE, BM_SETCHECK, nppGUI._findDlgAlwaysVisible, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
::SendDlgItemMessage(_hSelf, IDC_CHECK_CONFIRMREPLOPENDOCS, BM_SETCHECK, nppGUI._confirmReplaceInAllOpenDocs, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_REPLACEANDSTOP, BM_SETCHECK, nppGUI._replaceStopsWithoutFindingNext, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWONCEPERFOUNDLINE, BM_SETCHECK, nppGUI._finderShowOnlyOneEntryPerFoundLine, 0);
@ -4982,9 +4984,15 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
switch (wParam)
{
case IDC_CHECK_STOPFILLINGFINDFIELD:
case IDC_CHECK_FILL_FIND_FIELD_WITH_SELECTED:
{
nppGUI._stopFillingFindField = isCheckedOrNot(IDC_CHECK_STOPFILLINGFINDFIELD);
nppGUI._fillFindFieldWithSelected = isCheckedOrNot(IDC_CHECK_FILL_FIND_FIELD_WITH_SELECTED);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET), nppGUI._fillFindFieldWithSelected ? TRUE :FALSE);
if (!nppGUI._fillFindFieldWithSelected)
{
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET, BM_SETCHECK, BST_UNCHECKED, 0);
nppGUI._fillFindFieldSelectCaret = false;
}
return TRUE;
}
break;
@ -5024,6 +5032,13 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
}
break;
case IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET:
{
nppGUI._fillFindFieldSelectCaret = isCheckedOrNot(IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET);
return TRUE;
}
break;
default:
return FALSE;
}

View File

@ -399,12 +399,15 @@
#define IDD_AUTOC_USEENTER (IDD_PREFERENCE_SUB_AUTOCOMPLETION + 21)
#define IDD_PREFERENCE_SUB_SEARCHING 6900 //(IDD_PREFERENCE_BOX + 900)
#define IDC_CHECK_STOPFILLINGFINDFIELD (IDD_PREFERENCE_SUB_SEARCHING + 1)
//#define IDC_CHECK_STOPFILLINGFINDFIELD (IDD_PREFERENCE_SUB_SEARCHING + 1)
#define IDC_CHECK_MONOSPACEDFONT_FINDDLG (IDD_PREFERENCE_SUB_SEARCHING + 2)
#define IDC_CHECK_FINDDLG_ALWAYS_VISIBLE (IDD_PREFERENCE_SUB_SEARCHING + 3)
#define IDC_CHECK_CONFIRMREPLOPENDOCS (IDD_PREFERENCE_SUB_SEARCHING + 4)
#define IDC_CHECK_REPLACEANDSTOP (IDD_PREFERENCE_SUB_SEARCHING + 5)
#define IDC_CHECK_SHOWONCEPERFOUNDLINE (IDD_PREFERENCE_SUB_SEARCHING + 6)
#define IDD_FILL_FIND_FIELD_GRP_STATIC (IDD_PREFERENCE_SUB_SEARCHING + 7)
#define IDC_CHECK_FILL_FIND_FIELD_WITH_SELECTED (IDD_PREFERENCE_SUB_SEARCHING + 8)
#define IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET (IDD_PREFERENCE_SUB_SEARCHING + 9)
#define IDD_PREFERENCE_SUB_DARKMODE 7100 //(IDD_PREFERENCE_BOX + 1100)
#define IDC_CHECK_DARKMODE_ENABLE (IDD_PREFERENCE_SUB_DARKMODE + 1)