diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index 455e700ab..c95dd1bf7 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -1867,7 +1867,7 @@ Click on "?" button on right to open website with User Manual."/>
-
+
@@ -1891,8 +1891,9 @@ If you select advanced mode but do not edit files in the aforementioned language
-
-
+
+
+
diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml
index 1b7d19a5e..6a9187be7 100644
--- a/PowerEditor/installer/nativeLang/english_customizable.xml
+++ b/PowerEditor/installer/nativeLang/english_customizable.xml
@@ -1867,7 +1867,7 @@ Click on "?" button on right to open website with User Manual."/>
-
+
@@ -1891,8 +1891,9 @@ If you select advanced mode but do not edit files in the aforementioned language
-
-
+
+
+
diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml
index ef2597813..1af80ce78 100644
--- a/PowerEditor/installer/nativeLang/french.xml
+++ b/PowerEditor/installer/nativeLang/french.xml
@@ -1886,8 +1886,9 @@ Si vous sélectionnez le mode avancé sans modifier les fichiers des langues men
-
-
+
+
+
diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
index fb06fadda..0deb43403 100644
--- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
+++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
@@ -1711,8 +1711,9 @@ C、C++、Java、C#、Objective-C、PHP、JavaScript、JSP、CSS、Perl、Rust
-
-
+
+
+
diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp
index efffda584..f184174f3 100644
--- a/PowerEditor/src/NppBigSwitch.cpp
+++ b/PowerEditor/src/NppBigSwitch.cpp
@@ -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(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(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(strSize);
- std::fill_n(str.get(), strSize, L'\0');
-
Finder *launcher = reinterpret_cast(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(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"\\/"))
diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp
index ecf4388ba..dba869d51 100644
--- a/PowerEditor/src/NppCommands.cpp
+++ b/PowerEditor/src/NppCommands.cpp
@@ -439,7 +439,7 @@ void Notepad_plus::command(int id)
auto pBinText = std::make_unique(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(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(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(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(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(strSize);
- std::fill_n(selectedText.get(), strSize, L'\0');
+ auto selectedText = _pEditView->getSelectedTextToWChar(true);
- auto wordOnCaret = std::make_unique(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)
{
diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp
index 32d511904..094965ee3 100644
--- a/PowerEditor/src/NppNotification.cpp
+++ b/PowerEditor/src/NppNotification.cpp
@@ -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;
}
diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
index c64a125fb..71b576e1b 100644
--- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
+++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
@@ -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);
@@ -1971,17 +1971,41 @@ 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 hComboBox = ::GetDlgItem(_hSelf, LOWORD(wParam));
+ 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(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);
}
diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
index baaf69e8f..e366cfe5f 100644
--- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
+++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
@@ -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;
diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
index bdaf2447d..5c2e4c4b7 100644
--- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
+++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
@@ -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(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(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
diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h
index 5377efe38..58f67eef1 100644
--- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h
+++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h
@@ -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;
diff --git a/PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp b/PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp
index 29e916f51..d4fe69e6d 100644
--- a/PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp
+++ b/PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp
@@ -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(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;
}
diff --git a/PowerEditor/src/ScintillaComponent/columnEditor.cpp b/PowerEditor/src/ScintillaComponent/columnEditor.cpp
index 56a6f53b2..fb1408b87 100644
--- a/PowerEditor/src/ScintillaComponent/columnEditor.cpp
+++ b/PowerEditor/src/ScintillaComponent/columnEditor.cpp
@@ -634,7 +634,7 @@ UCHAR ColumnEditorDlg::getFormat()
}
-UCHAR ColumnEditorDlg::getHexCase(void)
+UCHAR ColumnEditorDlg::getHexCase()
{
int curSel = static_cast(::SendDlgItemMessage(_hSelf, IDC_COL_HEXUC_COMBO, CB_GETCURSEL, 0, 0));
return (curSel == 1) ? BASE_16_UPPERCASE : BASE_16;
diff --git a/PowerEditor/src/ScintillaComponent/columnEditor.h b/PowerEditor/src/ScintillaComponent/columnEditor.h
index 254174415..140640792 100644
--- a/PowerEditor/src/ScintillaComponent/columnEditor.h
+++ b/PowerEditor/src/ScintillaComponent/columnEditor.h
@@ -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;
diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp
index 611ad0cc9..2032a835e 100644
--- a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp
+++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp
@@ -1039,7 +1039,7 @@ void CustomFileDialog::setSaveAsCopy(bool isSavingAsCopy)
}
}
-bool CustomFileDialog::getOpenTheCopyAfterSaveAsCopy(void)
+bool CustomFileDialog::getOpenTheCopyAfterSaveAsCopy()
{
return (_impl->_savingAsCopyInfo & SAVE_AS_COPY_OPEN) != 0;
}
diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.h b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.h
index 977225169..6ed463d3c 100644
--- a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.h
+++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.h
@@ -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;
diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
index 589f4a4a2..12990a707 100644
--- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
+++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
@@ -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));