Skip to content

Commit 962a17e

Browse files
committed
Allow user to customize max selected chars to auto-fill "Find what" field
Add "Max Characters to Auto-Fill Find Field from Selection" option to allow users to customize max selected characters for auto-filling "Find what" field in Find dialog. The value can be set from 1 to 16383 characters (not byte). Note that if "Select Word Under Caret when Nothing Selected" is ON, the word's length in character will be limited also by the set value. Fix notepad-plus-plus#16955, close notepad-plus-plus#16983
1 parent d4442b9 commit 962a17e

File tree

14 files changed

+150
-49
lines changed

14 files changed

+150
-49
lines changed

PowerEditor/installer/nativeLang/english.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,7 @@ Translation note:
12141214
<Item id="6909" name="Select Word Under Caret when Nothing Selected"/>
12151215
<Item id="6910" name="Minimum Size for Auto-Checking &quot;In selection&quot;:"/>
12161216
<Item id="6913" name="Fill Find in Files Directory Field Based On Active Document"/>
1217+
<Item id="6916" name=": Max Characters to Auto-Fill Find Field from Selection"/>
12171218
</Searching>
12181219

12191220
<RecentFilesHistory title="Recent Files History">
@@ -1865,7 +1866,8 @@ Click on &quot;?&quot; button on right to open website with User Manual."/>
18651866
<!-- Don't translate "(&quot;Non-printing characters custom color&quot;)" -->
18661867
<npcCustomColor-tip value="Go to Style Configurator to change the default custom color for selected whitespace and non-printing characters (&quot;Non-printing characters custom color&quot;)."/>
18671868
<npcIncludeCcUniEol-tip value="Apply non-printing characters appearance settings to C0, C1 control and Unicode EOL (next line, line separator and paragraph separator) characters."/>
1868-
<searchingInSelThresh-tip value="Number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is 1024. Set the value to 0 to disable auto-checking."/>
1869+
<searchingInSelThresh-tip value="Minimum number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is $INT_REPLACE$. Set the value to 0 to disable auto-checking."/>
1870+
<searchingFillFindWhat-tip value="Maximun number of selected characters in edit zone to fill automatically the &quot;Find what&quot; field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of &quot;Find what&quot; field, limited by the system."/>
18691871
<verticalEdge-tip value="Add your column marker by indicating its position with a decimal number. You can define several column markers by using white space to separate the different numbers."/>
18701872
<fileSaveAsCopySaveButton-tip value="Hold Shift while pressing Save to open the copy after saving."/>
18711873
<autoIndentBasic-tip value="Ensure that the indentation of the current line (i.e. the new line created by pressing the ENTER key) matches the indentation of the previous line."/>

PowerEditor/installer/nativeLang/english_customizable.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,7 @@ Translation note:
12141214
<Item id="6909" name="Select Word Under Caret when Nothing Selected"/>
12151215
<Item id="6910" name="Minimum Size for Auto-Checking &quot;In selection&quot;:"/>
12161216
<Item id="6913" name="Fill Find in Files Directory Field Based On Active Document"/>
1217+
<Item id="6916" name=": Max Characters to Auto-Fill Find Field from Selection"/>
12171218
</Searching>
12181219

12191220
<RecentFilesHistory title="Recent Files History">
@@ -1865,7 +1866,8 @@ Click on &quot;?&quot; button on right to open website with User Manual."/>
18651866
<!-- Don't translate "(&quot;Non-printing characters custom color&quot;)" -->
18661867
<npcCustomColor-tip value="Go to Style Configurator to change the default custom color for selected whitespace and non-printing characters (&quot;Non-printing characters custom color&quot;)."/>
18671868
<npcIncludeCcUniEol-tip value="Apply non-printing characters appearance settings to C0, C1 control and Unicode EOL (next line, line separator and paragraph separator) characters."/>
1868-
<searchingInSelThresh-tip value="Number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is 1024. Set the value to 0 to disable auto-checking."/>
1869+
<searchingInSelThresh-tip value="Minimum number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is $INT_REPLACE$. Set the value to 0 to disable auto-checking."/>
1870+
<searchingFillFindWhat-tip value="Maximun number of selected characters in edit zone to fill automatically the &quot;Find what&quot; field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of &quot;Find what&quot; field, limited by the system."/>
18691871
<verticalEdge-tip value="Add your column marker by indicating its position with a decimal number. You can define several column markers by using white space to separate the different numbers."/>
18701872
<fileSaveAsCopySaveButton-tip value="Hold Shift while pressing Save to open the copy after saving."/>
18711873
<autoIndentBasic-tip value="Ensure that the indentation of the current line (i.e. the new line created by pressing the ENTER key) matches the indentation of the previous line."/>

PowerEditor/installer/nativeLang/french.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,8 @@ Translation note:
12111211
<Item id="6908" name="Remplir le champ de recherche avec le texte sélectionné"/>
12121212
<Item id="6909" name="Sélectionner le mot sous le curseur si rien n’est sélectionné"/>
12131213
<Item id="6910" name="Taille minimale pour l’auto-coche de « Dans la sélection » :"/>
1214-
<Item id="6913" name="Remplir le champ Répertoire de la Recherche dans les fichiers en se basant sur la document actif"/>
1214+
<Item id="6913" name="Remplir le champ de &quot;Dossier&quot; de &quot;Recherche dans les fichiers&quot; avec chemin du fichier actif"/>
1215+
<Item id="6916" name=" : Nombre max. de caractères sélectionnés à copier dans le champ de recherche"/>
12151216
</Searching>
12161217

12171218
<RecentFilesHistory title="Fichiers récents">
@@ -1860,7 +1861,8 @@ Cliquez sur le bouton « ? » à droite pour ouvrir le site web du manuel utilis
18601861
<!-- Don't translate "(&quot;Non-printing characters custom color&quot;)" -->
18611862
<npcCustomColor-tip value="Aller dans le Configurateur de style pour changer la couleur personnalisée par défaut pour la sélection des caractères blancs et des caractères non-imprimables (« Couleur personnalisée des caractères non-imprimables »)."/>
18621863
<npcIncludeCcUniEol-tip value="Applique les paramètres d’apparence des caractères non-imprimables aux contrôles C0, C1 et aux caractères Unicode EOL (ligne suivante, séparateur de ligne et séparateur de paragraphe)."/>
1863-
<searchingInSelThresh-tip value="Nombre de caractères sélectionnés dans la zone d’édition pour cocher automatiquement la case « Dans sélection » quand la fenêtre de recherche est activée. La valeur maximale est 1024. Mettre la valeur à 0 pour désactiver l’auto-coche."/>
1864+
<searchingInSelThresh-tip value="Nombre minimal de caractères sélectionnés dans la zone d’édition pour cocher automatiquement la case « Dans sélection » quand la fenêtre de recherche est activée. La valeur maximale est $INT_REPLACE$. Mettre la valeur à 0 pour désactiver l’auto-coche."/>
1865+
<searchingFillFindWhat-tip value="Nombre maximal de caractères sélectionnés dans la zone de texte à utiliser pour remplir automatiquement le champ « Rechercher » lors de l'activation de la combinaison Ctrl+F. La valeur maximale est $INT_REPLACE$, soit la taille maximale du champ « Rechercher », limitée par le système."/>
18641866
<verticalEdge-tip value="Ajoutez votre marqueur de colonne en indiquant sa position avec un nombre entier. Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour séparer les différents nombres."/>
18651867
<fileSaveAsCopySaveButton-tip value="Maintenez Shift en appuyant sur Enregistrer pour ouvrir une copie après enregistrement."/>
18661868
<autoIndentBasic-tip value="Assurez-vous que la ligne courante (c'est-à-dire la nouvelle ligne saisie en appuyant sur ENTRÉE) a la même indentation que la ligne précédente."/>

PowerEditor/installer/nativeLang/taiwaneseMandarin.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,8 @@
11671167
<Item id="6908" name="用選取詞填充尋找與取代對話方塊中的尋找內容"/>
11681168
<Item id="6909" name="在沒有任何選取時,選取游標下的字串"/>
11691169
<Item id="6910" name="啟動自動勾選核取方塊「僅尋找選取範圍」的最小值:"/>
1170+
<Item id="6913" name="根據目前啟用文件的路徑自動填入「在多個檔案中尋找」的「資料夾」欄"/>
1171+
<Item id="6916" name=":從選定內容中自動填入查找欄位的最大字元數"/>
11701172
</Searching>
11711173

11721174
<RecentFilesHistory title="最近使用的檔案">
@@ -1686,7 +1688,8 @@
16861688
1. 修改這些選項需要重新開啟已開啟的大型文件以達到預期的效果。
16871689
16881690
2. 如果「停用自動換行」被啟動,在開啟一個大型文件時,「自動換行」將對所有文件停用。 你可以通過選單「檢視-&gt;自動換行」重新啟動這個功能。"/>
1689-
<searchingInSelThresh-tip value="在尋找與取代對話方塊啟動時,為啟動自動勾選核取方塊「僅尋找選取範圍」在編輯區中選取的字符數量。 最大值為 1024。 將值設置為 0 將停止自動勾選功能。"/>
1691+
<searchingInSelThresh-tip value="在尋找與取代對話方塊啟動時,為啟動自動勾選核取方塊「僅尋找選取範圍」在編輯區中選取的最小字符數量。 最大值為 $INT_REPLACE$。 將值設置為 0 將停止自動勾選功能。"/>
1692+
<searchingFillFindWhat-tip value="在尋找與取代對話方塊啟動時,為啟動自動填入「尋找內容」欄位,以編輯區域中選定字元的最大值(最多 $INT_REPLACE 個字元)。此值是「尋找內容」欄位的最大長度,由系統限制。"/>
16901693
<verticalEdge-tip value="如欲添加列標記可以在下面以數字指示其列位置。使用空格分隔不同數字來定義多個列標記。"/>
16911694
<autoIndentBasic-tip value="確保目前行(即按 ENTER 鍵所打的新行)的縮排與上一行的縮排相同。"/>
16921695
<autoIndentAdvanced-tip value="啟用為「類 C 語言」和 Python 建構的智慧縮排 。 「類 C 語言」包括:

PowerEditor/src/NppBigSwitch.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
515515
std::fill_n(str.get(), strSize, L'\0');
516516

517517
_pEditView->getGenericSelectedText(str.get(), strSize, nppGui._fillFindFieldSelectCaret);
518-
_findReplaceDlg.setSearchText(str.get());
518+
519+
int selLen = lstrlen(str.get());
520+
if (selLen > 0 && selLen <= nppGui._fillFindWhatThreshold)
521+
{
522+
_findReplaceDlg.setSearchText(str.get());
523+
}
519524
}
520525

521526
if (isFirstTime)

PowerEditor/src/NppCommands.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,8 @@ void Notepad_plus::command(int id)
13771377

13781378
if (nppGui._fillFindFieldWithSelected)
13791379
{
1380-
if (lstrlen(str.get()) <= FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT)
1380+
int selLen = lstrlen(str.get());
1381+
if (selLen > 0 && selLen <= nppGui._fillFindWhatThreshold)
13811382
{
13821383
_findReplaceDlg.setSearchText(str.get());
13831384
}

PowerEditor/src/Parameters.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6185,6 +6185,17 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
61856185
_nppGUI._inSelectionAutocheckThreshold = FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT;
61866186
}
61876187

6188+
int fillFindWhatThresh;
6189+
if (element->Attribute(L"fillFindWhatThreshold", &fillFindWhatThresh) &&
6190+
(fillFindWhatThresh >= 1 && fillFindWhatThresh <= FINDREPLACE_MAXLENGTH - 1))
6191+
{
6192+
_nppGUI._fillFindWhatThreshold = fillFindWhatThresh;
6193+
}
6194+
else
6195+
{
6196+
_nppGUI._fillFindWhatThreshold = FILL_FINDWHAT_THRESHOLD_DEFAULT;
6197+
}
6198+
61886199
const wchar_t* optFillDirFieldFromActiveDoc = element->Attribute(L"fillDirFieldFromActiveDoc");
61896200
if (optFillDirFieldFromActiveDoc)
61906201
{
@@ -7827,6 +7838,7 @@ void NppParameters::createXmlTreeFromGUIParams()
78277838
GUIConfigElement->SetAttribute(L"confirmReplaceInAllOpenDocs", _nppGUI._confirmReplaceInAllOpenDocs ? L"yes" : L"no");
78287839
GUIConfigElement->SetAttribute(L"replaceStopsWithoutFindingNext", _nppGUI._replaceStopsWithoutFindingNext ? L"yes" : L"no");
78297840
GUIConfigElement->SetAttribute(L"inSelectionAutocheckThreshold", _nppGUI._inSelectionAutocheckThreshold);
7841+
GUIConfigElement->SetAttribute(L"fillFindWhatThreshold", _nppGUI._fillFindWhatThreshold);
78307842
GUIConfigElement->SetAttribute(L"fillDirFieldFromActiveDoc", _nppGUI._fillDirFieldFromActiveDoc ? L"yes" : L"no");
78317843
}
78327844

PowerEditor/src/Parameters.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ const int COPYDATA_FULL_CMDLINE = 3;
164164

165165
#define NPP_STYLING_FILESIZE_LIMIT_DEFAULT (200 * 1024 * 1024) // 200MB+ file won't be styled
166166

167+
#define FINDREPLACE_MAXLENGTH 16384 // the maximum length of the string (decrease 1 for '\0') to search in the editor
168+
167169
const int FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT = 1024;
170+
const int FILL_FINDWHAT_THRESHOLD_DEFAULT = 1024;
168171

169172
const wchar_t fontSizeStrs[][3] = {L"", L"5", L"6", L"7", L"8", L"9", L"10", L"11", L"12", L"14", L"16", L"18", L"20", L"22", L"24", L"26", L"28"};
170173

@@ -906,6 +909,7 @@ struct NppGUI final
906909
bool _confirmReplaceInAllOpenDocs = true;
907910
bool _replaceStopsWithoutFindingNext = false;
908911
int _inSelectionAutocheckThreshold = FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT;
912+
int _fillFindWhatThreshold = FILL_FINDWHAT_THRESHOLD_DEFAULT;
909913
bool _fillDirFieldFromActiveDoc = false;
910914
bool _muteSounds = false;
911915
bool _enableFoldCmdToggable = false;

PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4053,7 +4053,7 @@ void FindReplaceDlg::setSearchText(wchar_t * txt2find)
40534053
HWND hEdit = GetWindow(hCombo, GW_CHILD);
40544054
if (hEdit)
40554055
{
4056-
::SendMessage(hEdit, EM_SETSEL, 0, static_cast<WPARAM>(-1));
4056+
::SendMessage(hEdit, EM_SETSEL, 0, static_cast<WPARAM>(-1)); // Select all text
40574057
::SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)txt2find);
40584058
}
40594059
}

PowerEditor/src/ScintillaComponent/FindReplaceDlg.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#define FIND_INVALID_REGULAR_EXPRESSION -2
3131

32-
#define FINDREPLACE_MAXLENGTH 16384 // the maximum length of the string (decrease 1 for '\0') to search in the editor
3332
#define FINDREPLACE_MAXLENGTH2SAVE 2048 // the maximum length of the string (decrease 1 for '\0') to save in the config.xml file
3433

3534
#define FINDTEMPSTRING_MAXSIZE 1024*1024

0 commit comments

Comments
 (0)