mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
+ fix: grepWinNP3: wide char path names for language files
+ fix: clone full .ini-file path for forked new instance
This commit is contained in:
parent
dc879bb10d
commit
d59b2d9dee
@ -1,4 +1,4 @@
|
||||
// sktoolslib - common files for SK tools
|
||||
// sktoolslib - common files for SK tools
|
||||
|
||||
// Copyright (C) 2013, 2017-2018, 2020 - Stefan Kueng
|
||||
|
||||
@ -40,9 +40,9 @@ bool CLanguage::LoadFile(const std::wstring& path)
|
||||
if (_wcsicmp(lastLangPath.c_str(), path.c_str()))
|
||||
{
|
||||
std::map<std::wstring, std::wstring> langmap2;
|
||||
for (auto it = langmap.cbegin(); it != langmap.cend(); ++it)
|
||||
for (const auto& item : langmap)
|
||||
{
|
||||
langmap2[it->second] = it->first;
|
||||
langmap2[item.second] = item.first;
|
||||
}
|
||||
langmap = langmap2;
|
||||
}
|
||||
@ -52,11 +52,16 @@ bool CLanguage::LoadFile(const std::wstring& path)
|
||||
|
||||
lastLangPath = path;
|
||||
|
||||
#ifdef _WIN32
|
||||
// The wchar_t version is a compiler extension, it works on Microsoft C++ compiler
|
||||
const wchar_t* const filepath = path.c_str();
|
||||
#else
|
||||
// since stream classes still expect the filepath in char and not wchar_t
|
||||
// we need to convert the filepath to multibyte first
|
||||
char filepath[MAX_PATH + 1];
|
||||
SecureZeroMemory(filepath, sizeof(filepath));
|
||||
WideCharToMultiByte(CP_ACP, 0, path.c_str(), -1, filepath, _countof(filepath) - 1, nullptr, nullptr);
|
||||
#endif
|
||||
|
||||
std::wifstream File;
|
||||
File.imbue(std::locale(std::locale(), new utf8_conversion()));
|
||||
@ -72,7 +77,7 @@ bool CLanguage::LoadFile(const std::wstring& path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto line = std::make_unique<wchar_t[]>(2 * MAX_STRING_LENGTH);
|
||||
auto line = std::make_unique<wchar_t[]>(2 * MAX_STRING_LENGTH);
|
||||
std::vector<std::wstring> entry;
|
||||
do
|
||||
{
|
||||
|
||||
@ -4136,19 +4136,14 @@ bool CSearchDlg::IsVersionNewer(const std::wstring& sVer)
|
||||
|
||||
bool CSearchDlg::CloneWindow()
|
||||
{
|
||||
if (!SaveSettings())
|
||||
return false;
|
||||
if (bPortable)
|
||||
{
|
||||
g_iniFile.SaveFile(g_iniPath.c_str());
|
||||
}
|
||||
if (!SaveSettings()) { return false; }
|
||||
if (bPortable) { g_iniFile.SaveFile(g_iniPath.c_str()); }
|
||||
|
||||
auto const dir = CPathUtils::GetModuleDir();
|
||||
auto const file = CPathUtils::GetFileName(CPathUtils::GetModulePath());
|
||||
auto const inifn = CPathUtils::GetFileName(g_iniPath);
|
||||
|
||||
std::wstring arguments;
|
||||
arguments += CStringUtils::Format(L" /inipath:\"%s\"", inifn.c_str());
|
||||
arguments += CStringUtils::Format(L" /inipath:\"%s\"", g_iniPath.c_str());
|
||||
arguments += CStringUtils::Format(L" /searchpath:\"%s\"", m_searchpath.c_str());
|
||||
arguments += CStringUtils::Format(L" /searchfor:\"%s\"", m_searchString.c_str());
|
||||
arguments += CStringUtils::Format(L" /replacewith:\"%s\"", m_replaceString.c_str());
|
||||
|
||||
@ -142,8 +142,8 @@ LRESULT CSettingsDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
std::wstring path = moduledir;
|
||||
bool bRecurse = false;
|
||||
bool bIsDirectory = false;
|
||||
CRegStdString regLang(L"Software\\grepWinNP3\\languagefile");
|
||||
std::wstring setLang = regLang;
|
||||
|
||||
std::wstring setLang;
|
||||
|
||||
if (bPortable)
|
||||
{
|
||||
@ -174,6 +174,11 @@ LRESULT CSettingsDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
setLang = absLngPath;
|
||||
path = moduledir;
|
||||
}
|
||||
else
|
||||
{
|
||||
CRegStdString regLang(L"Software\\grepWinNP3\\languagefile");
|
||||
setLang = regLang;
|
||||
}
|
||||
|
||||
// ordered map of language files
|
||||
std::wstring sPath;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user