mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-09-21 17:08:12 +02:00
Fix filling Find what length not accurate problem
+ a lot of refactoring Ref: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/16955#issuecomment-3287770729 Fix #16955, fix #16992, close #17001
This commit is contained in:
parent
7a1cde702a
commit
be59048c5e
@ -1867,7 +1867,7 @@ Click on "?" button on right to open website with User Manual."/>
|
||||
<npcCustomColor-tip value="Go to Style Configurator to change the default custom color for selected whitespace and non-printing characters ("Non-printing characters custom color")."/>
|
||||
<npcIncludeCcUniEol-tip value="Apply non-printing characters appearance settings to C0, C1 control and Unicode EOL (next line, line separator and paragraph separator) characters."/>
|
||||
<searchingInSelThresh-tip value="Minimum number of selected characters in edit zone to automatically check the "In selection" checkbox when the Find dialog is activated. The maximum value is $INT_REPLACE$. Set the value to 0 to disable auto-checking."/>
|
||||
<searchingFillFindWhat-tip value="Maximun number of selected characters in edit zone to fill automatically the "Find what" field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of "Find what" field, limited by the system."/>
|
||||
<searchingFillFindWhat-tip value="Maximum number of selected characters in edit zone to fill automatically the "Find what" field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of "Find what" field, limited by the system."/>
|
||||
<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."/>
|
||||
<fileSaveAsCopySaveButton-tip value="Hold Shift while pressing Save to open the copy after saving."/>
|
||||
<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."/>
|
||||
@ -1891,8 +1891,9 @@ If you select advanced mode but do not edit files in the aforementioned language
|
||||
<statusbar-Sel value="Sel: "/>
|
||||
<statusbar-Sel-number value="Sel"/>
|
||||
<toolbar-accent-tip value="This option makes your toolbar icons follow Windows system accent color. Accent color is the highlight color used in buttons, borders, and Start menu tiles in Windows. To change it, go to Settings > Personalization > Colors, then select your preferred accent color."/>
|
||||
<max-len-on-search-tip value="Only $INT_REPLACE$ characters are allowed for the find/replace text length - your input could be truncated, and it won't be saved for the next session."/>
|
||||
<max-len-on-save-tip value="This search input (> $INT_REPLACE$ characters) won't be saved for the next session."/>
|
||||
<len-limit-exceeded-tip value="Length limit exceeded: Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session."/>
|
||||
<max-len-on-search-tip value="Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session."/>
|
||||
<max-len-on-save-tip value="The length of your input is very long and may not be saved for your next session."/>
|
||||
<goto-setting-tip value="Find your setting here"/>
|
||||
</MiscStrings>
|
||||
</Native-Langue>
|
||||
|
@ -1867,7 +1867,7 @@ Click on "?" button on right to open website with User Manual."/>
|
||||
<npcCustomColor-tip value="Go to Style Configurator to change the default custom color for selected whitespace and non-printing characters ("Non-printing characters custom color")."/>
|
||||
<npcIncludeCcUniEol-tip value="Apply non-printing characters appearance settings to C0, C1 control and Unicode EOL (next line, line separator and paragraph separator) characters."/>
|
||||
<searchingInSelThresh-tip value="Minimum number of selected characters in edit zone to automatically check the "In selection" checkbox when the Find dialog is activated. The maximum value is $INT_REPLACE$. Set the value to 0 to disable auto-checking."/>
|
||||
<searchingFillFindWhat-tip value="Maximun number of selected characters in edit zone to fill automatically the "Find what" field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of "Find what" field, limited by the system."/>
|
||||
<searchingFillFindWhat-tip value="Maximum number of selected characters in edit zone to fill automatically the "Find what" field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of "Find what" field, limited by the system."/>
|
||||
<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."/>
|
||||
<fileSaveAsCopySaveButton-tip value="Hold Shift while pressing Save to open the copy after saving."/>
|
||||
<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."/>
|
||||
@ -1891,8 +1891,9 @@ If you select advanced mode but do not edit files in the aforementioned language
|
||||
<statusbar-Sel value="Sel: "/>
|
||||
<statusbar-Sel-number value="Sel"/>
|
||||
<toolbar-accent-tip value="This option makes your toolbar icons follow Windows system accent color. Accent color is the highlight color used in buttons, borders, and Start menu tiles in Windows. To change it, go to Settings > Personalization > Colors, then select your preferred accent color."/>
|
||||
<max-len-on-search-tip value="Only $INT_REPLACE$ characters are allowed for the find/replace text length - your input could be truncated, and it won't be saved for the next session."/>
|
||||
<max-len-on-save-tip value="This search input (> $INT_REPLACE$ characters) won't be saved for the next session."/>
|
||||
<len-limit-exceeded-tip value="Length limit exceeded: Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session."/>
|
||||
<max-len-on-search-tip value="Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session."/>
|
||||
<max-len-on-save-tip value="The length of your input is very long and may not be saved for your next session."/>
|
||||
<goto-setting-tip value="Find your setting here"/>
|
||||
</MiscStrings>
|
||||
</Native-Langue>
|
||||
|
@ -1886,8 +1886,9 @@ Si vous sélectionnez le mode avancé sans modifier les fichiers des langues men
|
||||
<statusbar-Sel value="Sel : "/>
|
||||
<statusbar-Sel-number value="Sel"/>
|
||||
<toolbar-accent-tip value="Cette option permet aux icônes de votre barre d'outils d'adopter la couleur d'accentuation du système Windows. La couleur d'accentuation est la couleur de surbrillance utilisée pour les boutons, les bordures et les tuiles du menu Démarrer sous Windows. Pour la modifier, accédez à Paramètres > Personnalisation > Couleurs, puis sélectionnez votre couleur d'accentuation préférée."/>
|
||||
<max-len-on-search-tip value="Seuls $INT_REPLACE$ caractères sont autorisés pour la longueur du texte de recherche/remplacement - votre saisie pourrait être tronquée et ne serait pas enregistrée pour la session suivante."/>
|
||||
<max-len-on-save-tip value="Cette entrée de recherche (> $INT_REPLACE$ caractères) ne sera pas enregistrée pour la prochaine session."/>
|
||||
<len-limit-exceeded-tip value="Limite de longueur dépassée : Votre saisie peut dépasser la limite autorisée et avoir été tronquée, et elle ne sera pas enregistrée pour la prochaine session."/>
|
||||
<max-len-on-search-tip value="Votre saisie peut dépasser la limite autorisée et avoir été tronquée, et elle ne sera pas enregistrée pour la prochaine session."/>
|
||||
<max-len-on-save-tip value="La longueur de votre saisie est très longue et il se peut qu'elle ne soit pas enregistrée pour votre prochaine session."/>
|
||||
<goto-setting-tip value="Réglage du paramètre ici"/>
|
||||
</MiscStrings>
|
||||
</Native-Langue>
|
||||
|
@ -1711,8 +1711,9 @@ C、C++、Java、C#、Objective-C、PHP、JavaScript、JSP、CSS、Perl、Rust
|
||||
<statusbar-Sel value="選取:"/>
|
||||
<statusbar-Sel-number value="選取"/>
|
||||
<toolbar-accent-tip value="此選項可讓您的工具列圖示遵循 Windows 系統強調色。強調色是 Windows 中的按鈕、邊框和開始功能表圖塊所使用的反白顯示顏色。要更改它,請轉到「設定」>「個性化」>「顏色」,然後選擇您喜歡的強調色。"/>
|
||||
<max-len-on-search-tip value="尋找/取代文字長度僅允許 $INT_REPLACE$ 個字元 - 您的輸入可能會被截斷,此搜尋輸入也將不會保存以供下次 Notepad++ 啟動時使用。"/>
|
||||
<max-len-on-save-tip value="此搜尋輸入( > $INT_REPLACE$ 個字元)將不會保存以供下次 Notepad++ 啟動時使用。"/>
|
||||
<len-limit-exceeded-tip value="已超出長度限制:輸入內容可能超出允許的限制並已被截斷,此輸入也將不會保存以供下次 Notepad++ 啟動時使用。"/>
|
||||
<max-len-on-search-tip value="輸入內容可能超出允許的限制並已被截斷,此輸入也將不會保存以供下次 Notepad++ 啟動時使用。"/>
|
||||
<max-len-on-save-tip value="輸入內容過長,可能無法保存以供下次 Notepad++ 啟動時使用。"/>
|
||||
<goto-setting-tip value="相關的偏好設定在此"/>
|
||||
</MiscStrings>
|
||||
</Native-Langue>
|
||||
|
@ -503,25 +503,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
case NPPM_LAUNCHFINDINFILESDLG:
|
||||
{
|
||||
// Find in files function code should be here due to the number of parameters (2) cannot be passed via WM_COMMAND
|
||||
constexpr int strSize = FINDREPLACE_MAXLENGTH;
|
||||
|
||||
bool isFirstTime = !_findReplaceDlg.isCreated();
|
||||
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
|
||||
|
||||
const NppGUI& nppGui = nppParam.getNppGUI();
|
||||
if (nppGui._fillFindFieldWithSelected)
|
||||
{
|
||||
auto str = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(str.get(), strSize, L'\0');
|
||||
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize, nppGui._fillFindFieldSelectCaret);
|
||||
|
||||
int selLen = lstrlen(str.get());
|
||||
if (selLen > 0 && selLen <= nppGui._fillFindWhatThreshold)
|
||||
{
|
||||
_findReplaceDlg.setSearchText(str.get());
|
||||
}
|
||||
}
|
||||
_findReplaceDlg.setSearchTextWithSettings();
|
||||
|
||||
if (isFirstTime)
|
||||
_nativeLangSpeaker.changeFindReplaceDlgLang(_findReplaceDlg);
|
||||
@ -533,17 +519,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_INTERNAL_FINDINPROJECTS:
|
||||
{
|
||||
constexpr int strSize = FINDREPLACE_MAXLENGTH;
|
||||
auto str = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(str.get(), strSize, L'\0');
|
||||
|
||||
bool isFirstTime = not _findReplaceDlg.isCreated();
|
||||
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
|
||||
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize);
|
||||
_findReplaceDlg.setSearchText(str.get());
|
||||
_findReplaceDlg.setSearchTextWithSettings();
|
||||
|
||||
if (isFirstTime)
|
||||
_nativeLangSpeaker.changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
|
||||
|
||||
_findReplaceDlg.launchFindInProjectsDlg();
|
||||
_findReplaceDlg.setProjectCheckmarks(NULL, (int) wParam);
|
||||
return TRUE;
|
||||
@ -551,18 +534,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_INTERNAL_FINDINFINDERDLG:
|
||||
{
|
||||
constexpr int strSize = FINDREPLACE_MAXLENGTH;
|
||||
auto str = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(str.get(), strSize, L'\0');
|
||||
|
||||
Finder *launcher = reinterpret_cast<Finder *>(wParam);
|
||||
|
||||
bool isFirstTime = !_findInFinderDlg.isCreated();
|
||||
|
||||
_findInFinderDlg.doDialog(launcher, _nativeLangSpeaker.isRTL());
|
||||
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize);
|
||||
_findReplaceDlg.setSearchText(str.get());
|
||||
_findReplaceDlg.setSearchTextWithSettings();
|
||||
setFindReplaceFolderFilter(NULL, NULL);
|
||||
|
||||
if (isFirstTime)
|
||||
@ -1033,9 +1011,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
wchar_t *pTchar = reinterpret_cast<wchar_t *>(lParam);
|
||||
|
||||
if (message == NPPM_GETCURRENTWORD)
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize);
|
||||
{
|
||||
auto txtW = _pEditView->getSelectedTextToWChar();
|
||||
if (txtW)
|
||||
wcscpy_s(str.get(), strSize, txtW);
|
||||
}
|
||||
else if (message == NPPM_GETCURRENTLINESTR)
|
||||
{
|
||||
_pEditView->getLine(_pEditView->getCurrentLineNumber(), str.get(), strSize);
|
||||
}
|
||||
|
||||
// For the compatibility reason, if wParam is 0, then we assume the size of wstring buffer (lParam) is large enough.
|
||||
// otherwise we check if the wstring buffer size is enough for the wstring to copy.
|
||||
@ -1065,7 +1049,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
int hasSlash = 0;
|
||||
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize); // this is either the selected text, or the word under the cursor if there is no selection
|
||||
auto txtW = _pEditView->getSelectedTextToWChar(); // this is either the selected text, or the word under the cursor if there is no selection
|
||||
if (txtW)
|
||||
wcscpy_s(str.get(), strSize, txtW);
|
||||
|
||||
hasSlash = FALSE;
|
||||
for (int i = 0; str[i] != 0; i++)
|
||||
if (CharacterIs(str[i], L"\\/"))
|
||||
|
@ -439,7 +439,7 @@ void Notepad_plus::command(int id)
|
||||
auto pBinText = std::make_unique<char[]>(strSize);
|
||||
std::fill_n(pBinText.get(), strSize, '\0');
|
||||
|
||||
_pEditView->getSelectedText(pBinText.get(), textLen + 1);
|
||||
_pEditView->getSelectedTextToMultiChar(pBinText.get(), textLen + 1);
|
||||
|
||||
// Open the clipboard and empty it.
|
||||
if (!::OpenClipboard(NULL))
|
||||
@ -1356,16 +1356,6 @@ void Notepad_plus::command(int id)
|
||||
case IDM_SEARCH_REPLACE :
|
||||
case IDM_SEARCH_MARK :
|
||||
{
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
auto str = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(str.get(), strSize, L'\0');
|
||||
|
||||
const NppGUI& nppGui = (NppParameters::getInstance()).getNppGUI();
|
||||
if (nppGui._fillFindFieldWithSelected)
|
||||
{
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize, nppGui._fillFindFieldSelectCaret);
|
||||
}
|
||||
|
||||
bool isFirstTime = !_findReplaceDlg.isCreated();
|
||||
|
||||
DIALOG_TYPE dlgID = FIND_DLG;
|
||||
@ -1375,14 +1365,7 @@ void Notepad_plus::command(int id)
|
||||
dlgID = MARK_DLG;
|
||||
_findReplaceDlg.doDialog(dlgID, _nativeLangSpeaker.isRTL());
|
||||
|
||||
if (nppGui._fillFindFieldWithSelected)
|
||||
{
|
||||
int selLen = lstrlen(str.get());
|
||||
if (selLen > 0 && selLen <= nppGui._fillFindWhatThreshold)
|
||||
{
|
||||
_findReplaceDlg.setSearchText(str.get());
|
||||
}
|
||||
}
|
||||
_findReplaceDlg.setSearchTextWithSettings();
|
||||
|
||||
setFindReplaceFolderFilter(NULL, NULL);
|
||||
|
||||
@ -1399,10 +1382,6 @@ void Notepad_plus::command(int id)
|
||||
|
||||
case IDM_SEARCH_FINDINCREMENT :
|
||||
{
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
auto str = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(str.get(), strSize, L'\0');
|
||||
|
||||
static bool isFirstTime = true;
|
||||
if (isFirstTime)
|
||||
{
|
||||
@ -1410,9 +1389,9 @@ void Notepad_plus::command(int id)
|
||||
isFirstTime = false;
|
||||
}
|
||||
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize, false);
|
||||
if (0 != str[0]) // the selected text is not empty, then use it
|
||||
_incrementFindDlg.setSearchText(str.get(), _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit);
|
||||
auto str = _pEditView->getSelectedTextToWChar(false);
|
||||
if (str) // the selected text is not empty, then use it
|
||||
_incrementFindDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit);
|
||||
|
||||
_incrementFindDlg.display();
|
||||
}
|
||||
@ -1460,13 +1439,11 @@ void Notepad_plus::command(int id)
|
||||
if (isFirstTime)
|
||||
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL(), false);
|
||||
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
auto str = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(str.get(), strSize, L'\0');
|
||||
const wchar_t* str = _findReplaceDlg.setSearchTextWithSettings();
|
||||
if (!str) return;
|
||||
|
||||
_findReplaceDlg._env->_str2Search = str;
|
||||
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize);
|
||||
_findReplaceDlg.setSearchText(str.get());
|
||||
_findReplaceDlg._env->_str2Search = str.get();
|
||||
setFindReplaceFolderFilter(NULL, NULL);
|
||||
if (isFirstTime)
|
||||
_nativeLangSpeaker.changeFindReplaceDlgLang(_findReplaceDlg);
|
||||
@ -1476,7 +1453,7 @@ void Notepad_plus::command(int id)
|
||||
op._whichDirection = (id == IDM_SEARCH_SETANDFINDNEXT?DIR_DOWN:DIR_UP);
|
||||
|
||||
FindStatus status = FSNoMessage;
|
||||
_findReplaceDlg.processFindNext(str.get(), &op, &status);
|
||||
_findReplaceDlg.processFindNext(str, &op, &status);
|
||||
if (status == FSEndReached)
|
||||
{
|
||||
wstring msg = _nativeLangSpeaker.getLocalizedStrFromID("find-status-end-reached", FIND_STATUS_END_REACHED_TEXT);
|
||||
@ -1515,10 +1492,8 @@ void Notepad_plus::command(int id)
|
||||
case IDM_SEARCH_VOLATILE_FINDNEXT :
|
||||
case IDM_SEARCH_VOLATILE_FINDPREV :
|
||||
{
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
auto str = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(str.get(), strSize, L'\0');
|
||||
_pEditView->getGenericSelectedText(str.get(), strSize);
|
||||
auto str = _pEditView->getSelectedTextToWChar();
|
||||
if (!str) return;
|
||||
|
||||
FindOption op;
|
||||
op._isMatchCase = false;
|
||||
@ -1528,7 +1503,7 @@ void Notepad_plus::command(int id)
|
||||
op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT ? DIR_DOWN : DIR_UP);
|
||||
|
||||
FindStatus status = FSNoMessage;
|
||||
_findReplaceDlg.processFindNext(str.get(), &op, &status);
|
||||
_findReplaceDlg.processFindNext(str, &op, &status);
|
||||
if (status == FSEndReached)
|
||||
{
|
||||
wstring msg = _nativeLangSpeaker.getLocalizedStrFromID("find-status-end-reached", FIND_STATUS_END_REACHED_TEXT);
|
||||
@ -1560,26 +1535,11 @@ void Notepad_plus::command(int id)
|
||||
else // (id == IDM_SEARCH_MARKALLEXT5)
|
||||
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT5;
|
||||
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
auto selectedText = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(selectedText.get(), strSize, L'\0');
|
||||
auto selectedText = _pEditView->getSelectedTextToWChar(true);
|
||||
|
||||
auto wordOnCaret = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(wordOnCaret.get(), strSize, L'\0');
|
||||
|
||||
_pEditView->getGenericSelectedText(selectedText.get(), strSize, false);
|
||||
_pEditView->getGenericWordOnCaretPos(wordOnCaret.get(), strSize);
|
||||
|
||||
if (selectedText[0] == '\0')
|
||||
if (selectedText)
|
||||
{
|
||||
if (lstrlen(wordOnCaret.get()) > 0)
|
||||
{
|
||||
_findReplaceDlg.markAll(wordOnCaret.get(), styleID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_findReplaceDlg.markAll(selectedText.get(), styleID);
|
||||
_findReplaceDlg.markAll(selectedText, styleID);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -3506,20 +3466,16 @@ void Notepad_plus::command(int id)
|
||||
case IDM_ABOUT:
|
||||
{
|
||||
bool doAboutDlg = false;
|
||||
const int maxSelLen = 64;
|
||||
auto textLen = _pEditView->execute(SCI_GETSELTEXT, 0, 0);
|
||||
if (textLen <= 0)
|
||||
doAboutDlg = true;
|
||||
if (textLen > maxSelLen)
|
||||
doAboutDlg = true;
|
||||
|
||||
if (!doAboutDlg)
|
||||
{
|
||||
char author[maxSelLen+1] = "";
|
||||
_pEditView->getSelectedText(author, maxSelLen + 1);
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
const wchar_t * authorW = wmc.char2wchar(author, _nativeLangSpeaker.getLangEncoding());
|
||||
int iQuote = getQuoteIndexFrom(authorW);
|
||||
int iQuote = -1;
|
||||
auto authorW = _pEditView->getSelectedTextToWChar();
|
||||
if (authorW)
|
||||
iQuote = getQuoteIndexFrom(authorW);
|
||||
|
||||
if (iQuote == -1)
|
||||
{
|
||||
|
@ -420,9 +420,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
{
|
||||
if (nppGui._smartHiliteOnAnotherView)
|
||||
{
|
||||
wchar_t selectedText[1024];
|
||||
_pEditView->getGenericSelectedText(selectedText, sizeof(selectedText) / sizeof(wchar_t), false);
|
||||
_smartHighlighter.highlightViewWithWord(notifyView, selectedText);
|
||||
auto selectedText = _pEditView->getSelectedTextToWChar(false);
|
||||
if (selectedText)
|
||||
_smartHighlighter.highlightViewWithWord(notifyView, selectedText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1579,8 +1579,8 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
||||
HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH);
|
||||
|
||||
::SendMessage(hFindCombo, CB_LIMITTEXT, FINDREPLACE_MAXLENGTH - 1, 0);
|
||||
::SendMessage(hReplaceCombo, CB_LIMITTEXT, FINDREPLACE_MAXLENGTH - 1, 0);
|
||||
::SendMessage(hFindCombo, CB_LIMITTEXT, FINDREPLACE_MAXLENGTH * 2 - 1, 0);
|
||||
::SendMessage(hReplaceCombo, CB_LIMITTEXT, FINDREPLACE_MAXLENGTH * 2 - 1, 0);
|
||||
|
||||
HWND hFiltersCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO);
|
||||
HWND hDirCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO);
|
||||
@ -1972,16 +1972,40 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
if (HIWORD(wParam) == CBN_EDITUPDATE)
|
||||
{
|
||||
HWND hComboBox = ::GetDlgItem(_hSelf, LOWORD(wParam));
|
||||
LRESULT length = ::GetWindowTextLength(hComboBox);
|
||||
HWND hEdit = GetWindow(hComboBox, GW_CHILD);
|
||||
if (!hEdit)
|
||||
return FALSE;
|
||||
|
||||
static int maxLength = (int)SendMessage(hEdit, EM_GETLIMITTEXT, 0, 0);
|
||||
LRESULT length = ::GetWindowTextLength(hEdit);
|
||||
|
||||
if (length >= FINDREPLACE_MAXLENGTH - 1)
|
||||
if (length >= maxLength) // should be (FINDREPLACE_MAXLENGTH * 2 - 1)
|
||||
{
|
||||
if (!_maxLenOnSearchTip.isValid()) // Create the tooltip and add the tool ONLY ONCE
|
||||
{
|
||||
NativeLangSpeaker* pNativeSpeaker = nppParamInst.getNativeLangSpeaker();
|
||||
wstring tip = pNativeSpeaker->getLocalizedStrFromID("max-len-on-search-tip", L"Only $INT_REPLACE$ characters are allowed for the find/replace text length - your input could be truncated, and it won't be saved for the next session.");
|
||||
tip = stringReplace(tip, L"$INT_REPLACE$", std::to_wstring(FINDREPLACE_MAXLENGTH - 1));
|
||||
wstring tip = pNativeSpeaker->getLocalizedStrFromID("len-limit-exceeded-tip", L"Length limit exceeded: Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session.");
|
||||
|
||||
static wstring maxLenOnSearchTip = tip;
|
||||
|
||||
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSearchTip.c_str(), _isRTL, 0, 170);
|
||||
|
||||
if (!isSuccessful)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
|
||||
}
|
||||
_maxLenOnSearchTip.show(ControlInfoTip::showPosition::beginning);
|
||||
|
||||
}
|
||||
else if (length > FINDREPLACE_MAXLENGTH - 1)
|
||||
{
|
||||
if (!_maxLenOnSearchTip.isValid()) // Create the tooltip and add the tool ONLY ONCE
|
||||
{
|
||||
NativeLangSpeaker* pNativeSpeaker = nppParamInst.getNativeLangSpeaker();
|
||||
wstring tip = pNativeSpeaker->getLocalizedStrFromID("max-len-on-search-tip", L"Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session.");
|
||||
|
||||
static wstring maxLenOnSearchTip = tip;
|
||||
|
||||
@ -2001,8 +2025,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
if (!_maxLenOnSearchTip.isValid()) // Create the tooltip and add the tool ONLY ONCE
|
||||
{
|
||||
NativeLangSpeaker* pNativeSpeaker = nppParamInst.getNativeLangSpeaker();
|
||||
wstring tip = pNativeSpeaker->getLocalizedStrFromID("max-len-on-save-tip", L"This search input (> $INT_REPLACE$ characters) won't be saved for the next session");
|
||||
tip = stringReplace(tip, L"$INT_REPLACE$", std::to_wstring(FINDREPLACE_MAXLENGTH2SAVE - 1));
|
||||
wstring tip = pNativeSpeaker->getLocalizedStrFromID("max-len-on-save-tip", L"The length of your input is very long and may not be saved for your next session.");
|
||||
|
||||
static wstring maxLenOnSaveTip = tip;
|
||||
|
||||
@ -4044,7 +4067,7 @@ int FindReplaceDlg::regexBackwardMsgBox()
|
||||
return msgboxID;
|
||||
}
|
||||
|
||||
void FindReplaceDlg::setSearchText(wchar_t * txt2find)
|
||||
void FindReplaceDlg::setSearchText(const wchar_t * txt2find)
|
||||
{
|
||||
HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
||||
if (txt2find && txt2find[0])
|
||||
@ -5357,7 +5380,7 @@ bool FindReplaceDlg::replaceInProjectsConfirmCheck()
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
bool FindReplaceDlg::replaceInOpenDocsConfirmCheck(void)
|
||||
bool FindReplaceDlg::replaceInOpenDocsConfirmCheck()
|
||||
{
|
||||
bool confirmed = false;
|
||||
|
||||
@ -5375,6 +5398,26 @@ bool FindReplaceDlg::replaceInOpenDocsConfirmCheck(void)
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
// return NULL if nothing to set in find field.
|
||||
// Otherwise return string pointer (wchar_t *) in which the selected text was copied.
|
||||
// Note that the string pointer don't need to and should not be deallocated.
|
||||
const wchar_t* FindReplaceDlg::setSearchTextWithSettings()
|
||||
{
|
||||
const NppGUI& nppGui = NppParameters::getInstance().getNppGUI();
|
||||
if (nppGui._fillFindFieldWithSelected)
|
||||
{
|
||||
Sci_Position selStrCharNum = 0;
|
||||
const wchar_t* selStr = (*_ppEditView)->getSelectedTextToWChar(nppGui._fillFindFieldSelectCaret, &selStrCharNum);
|
||||
|
||||
if (selStr && selStrCharNum <= nppGui._fillFindWhatThreshold)
|
||||
{
|
||||
setSearchText(selStr);
|
||||
return selStr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wstring Finder::getHitsString(int count) const
|
||||
{
|
||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||
@ -6284,12 +6327,11 @@ void FindIncrementDlg::markSelectedTextInc(bool enable, FindOption *opt)
|
||||
if (range.cpMin == range.cpMax)
|
||||
return;
|
||||
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
auto text2Find = std::make_unique<wchar_t[]>(strSize);
|
||||
std::fill_n(text2Find.get(), strSize, L'\0');
|
||||
auto text2Find = (*(_pFRDlg->_ppEditView))->getSelectedTextToWChar(false); //do not expand selection (false)
|
||||
if (!text2Find)
|
||||
return;
|
||||
|
||||
(*(_pFRDlg->_ppEditView))->getGenericSelectedText(text2Find.get(), FINDREPLACE_MAXLENGTH, false); //do not expand selection (false)
|
||||
opt->_str2Search = text2Find.get();
|
||||
opt->_str2Search = text2Find;
|
||||
_pFRDlg->markAllInc(opt);
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ public :
|
||||
|
||||
void replaceAllInOpenedDocs();
|
||||
void findAllIn(InWhat op);
|
||||
void setSearchText(wchar_t * txt2find);
|
||||
void setSearchText(const wchar_t * txt2find);
|
||||
|
||||
void gotoNextFoundResult(int direction = 0) const {
|
||||
if (_pFinder) _pFinder->gotoNextFoundResult(direction);
|
||||
@ -336,14 +336,13 @@ public :
|
||||
_tab.getCurrentTitle(label, MAX_PATH);
|
||||
::SetWindowText(_hSelf, label);
|
||||
}
|
||||
void beginNewFilesSearch()
|
||||
{
|
||||
|
||||
void beginNewFilesSearch() {
|
||||
_pFinder->beginNewFilesSearch();
|
||||
_pFinder->addSearchLine(getText2search().c_str());
|
||||
}
|
||||
|
||||
void finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection)
|
||||
{
|
||||
void finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection) {
|
||||
_pFinder->finishFilesSearch(count, searchedCount, searchedEntireNotSelection, _env);
|
||||
}
|
||||
|
||||
@ -421,6 +420,7 @@ public :
|
||||
DIALOG_TYPE getCurrentStatus() {return _currentStatus;};
|
||||
Finder* getFinderFrom(HWND hwnd);
|
||||
int regexBackwardMsgBox();
|
||||
const wchar_t* setSearchTextWithSettings();
|
||||
|
||||
protected :
|
||||
void resizeDialogElements();
|
||||
@ -526,7 +526,7 @@ private:
|
||||
void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
|
||||
bool replaceInFilesConfirmCheck(const std::wstring& directory, const std::wstring& fileTypes);
|
||||
bool replaceInProjectsConfirmCheck();
|
||||
bool replaceInOpenDocsConfirmCheck(void);
|
||||
bool replaceInOpenDocsConfirmCheck();
|
||||
|
||||
ContextMenu _swapPopupMenu;
|
||||
enum SwapButtonStatus {swap, down, up} _swapButtonStatus = swap;
|
||||
|
@ -2793,48 +2793,61 @@ char * ScintillaEditView::getWordOnCaretPos(char * txt, size_t size)
|
||||
return getWordFromRange(txt, size, range.first, range.second);
|
||||
}
|
||||
|
||||
wchar_t * ScintillaEditView::getGenericWordOnCaretPos(wchar_t * txt, int size)
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
char *txtA = new char[size + 1];
|
||||
getWordOnCaretPos(txtA, size);
|
||||
|
||||
const wchar_t * txtW = wmc.char2wchar(txtA, cp);
|
||||
wcscpy_s(txt, size, txtW);
|
||||
delete [] txtA;
|
||||
return txt;
|
||||
}
|
||||
|
||||
char * ScintillaEditView::getSelectedText(char * txt, size_t size, bool expand)
|
||||
char * ScintillaEditView::getSelectedTextToMultiChar(char * txt, size_t size, bool expand)
|
||||
{
|
||||
if (!size)
|
||||
return NULL;
|
||||
|
||||
Sci_CharacterRangeFull range = getSelection();
|
||||
if (range.cpMax == range.cpMin && expand)
|
||||
{
|
||||
expandWordSelection();
|
||||
range = getSelection();
|
||||
}
|
||||
|
||||
if (!(static_cast<Sci_Position>(size) > (range.cpMax - range.cpMin))) //there must be atleast 1 byte left for zero terminator
|
||||
{
|
||||
range.cpMax = range.cpMin + size -1; //keep room for zero terminator
|
||||
}
|
||||
//getText(txt, range.cpMin, range.cpMax);
|
||||
|
||||
return getWordFromRange(txt, size, range.cpMin, range.cpMax);
|
||||
}
|
||||
|
||||
wchar_t * ScintillaEditView::getGenericSelectedText(wchar_t * txt, int size, bool expand)
|
||||
// get the selected text & selected text character number (not the multi-chars lenghth for the allocation, if selCharNumber is not nul).
|
||||
// This function returns the pointer of wide char string (wchar_t *) that we don't need to and should not deallocate.
|
||||
const wchar_t * ScintillaEditView::getSelectedTextToWChar(bool expand, Sci_Position* selCharNumber)
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
char *txtA = new char[size + 1];
|
||||
getSelectedText(txtA, size, expand);
|
||||
char *txtA = nullptr;
|
||||
|
||||
Sci_CharacterRangeFull range = getSelection();
|
||||
if (range.cpMax == range.cpMin && expand)
|
||||
{
|
||||
expandWordSelection();
|
||||
range = getSelection();
|
||||
}
|
||||
|
||||
auto selNum = execute(SCI_COUNTCHARACTERS, range.cpMin, range.cpMax);
|
||||
|
||||
// return the selected string's character number
|
||||
if (selCharNumber)
|
||||
*selCharNumber = selNum;
|
||||
|
||||
if (selNum == 0)
|
||||
return nullptr;
|
||||
|
||||
// then get the selected string's total bytes (without counting the last NULL char)
|
||||
auto neededByte = execute(SCI_GETSELTEXT, 0, NULL);
|
||||
|
||||
txtA = new char[neededByte + 1];
|
||||
execute(SCI_GETSELTEXT, 0, reinterpret_cast<LPARAM>(txtA));
|
||||
|
||||
const wchar_t * txtW = wmc.char2wchar(txtA, cp);
|
||||
wcscpy_s(txt, size, txtW);
|
||||
delete [] txtA;
|
||||
return txt;
|
||||
|
||||
return txtW;
|
||||
}
|
||||
|
||||
intptr_t ScintillaEditView::searchInTarget(const wchar_t * text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const
|
||||
|
@ -464,10 +464,10 @@ public:
|
||||
|
||||
void getVisibleStartAndEndPosition(intptr_t* startPos, intptr_t* endPos);
|
||||
char * getWordFromRange(char * txt, size_t size, size_t pos1, size_t pos2);
|
||||
char * getSelectedText(char * txt, size_t size, bool expand = true);
|
||||
char * getSelectedTextToMultiChar(char * txt, size_t size, bool expand = true);
|
||||
const wchar_t* getSelectedTextToWChar(bool expand = true, Sci_Position* selCharNumber = nullptr);
|
||||
char * getWordOnCaretPos(char * txt, size_t size);
|
||||
wchar_t * getGenericWordOnCaretPos(wchar_t * txt, int size);
|
||||
wchar_t * getGenericSelectedText(wchar_t * txt, int size, bool expand = true);
|
||||
|
||||
intptr_t searchInTarget(const wchar_t * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
|
||||
void appendGenericText(const wchar_t * text2Append) const;
|
||||
void addGenericText(const wchar_t * text2Append) const;
|
||||
|
@ -151,12 +151,7 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil
|
||||
return;
|
||||
}
|
||||
|
||||
char * text2Find = new char[textlen + 1];
|
||||
pHighlightView->getSelectedText(text2Find, textlen + 1, false); //do not expand selection (false)
|
||||
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(pHighlightView->execute(SCI_GETCODEPAGE));
|
||||
const wchar_t * text2FindW = wmc.char2wchar(text2Find, cp);
|
||||
const wchar_t * text2FindW = pHighlightView->getSelectedTextToWChar(false); //do not expand selection (false)
|
||||
|
||||
highlightViewWithWord(pHighlightView, text2FindW);
|
||||
|
||||
@ -171,6 +166,4 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil
|
||||
// Hightlight the unfocused view even if it's a clone, as it might be in a different area of the document
|
||||
highlightViewWithWord(unfocusView, text2FindW);
|
||||
}
|
||||
|
||||
delete[] text2Find;
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ UCHAR ColumnEditorDlg::getFormat()
|
||||
}
|
||||
|
||||
|
||||
UCHAR ColumnEditorDlg::getHexCase(void)
|
||||
UCHAR ColumnEditorDlg::getHexCase()
|
||||
{
|
||||
int curSel = static_cast<int>(::SendDlgItemMessage(_hSelf, IDC_COL_HEXUC_COMBO, CB_GETCURSEL, 0, 0));
|
||||
return (curSel == 1) ? BASE_16_UPPERCASE : BASE_16;
|
||||
|
@ -45,7 +45,7 @@ public :
|
||||
void switchTo(bool toText);
|
||||
UCHAR getFormat();
|
||||
ColumnEditorParam::leadingChoice getLeading();
|
||||
UCHAR getHexCase(void);
|
||||
UCHAR getHexCase();
|
||||
|
||||
protected :
|
||||
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
|
||||
|
@ -1039,7 +1039,7 @@ void CustomFileDialog::setSaveAsCopy(bool isSavingAsCopy)
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomFileDialog::getOpenTheCopyAfterSaveAsCopy(void)
|
||||
bool CustomFileDialog::getOpenTheCopyAfterSaveAsCopy()
|
||||
{
|
||||
return (_impl->_savingAsCopyInfo & SAVE_AS_COPY_OPEN) != 0;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
void setCheckbox(const wchar_t* text, bool isActive = true);
|
||||
void setExtIndex(int extTypeIndex);
|
||||
void setSaveAsCopy(bool isSavingAsCopy);
|
||||
bool getOpenTheCopyAfterSaveAsCopy(void);
|
||||
bool getOpenTheCopyAfterSaveAsCopy();
|
||||
|
||||
void enableFileTypeCheckbox(const std::wstring& text, bool value);
|
||||
bool getFileTypeCheckboxValue() const;
|
||||
|
@ -6887,7 +6887,7 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||
::SendMessage(_tipInSelThresh, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELPARAM((30000), (0)));
|
||||
}
|
||||
|
||||
wstring tipFillFindWhatText = pNativeSpeaker->getLocalizedStrFromID("searchingFillFindWhat-tip", L"Maximun number of selected characters in edit zone to fill automatically the \"Find what\" field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of \"Find what\" field, limited by the system.");
|
||||
wstring tipFillFindWhatText = pNativeSpeaker->getLocalizedStrFromID("searchingFillFindWhat-tip", L"Maximum number of selected characters in edit zone to fill automatically the \"Find what\" field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of \"Find what\" field, limited by the system.");
|
||||
|
||||
tipFillFindWhatText = stringReplace(tipFillFindWhatText, L"$INT_REPLACE$", std::to_wstring(FINDREPLACE_MAXLENGTH - 1));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user