Browse Source

Make Find result panel translatable

Fix also a folding visual glitchy in Find result.
pull/8218/head
Don HO 5 years ago
parent
commit
2b345c8f39
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
  1. 7
      PowerEditor/installer/nativeLang/english.xml
  2. 7
      PowerEditor/installer/nativeLang/french.xml
  3. 7
      PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
  4. 137
      PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp
  5. 4
      PowerEditor/src/ScitillaComponent/FindReplaceDlg.h
  6. 14
      scintilla/lexers/LexSearchResult.cxx

7
PowerEditor/installer/nativeLang/english.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<NotepadPlus>
<Native-Langue name="English" filename="english.xml" version="7.8.6">
<Native-Langue name="English" filename="english.xml" version="7.8.7">
<Menu>
<Main>
<!-- Main Menu Entries -->
@ -1268,6 +1268,11 @@ Find in all files except exe, obj &amp;&amp; log:
<replace-in-files-confirm-title value="Are you sure?"/>
<replace-in-files-confirm-directory value="Are you sure you want to replace all occurrences in :"/>
<replace-in-files-confirm-filetype value="For file type :"/>
<find-result-caption value="Find result"/>
<find-result-title value="Search"/>
<find-result-title-info value="($INT_REPLACE1$ hits in $INT_REPLACE2$ files of $INT_REPLACE3$ searched)"/>
<find-result-title-info-extra value=" - Line Filter Mode: only display the filtered results"/>
<find-result-hits value="($INT_REPLACE1$ hits)"/>
</MiscStrings>
</Native-Langue>
</NotepadPlus>

7
PowerEditor/installer/nativeLang/french.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<NotepadPlus>
<Native-Langue name="Français" filename="french.xml" version="7.8.6">
<Native-Langue name="Français" filename="french.xml" version="7.8.7">
<Menu>
<Main>
<!-- Main Menu Entries -->
@ -1245,6 +1245,11 @@ Rechercher dans tous les fichiers sauf exe, obj &amp;&amp; log:
<replace-in-files-confirm-title value="Confirmation"/>
<replace-in-files-confirm-directory value="Voulez-vous remplacer toutes les occurrences dans :"/>
<replace-in-files-confirm-filetype value="Pour le(s) type(s) de fichier :"/>
<find-result-caption value="Résultats de recherche"/>
<find-result-title value="Rechercher"/>
<find-result-title-info value="($INT_REPLACE1$ résultats dans $INT_REPLACE2$ documents depuis $INT_REPLACE3$ documents recherchés)"/>
<find-result-title-info-extra value=" - Mode de filtre de ligne : affiche uniquement les résultats filtrés"/>
<find-result-hits value="($INT_REPLACE$ résultats)"/>
</MiscStrings>
</Native-Langue>
</NotepadPlus>

7
PowerEditor/installer/nativeLang/taiwaneseMandarin.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<NotepadPlus>
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="7.8.6">
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="7.8.7">
<Menu>
<Main>
<!-- Main Menu Entries -->
@ -1221,6 +1221,11 @@
<replace-in-files-confirm-title value="確認"/>
<replace-in-files-confirm-directory value="是否要替換所有匹配項在此目錄中:"/>
<replace-in-files-confirm-filetype value="向所有擁有下列副檔名的檔案:"/>
<find-result-caption value="搜尋結果"/>
<find-result-title value="搜尋"/>
<find-result-title-info value="(找到 $INT_REPLACE1$ 個結果在 $INT_REPLACE2$ 的文件中。搜尋文件量: $INT_REPLACE3$)"/>
<find-result-title-info-extra value=" - 僅在搜尋結果中尋找"/>
<find-result-hits value="($INT_REPLACE$ 個結果)"/>
</MiscStrings>
</Native-Langue>
</NotepadPlus>

137
PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp

@ -2260,6 +2260,15 @@ void FindReplaceDlg::findAllIn(InWhat op)
// the dlgDlg should be the index of funcItem where the current function pointer is
// in this case is DOCKABLE_DEMO_INDEX
data.dlgID = 0;
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
generic_string text = pNativeSpeaker->getLocalizedStrFromID("find-result-caption", TEXT(""));
if (!text.empty())
{
_findResTitle = text;
data.pszName = _findResTitle.c_str();
}
::SendMessage(_hParent, NPPM_DMMREGASDCKDLG, 0, reinterpret_cast<LPARAM>(&data));
_pFinder->_scintView.init(_hInst, _pFinder->getHSelf());
@ -2314,10 +2323,9 @@ void FindReplaceDlg::findAllIn(InWhat op)
if (::SendMessage(_hParent, cmdid, 0, 0))
{
if (_findAllResult == 1)
wsprintf(_findAllResultStr, TEXT("1 hit"));
else
wsprintf(_findAllResultStr, TEXT("%s hits"), commafyInt(_findAllResult).c_str());
generic_string text = _pFinder->getHitsString(_findAllResult);
wsprintf(_findAllResultStr, text.c_str());
if (_findAllResult)
{
focusOnFinder();
@ -2352,6 +2360,15 @@ Finder * FindReplaceDlg::createFinder()
// the dlgDlg should be the index of funcItem where the current function pointer is
// in this case is DOCKABLE_DEMO_INDEX
data.dlgID = 0;
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
generic_string text = pNativeSpeaker->getLocalizedStrFromID("find-result-caption", TEXT(""));
if (!text.empty())
{
_findResTitle = text;
data.pszName = _findResTitle.c_str();
}
::SendMessage(_hParent, NPPM_DMMREGASDCKDLG, 0, reinterpret_cast<LPARAM>(&data));
pFinder->_scintView.init(_hInst, pFinder->getHSelf());
@ -2388,6 +2405,17 @@ Finder * FindReplaceDlg::createFinder()
pFinder->_scintView.execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("@MarkingsStruct"), reinterpret_cast<LPARAM>(ptrword));
_findersOfFinder.push_back(pFinder);
/*
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
generic_string title_temp = pNativeSpeaker->getAttrNameStr(FS_PROJECTPANELTITLE, "DocSwitcher", "PanelTitle");
static TCHAR title[32];
if (title_temp.length() < 32)
{
wcscpy_s(title, title_temp.c_str());
data.pszName = title;
}
*/
::SendMessage(pFinder->getHSelf(), WM_SIZE, 0, 0);
@ -3101,11 +3129,39 @@ bool FindReplaceDlg::replaceInFilesConfirmCheck(generic_string directory, generi
return confirmed;
}
generic_string Finder::getHitsString(int count) const
{
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
generic_string text = pNativeSpeaker->getLocalizedStrFromID("find-result-hits", TEXT(""));
if (text.empty())
{
if (count == 1)
{
text = TEXT(" (1 hit)");
}
else
{
text = TEXT(" (");
text += std::to_wstring(count);
text += TEXT(" hits)");
}
}
else
{
text = stringReplace(text, TEXT("$INT_REPLACE$"), std::to_wstring(count));
}
return text;
}
void Finder::addSearchLine(const TCHAR *searchName)
{
generic_string str = TEXT("Search \"");
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
generic_string str = pNativeSpeaker->getLocalizedStrFromID("find-result-title", TEXT("Search"));
str += TEXT(" \"");
str += searchName;
str += TEXT("\"\r\n");
str += TEXT("\" \r\n");
setFinderReadOnly(false);
_scintView.addGenericText(str.c_str());
@ -3133,31 +3189,72 @@ void Finder::addFileNameTitle(const TCHAR * fileName)
void Finder::addFileHitCount(int count)
{
TCHAR text[20];
if (count == 1)
wsprintf(text, TEXT(" (1 hit)"));
else
wsprintf(text, TEXT(" (%i hits)"), count);
wstring text = TEXT(" ");
text += getHitsString(count);
setFinderReadOnly(false);
_scintView.insertGenericTextFrom(_lastFileHeaderPos, text);
_scintView.insertGenericTextFrom(_lastFileHeaderPos, text.c_str());
setFinderReadOnly(true);
++_nbFoundFiles;
}
void Finder::addSearchHitCount(int count, int countSearched, bool isMatchLines)
{
const TCHAR *moreInfo = isMatchLines ? TEXT(" - Line Filter Mode: only display the filtered results") :TEXT("");
TCHAR text[100];
generic_string hitIn;
generic_string fileOf;
generic_string nbResStr = std::to_wstring(count);
generic_string nbFoundFilesStr = std::to_wstring(_nbFoundFiles);
generic_string nbSearchedFilesStr = std::to_wstring(countSearched);
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
generic_string text = pNativeSpeaker->getLocalizedStrFromID("find-result-title-info", TEXT(""));
if (text.empty())
{
if (count == 1 && _nbFoundFiles == 1)
wsprintf(text, TEXT(" (1 hit in 1 file of %i searched%s)"), countSearched, moreInfo);
{
hitIn = TEXT(" hit in ");
fileOf = TEXT(" file of ");
}
else if (count == 1 && _nbFoundFiles != 1)
wsprintf(text, TEXT(" (1 hit in %i files of %i searched%s)"), _nbFoundFiles, countSearched, moreInfo);
{
hitIn = TEXT(" hit in ");
fileOf = TEXT(" files of ");
}
else if (count != 1 && _nbFoundFiles == 1)
wsprintf(text, TEXT(" (%i hits in 1 file of %i searched%s)"), count, countSearched, moreInfo);
else if (count != 1 && _nbFoundFiles != 1)
wsprintf(text, TEXT(" (%i hits in %i files of %i searched%s)"), count, _nbFoundFiles, countSearched, moreInfo);
{
hitIn = TEXT(" hits in ");
fileOf = TEXT(" file of ");
}
else //if (count != 1 && _nbFoundFiles != 1)
{
hitIn = TEXT(" hits in ");
fileOf = TEXT(" files of ");
}
const TCHAR *moreInfo = isMatchLines ? TEXT(" - Line Filter Mode: only display the filtered results") : TEXT("");
text = TEXT(" (");
text += nbResStr;
text += hitIn;
text += nbFoundFilesStr;
text += fileOf;
text += nbSearchedFilesStr;
text += TEXT(" searched");
text += moreInfo;
text += TEXT(")");
}
else
{
text = stringReplace(text, TEXT("$INT_REPLACE1$"), nbResStr);
text = stringReplace(text, TEXT("$INT_REPLACE2$"), nbFoundFilesStr);
text = stringReplace(text, TEXT("$INT_REPLACE3$"), nbSearchedFilesStr);
text += isMatchLines ? pNativeSpeaker->getLocalizedStrFromID("find-result-title-info-extra", TEXT("")) : TEXT("");
}
setFinderReadOnly(false);
_scintView.insertGenericTextFrom(_lastSearchHeaderPos, text);
_scintView.insertGenericTextFrom(_lastSearchHeaderPos, text.c_str());
setFinderReadOnly(true);
}

4
PowerEditor/src/ScitillaComponent/FindReplaceDlg.h

@ -139,6 +139,7 @@ public:
std::vector<generic_string> getResultFilePaths() const;
bool canFind(const TCHAR *fileName, size_t lineNumber) const;
void setVolatiled(bool val) { _canBeVolatiled = val; };
generic_string getHitsString(int count) const;
protected :
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
@ -146,7 +147,7 @@ protected :
private:
enum { searchHeaderLevel = SC_FOLDLEVELBASE + 1, fileHeaderLevel, resultLevel };
enum { searchHeaderLevel = SC_FOLDLEVELBASE, fileHeaderLevel, resultLevel };
ScintillaEditView **_ppEditView = nullptr;
std::vector<FoundInfo> _foundInfos1;
@ -357,6 +358,7 @@ private :
ScintillaEditView **_ppEditView = nullptr;
Finder *_pFinder = nullptr;
generic_string _findResTitle;
std::vector<Finder *> _findersOfFinder;

14
scintilla/lexers/LexSearchResult.cxx

@ -40,7 +40,7 @@
using namespace Scintilla;
// The following definitions are a copy of the ones in FindReplaceDlg.h
enum { searchHeaderLevel = SC_FOLDLEVELBASE + 1, fileHeaderLevel, resultLevel };
enum { searchHeaderLevel = SC_FOLDLEVELBASE, fileHeaderLevel, resultLevel };
static inline bool AtEOL(Accessor &styler, size_t i) {
@ -56,15 +56,11 @@ static void ColouriseSearchResultLine(SearchResultMarkings* pMarkings, char *lin
{
// startLine and endPos are the absolute positions.
if (lineBuffer[0] == ' ') // file header
if (lineBuffer[0] == ' ') // white space - file header
{
styler.ColourTo(endPos, SCE_SEARCHRESULT_FILE_HEADER);
}
else if (lineBuffer[0] == 'S') // search header
{
styler.ColourTo(endPos, SCE_SEARCHRESULT_SEARCH_HEADER);
}
else // line info
else if (lineBuffer[0] == ' ')// \t - line info
{
const unsigned int firstTokenLen = 4;
unsigned int currentPos;
@ -95,6 +91,10 @@ static void ColouriseSearchResultLine(SearchResultMarkings* pMarkings, char *lin
}
styler.ColourTo(endPos, currentStat);
}
else // every character - search header
{
styler.ColourTo(endPos, SCE_SEARCHRESULT_SEARCH_HEADER);
}
}
static void ColouriseSearchResultDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) {

Loading…
Cancel
Save