diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 0d3a8f6c1958..755b076f06f0 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -27,8 +27,8 @@ using namespace std; -const TCHAR * USERMSG = TEXT(" is not compatible with the current version of Notepad++.\n\n\ -Do you want to remove this plugin from the plugins directory to prevent this message from the next launch?"); +const wchar_t * USERMSG = L" is not compatible with the current version of Notepad++.\n\n\ +Do you want to remove this plugin from the plugins directory to prevent this message from the next launch?"; bool PluginsManager::unloadPlugin(int index, HWND nppHandle) @@ -45,20 +45,20 @@ bool PluginsManager::unloadPlugin(int index, HWND nppHandle) if (::FreeLibrary(_pluginInfos[index]->_hLib)) { _pluginInfos[index]->_hLib = nullptr; - printStr(TEXT("we're good")); + printStr(L"we're good"); } else - printStr(TEXT("not ok")); + printStr(L"not ok"); //delete _pluginInfos[index]; // printInt(index); //vector::iterator it = _pluginInfos.begin() + index; //_pluginInfos.erase(it); - //printStr(TEXT("remove")); + //printStr(L"remove"); return true; } -static WORD getBinaryArchitectureType(const TCHAR *filePath) +static WORD getBinaryArchitectureType(const wchar_t *filePath) { HANDLE hFile = CreateFile(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL); if (hFile == INVALID_HANDLE_VALUE) @@ -101,9 +101,9 @@ static WORD getBinaryArchitectureType(const TCHAR *filePath) #define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000 #endif -int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath) +int PluginsManager::loadPluginFromPath(const wchar_t *pluginFilePath) { - const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath); + const wchar_t *pluginFileName = ::PathFindFileName(pluginFilePath); if (isInLoadedDlls(pluginFileName)) return 0; @@ -116,66 +116,66 @@ int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath) int archType = nppParams.archType(); if (getBinaryArchitectureType(pluginFilePath) != archType) { - const TCHAR* archErrMsg = TEXT("Cannot load plugin."); + const wchar_t* archErrMsg = L"Cannot load plugin."; switch (archType) { case IMAGE_FILE_MACHINE_ARM64: - archErrMsg = TEXT("Cannot load ARM64 plugin."); + archErrMsg = L"Cannot load ARM64 plugin."; break; case IMAGE_FILE_MACHINE_I386: - archErrMsg = TEXT("Cannot load 32-bit plugin."); + archErrMsg = L"Cannot load 32-bit plugin."; break; case IMAGE_FILE_MACHINE_AMD64: - archErrMsg = TEXT("Cannot load 64-bit plugin."); + archErrMsg = L"Cannot load 64-bit plugin."; break; } - throw generic_string(archErrMsg); + throw wstring(archErrMsg); } - const DWORD dwFlags = GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "AddDllDirectory") != NULL ? LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0; + const DWORD dwFlags = GetProcAddress(GetModuleHandle(L"kernel32.dll"), "AddDllDirectory") != NULL ? LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0; pi->_hLib = ::LoadLibraryEx(pluginFilePath, NULL, dwFlags); if (!pi->_hLib) { - generic_string lastErrorMsg = GetLastErrorAsString(); + wstring lastErrorMsg = GetLastErrorAsString(); if (lastErrorMsg.empty()) - throw generic_string(TEXT("Load Library has failed.\nChanging the project's \"Runtime Library\" setting to \"Multi-threaded(/MT)\" might solve this problem.")); + throw wstring(L"Load Library has failed.\nChanging the project's \"Runtime Library\" setting to \"Multi-threaded(/MT)\" might solve this problem."); else - throw generic_string(lastErrorMsg.c_str()); + throw wstring(lastErrorMsg.c_str()); } pi->_pFuncIsUnicode = (PFUNCISUNICODE)GetProcAddress(pi->_hLib, "isUnicode"); if (!pi->_pFuncIsUnicode || !pi->_pFuncIsUnicode()) - throw generic_string(TEXT("This ANSI plugin is not compatible with your Unicode Notepad++.")); + throw wstring(L"This ANSI plugin is not compatible with your Unicode Notepad++."); pi->_pFuncSetInfo = (PFUNCSETINFO)GetProcAddress(pi->_hLib, "setInfo"); if (!pi->_pFuncSetInfo) - throw generic_string(TEXT("Missing \"setInfo\" function")); + throw wstring(L"Missing \"setInfo\" function"); pi->_pFuncGetName = (PFUNCGETNAME)GetProcAddress(pi->_hLib, "getName"); if (!pi->_pFuncGetName) - throw generic_string(TEXT("Missing \"getName\" function")); + throw wstring(L"Missing \"getName\" function"); pi->_funcName = pi->_pFuncGetName(); pi->_pBeNotified = (PBENOTIFIED)GetProcAddress(pi->_hLib, "beNotified"); if (!pi->_pBeNotified) - throw generic_string(TEXT("Missing \"beNotified\" function")); + throw wstring(L"Missing \"beNotified\" function"); pi->_pMessageProc = (PMESSAGEPROC)GetProcAddress(pi->_hLib, "messageProc"); if (!pi->_pMessageProc) - throw generic_string(TEXT("Missing \"messageProc\" function")); + throw wstring(L"Missing \"messageProc\" function"); pi->_pFuncSetInfo(_nppData); pi->_pFuncGetFuncsArray = (PFUNCGETFUNCSARRAY)GetProcAddress(pi->_hLib, "getFuncsArray"); if (!pi->_pFuncGetFuncsArray) - throw generic_string(TEXT("Missing \"getFuncsArray\" function")); + throw wstring(L"Missing \"getFuncsArray\" function"); pi->_funcItems = pi->_pFuncGetFuncsArray(&pi->_nbFuncItem); if ((!pi->_funcItems) || (pi->_nbFuncItem <= 0)) - throw generic_string(TEXT("Missing \"FuncItems\" array, or the nb of Function Item is not set correctly")); + throw wstring(L"Missing \"FuncItems\" array, or the nb of Function Item is not set correctly"); pi->_pluginMenu = ::CreateMenu(); @@ -185,27 +185,27 @@ int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath) { Lexilla::GetLexerNameFn GetLexerName = (Lexilla::GetLexerNameFn)::GetProcAddress(pi->_hLib, LEXILLA_GETLEXERNAME); if (!GetLexerName) - throw generic_string(TEXT("Loading GetLexerName function failed.")); + throw wstring(L"Loading GetLexerName function failed."); //Lexilla::GetLexerFactoryFn GetLexerFactory = (Lexilla::GetLexerFactoryFn)::GetProcAddress(pi->_hLib, LEXILLA_GETLEXERFACTORY); //if (!GetLexerFactory) - //throw generic_string(TEXT("Loading GetLexerFactory function failed.")); + //throw wstring(L"Loading GetLexerFactory function failed."); Lexilla::CreateLexerFn CreateLexer = (Lexilla::CreateLexerFn)::GetProcAddress(pi->_hLib, LEXILLA_CREATELEXER); if (!CreateLexer) - throw generic_string(TEXT("Loading CreateLexer function failed.")); + throw wstring(L"Loading CreateLexer function failed."); //Lexilla::GetLibraryPropertyNamesFn GetLibraryPropertyNames = (Lexilla::GetLibraryPropertyNamesFn)::GetProcAddress(pi->_hLib, LEXILLA_GETLIBRARYPROPERTYNAMES); //if (!GetLibraryPropertyNames) - //throw generic_string(TEXT("Loading GetLibraryPropertyNames function failed.")); + //throw wstring(L"Loading GetLibraryPropertyNames function failed."); //Lexilla::SetLibraryPropertyFn SetLibraryProperty = (Lexilla::SetLibraryPropertyFn)::GetProcAddress(pi->_hLib, LEXILLA_SETLIBRARYPROPERTY); //if (!SetLibraryProperty) - //throw generic_string(TEXT("Loading SetLibraryProperty function failed.")); + //throw wstring(L"Loading SetLibraryProperty function failed."); //Lexilla::GetNameSpaceFn GetNameSpace = (Lexilla::GetNameSpaceFn)::GetProcAddress(pi->_hLib, LEXILLA_GETNAMESPACE); //if (!GetNameSpace) - //throw generic_string(TEXT("Loading GetNameSpace function failed.")); + //throw wstring(L"Loading GetNameSpace function failed."); // Assign a buffer for the lexer name. char lexName[MAX_EXTERNAL_LEXER_NAME_LEN]; @@ -232,25 +232,25 @@ int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath) } } - TCHAR xmlPath[MAX_PATH]; + wchar_t xmlPath[MAX_PATH]; wcscpy_s(xmlPath, nppParams.getNppPath().c_str()); - PathAppend(xmlPath, TEXT("plugins\\Config")); + PathAppend(xmlPath, L"plugins\\Config"); PathAppend(xmlPath, pi->_moduleName.c_str()); PathRemoveExtension(xmlPath); - PathAddExtension(xmlPath, TEXT(".xml")); + PathAddExtension(xmlPath, L".xml"); if (!PathFileExists(xmlPath)) { - lstrcpyn(xmlPath, TEXT("\0"), MAX_PATH ); + lstrcpyn(xmlPath, L"\0", MAX_PATH ); wcscpy_s(xmlPath, nppParams.getAppDataNppDir() ); - PathAppend(xmlPath, TEXT("plugins\\Config")); + PathAppend(xmlPath, L"plugins\\Config"); PathAppend(xmlPath, pi->_moduleName.c_str()); PathRemoveExtension( xmlPath ); - PathAddExtension( xmlPath, TEXT(".xml") ); + PathAddExtension( xmlPath, L".xml" ); if (! PathFileExists( xmlPath ) ) { - throw generic_string(generic_string(xmlPath) + TEXT(" is missing.")); + throw wstring(wstring(xmlPath) + L" is missing."); } } @@ -260,7 +260,7 @@ int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath) { delete pXmlDoc; pXmlDoc = NULL; - throw generic_string(generic_string(xmlPath) + TEXT(" failed to load.")); + throw wstring(wstring(xmlPath) + L" failed to load."); } for (int x = 0; x < numLexers; ++x) // postpone adding in case the xml is missing/corrupt @@ -287,14 +287,14 @@ int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath) pluginExceptionAlert(pluginFileName, e); return -1; } - catch (generic_string& s) + catch (wstring& s) { if (pi && pi->_hLib) { ::FreeLibrary(pi->_hLib); } - s += TEXT("\n\n"); + s += L"\n\n"; s += pluginFileName; s += USERMSG; if (::MessageBox(_nppData._nppHandle, s.c_str(), pluginFilePath, MB_YESNO) == IDYES) @@ -312,8 +312,8 @@ int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath) ::FreeLibrary(pi->_hLib); } - generic_string msg = TEXT("Failed to load"); - msg += TEXT("\n\n"); + wstring msg = L"Failed to load"; + msg += L"\n\n"; msg += pluginFileName; msg += USERMSG; if (::MessageBox(_nppData._nppHandle, msg.c_str(), pluginFilePath, MB_YESNO) == IDYES) @@ -325,17 +325,17 @@ int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath) } } -bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginUpdateInfoList, PluginViewList* pluginIncompatibleList) +bool PluginsManager::loadPlugins(const wchar_t* dir, const PluginViewList* pluginUpdateInfoList, PluginViewList* pluginIncompatibleList) { if (_isDisabled) return false; - vector dllNames; + vector dllNames; NppParameters& nppParams = NppParameters::getInstance(); - generic_string nppPath = nppParams.getNppPath(); + wstring nppPath = nppParams.getNppPath(); - generic_string pluginsFolder; + wstring pluginsFolder; if (dir && dir[0]) { pluginsFolder = dir; @@ -343,34 +343,34 @@ bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginU else { pluginsFolder = nppPath; - pathAppend(pluginsFolder, TEXT("plugins")); + pathAppend(pluginsFolder, L"plugins"); } - generic_string pluginsFolderFilter = pluginsFolder; - pathAppend(pluginsFolderFilter, TEXT("*.*")); + wstring pluginsFolderFilter = pluginsFolder; + pathAppend(pluginsFolderFilter, L"*.*"); WIN32_FIND_DATA foundData; HANDLE hFindFolder = ::FindFirstFile(pluginsFolderFilter.c_str(), &foundData); HANDLE hFindDll = INVALID_HANDLE_VALUE; // Get Notepad++ current version - TCHAR nppFullPathName[MAX_PATH]; + wchar_t nppFullPathName[MAX_PATH]; GetModuleFileName(NULL, nppFullPathName, MAX_PATH); Version nppVer; nppVer.setVersionFrom(nppFullPathName); - const TCHAR* incompatibleWarning = L"%s's version %s is not compatible to this version of Notepad++ (v%s).\r\nAs a result the plugin cannot be loaded."; - const TCHAR* incompatibleWarningWithSolution = L"%s's version %s is not compatible to this version of Notepad++ (v%s).\r\nAs a result the plugin cannot be loaded.\r\n\r\nGo to Updates section and update your plugin to %s for solving the compatibility issue."; + const wchar_t* incompatibleWarning = L"%s's version %s is not compatible to this version of Notepad++ (v%s).\r\nAs a result the plugin cannot be loaded."; + const wchar_t* incompatibleWarningWithSolution = L"%s's version %s is not compatible to this version of Notepad++ (v%s).\r\nAs a result the plugin cannot be loaded.\r\n\r\nGo to Updates section and update your plugin to %s for solving the compatibility issue."; // get plugin folder if (hFindFolder != INVALID_HANDLE_VALUE && (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - generic_string foundFileName = foundData.cFileName; - if (foundFileName != TEXT(".") && foundFileName != TEXT("..") && wcsicmp(foundFileName.c_str(), TEXT("Config")) != 0) + wstring foundFileName = foundData.cFileName; + if (foundFileName != L"." && foundFileName != L".." && wcsicmp(foundFileName.c_str(), L"Config") != 0) { - generic_string pluginsFullPathFilter = pluginsFolder; + wstring pluginsFullPathFilter = pluginsFolder; pathAppend(pluginsFullPathFilter, foundFileName); - generic_string dllName = foundFileName; - dllName += TEXT(".dll"); + wstring dllName = foundFileName; + dllName += L".dll"; pathAppend(pluginsFullPathFilter, dllName); // get plugin @@ -401,7 +401,7 @@ bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginU { PluginUpdateInfo* incompatiblePlg = new PluginUpdateInfo(*pui); incompatiblePlg->_version = v; - TCHAR msg[1024]; + wchar_t msg[1024]; wsprintf(msg, incompatibleWarning, incompatiblePlg->_displayName.c_str(), v.toString().c_str(), nppVer.toString().c_str()); incompatiblePlg->_description = msg; pluginIncompatibleList->pushBack(incompatiblePlg); @@ -419,7 +419,7 @@ bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginU { PluginUpdateInfo* incompatiblePlg = new PluginUpdateInfo(*pui); incompatiblePlg->_version = v; - TCHAR msg[1024]; + wchar_t msg[1024]; wsprintf(msg, incompatibleWarningWithSolution, incompatiblePlg->_displayName.c_str(), v.toString().c_str(), nppVer.toString().c_str(), pui->_version.toString().c_str()); incompatiblePlg->_description = msg; pluginIncompatibleList->pushBack(incompatiblePlg); @@ -436,14 +436,14 @@ bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginU // get plugin folder while (::FindNextFile(hFindFolder, &foundData)) { - generic_string foundFileName2 = foundData.cFileName; - if (foundFileName2 != TEXT(".") && foundFileName2 != TEXT("..") && wcsicmp(foundFileName2.c_str(), TEXT("Config")) != 0) + wstring foundFileName2 = foundData.cFileName; + if (foundFileName2 != L"." && foundFileName2 != L".." && wcsicmp(foundFileName2.c_str(), L"Config") != 0) { - generic_string pluginsFullPathFilter2 = pluginsFolder; + wstring pluginsFullPathFilter2 = pluginsFolder; pathAppend(pluginsFullPathFilter2, foundFileName2); - generic_string pluginsFolderPath2 = pluginsFullPathFilter2; - generic_string dllName2 = foundFileName2; - dllName2 += TEXT(".dll"); + wstring pluginsFolderPath2 = pluginsFullPathFilter2; + wstring dllName2 = foundFileName2; + dllName2 += L".dll"; pathAppend(pluginsFullPathFilter2, dllName2); // get plugin @@ -479,7 +479,7 @@ bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginU { PluginUpdateInfo* incompatiblePlg = new PluginUpdateInfo(*pui2); incompatiblePlg->_version = v2; - TCHAR msg[1024]; + wchar_t msg[1024]; wsprintf(msg, incompatibleWarning, incompatiblePlg->_displayName.c_str(), v2.toString().c_str(), nppVer.toString().c_str()); incompatiblePlg->_description = msg; pluginIncompatibleList->pushBack(incompatiblePlg); @@ -497,7 +497,7 @@ bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginU { PluginUpdateInfo* incompatiblePlg = new PluginUpdateInfo(*pui2); incompatiblePlg->_version = v2; - TCHAR msg[1024]; + wchar_t msg[1024]; wsprintf(msg, incompatibleWarningWithSolution, incompatiblePlg->_displayName.c_str(), v2.toString().c_str(), nppVer.toString().c_str(), pui2->_version.toString().c_str()); incompatiblePlg->_description = msg; pluginIncompatibleList->pushBack(incompatiblePlg); @@ -591,7 +591,7 @@ void PluginsManager::addInMenuFromPMIndex(int i) { if (_pluginInfos[i]->_funcItems[j]._pFunc == NULL) { - ::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); + ::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION | MF_SEPARATOR, 0, L""); continue; } @@ -633,12 +633,12 @@ HMENU PluginsManager::initMenu(HMENU hMenu, bool enablePluginAdmin) int i = 1; if (nbPlugin > 0) - ::InsertMenu(_hPluginsMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); + ::InsertMenu(_hPluginsMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, L""); if (enablePluginAdmin) { - ::InsertMenu(_hPluginsMenu, i++, MF_BYPOSITION, IDM_SETTING_PLUGINADM, TEXT("Plugins Admin...")); - ::InsertMenu(_hPluginsMenu, i++, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); + ::InsertMenu(_hPluginsMenu, i++, MF_BYPOSITION, IDM_SETTING_PLUGINADM, L"Plugins Admin..."); + ::InsertMenu(_hPluginsMenu, i++, MF_BYPOSITION | MF_SEPARATOR, 0, L""); } } @@ -667,8 +667,8 @@ void PluginsManager::runPluginCommand(size_t i) catch (...) { constexpr size_t bufSize = 128; - TCHAR funcInfo[bufSize] = { '\0' }; - swprintf(funcInfo, bufSize, TEXT("runPluginCommand(size_t i : %zd)"), i); + wchar_t funcInfo[bufSize] = { '\0' }; + swprintf(funcInfo, bufSize, L"runPluginCommand(size_t i : %zd)", i); pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo); } } @@ -676,7 +676,7 @@ void PluginsManager::runPluginCommand(size_t i) } -void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID) +void PluginsManager::runPluginCommand(const wchar_t *pluginName, int commandID) { for (size_t i = 0, len = _pluginsCommands.size() ; i < len ; ++i) { @@ -695,8 +695,8 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID) catch (...) { constexpr size_t bufSize = 128; - TCHAR funcInfo[bufSize] = { '\0' }; - swprintf(funcInfo, bufSize, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID); + wchar_t funcInfo[bufSize] = { '\0' }; + swprintf(funcInfo, bufSize, L"runPluginCommand(const wchar_t *pluginName : %s, int commandID : %d)", pluginName, commandID); pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo); } } @@ -726,8 +726,8 @@ void PluginsManager::notify(size_t indexPluginInfo, const SCNotification *notifi catch (...) { constexpr size_t bufSize = 256; - TCHAR funcInfo[bufSize] = { '\0' }; - swprintf(funcInfo, bufSize, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %" PRIuPTR), \ + wchar_t funcInfo[bufSize] = { '\0' }; + swprintf(funcInfo, bufSize, L"notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %" PRIuPTR, \ scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom); pluginCrashAlert(_pluginInfos[indexPluginInfo]->_moduleName.c_str(), funcInfo); } @@ -765,8 +765,8 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam catch (...) { constexpr size_t bufSize = 128; - TCHAR funcInfo[bufSize] = { '\0' }; - swprintf(funcInfo, bufSize, TEXT("relayNppMessages(UINT Message : %u, WPARAM wParam : %" PRIuPTR ", LPARAM lParam : %" PRIiPTR ")"), Message, wParam, lParam); + wchar_t funcInfo[bufSize] = { '\0' }; + swprintf(funcInfo, bufSize, L"relayNppMessages(UINT Message : %u, WPARAM wParam : %" PRIuPTR ", LPARAM lParam : %" PRIiPTR ")", Message, wParam, lParam); pluginCrashAlert(_pluginInfos[i]->_moduleName.c_str(), funcInfo); } } @@ -776,7 +776,7 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam) { - const TCHAR * moduleName = (const TCHAR *)wParam; + const wchar_t * moduleName = (const wchar_t *)wParam; if (!moduleName || !moduleName[0] || !lParam) return false; @@ -797,8 +797,8 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa catch (...) { constexpr size_t bufSize = 128; - TCHAR funcInfo[bufSize] = { '\0' }; - swprintf(funcInfo, bufSize, TEXT("relayPluginMessages(UINT Message : %u, WPARAM wParam : %" PRIuPTR ", LPARAM lParam : %" PRIiPTR ")"), Message, wParam, lParam); + wchar_t funcInfo[bufSize] = { '\0' }; + swprintf(funcInfo, bufSize, L"relayPluginMessages(UINT Message : %u, WPARAM wParam : %" PRIuPTR ", LPARAM lParam : %" PRIiPTR ")", Message, wParam, lParam); pluginCrashAlert(_pluginInfos[i]->_moduleName.c_str(), funcInfo); } return true; @@ -847,18 +847,18 @@ bool PluginsManager::allocateIndicator(int numberRequired, int* start) return retVal; } -generic_string PluginsManager::getLoadedPluginNames() const +wstring PluginsManager::getLoadedPluginNames() const { - generic_string pluginPaths; + wstring pluginPaths; PluginUpdateInfo pl; for (const auto &dll : _loadedDlls) { pl = PluginUpdateInfo(dll._fullFilePath, dll._fileName); - pluginPaths += TEXT("\r\n "); + pluginPaths += L"\r\n "; pluginPaths += dll._displayName; - pluginPaths += TEXT(" ("); + pluginPaths += L" ("; pluginPaths += pl._version.toString(); - pluginPaths += TEXT(")"); + pluginPaths += L")"; } return pluginPaths; } diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index eae12edc3296..fbe7344ca7da 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -27,10 +27,10 @@ class PluginViewList; struct PluginCommand { - generic_string _pluginName; + std::wstring _pluginName; int _funcID = 0; PFUNCPLUGINCMD _pFunc = nullptr; - PluginCommand(const TCHAR *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _pluginName(pluginName), _funcID(funcID), _pFunc(pFunc) {}; + PluginCommand(const wchar_t *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _pluginName(pluginName), _funcID(funcID), _pFunc(pFunc) {}; }; struct PluginInfo @@ -57,17 +57,17 @@ struct PluginInfo FuncItem *_funcItems = nullptr; int _nbFuncItem = 0; - generic_string _moduleName; - generic_string _funcName; + std::wstring _moduleName; + std::wstring _funcName; }; struct LoadedDllInfo { - generic_string _fullFilePath; - generic_string _fileName; - generic_string _displayName; + std::wstring _fullFilePath; + std::wstring _fileName; + std::wstring _displayName; - LoadedDllInfo(const generic_string & fullFilePath, const generic_string & fileName) : _fullFilePath(fullFilePath), _fileName(fileName) + LoadedDllInfo(const std::wstring & fullFilePath, const std::wstring & fileName) : _fullFilePath(fullFilePath), _fileName(fileName) { // the plugin module's name, without '.dll' _displayName = fileName.substr(0, fileName.find_last_of('.')); @@ -92,12 +92,12 @@ friend class PluginsAdminDlg; _nppData = nppData; } - bool loadPlugins(const TCHAR *dir = NULL, const PluginViewList* pluginUpdateInfoList = nullptr, PluginViewList* pluginImcompatibleList = nullptr); + bool loadPlugins(const wchar_t *dir = NULL, const PluginViewList* pluginUpdateInfoList = nullptr, PluginViewList* pluginImcompatibleList = nullptr); bool unloadPlugin(int index, HWND nppHandle); void runPluginCommand(size_t i); - void runPluginCommand(const TCHAR *pluginName, int commandID); + void runPluginCommand(const wchar_t *pluginName, int commandID); void addInMenuFromPMIndex(int i); HMENU initMenu(HMENU hMenu, bool enablePluginAdmin = false); @@ -119,7 +119,7 @@ friend class PluginsAdminDlg; bool allocateMarker(int numberRequired, int* start); bool allocateIndicator(int numberRequired, int* start); - generic_string getLoadedPluginNames() const; + std::wstring getLoadedPluginNames() const; private: NppData _nppData; @@ -134,32 +134,32 @@ friend class PluginsAdminDlg; IDAllocator _indicatorAlloc; bool _noMoreNotification = false; - int loadPluginFromPath(const TCHAR* pluginFilePath); + int loadPluginFromPath(const wchar_t* pluginFilePath); - void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature) { - generic_string msg = pluginName; - msg += TEXT(" just crashed in\r"); + void pluginCrashAlert(const wchar_t *pluginName, const wchar_t *funcSignature) { + std::wstring msg = pluginName; + msg += L" just crashed in\r"; msg += funcSignature; - ::MessageBox(NULL, msg.c_str(), TEXT("Plugin Crash"), MB_OK|MB_ICONSTOP); + ::MessageBox(NULL, msg.c_str(), L"Plugin Crash", MB_OK|MB_ICONSTOP); } - void pluginExceptionAlert(const TCHAR *pluginName, const std::exception& e) { - generic_string msg = TEXT("An exception occurred due to plugin: "); + void pluginExceptionAlert(const wchar_t *pluginName, const std::exception& e) { + std::wstring msg = L"An exception occurred due to plugin: "; msg += pluginName; - msg += TEXT("\r\n\r\nException reason: "); + msg += L"\r\n\r\nException reason: "; msg += s2ws(e.what()); - ::MessageBox(NULL, msg.c_str(), TEXT("Plugin Exception"), MB_OK); + ::MessageBox(NULL, msg.c_str(), L"Plugin Exception", MB_OK); } - bool isInLoadedDlls(const TCHAR *fn) const { + bool isInLoadedDlls(const wchar_t *fn) const { for (size_t i = 0; i < _loadedDlls.size(); ++i) if (wcsicmp(fn, _loadedDlls[i]._fileName.c_str()) == 0) return true; return false; } - void addInLoadedDlls(const TCHAR *fullPath, const TCHAR *fn) { + void addInLoadedDlls(const wchar_t *fullPath, const wchar_t *fn) { _loadedDlls.push_back(LoadedDllInfo(fullPath, fn)); } }; diff --git a/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp index 748522c620c1..d2c91dfb4563 100644 --- a/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp @@ -252,7 +252,7 @@ using namespace std; constexpr size_t tagMaxLen = 256; -static bool isInList(const generic_string& word, const vector & wordArray) +static bool isInList(const wstring& word, const vector & wordArray) { for (size_t i = 0, len = wordArray.size(); i < len; ++i) if (wordArray[i] == word) @@ -260,7 +260,7 @@ static bool isInList(const generic_string& word, const vector & return false; } -static bool isAllDigits(const generic_string &str) +static bool isAllDigits(const wstring &str) { for (const auto& i : str) { @@ -270,12 +270,12 @@ static bool isAllDigits(const generic_string &str) return true; } -static void sortInsensitive(vector &wordArray) +static void sortInsensitive(vector &wordArray) { sort( wordArray.begin(), wordArray.end(), - [](const generic_string &a, const generic_string &b) + [](const wstring &a, const wstring &b) { return lexicographical_compare( a.begin(), a.end(), @@ -305,7 +305,7 @@ bool AutoCompletion::showAutoComplete(AutocompleteType autocType, bool autoInser size_t len = (curPos > startPos)?(curPos - startPos):(startPos - curPos); - generic_string words; + wstring words; if (autocType == autocFunc) { @@ -324,16 +324,16 @@ bool AutoCompletion::showAutoComplete(AutocompleteType autocType, bool autoInser if (lena >= bufSize) return false; - TCHAR beginChars[bufSize]; + wchar_t beginChars[bufSize]; _pEditView->getGenericText(beginChars, bufSize, startPos, curPos); // Get word array containing all words beginning with beginChars, excluding word equal to allChars - vector wordArray; + vector wordArray; if (autocType == autocWord || autocType == autocFuncAndWord) { - TCHAR allChars[bufSize]; + wchar_t allChars[bufSize]; _pEditView->getGenericText(allChars, bufSize, startPos, endPos); getWordArray(wordArray, beginChars, allChars); } @@ -349,7 +349,7 @@ bool AutoCompletion::showAutoComplete(AutocompleteType autocType, bool autoInser if (_ignoreCase) { - generic_string kwSufix = _keyWordArray[i].substr(0, len); + wstring kwSufix = _keyWordArray[i].substr(0, len); compareResult = wcsicmp(beginChars, kwSufix.c_str()); } else @@ -399,7 +399,7 @@ bool AutoCompletion::showAutoComplete(AutocompleteType autocType, bool autoInser { words += wordArray[i]; if (i != wordArrayLen - 1) - words += TEXT(" "); + words += L" "; } } @@ -451,7 +451,7 @@ bool AutoCompletion::showApiAndWordComplete() return showAutoComplete(autocFuncAndWord, false); } -void AutoCompletion::getWordArray(vector & wordArray, TCHAR *beginChars, TCHAR *allChars) +void AutoCompletion::getWordArray(vector & wordArray, wchar_t *beginChars, wchar_t *allChars) { const size_t bufSize = 256; const NppGUI & nppGUI = NppParameters::getInstance().getNppGUI(); @@ -459,9 +459,9 @@ void AutoCompletion::getWordArray(vector & wordArray, TCHAR *beg if (nppGUI._autocIgnoreNumbers && isAllDigits(beginChars)) return; - generic_string expr(TEXT("\\<")); + wstring expr(L"\\<"); expr += beginChars; - expr += TEXT("[^ \\t\\n\\r.,;:\"(){}=<>'+!?\\[\\]]+"); + expr += L"[^ \\t\\n\\r.,;:\"(){}=<>'+!?\\[\\]]+"; size_t docLength = _pEditView->execute(SCI_GETLENGTH); @@ -473,8 +473,8 @@ void AutoCompletion::getWordArray(vector & wordArray, TCHAR *beg _pEditView->execute(SCI_SETSEARCHFLAGS, flags); intptr_t posFind = _pEditView->searchInTarget(expr.c_str(), expr.length(), 0, docLength); - generic_string boxId = TEXT("\x1E") + intToString(BOX_IMG_ID); - generic_string funcId = TEXT("\x1E") + intToString(FUNC_IMG_ID); + wstring boxId = L"\x1E" + intToString(BOX_IMG_ID); + wstring funcId = L"\x1E" + intToString(FUNC_IMG_ID); while (posFind >= 0) { @@ -484,7 +484,7 @@ void AutoCompletion::getWordArray(vector & wordArray, TCHAR *beg size_t foundTextLen = wordEnd - wordStart; if (foundTextLen < bufSize) { - TCHAR w[bufSize]; + wchar_t w[bufSize]; _pEditView->getGenericText(w, bufSize, wordStart, wordEnd); if (!allChars || (wcsncmp(w, allChars, bufSize) != 0)) { @@ -516,7 +516,7 @@ void AutoCompletion::getWordArray(vector & wordArray, TCHAR *beg } } -static generic_string addTrailingSlash(const generic_string& path) +static wstring addTrailingSlash(const wstring& path) { if (path.length() >=1 && path[path.length() - 1] == '\\') return path; @@ -524,7 +524,7 @@ static generic_string addTrailingSlash(const generic_string& path) return path + L"\\"; } -static generic_string removeTrailingSlash(const generic_string& path) +static wstring removeTrailingSlash(const wstring& path) { if (path.length() >= 1 && path[path.length() - 1] == '\\') return path.substr(0, path.length() - 1); @@ -532,25 +532,25 @@ static generic_string removeTrailingSlash(const generic_string& path) return path; } -static bool isDirectory(const generic_string& path) +static bool isDirectory(const wstring& path) { DWORD type = ::GetFileAttributes(path.c_str()); return type != INVALID_FILE_ATTRIBUTES && (type & FILE_ATTRIBUTE_DIRECTORY); } -static bool isFile(const generic_string& path) +static bool isFile(const wstring& path) { DWORD type = ::GetFileAttributes(path.c_str()); return type != INVALID_FILE_ATTRIBUTES && ! (type & FILE_ATTRIBUTE_DIRECTORY); } -static bool isAllowedBeforeDriveLetter(TCHAR c) +static bool isAllowedBeforeDriveLetter(wchar_t c) { locale loc; return c == '\'' || c == '"' || c == '(' || std::isspace(c, loc); } -static bool getRawPath(const generic_string& input, generic_string &rawPath_out) +static bool getRawPath(const wstring& input, wstring &rawPath_out) { // Try to find a path in the given input. // Algorithm: look for a colon. The colon must be preceded by an alphabetic character. @@ -571,9 +571,9 @@ static bool getRawPath(const generic_string& input, generic_string &rawPath_out) return true; } -static bool getPathsForPathCompletion(const generic_string& input, generic_string &rawPath_out, generic_string &pathToMatch_out) +static bool getPathsForPathCompletion(const wstring& input, wstring &rawPath_out, wstring &pathToMatch_out) { - generic_string rawPath; + wstring rawPath; if (! getRawPath(input, rawPath)) { return false; @@ -605,10 +605,10 @@ static bool getPathsForPathCompletion(const generic_string& input, generic_strin void AutoCompletion::showPathCompletion() { // Get current line (at most MAX_PATH characters "backwards" from current caret). - generic_string currentLine; + wstring currentLine; { const intptr_t bufSize = MAX_PATH; - TCHAR buf[bufSize + 1] = { '\0' }; + wchar_t buf[bufSize + 1] = { '\0' }; const intptr_t currentPos = _pEditView->execute(SCI_GETCURRENTPOS); const auto startPos = std::max(0, currentPos - bufSize); _pEditView->getGenericText(buf, bufSize + 1, startPos, currentPos); @@ -623,17 +623,17 @@ void AutoCompletion::showPathCompletion() For instance: the user wants to autocomplete "C:\Wind", and assuming that no such directory exists, this means we should list all files and directories in C:. */ - generic_string rawPath, pathToMatch; + wstring rawPath, pathToMatch; if (! getPathsForPathCompletion(currentLine, rawPath, pathToMatch)) return; // Get all files and directories in the path. - generic_string autoCompleteEntries; + wstring autoCompleteEntries; { HANDLE hFind; WIN32_FIND_DATA data; - generic_string pathToMatchPlusSlash = addTrailingSlash(pathToMatch); - generic_string searchString = pathToMatchPlusSlash + TEXT("*.*"); + wstring pathToMatchPlusSlash = addTrailingSlash(pathToMatch); + wstring searchString = pathToMatchPlusSlash + L"*.*"; hFind = ::FindFirstFile(searchString.c_str(), &data); if (hFind != INVALID_HANDLE_VALUE) { @@ -646,16 +646,16 @@ void AutoCompletion::showPathCompletion() if (++counter > maxEntries) break; - if (generic_string(data.cFileName) == TEXT(".") || generic_string(data.cFileName) == TEXT("..")) + if (wstring(data.cFileName) == L"." || wstring(data.cFileName) == L"..") continue; if (! autoCompleteEntries.empty()) - autoCompleteEntries += TEXT("\n"); + autoCompleteEntries += L"\n"; autoCompleteEntries += pathToMatchPlusSlash; autoCompleteEntries += data.cFileName; if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // If directory, add trailing slash. - autoCompleteEntries += TEXT("\\"); + autoCompleteEntries += L"\\"; } while (::FindNextFile(hFind, &data)); ::FindClose(hFind); @@ -712,7 +712,7 @@ void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t car int flags = SCFIND_REGEXP | SCFIND_POSIX; _pEditView->execute(SCI_SETSEARCHFLAGS, flags); - TCHAR tag2find[] = TEXT("<[^\\s>]*"); + wchar_t tag2find[] = L"<[^\\s>]*"; intptr_t targetStart = _pEditView->searchInTarget(tag2find, lstrlen(tag2find), caretPos, 0); @@ -1047,7 +1047,7 @@ void AutoCompletion::update(int character) return; const int wordSize = 64; - TCHAR s[wordSize]; + wchar_t s[wordSize]; _pEditView->getWordToCurrentPos(s, wordSize); if (lstrlen(s) >= int(nppGUI._autocFromLen)) @@ -1086,12 +1086,12 @@ bool AutoCompletion::setLanguage(LangType language) _curLang = language; - TCHAR path[MAX_PATH]; + wchar_t path[MAX_PATH]; ::GetModuleFileName(NULL, path, MAX_PATH); PathRemoveFileSpec(path); - wcscat_s(path, TEXT("\\autoCompletion\\")); + wcscat_s(path, L"\\autoCompletion\\"); wcscat_s(path, getApiFileName()); - wcscat_s(path, TEXT(".xml")); + wcscat_s(path, L".xml"); if (_pXmlFile) delete _pXmlFile; @@ -1103,13 +1103,13 @@ bool AutoCompletion::setLanguage(LangType language) if (_funcCompletionActive) { _funcCompletionActive = false; //safety - TiXmlNode * pNode = _pXmlFile->FirstChild(TEXT("NotepadPlus")); + TiXmlNode * pNode = _pXmlFile->FirstChild(L"NotepadPlus"); if (!pNode) return false; - pAutoNode = pNode = pNode->FirstChildElement(TEXT("AutoComplete")); + pAutoNode = pNode = pNode->FirstChildElement(L"AutoComplete"); if (!pNode) return false; - pNode = pNode->FirstChildElement(TEXT("KeyWord")); + pNode = pNode->FirstChildElement(L"KeyWord"); if (!pNode) return false; _pXmlKeyword = reinterpret_cast(pNode); @@ -1129,29 +1129,29 @@ bool AutoCompletion::setLanguage(LangType language) _funcCalltip._ignoreCase = true; _funcCalltip._additionalWordChar.clear(); - TiXmlElement * pElem = pAutoNode->FirstChildElement(TEXT("Environment")); + TiXmlElement * pElem = pAutoNode->FirstChildElement(L"Environment"); if (pElem) { - const TCHAR * val = 0; - val = pElem->Attribute(TEXT("ignoreCase")); - if (val && !lstrcmp(val, TEXT("no"))) + const wchar_t * val = 0; + val = pElem->Attribute(L"ignoreCase"); + if (val && !lstrcmp(val, L"no")) { _ignoreCase = false; _funcCalltip._ignoreCase = false; } - val = pElem->Attribute(TEXT("startFunc")); + val = pElem->Attribute(L"startFunc"); if (val && val[0]) _funcCalltip._start = val[0]; - val = pElem->Attribute(TEXT("stopFunc")); + val = pElem->Attribute(L"stopFunc"); if (val && val[0]) _funcCalltip._stop = val[0]; - val = pElem->Attribute(TEXT("paramSeparator")); + val = pElem->Attribute(L"paramSeparator"); if (val && val[0]) _funcCalltip._param = val[0]; - val = pElem->Attribute(TEXT("terminal")); + val = pElem->Attribute(L"terminal"); if (val && val[0]) _funcCalltip._terminal = val[0]; - val = pElem->Attribute(TEXT("additionalWordChar")); + val = pElem->Attribute(L"additionalWordChar"); if (val && val[0]) _funcCalltip._additionalWordChar = val; } @@ -1175,18 +1175,18 @@ bool AutoCompletion::setLanguage(LangType language) //Iterate through all keywords TiXmlElement *funcNode = _pXmlKeyword; - for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) + for (; funcNode; funcNode = funcNode->NextSiblingElement(L"KeyWord") ) { - const TCHAR *name = funcNode->Attribute(TEXT("name")); + const wchar_t *name = funcNode->Attribute(L"name"); if (name) { size_t len = lstrlen(name); if (len) { - generic_string word = name; - generic_string imgid = TEXT("\x1E"); - const TCHAR *func = funcNode->Attribute(TEXT("func")); - if (func && !lstrcmp(func, TEXT("yes"))) + wstring word = name; + wstring imgid = L"\x1E"; + const wchar_t *func = funcNode->Attribute(L"func"); + if (func && !lstrcmp(func, L"yes")) imgid += intToString(FUNC_IMG_ID); else imgid += intToString(BOX_IMG_ID); @@ -1206,13 +1206,13 @@ bool AutoCompletion::setLanguage(LangType language) for (size_t i = 0, len = _keyWordArray.size(); i < len; ++i) { _keyWords.append(_keyWordArray[i]); - _keyWords.append(TEXT(" ")); + _keyWords.append(L" "); } } return _funcCompletionActive; } -const TCHAR * AutoCompletion::getApiFileName() +const wchar_t * AutoCompletion::getApiFileName() { if (_curLang == L_USER) { diff --git a/PowerEditor/src/ScintillaComponent/AutoCompletion.h b/PowerEditor/src/ScintillaComponent/AutoCompletion.h index 5257894acd57..9448acd3cd94 100644 --- a/PowerEditor/src/ScintillaComponent/AutoCompletion.h +++ b/PowerEditor/src/ScintillaComponent/AutoCompletion.h @@ -106,14 +106,14 @@ class AutoCompletion { bool _ignoreCase = true; - std::vector _keyWordArray; - generic_string _keyWords; + std::vector _keyWordArray; + std::wstring _keyWords; size_t _keyWordMaxLen = 0; FunctionCallTip _funcCalltip; - const TCHAR * getApiFileName(); - void getWordArray(std::vector & wordArray, TCHAR *beginChars, TCHAR *excludeChars); + const wchar_t * getApiFileName(); + void getWordArray(std::vector & wordArray, wchar_t *beginChars, wchar_t *excludeChars); // Type of autocomplete function enum AutocompleteType { diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index 5c4d273bcbfb..6eae6f6fe499 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -52,7 +52,7 @@ FunctionListPanel::~FunctionListPanel() _iconListVector.clear(); } -void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos) +void FunctionListPanel::addEntry(const wchar_t *nodeName, const wchar_t *displayText, size_t pos) { HTREEITEM itemParent = NULL; std::wstring posStr = std::to_wstring(pos); @@ -64,7 +64,7 @@ void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText itemParent = _treeView.searchSubItemByName(nodeName, root); if (!itemParent) { - generic_string* invalidValueStr = new generic_string(posStr); + wstring* invalidValueStr = new wstring(posStr); _posStrs.push_back(invalidValueStr); LPARAM lParamInvalidPosStr = reinterpret_cast(invalidValueStr); @@ -74,7 +74,7 @@ void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText else itemParent = root; - generic_string* posString = new generic_string(posStr); + wstring* posString = new wstring(posStr); _posStrs.push_back(posString); LPARAM lParamPosStr = reinterpret_cast(posString); @@ -87,7 +87,7 @@ void FunctionListPanel::removeAllEntries() } // bodyOpenSybe mbol & bodyCloseSymbol should be RE -size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol) +size_t FunctionListPanel::getBodyClosePos(size_t begin, const wchar_t *bodyOpenSymbol, const wchar_t *bodyCloseSymbol) { size_t cntOpen = 1; @@ -96,11 +96,11 @@ size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSym if (begin >= docLen) return docLen; - generic_string exprToSearch = TEXT("("); + wstring exprToSearch = L"("; exprToSearch += bodyOpenSymbol; - exprToSearch += TEXT("|"); + exprToSearch += L"|"; exprToSearch += bodyCloseSymbol; - exprToSearch += TEXT(")"); + exprToSearch += L")"; int flags = SCFIND_REGEXP | SCFIND_POSIX; @@ -139,27 +139,27 @@ size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSym return targetEnd; } -generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, intptr_t& foundPos) +wstring FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::vector< wstring > dataToSearch, intptr_t& foundPos) { if (begin >= end) { foundPos = -1; - return TEXT(""); + return L""; } if (!dataToSearch.size()) - return TEXT(""); + return L""; int flags = SCFIND_REGEXP | SCFIND_POSIX; (*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags); - const TCHAR *regExpr2search = dataToSearch[0].c_str(); + const wchar_t *regExpr2search = dataToSearch[0].c_str(); intptr_t targetStart = (*_ppEditView)->searchInTarget(regExpr2search, lstrlen(regExpr2search), begin, end); if (targetStart < 0) { foundPos = -1; - return TEXT(""); + return L""; } intptr_t targetEnd = (*_ppEditView)->execute(SCI_GETTARGETEND); @@ -170,7 +170,7 @@ generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::v } else // only one processed element, so we conclude the result { - TCHAR foundStr[1024]{}; + wchar_t foundStr[1024]{}; (*_ppEditView)->getGenericText(foundStr, 1024, targetStart, targetEnd); @@ -179,7 +179,7 @@ generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::v } } -void FunctionListPanel::addInStateArray(TreeStateNode tree2Update, const TCHAR *searchText, bool isSorted) +void FunctionListPanel::addInStateArray(TreeStateNode tree2Update, const wchar_t *searchText, bool isSorted) { bool found = false; for (size_t i = 0, len = _treeParams.size(); i < len; ++i) @@ -202,7 +202,7 @@ void FunctionListPanel::addInStateArray(TreeStateNode tree2Update, const TCHAR * } } -TreeParams* FunctionListPanel::getFromStateArray(generic_string fullFilePath) +TreeParams* FunctionListPanel::getFromStateArray(wstring fullFilePath) { for (size_t i = 0, len = _treeParams.size(); i < len; ++i) { @@ -219,7 +219,7 @@ void FunctionListPanel::sortOrUnsort() _pTreeView->sort(_pTreeView->getRoot(), true); else { - TCHAR text2search[MAX_PATH] = { '\0' }; + wchar_t text2search[MAX_PATH] = { '\0' }; ::SendMessage(_hSearchEdit, WM_GETTEXT, MAX_PATH, reinterpret_cast(text2search)); if (text2search[0] == '\0') // main view @@ -234,9 +234,9 @@ void FunctionListPanel::sortOrUnsort() return; _treeViewSearchResult.removeAllItems(); - const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); + const wchar_t *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); - generic_string* invalidValueStr = new generic_string(TEXT("-1")); + wstring* invalidValueStr = new wstring(L"-1"); _posStrs.push_back(invalidValueStr); LPARAM lParamInvalidPosStr = reinterpret_cast(invalidValueStr); _treeViewSearchResult.addItem(fn, NULL, INDEX_ROOT, lParamInvalidPosStr); @@ -252,8 +252,8 @@ void FunctionListPanel::sortOrUnsort() int CALLBACK FunctionListPanel::categorySortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM /*lParamSort*/) { - generic_string* posString1 = reinterpret_cast(lParam1); - generic_string* posString2 = reinterpret_cast(lParam2); + wstring* posString1 = reinterpret_cast(lParam1); + wstring* posString2 = reinterpret_cast(lParam2); size_t pos1 = _wtoi(posString1->c_str()); size_t pos2 = _wtoi(posString2->c_str()); @@ -263,23 +263,23 @@ int CALLBACK FunctionListPanel::categorySortFunc(LPARAM lParam1, LPARAM lParam2, return -1; } -bool FunctionListPanel::serialize(const generic_string & outputFilename) +bool FunctionListPanel::serialize(const wstring & outputFilename) { Buffer* currentBuf = (*_ppEditView)->getCurrentBuffer(); - const TCHAR* fileNameLabel = currentBuf->getFileName(); + const wchar_t* fileNameLabel = currentBuf->getFileName(); - generic_string fname2write; + wstring fname2write; if (outputFilename.empty()) // if outputFilename is not given, get the current file path by adding the file extension { - const TCHAR *fullFilePath = currentBuf->getFullPathName(); + const wchar_t *fullFilePath = currentBuf->getFullPathName(); // Export function list from an existing file bool exportFuncntionList = (NppParameters::getInstance()).doFunctionListExport(); if (exportFuncntionList && ::PathFileExists(fullFilePath)) { fname2write = fullFilePath; - fname2write += TEXT(".result"); - fname2write += TEXT(".json"); + fname2write += L".result"; + fname2write += L".json"; } else return false; @@ -352,24 +352,24 @@ void FunctionListPanel::reload() bool isOK = _treeView.retrieveFoldingStateTo(currentTree, _treeView.getRoot()); if (isOK) { - TCHAR text2Search[MAX_PATH] = { '\0' }; + wchar_t text2Search[MAX_PATH] = { '\0' }; ::SendMessage(_hSearchEdit, WM_GETTEXT, MAX_PATH, reinterpret_cast(text2Search)); bool isSorted = shouldSort(); addInStateArray(currentTree, text2Search, isSorted); } removeAllEntries(); - ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, reinterpret_cast(TEXT(""))); + ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, reinterpret_cast(L"")); setSort(false); _foundFuncInfos.clear(); Buffer* currentBuf = (*_ppEditView)->getCurrentBuffer(); - const TCHAR *fn = currentBuf->getFileName(); + const wchar_t *fn = currentBuf->getFileName(); LangType langID = currentBuf->getLangType(); if (langID == L_JS) langID = L_JAVASCRIPT; - const TCHAR *udln = NULL; + const wchar_t *udln = NULL; if (langID == L_USER) { udln = currentBuf->getUserDefineLangName(); @@ -380,7 +380,7 @@ void FunctionListPanel::reload() bool parsedOK = _funcParserMgr.parse(_foundFuncInfos, AssociationInfo(-1, langID, ext, udln)); if (parsedOK) { - generic_string* invalidValueStr = new generic_string(TEXT("-1")); + wstring* invalidValueStr = new wstring(L"-1"); _posStrs.push_back(invalidValueStr); LPARAM lParamInvalidPosStr = reinterpret_cast(invalidValueStr); @@ -397,9 +397,9 @@ void FunctionListPanel::reload() if (root) { currentBuf = (*_ppEditView)->getCurrentBuffer(); - const TCHAR *fullFilePath = currentBuf->getFullPathName(); + const wchar_t *fullFilePath = currentBuf->getFullPathName(); - generic_string* fullPathStr = new generic_string(fullFilePath); + wstring* fullPathStr = new wstring(fullFilePath); _posStrs.push_back(fullPathStr); LPARAM lParamFullPathStr = reinterpret_cast(fullPathStr); @@ -407,7 +407,7 @@ void FunctionListPanel::reload() TreeParams *previousParams = getFromStateArray(fullFilePath); if (!previousParams) { - ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, reinterpret_cast(TEXT(""))); + ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, reinterpret_cast(L"")); setSort(NppParameters::getInstance().getNppGUI()._shouldSortFunctionList); sortOrUnsort(); _treeView.expand(root); @@ -440,7 +440,7 @@ void FunctionListPanel::initPreferencesMenu() NativeLangSpeaker* pNativeSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); const NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); - generic_string shouldSortFunctionListStr = pNativeSpeaker->getAttrNameStr(TEXT("Sort functions (A to Z) by default"), FL_FUCTIONLISTROOTNODE, FL_PREFERENCE_INITIALSORT); + wstring shouldSortFunctionListStr = pNativeSpeaker->getAttrNameStr(L"Sort functions (A to Z) by default", FL_FUCTIONLISTROOTNODE, FL_PREFERENCE_INITIALSORT); _hPreferencesMenu = ::CreatePopupMenu(); ::InsertMenu(_hPreferencesMenu, 0, MF_BYCOMMAND, FL_PREFERENCES_INITIALSORT_ID, shouldSortFunctionListStr.c_str()); @@ -498,7 +498,7 @@ void FunctionListPanel::findMarkEntry(HTREEITEM htItem, LONG line) tvItem.mask = TVIF_IMAGE | TVIF_PARAM; ::SendMessage(_treeViewSearchResult.getHSelf(), TVM_GETITEM, 0, reinterpret_cast(&tvItem)); - generic_string *posStr = reinterpret_cast(tvItem.lParam); + wstring *posStr = reinterpret_cast(tvItem.lParam); if (posStr) { int pos = _wtoi(posStr->c_str()); @@ -530,11 +530,11 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp _ppEditView = ppEditView; NppParameters& nppParams = NppParameters::getInstance(); - generic_string funcListXmlPath = nppParams.getUserPath(); - pathAppend(funcListXmlPath, TEXT("functionList")); + wstring funcListXmlPath = nppParams.getUserPath(); + pathAppend(funcListXmlPath, L"functionList"); - generic_string funcListDefaultXmlPath = nppParams.getNppPath(); - pathAppend(funcListDefaultXmlPath, TEXT("functionList")); + wstring funcListDefaultXmlPath = nppParams.getNppPath(); + pathAppend(funcListDefaultXmlPath, L"functionList"); bool doLocalConf = nppParams.isLocal(); @@ -579,7 +579,7 @@ bool FunctionListPanel::openSelection(const TreeView & treeView) return false; } - generic_string *posStr = reinterpret_cast(tvItem.lParam); + wstring *posStr = reinterpret_cast(tvItem.lParam); if (!posStr) return false; @@ -651,7 +651,7 @@ void FunctionListPanel::notified(LPNMHDR notification) } else if (ptvkd->wVKey == VK_ESCAPE) { - ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, reinterpret_cast(TEXT(""))); + ::SendMessage(_hSearchEdit, WM_SETTEXT, 0, reinterpret_cast(L"")); SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, 1); // remove beep PostMessage(_hParent, WM_COMMAND, SCEN_SETFOCUS << 16, reinterpret_cast((*_ppEditView)->getHSelf())); } @@ -671,7 +671,7 @@ void FunctionListPanel::notified(LPNMHDR notification) void FunctionListPanel::searchFuncAndSwitchView() { - TCHAR text2search[MAX_PATH] = { '\0' }; + wchar_t text2search[MAX_PATH] = { '\0' }; ::SendMessage(_hSearchEdit, WM_GETTEXT, MAX_PATH, reinterpret_cast(text2search)); if (text2search[0] == '\0') @@ -686,9 +686,9 @@ void FunctionListPanel::searchFuncAndSwitchView() return; _treeViewSearchResult.removeAllItems(); - const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); + const wchar_t *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); - generic_string* invalidValueStr = new generic_string(TEXT("-1")); + wstring* invalidValueStr = new wstring(L"-1"); _posStrs.push_back(invalidValueStr); LPARAM lParamInvalidPosStr = reinterpret_cast(invalidValueStr); _treeViewSearchResult.addItem(fn, NULL, INDEX_ROOT, lParamInvalidPosStr); @@ -732,7 +732,7 @@ static LRESULT CALLBACK funclstSearchEditProc(HWND hwnd, UINT message, WPARAM wP { if (wParam == VK_ESCAPE) { - ::SendMessage(hwnd, WM_SETTEXT, 0, reinterpret_cast(TEXT(""))); + ::SendMessage(hwnd, WM_SETTEXT, 0, reinterpret_cast(L"")); return FALSE; } else if (wParam == VK_TAB) @@ -772,7 +772,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP // Make edit field red if not found case WM_CTLCOLOREDIT : { - TCHAR text2search[MAX_PATH] = { '\0' }; + wchar_t text2search[MAX_PATH] = { '\0' }; ::SendMessage(_hSearchEdit, WM_GETTEXT, MAX_PATH, reinterpret_cast(text2search)); bool textFound = false; if (text2search[0] == '\0') diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h index 7722e926d169..fb7aa29daef5 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h @@ -21,7 +21,7 @@ #include "functionParser.h" #include "TreeView.h" -#define FL_PANELTITLE TEXT("Function List") +#define FL_PANELTITLE L"Function List" #define FL_FUCTIONLISTROOTNODE "FunctionList" #define FL_SORTLOCALNODENAME "SortTip" @@ -55,11 +55,11 @@ root */ struct SearchParameters { - generic_string _text2Find; + std::wstring _text2Find; bool _doSort = false; bool hasParams()const{ - return (_text2Find != TEXT("") || _doSort); + return (_text2Find != L"" || _doSort); }; }; @@ -98,8 +98,8 @@ class FunctionListPanel : public DockingDlgInterface { void sortOrUnsort(); void reload(); void markEntry(); - bool serialize(const generic_string & outputFilename = TEXT("")); - void addEntry(const TCHAR *node, const TCHAR *displayText, size_t pos); + bool serialize(const std::wstring & outputFilename = L""); + void addEntry(const wchar_t *node, const wchar_t *displayText, size_t pos); void removeAllEntries(); void searchFuncAndSwitchView(); @@ -122,24 +122,24 @@ class FunctionListPanel : public DockingDlgInterface { long _findEndLine = -1; HTREEITEM _findItem = nullptr; - generic_string _sortTipStr = TEXT("Sort"); - generic_string _reloadTipStr = TEXT("Reload"); - generic_string _preferenceTipStr = TEXT("Preferences"); + std::wstring _sortTipStr = L"Sort"; + std::wstring _reloadTipStr = L"Reload"; + std::wstring _preferenceTipStr = L"Preferences"; std::vector _foundFuncInfos; - std::vector _posStrs; + std::vector _posStrs; ScintillaEditView **_ppEditView = nullptr; FunctionParsersManager _funcParserMgr; std::vector< std::pair > _skipZones; std::vector _treeParams; - generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, intptr_t& foundPos); - size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol); + std::wstring parseSubLevel(size_t begin, size_t end, std::vector< std::wstring > dataToSearch, intptr_t& foundPos); + size_t getBodyClosePos(size_t begin, const wchar_t *bodyOpenSymbol, const wchar_t *bodyCloseSymbol); void notified(LPNMHDR notification); - void addInStateArray(TreeStateNode tree2Update, const TCHAR *searchText, bool isSorted); - TreeParams* getFromStateArray(generic_string fullFilePath); + void addInStateArray(TreeStateNode tree2Update, const wchar_t *searchText, bool isSorted); + TreeParams* getFromStateArray(std::wstring fullFilePath); bool openSelection(const TreeView &treeView); bool shouldSort(); void setSort(bool isEnabled); diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index 0010362afc7c..1de6f2ffcaf5 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -65,28 +65,28 @@ void ShortcutMapper::getClientRect(RECT& rc) const ::InflateRect(&rc, -padding, 0); } -generic_string ShortcutMapper::getTabString(size_t i) const +wstring ShortcutMapper::getTabString(size_t i) const { if (i >= _nbTab) - return TEXT(""); + return L""; NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); switch (i) { case 1: - return nativeLangSpeaker->getShortcutMapperLangStr("MacrosTab", TEXT("Macros")); + return nativeLangSpeaker->getShortcutMapperLangStr("MacrosTab", L"Macros"); case 2: - return nativeLangSpeaker->getShortcutMapperLangStr("RunCommandsTab", TEXT("Run commands")); + return nativeLangSpeaker->getShortcutMapperLangStr("RunCommandsTab", L"Run commands"); case 3: - return nativeLangSpeaker->getShortcutMapperLangStr("PluginCommandsTab", TEXT("Plugin commands")); + return nativeLangSpeaker->getShortcutMapperLangStr("PluginCommandsTab", L"Plugin commands"); case 4: - return nativeLangSpeaker->getShortcutMapperLangStr("ScintillaCommandsTab", TEXT("Scintilla commands")); + return nativeLangSpeaker->getShortcutMapperLangStr("ScintillaCommandsTab", L"Scintilla commands"); default: //0 - return nativeLangSpeaker->getShortcutMapperLangStr("MainMenuTab", TEXT("Main menu")); + return nativeLangSpeaker->getShortcutMapperLangStr("MainMenuTab", L"Main menu"); } } @@ -166,16 +166,16 @@ void ShortcutMapper::initBabyGrid() NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); nativeLangSpeaker->changeDlgLang(_hSelf, "ShortcutMapper"); - _conflictInfoOk = nativeLangSpeaker->getShortcutMapperLangStr("ConflictInfoOk", TEXT("No shortcut conflicts for this item.")); - _conflictInfoEditing = nativeLangSpeaker->getShortcutMapperLangStr("ConflictInfoEditing", TEXT("No conflicts . . .")); + _conflictInfoOk = nativeLangSpeaker->getShortcutMapperLangStr("ConflictInfoOk", L"No shortcut conflicts for this item."); + _conflictInfoEditing = nativeLangSpeaker->getShortcutMapperLangStr("ConflictInfoEditing", L"No conflicts . . ."); } -generic_string ShortcutMapper::getTextFromCombo(HWND hCombo) +wstring ShortcutMapper::getTextFromCombo(HWND hCombo) { const int NB_MAX(128); - TCHAR str[NB_MAX](TEXT("\0")); + wchar_t str[NB_MAX](L"\0"); ::SendMessage(hCombo, WM_GETTEXT, NB_MAX, reinterpret_cast(str)); - generic_string res(str); + wstring res(str); return stringToLower(res); } @@ -194,7 +194,7 @@ bool ShortcutMapper::isFilterValid(Shortcut sc) for (size_t i = 0; i < filterSize; ++i) { - generic_string filterWord = _shortcutFilter.at(i); + wstring filterWord = _shortcutFilter.at(i); // every word must be matched by keycombo or name if (shortcut_name.find(filterWord) == std::string::npos && shortcut_value.find(filterWord) == std::string::npos) @@ -219,7 +219,7 @@ bool ShortcutMapper::isFilterValid(PluginCmdShortcut sc) for (size_t i = 0; i < filterSize; ++i) { - generic_string filterWord = _shortcutFilter.at(i); + wstring filterWord = _shortcutFilter.at(i); // every word must be matched by keycombo or name or plugin name if (shortcut_name.find(filterWord) == std::string::npos && shortcut_value.find(filterWord) == std::string::npos && @@ -244,7 +244,7 @@ bool ShortcutMapper::isFilterValid(ScintillaKeyMap sc) for (size_t i = 0; i < filterSize; ++i) { - generic_string filterWord = _shortcutFilter.at(i); + wstring filterWord = _shortcutFilter.at(i); // every word must be matched by keycombo or name if (shortcut_name.find(filterWord) == std::string::npos && shortcut_value.find(filterWord) == std::string::npos) @@ -262,8 +262,8 @@ void ShortcutMapper::fillOutBabyGrid() size_t nbItems = 0; NativeLangSpeaker* nativeLangSpeaker = nppParam.getNativeLangSpeaker(); - generic_string nameStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnName", TEXT("Name")); - generic_string shortcutStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnShortcut", TEXT("Shortcut")); + wstring nameStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnName", L"Name"); + wstring shortcutStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnShortcut", L"Shortcut"); _babygrid.setText(0, 1, nameStr.c_str()); _babygrid.setText(0, 2, shortcutStr.c_str()); @@ -274,7 +274,7 @@ void ShortcutMapper::fillOutBabyGrid() { nbItems = nppParam.getUserShortcuts().size(); _babygrid.setLineColNumber(nbItems, 3); - generic_string categoryStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnCategory", TEXT("Category")); + wstring categoryStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnCategory", L"Category"); _babygrid.setText(0, 3, categoryStr.c_str()); } break; @@ -297,7 +297,7 @@ void ShortcutMapper::fillOutBabyGrid() { nbItems = nppParam.getPluginCommandList().size(); _babygrid.setLineColNumber(nbItems, 3); - generic_string pluginStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnPlugin", TEXT("Plugin")); + wstring pluginStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnPlugin", L"Plugin"); _babygrid.setText(0, 3, pluginStr.c_str()); } break; @@ -314,15 +314,15 @@ void ShortcutMapper::fillOutBabyGrid() size_t cs_index = 0; // make _shortcutFilter a list of the words in IDC_BABYGRID_FILTER - generic_string shortcutFilterStr = getTextFromCombo(::GetDlgItem(_hSelf, IDC_BABYGRID_FILTER)); - const generic_string whitespace(TEXT(" ")); - std::vector shortcutFilterWithEmpties; + wstring shortcutFilterStr = getTextFromCombo(::GetDlgItem(_hSelf, IDC_BABYGRID_FILTER)); + const wstring whitespace(L" "); + std::vector shortcutFilterWithEmpties; stringSplit(shortcutFilterStr, whitespace, shortcutFilterWithEmpties); // now add only the non-empty strings in the split list to _shortcutFilter - _shortcutFilter = std::vector(); + _shortcutFilter = std::vector(); for (size_t i = 0; i < shortcutFilterWithEmpties.size(); ++i) { - generic_string filterWord = shortcutFilterWithEmpties.at(i); + wstring filterWord = shortcutFilterWithEmpties.at(i); if (!filterWord.empty()) _shortcutFilter.push_back(filterWord); } @@ -712,7 +712,7 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA if (!wParam || !lParam) break; - generic_string conflictInfo; + wstring conflictInfo; // In case of using filter will make the filtered items change index, so here we get its real index size_t realIndexOfSelectedItem = _shortcutIndex[_babygrid.getSelectedRow() - 1]; @@ -1073,8 +1073,8 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA NppParameters& nppParam = NppParameters::getInstance(); int res = nppParam.getNativeLangSpeaker()->messageBox("SCMapperDoDeleteOrNot", _hSelf, - TEXT("Are you sure you want to delete this shortcut?"), - TEXT("Are you sure?"), + L"Are you sure you want to delete this shortcut?", + L"Are you sure?", MB_OKCANCEL); if (res == IDOK) @@ -1226,9 +1226,9 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA { vector itemUnitArray; NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); - generic_string modifyStr = nativeLangSpeaker->getShortcutMapperLangStr("ModifyContextMenu", TEXT("Modify")); - generic_string deleteStr = nativeLangSpeaker->getShortcutMapperLangStr("DeleteContextMenu", TEXT("Delete")); - generic_string clearStr = nativeLangSpeaker->getShortcutMapperLangStr("ClearContextMenu", TEXT("Clear")); + wstring modifyStr = nativeLangSpeaker->getShortcutMapperLangStr("ModifyContextMenu", L"Modify"); + wstring deleteStr = nativeLangSpeaker->getShortcutMapperLangStr("DeleteContextMenu", L"Delete"); + wstring clearStr = nativeLangSpeaker->getShortcutMapperLangStr("ClearContextMenu", L"Clear"); itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_MODIFY, modifyStr.c_str())); itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_DELETE, deleteStr.c_str())); itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_CLEAR, clearStr.c_str())); @@ -1301,7 +1301,7 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA // In case of using filter will make the filtered items change index, so here we get its real index size_t realIndexOfSelectedItem = _shortcutIndex[currentIndex]; - generic_string conflictInfo; + wstring conflictInfo; switch (_currentState) { @@ -1378,7 +1378,7 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA return FALSE; } -bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConflictLocation, +bool ShortcutMapper::findKeyConflicts(__inout_opt wstring * const keyConflictLocation, const KeyCombo & itemKeyComboToTest, const size_t & itemIndexToTest) const { if (itemKeyComboToTest._key == 0) //no key assignment @@ -1411,15 +1411,15 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf else { if (!keyConflictLocation->empty()) - *keyConflictLocation += TEXT("\r\n"); + *keyConflictLocation += L"\r\n"; *keyConflictLocation += _tabNames[gridState]; - *keyConflictLocation += TEXT(" | "); + *keyConflictLocation += L" | "; *keyConflictLocation += std::to_wstring(itemIndex + 1); - *keyConflictLocation += TEXT(" "); + *keyConflictLocation += L" "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].getName(), CP_UTF8); - *keyConflictLocation += TEXT(" ( "); + *keyConflictLocation += L" ( "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].toString(), CP_UTF8); - *keyConflictLocation += TEXT(" )"); + *keyConflictLocation += L" )"; } } } @@ -1445,15 +1445,15 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf else { if (!keyConflictLocation->empty()) - *keyConflictLocation += TEXT("\r\n"); + *keyConflictLocation += L"\r\n"; *keyConflictLocation += _tabNames[gridState]; - *keyConflictLocation += TEXT(" | "); + *keyConflictLocation += L" | "; *keyConflictLocation += std::to_wstring(itemIndex + 1); - *keyConflictLocation += TEXT(" "); + *keyConflictLocation += L" "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].getName(), CP_UTF8); - *keyConflictLocation += TEXT(" ( "); + *keyConflictLocation += L" ( "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].toString(), CP_UTF8); - *keyConflictLocation += TEXT(" )"); + *keyConflictLocation += L" )"; } } } @@ -1479,15 +1479,15 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf else { if (!keyConflictLocation->empty()) - *keyConflictLocation += TEXT("\r\n"); + *keyConflictLocation += L"\r\n"; *keyConflictLocation += _tabNames[gridState]; - *keyConflictLocation += TEXT(" | "); + *keyConflictLocation += L" | "; *keyConflictLocation += std::to_wstring(itemIndex + 1); - *keyConflictLocation += TEXT(" "); + *keyConflictLocation += L" "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].getName(), CP_UTF8); - *keyConflictLocation += TEXT(" ( "); + *keyConflictLocation += L" ( "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].toString(), CP_UTF8); - *keyConflictLocation += TEXT(" )"); + *keyConflictLocation += L" )"; } } } @@ -1513,15 +1513,15 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf else { if (!keyConflictLocation->empty()) - *keyConflictLocation += TEXT("\r\n"); + *keyConflictLocation += L"\r\n"; *keyConflictLocation += _tabNames[gridState]; - *keyConflictLocation += TEXT(" | "); + *keyConflictLocation += L" | "; *keyConflictLocation += std::to_wstring(itemIndex + 1); - *keyConflictLocation += TEXT(" "); + *keyConflictLocation += L" "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].getName(), CP_UTF8); - *keyConflictLocation += TEXT(" ( "); + *keyConflictLocation += L" ( "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].toString(), CP_UTF8); - *keyConflictLocation += TEXT(" )"); + *keyConflictLocation += L" )"; } } } @@ -1550,18 +1550,18 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf else { if (!keyConflictLocation->empty()) - *keyConflictLocation += TEXT("\r\n"); + *keyConflictLocation += L"\r\n"; *keyConflictLocation += _tabNames[gridState]; - *keyConflictLocation += TEXT(" | "); + *keyConflictLocation += L" | "; *keyConflictLocation += std::to_wstring(itemIndex + 1); if (sciIndex > 0) - *keyConflictLocation += TEXT("* "); + *keyConflictLocation += L"* "; else - *keyConflictLocation += TEXT(" "); + *keyConflictLocation += L" "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].getName(), CP_UTF8); - *keyConflictLocation += TEXT(" ( "); + *keyConflictLocation += L" ( "; *keyConflictLocation += string2wstring(vShortcuts[itemIndex].toString(sciIndex), CP_UTF8); - *keyConflictLocation += TEXT(" )"); + *keyConflictLocation += L" )"; } } } diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h index 872b4d2687f5..fa0ff4140f3e 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h @@ -27,7 +27,7 @@ enum GridState {STATE_MENU, STATE_MACRO, STATE_USER, STATE_PLUGIN, STATE_SCINTIL class ShortcutMapper : public StaticDialog { public: ShortcutMapper() : StaticDialog(), _currentState(STATE_MENU) { - _shortcutFilter = std::vector(); + _shortcutFilter = std::vector(); _dialogInitDone = false; }; ~ShortcutMapper() = default; @@ -51,10 +51,10 @@ class ShortcutMapper : public StaticDialog { }; void getClientRect(RECT & rc) const override; - bool findKeyConflicts(__inout_opt generic_string * const keyConflictLocation, + bool findKeyConflicts(__inout_opt std::wstring * const keyConflictLocation, const KeyCombo & itemKeyCombo, const size_t & itemIndex) const; - generic_string getTextFromCombo(HWND hCombo); + std::wstring getTextFromCombo(HWND hCombo); bool isFilterValid(Shortcut sc); bool isFilterValid(PluginCmdShortcut sc); bool isFilterValid(ScintillaKeyMap sc); @@ -71,16 +71,16 @@ class ShortcutMapper : public StaticDialog { HWND _hTabCtrl = nullptr; const static int _nbTab = 5; - generic_string _tabNames[_nbTab]; - std::vector _shortcutFilter; + std::wstring _tabNames[_nbTab]; + std::vector _shortcutFilter; std::vector _shortcutIndex; //save/restore the last view std::vector _lastHomeRow; std::vector _lastCursorRow; - generic_string _conflictInfoOk; - generic_string _conflictInfoEditing; + std::wstring _conflictInfoOk; + std::wstring _conflictInfoEditing; std::vector _hGridFonts; @@ -98,7 +98,7 @@ class ShortcutMapper : public StaticDialog { void initTabs(); void initBabyGrid(); void fillOutBabyGrid(); - generic_string getTabString(size_t i) const; + std::wstring getTabString(size_t i) const; bool isConflict(const KeyCombo & lhs, const KeyCombo & rhs) const { diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp index 96b32d308293..50ca3fde7af7 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp @@ -26,6 +26,8 @@ #include "CustomFileDialog.h" #include "Parameters.h" +using namespace std; + // Workaround for MinGW because its implementation of __uuidof is different. template struct ComTraits @@ -45,8 +47,8 @@ namespace // anonymous struct Filter { - generic_string name; - generic_string ext; + wstring name; + wstring ext; }; static const int IDC_FILE_CUSTOM_CHECKBOX = 4; @@ -55,13 +57,13 @@ namespace // anonymous // Returns a first extension from the extension specification string. // Multiple extensions are separated with ';'. // Example: input - ".c;.cpp;.h", output - ".c" - generic_string get1stExt(const generic_string& extSpec) + wstring get1stExt(const wstring& extSpec) { size_t pos = extSpec.find('.'); - if (pos != generic_string::npos) + if (pos != wstring::npos) { size_t posEnd = extSpec.find(';', pos + 1); - if (posEnd != generic_string::npos) + if (posEnd != wstring::npos) { size_t extLen = posEnd - pos; return extSpec.substr(pos, extLen); @@ -71,13 +73,13 @@ namespace // anonymous return {}; } - bool replaceExt(generic_string& name, const generic_string& ext) + bool replaceExt(wstring& name, const wstring& ext) { if (!name.empty() && !ext.empty()) { // Remove an existing extension from the name. size_t posNameExt = name.find_last_of('.'); - if (posNameExt != generic_string::npos) + if (posNameExt != wstring::npos) name.erase(posNameExt); // Append a new extension. name += ext; @@ -86,14 +88,14 @@ namespace // anonymous return false; } - bool hasExt(const generic_string& name) + bool hasExt(const wstring& name) { - return name.find_last_of('.') != generic_string::npos; + return name.find_last_of('.') != wstring::npos; } - void expandEnv(generic_string& s) + void expandEnv(wstring& s) { - TCHAR buffer[MAX_PATH] = { '\0' }; + wchar_t buffer[MAX_PATH] = { '\0' }; // This returns the resulting string length or 0 in case of error. DWORD ret = ExpandEnvironmentStrings(s.c_str(), buffer, static_cast(std::size(buffer))); if (ret != 0) @@ -105,7 +107,7 @@ namespace // anonymous else { // Buffer was too small, try with a bigger buffer of the required size. - std::vector buffer2(ret, 0); + std::vector buffer2(ret, 0); ret = ExpandEnvironmentStrings(s.c_str(), buffer2.data(), static_cast(buffer2.size())); assert(ret == static_cast(lstrlen(buffer2.data()) + 1)); s = buffer2.data(); @@ -113,9 +115,9 @@ namespace // anonymous } } - generic_string getFilename(IShellItem* psi) + wstring getFilename(IShellItem* psi) { - generic_string result; + wstring result; if (psi) { PWSTR pszFilePath = nullptr; @@ -129,7 +131,7 @@ namespace // anonymous return result; } - bool setDialogFolder(IFileDialog* dialog, const TCHAR* path) + bool setDialogFolder(IFileDialog* dialog, const wchar_t* path) { com_ptr shellItem; HRESULT hr = SHCreateItemFromParsingName(path, @@ -147,9 +149,9 @@ namespace // anonymous return SUCCEEDED(hr); } - generic_string getDialogFileName(IFileDialog* dialog) + wstring getDialogFileName(IFileDialog* dialog) { - generic_string fileName; + wstring fileName; if (dialog) { PWSTR pszFilePath = nullptr; @@ -163,7 +165,7 @@ namespace // anonymous return fileName; } - generic_string getDialogFolder(IFileDialog* dialog) + wstring getDialogFolder(IFileDialog* dialog) { com_ptr psi; HRESULT hr = dialog->GetFolder(&psi); @@ -198,7 +200,7 @@ namespace // anonymous ::SetCurrentDirectory(_dir); } private: - TCHAR _dir[MAX_PATH]; + wchar_t _dir[MAX_PATH]; }; } // anonymous namespace @@ -300,7 +302,7 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo // Since GetFileTypeIndex() might return the old value in some cases. // Specifically, when called after SetFileTypeIndex(). _currentType = dialogIndex; - generic_string name = getDialogFileName(_dialog); + wstring name = getDialogFileName(_dialog); if (changeExt(name, dialogIndex - 1)) { // Set the file name and clear the selection in the edit box. @@ -376,7 +378,7 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo removeHooks(); } - const generic_string& getLastUsedFolder() const { return _lastUsedFolder; } + const wstring& getLastUsedFolder() const { return _lastUsedFolder; } private: FileDialogEventHandler(const FileDialogEventHandler&) = delete; @@ -444,23 +446,23 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo } } - bool changeExt(generic_string& name, int extIndex) + bool changeExt(wstring& name, int extIndex) { if (extIndex >= 0 && extIndex < static_cast(_filterSpec.size())) { - const generic_string ext = get1stExt(_filterSpec[extIndex].ext); + const wstring ext = get1stExt(_filterSpec[extIndex].ext); if (!ext.ends_with(_T(".*"))) return replaceExt(name, ext); } return false; } - generic_string getAbsPath(const generic_string& fileName) + wstring getAbsPath(const wstring& fileName) { if (::PathIsRelative(fileName.c_str())) { - TCHAR buffer[MAX_PATH] = { '\0' }; - const generic_string folder = getDialogFolder(_dialog); + wchar_t buffer[MAX_PATH] = { '\0' }; + const wstring folder = getDialogFolder(_dialog); LPTSTR ret = ::PathCombine(buffer, folder.c_str(), fileName.c_str()); if (ret) return buffer; @@ -475,7 +477,7 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo if (!_dialog) return; // Get the entered name. - generic_string fileName = getDialogFileName(_dialog); + wstring fileName = getDialogFileName(_dialog); expandEnv(fileName); bool nameChanged = transformPath(fileName); // Update the controls. @@ -497,14 +499,14 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo } // Transforms a forward-slash path to a canonical Windows path. - static bool transformPath(generic_string& fileName) + static bool transformPath(wstring& fileName) { if (fileName.empty()) return false; bool transformed = false; // Replace a forward-slash with a backslash. std::replace_if(fileName.begin(), fileName.end(), - [&transformed](generic_string::value_type c) + [&transformed](wstring::value_type c) { const bool eq = (c == '/'); transformed |= eq; @@ -519,7 +521,7 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo static BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM param) { const int bufferLen = MAX_PATH; - static TCHAR buffer[bufferLen]; + static wchar_t buffer[bufferLen]; static bool isRTL = false; auto* inst = reinterpret_cast(param); @@ -629,7 +631,7 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo com_ptr _dialog; com_ptr _customize; const std::vector _filterSpec; - generic_string _lastUsedFolder; + wstring _lastUsedFolder; HHOOK _prevKbdHook = nullptr; HHOOK _prevCallHook = nullptr; HWND _hwndNameEdit = nullptr; @@ -693,12 +695,12 @@ class CustomFileDialog::Impl if (SUCCEEDED(hr) && _initialFileName) { - generic_string newFileName = _initialFileName; + wstring newFileName = _initialFileName; if (_fileTypeIndex >= 0 && _fileTypeIndex < static_cast(_filterSpec.size())) { if (!hasExt(newFileName)) { - const generic_string ext = get1stExt(_filterSpec[_fileTypeIndex].ext); + const wstring ext = get1stExt(_filterSpec[_fileTypeIndex].ext); if (!ext.ends_with(_T(".*"))) newFileName += ext; } @@ -760,7 +762,7 @@ class CustomFileDialog::Impl return true; } - bool addCheckbox(int id, const TCHAR* label, bool value, bool enabled = true) + bool addCheckbox(int id, const wchar_t* label, bool value, bool enabled = true) { if (!_customize) return false; @@ -832,9 +834,9 @@ class CustomFileDialog::Impl return FALSE; } - generic_string getResultFilename() + wstring getResultFilename() { - generic_string fileName; + wstring fileName; com_ptr psiResult; HRESULT hr = _dialog->GetResult(&psiResult); if (SUCCEEDED(hr)) @@ -854,9 +856,9 @@ class CustomFileDialog::Impl return false; } - std::vector getFilenames() + std::vector getFilenames() { - std::vector result; + std::vector result; // Only the open dialog can have multiple results. com_ptr pfd = _dialog; if (pfd) @@ -886,12 +888,12 @@ class CustomFileDialog::Impl } HWND _hwndOwner = nullptr; - const TCHAR* _title = nullptr; - const TCHAR* _defExt = nullptr; - generic_string _initialFolder; - generic_string _fallbackFolder; - const TCHAR* _checkboxLabel = nullptr; - const TCHAR* _initialFileName = nullptr; + const wchar_t* _title = nullptr; + const wchar_t* _defExt = nullptr; + wstring _initialFolder; + wstring _fallbackFolder; + const wchar_t* _checkboxLabel = nullptr; + const wchar_t* _initialFileName = nullptr; bool _isCheckboxActive = true; std::vector _filterSpec; int _fileTypeIndex = -1; // preferred file type index @@ -899,7 +901,7 @@ class CustomFileDialog::Impl bool _hasReadonly = false; // set during the result handling bool _enableFileTypeCheckbox = false; bool _fileTypeCheckboxValue = false; // initial value - generic_string _fileTypeCheckboxLabel; + wstring _fileTypeCheckboxLabel; private: com_ptr _dialog; @@ -915,26 +917,26 @@ CustomFileDialog::CustomFileDialog(HWND hwnd) : _impl{ std::make_unique() NppParameters& params = NppParameters::getInstance(); NppGUI& nppGUI = params.getNppGUI(); - const TCHAR* workDir = nppGUI._openSaveDir == dir_last ? nppGUI._lastUsedDir : params.getWorkingDir(); + const wchar_t* workDir = nppGUI._openSaveDir == dir_last ? nppGUI._lastUsedDir : params.getWorkingDir(); if (workDir) _impl->_fallbackFolder = workDir; } CustomFileDialog::~CustomFileDialog() = default; -void CustomFileDialog::setTitle(const TCHAR* title) +void CustomFileDialog::setTitle(const wchar_t* title) { _impl->_title = title; } -void CustomFileDialog::setExtFilter(const TCHAR *extText, const TCHAR *exts) +void CustomFileDialog::setExtFilter(const wchar_t *extText, const wchar_t *exts) { // Add an asterisk before each dot in file patterns - generic_string newExts{ exts ? exts : _T("") }; + wstring newExts{ exts ? exts : _T("") }; for (size_t pos = 0; pos < newExts.size(); ++pos) { pos = newExts.find(_T('.'), pos); - if (pos == generic_string::npos) + if (pos == wstring::npos) break; if (pos == 0 || newExts[pos - 1] != _T('*')) { @@ -949,9 +951,9 @@ void CustomFileDialog::setExtFilter(const TCHAR *extText, const TCHAR *exts) _impl->_filterSpec.push_back({ extText, newExts }); } -void CustomFileDialog::setExtFilter(const TCHAR *extText, std::initializer_list extList) +void CustomFileDialog::setExtFilter(const wchar_t *extText, std::initializer_list extList) { - generic_string exts; + wstring exts; for (auto&& x : extList) { exts += x; @@ -961,22 +963,22 @@ void CustomFileDialog::setExtFilter(const TCHAR *extText, std::initializer_list< setExtFilter(extText, exts.c_str()); } -void CustomFileDialog::setDefExt(const TCHAR* ext) +void CustomFileDialog::setDefExt(const wchar_t* ext) { _impl->_defExt = ext; } -void CustomFileDialog::setDefFileName(const TCHAR* fn) +void CustomFileDialog::setDefFileName(const wchar_t* fn) { _impl->_initialFileName = fn; } -void CustomFileDialog::setFolder(const TCHAR* folder) +void CustomFileDialog::setFolder(const wchar_t* folder) { _impl->_initialFolder = folder ? folder : _T(""); } -void CustomFileDialog::setCheckbox(const TCHAR* text, bool isActive) +void CustomFileDialog::setCheckbox(const wchar_t* text, bool isActive) { _impl->_checkboxLabel = text; _impl->_isCheckboxActive = isActive; @@ -997,7 +999,7 @@ bool CustomFileDialog::isReadOnly() const return _impl->_hasReadonly; } -void CustomFileDialog::enableFileTypeCheckbox(const generic_string& text, bool value) +void CustomFileDialog::enableFileTypeCheckbox(const wstring& text, bool value) { assert(!text.empty()); if (!text.empty()) @@ -1013,7 +1015,7 @@ bool CustomFileDialog::getFileTypeCheckboxValue() const return _impl->getCheckboxState(IDC_FILE_TYPE_CHECKBOX); } -generic_string CustomFileDialog::doSaveDlg() +wstring CustomFileDialog::doSaveDlg() { if (!_impl->initSave()) return {}; @@ -1025,7 +1027,7 @@ generic_string CustomFileDialog::doSaveDlg() return bOk ? _impl->getResultFilename() : _T(""); } -generic_string CustomFileDialog::doOpenSingleFileDlg() +wstring CustomFileDialog::doOpenSingleFileDlg() { if (!_impl->initOpen()) return {}; @@ -1037,7 +1039,7 @@ generic_string CustomFileDialog::doOpenSingleFileDlg() return bOk ? _impl->getResultFilename() : _T(""); } -std::vector CustomFileDialog::doOpenMultiFilesDlg() +std::vector CustomFileDialog::doOpenMultiFilesDlg() { if (!_impl->initOpen()) return {}; @@ -1051,7 +1053,7 @@ std::vector CustomFileDialog::doOpenMultiFilesDlg() return {}; } -generic_string CustomFileDialog::pickFolder() +wstring CustomFileDialog::pickFolder() { if (!_impl->initOpen()) return {}; diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.h b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.h index 3d221a230b48..1dbb839e36bf 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.h +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.h @@ -29,23 +29,23 @@ class CustomFileDialog public: explicit CustomFileDialog(HWND hwnd); ~CustomFileDialog(); - void setTitle(const TCHAR* title); - void setExtFilter(const TCHAR* text, const TCHAR* ext); - void setExtFilter(const TCHAR* text, std::initializer_list exts); - void setDefExt(const TCHAR* ext); - void setDefFileName(const TCHAR *fn); - void setFolder(const TCHAR* folder); - void setCheckbox(const TCHAR* text, bool isActive = true); + void setTitle(const wchar_t* title); + void setExtFilter(const wchar_t* text, const wchar_t* ext); + void setExtFilter(const wchar_t* text, std::initializer_list exts); + void setDefExt(const wchar_t* ext); + void setDefFileName(const wchar_t *fn); + void setFolder(const wchar_t* folder); + void setCheckbox(const wchar_t* text, bool isActive = true); void setExtIndex(int extTypeIndex); - void enableFileTypeCheckbox(const generic_string& text, bool value); + void enableFileTypeCheckbox(const std::wstring& text, bool value); bool getFileTypeCheckboxValue() const; // Empty string is not a valid file name and may signal that the dialog was canceled. - generic_string doSaveDlg(); - generic_string pickFolder(); - generic_string doOpenSingleFileDlg(); - std::vector doOpenMultiFilesDlg(); + std::wstring doSaveDlg(); + std::wstring pickFolder(); + std::wstring doOpenSingleFileDlg(); + std::vector doOpenMultiFilesDlg(); bool getCheckboxState() const; bool isReadOnly() const; diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index c5fcad4a5a63..16d42b1446bc 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -37,10 +37,10 @@ using nlohmann::json; -generic_string PluginUpdateInfo::describe() +wstring PluginUpdateInfo::describe() { - generic_string desc; - const TCHAR *EOL = TEXT("\r\n"); + wstring desc; + const wchar_t *EOL = L"\r\n"; if (!_description.empty()) { desc = _description; @@ -49,14 +49,14 @@ generic_string PluginUpdateInfo::describe() if (!_author.empty()) { - desc += TEXT("Author: "); + desc += L"Author: "; desc += _author; desc += EOL; } if (!_homepage.empty()) { - desc += TEXT("Homepage: "); + desc += L"Homepage: "; desc += _homepage; desc += EOL; } @@ -65,7 +65,7 @@ generic_string PluginUpdateInfo::describe() } /// Try to find in the Haystack the Needle - ignore case -bool findStrNoCase(const generic_string & strHaystack, const generic_string & strNeedle) +bool findStrNoCase(const wstring & strHaystack, const wstring & strNeedle) { auto it = std::search( strHaystack.begin(), strHaystack.end(), @@ -75,10 +75,10 @@ bool findStrNoCase(const generic_string & strHaystack, const generic_string & st return (it != strHaystack.end()); } -bool PluginsAdminDlg::isFoundInListFromIndex(const PluginViewList& inWhichList, int index, const generic_string& str2search, bool inWhichPart) const +bool PluginsAdminDlg::isFoundInListFromIndex(const PluginViewList& inWhichList, int index, const wstring& str2search, bool inWhichPart) const { const PluginUpdateInfo* pui = inWhichList.getPluginInfoFromUiIndex(index); - generic_string searchIn; + wstring searchIn; if (inWhichPart == _inNames) searchIn = pui->_displayName; else //(inWhichPart == inDescs) @@ -87,7 +87,7 @@ bool PluginsAdminDlg::isFoundInListFromIndex(const PluginViewList& inWhichList, return (findStrNoCase(searchIn, str2search)); } -long PluginsAdminDlg::searchFromCurrentSel(const PluginViewList& inWhichList, const generic_string& str2search, bool inWhichPart, bool isNextMode) const +long PluginsAdminDlg::searchFromCurrentSel(const PluginViewList& inWhichList, const wstring& str2search, bool inWhichPart, bool isNextMode) const { // search from curent selected item or from the beginning long currentIndex = inWhichList.getSelectedIndex(); @@ -132,10 +132,10 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent) _tab.init(_hInst, _hSelf, false, true); NppDarkMode::subclassTabControl(_tab.getHSelf()); - const TCHAR *available = TEXT("Available"); - const TCHAR *updates = TEXT("Updates"); - const TCHAR *installed = TEXT("Installed"); - const TCHAR *incompatible = TEXT("Incompatible"); + const wchar_t *available = L"Available"; + const wchar_t *updates = L"Updates"; + const wchar_t *installed = L"Installed"; + const wchar_t *incompatible = L"Incompatible"; _tab.insertAtEnd(available); _tab.insertAtEnd(updates); @@ -164,8 +164,8 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent) NppParameters& nppParam = NppParameters::getInstance(); NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker(); - generic_string pluginStr = pNativeSpeaker->getAttrNameStr(TEXT("Plugin"), "PluginAdmin", "Plugin"); - generic_string vesionStr = pNativeSpeaker->getAttrNameStr(TEXT("Version"), "PluginAdmin", "Version"); + wstring pluginStr = pNativeSpeaker->getAttrNameStr(L"Plugin", "PluginAdmin", "Plugin"); + wstring vesionStr = pNativeSpeaker->getAttrNameStr(L"Version", "PluginAdmin", "Version"); const COLORREF fgColor = nppParam.getCurrentDefaultFgColor(); const COLORREF bgColor = nppParam.getCurrentDefaultBgColor(); @@ -202,7 +202,7 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent) ::SetWindowText(hPluginListVersionNumber, _pluginListVersion.c_str()); _repoLink.init(_hInst, _hSelf); - _repoLink.create(::GetDlgItem(_hSelf, IDC_PLUGINLIST_ADDR), TEXT("https://github.com/notepad-plus-plus/nppPluginList")); + _repoLink.create(::GetDlgItem(_hSelf, IDC_PLUGINLIST_ADDR), L"https://github.com/notepad-plus-plus/nppPluginList"); goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE); } @@ -214,7 +214,7 @@ void PluginsAdminDlg::collectNppCurrentStatusInfos() _nppCurrentStatus._isAppDataPluginsAllowed = ::SendMessage(_hParent, NPPM_GETAPPDATAPLUGINSALLOWED, 0, 0) == TRUE; _nppCurrentStatus._appdataPath = nppParam.getAppDataNppDir(); - generic_string programFilesPath = NppParameters::getSpecialFolderLocation(CSIDL_PROGRAM_FILES); + wstring programFilesPath = NppParameters::getSpecialFolderLocation(CSIDL_PROGRAM_FILES); _nppCurrentStatus._isInProgramFiles = (_nppCurrentStatus._nppInstallPath.find(programFilesPath) == 0); } @@ -239,22 +239,22 @@ PluginsAdminDlg::PluginsAdminDlg() // Get wingup path NppParameters& nppParameters = NppParameters::getInstance(); _updaterDir = nppParameters.getNppPath(); - pathAppend(_updaterDir, TEXT("updater")); + pathAppend(_updaterDir, L"updater"); _updaterFullPath = _updaterDir; - pathAppend(_updaterFullPath, TEXT("gup.exe")); + pathAppend(_updaterFullPath, L"gup.exe"); // get plugin-list path _pluginListFullPath = nppParameters.getPluginConfDir(); #ifdef DEBUG // if not debug, then it's release // load from nppPluginList.json instead of nppPluginList.dll - pathAppend(_pluginListFullPath, TEXT("nppPluginList.json")); + pathAppend(_pluginListFullPath, L"nppPluginList.json"); #else //RELEASE - pathAppend(_pluginListFullPath, TEXT("nppPluginList.dll")); + pathAppend(_pluginListFullPath, L"nppPluginList.dll"); #endif } -generic_string PluginsAdminDlg::getPluginListVerStr() const +wstring PluginsAdminDlg::getPluginListVerStr() const { Version v; v.setVersionFrom(_pluginListFullPath); @@ -263,63 +263,63 @@ generic_string PluginsAdminDlg::getPluginListVerStr() const bool PluginsAdminDlg::exitToInstallRemovePlugins(Operation op, const vector& puis) { - generic_string opStr; + wstring opStr; if (op == pa_install) - opStr = TEXT("-unzipTo "); + opStr = L"-unzipTo "; else if (op == pa_update) - opStr = TEXT("-unzipTo -clean "); + opStr = L"-unzipTo -clean "; else if (op == pa_remove) - opStr = TEXT("-clean "); + opStr = L"-clean "; else return false; NppParameters& nppParameters = NppParameters::getInstance(); - generic_string updaterDir = nppParameters.getNppPath(); - updaterDir += TEXT("\\updater\\"); + wstring updaterDir = nppParameters.getNppPath(); + updaterDir += L"\\updater\\"; - generic_string updaterFullPath = updaterDir + TEXT("gup.exe"); + wstring updaterFullPath = updaterDir + L"gup.exe"; - generic_string updaterParams = opStr; + wstring updaterParams = opStr; - TCHAR nppFullPath[MAX_PATH]{}; + wchar_t nppFullPath[MAX_PATH]{}; ::GetModuleFileName(NULL, nppFullPath, MAX_PATH); - updaterParams += TEXT("\""); + updaterParams += L"\""; updaterParams += nppFullPath; - updaterParams += TEXT("\" "); + updaterParams += L"\" "; - updaterParams += TEXT("\""); + updaterParams += L"\""; updaterParams += nppParameters.getPluginRootDir(); - updaterParams += TEXT("\""); + updaterParams += L"\""; for (const auto &i : puis) { if (op == pa_install || op == pa_update) { // add folder to operate - updaterParams += TEXT(" \""); + updaterParams += L" \""; updaterParams += i->_folderName; - updaterParams += TEXT(" "); + updaterParams += L" "; updaterParams += i->_repository; - updaterParams += TEXT(" "); + updaterParams += L" "; updaterParams += i->_id; - updaterParams += TEXT("\""); + updaterParams += L"\""; } else // op == pa_remove { // add folder to operate - updaterParams += TEXT(" \""); - generic_string folderName = i->_folderName; + updaterParams += L" \""; + wstring folderName = i->_folderName; if (folderName.empty()) { - auto lastindex = i->_displayName.find_last_of(TEXT(".")); - if (lastindex != generic_string::npos) + auto lastindex = i->_displayName.find_last_of(L"."); + if (lastindex != wstring::npos) folderName = i->_displayName.substr(0, lastindex); else folderName = i->_displayName; // This case will never occur, but in case if it occurs too // just putting the plugin name, so that whole plugin system is not screewed. } updaterParams += folderName; - updaterParams += TEXT("\""); + updaterParams += L"\""; } } @@ -327,8 +327,8 @@ bool PluginsAdminDlg::exitToInstallRemovePlugins(Operation op, const vectormessageBox("ExitToUpdatePlugins", _hSelf, - TEXT("If you click YES, you will quit Notepad++ to continue the operations.\nNotepad++ will be restarted after all the operations are terminated.\nContinue?"), - TEXT("Notepad++ is about to exit"), + L"If you click YES, you will quit Notepad++ to continue the operations.\nNotepad++ will be restarted after all the operations are terminated.\nContinue?", + L"Notepad++ is about to exit", MB_YESNO | MB_APPLMODAL); if (res == IDYES) @@ -384,19 +384,19 @@ bool PluginsAdminDlg::removePlugins() return exitToInstallRemovePlugins(pa_remove, puis); } -void PluginsAdminDlg::changeTabName(LIST_TYPE index, const TCHAR *name2change) +void PluginsAdminDlg::changeTabName(LIST_TYPE index, const wchar_t *name2change) { TCITEM tie{}; tie.mask = TCIF_TEXT; - tie.pszText = (TCHAR *)name2change; + tie.pszText = (wchar_t *)name2change; TabCtrl_SetItem(_tab.getHSelf(), index, &tie); - TCHAR label[MAX_PATH]{}; + wchar_t label[MAX_PATH]{}; _tab.getCurrentTitle(label, MAX_PATH); ::SetWindowText(_hSelf, label); } -void PluginsAdminDlg::changeColumnName(COLUMN_TYPE index, const TCHAR *name2change) +void PluginsAdminDlg::changeColumnName(COLUMN_TYPE index, const wchar_t *name2change) { _availableList.changeColumnName(index, name2change); _updateList.changeColumnName(index, name2change); @@ -404,12 +404,12 @@ void PluginsAdminDlg::changeColumnName(COLUMN_TYPE index, const TCHAR *name2chan _incompatibleList.changeColumnName(index, name2change); } -void PluginViewList::changeColumnName(COLUMN_TYPE index, const TCHAR *name2change) +void PluginViewList::changeColumnName(COLUMN_TYPE index, const wchar_t *name2change) { _ui.setColumnText(index, name2change); } -bool PluginViewList::removeFromFolderName(const generic_string& folderName) +bool PluginViewList::removeFromFolderName(const wstring& folderName) { for (size_t i = 0; i < _ui.nbItem(); ++i) @@ -437,7 +437,7 @@ void PluginViewList::pushBack(PluginUpdateInfo* pi) { _list.push_back(pi); - vector values2Add; + vector values2Add; values2Add.push_back(pi->_displayName); Version v = pi->_version; values2Add.push_back(v.toString()); @@ -454,7 +454,7 @@ void PluginViewList::pushBack(PluginUpdateInfo* pi) // "[8.3,]" : any version from 8.3 to the latest one // "[,8.2.1]" : 8.2.1 and any previous version // -std::pair getIntervalVersions(generic_string intervalVerStr) +std::pair getIntervalVersions(wstring intervalVerStr) { std::pair result; @@ -464,8 +464,8 @@ std::pair getIntervalVersions(generic_string intervalVerStr) const size_t indexEnd = intervalVerStr.length() - 1; if (intervalVerStr[0] == '[' && intervalVerStr[indexEnd] == ']') // interval versions format { - generic_string cleanIntervalVerStr = intervalVerStr.substr(1, indexEnd - 1); - vector versionVect; + wstring cleanIntervalVerStr = intervalVerStr.substr(1, indexEnd - 1); + vector versionVect; cutStringBy(cleanIntervalVerStr.c_str(), versionVect, ',', true); if (versionVect.size() == 2) { @@ -501,16 +501,16 @@ std::pair getIntervalVersions(generic_string intervalVerStr) // "[4.2,6.6.6][6.4,8.9]" : The 1st interval from version 4.2 to 6.6.6 inclusive, the 2nd interval from version 6.4 to 8.9 // "[8.3,][6.9,6.9]" : The 1st interval any version from 8.3 to the latest version, the 2nd interval present only version 6.9 // "[,8.2.1][4.4,]" : The 1st interval 8.2.1 and any previous version, , the 2nd interval any version from 4.4 to the latest version -std::pair, std::pair> getTwoIntervalVersions(generic_string twoIntervalVerStr) +std::pair, std::pair> getTwoIntervalVersions(wstring twoIntervalVerStr) { std::pair, std::pair> r; - generic_string sep = TEXT("]["); - generic_string::size_type pos = twoIntervalVerStr.find(sep, 0); + wstring sep = L"]["; + wstring::size_type pos = twoIntervalVerStr.find(sep, 0); if (pos == string::npos) return r; - generic_string intervalStr1 = twoIntervalVerStr.substr(0, pos + 1); - generic_string intervalStr2 = twoIntervalVerStr.substr(pos + 1, twoIntervalVerStr.length() - pos + 1); + wstring intervalStr1 = twoIntervalVerStr.substr(0, pos + 1); + wstring intervalStr2 = twoIntervalVerStr.substr(pos + 1, twoIntervalVerStr.length() - pos + 1); r.first = getIntervalVersions(intervalStr1); r.second = getIntervalVersions(intervalStr2); @@ -558,7 +558,7 @@ bool loadFromJson(std::vector& pl, wstring& verStr, const jso try { valStr = i.at("version").get(); - generic_string newValStr(valStr.begin(), valStr.end()); + wstring newValStr(valStr.begin(), valStr.end()); pi->_version = Version(newValStr); if (i.contains("npp-compatible-versions")) @@ -566,7 +566,7 @@ bool loadFromJson(std::vector& pl, wstring& verStr, const jso json jNppCompatibleVer = i["npp-compatible-versions"]; string versionsStr = jNppCompatibleVer.get(); - generic_string nppCompatibleVersionStr(versionsStr.begin(), versionsStr.end()); + wstring nppCompatibleVersionStr(versionsStr.begin(), versionsStr.end()); pi->_nppCompatibleVersions = getIntervalVersions(nppCompatibleVersionStr); } @@ -575,7 +575,7 @@ bool loadFromJson(std::vector& pl, wstring& verStr, const jso json jOldVerCompatibility = i["old-versions-compatibility"]; string versionsStr = jOldVerCompatibility.get(); - generic_string oldVerCompatibilityStr(versionsStr.begin(), versionsStr.end()); + wstring oldVerCompatibilityStr(versionsStr.begin(), versionsStr.end()); pi->_oldVersionCompatibility = getTwoIntervalVersions(oldVerCompatibilityStr); } } @@ -596,7 +596,7 @@ bool loadFromJson(std::vector& pl, wstring& verStr, const jso #ifdef DEBUG catch (const wstring& exceptionStr) { - ::MessageBox(NULL, exceptionStr.c_str(), TEXT("Exception caught in: PluginsAdmin loadFromJson()"), MB_ICONERROR); + ::MessageBox(NULL, exceptionStr.c_str(), L"Exception caught in: PluginsAdmin loadFromJson()", MB_ICONERROR); continue; } @@ -617,7 +617,7 @@ bool loadFromJson(std::vector& pl, wstring& verStr, const jso return true; } -PluginUpdateInfo::PluginUpdateInfo(const generic_string& fullFilePath, const generic_string& filename) +PluginUpdateInfo::PluginUpdateInfo(const wstring& fullFilePath, const wstring& filename) { if (!::PathFileExists(fullFilePath.c_str())) return; @@ -686,7 +686,7 @@ bool PluginsAdminDlg::initFromJson() if (!hLib) { // Error treatment - //printStr(TEXT("LoadLibrary PB!!!")); + //printStr(L"LoadLibrary PB!!!"); return false; } @@ -743,7 +743,7 @@ bool PluginsAdminDlg::updateList() bool PluginsAdminDlg::initAvailablePluginsViewFromList() { - TCHAR nppFullPathName[MAX_PATH]{}; + wchar_t nppFullPathName[MAX_PATH]{}; GetModuleFileName(NULL, nppFullPathName, MAX_PATH); Version nppVer; @@ -755,7 +755,7 @@ bool PluginsAdminDlg::initAvailablePluginsViewFromList() if (isCompatible) { - vector values2Add; + vector values2Add; values2Add.push_back(i->_displayName); Version v = i->_version; values2Add.push_back(v.toString()); @@ -772,7 +772,7 @@ bool PluginsAdminDlg::initAvailablePluginsViewFromList() bool PluginsAdminDlg::initIncompatiblePluginList() { - TCHAR nppFullPathName[MAX_PATH]{}; + wchar_t nppFullPathName[MAX_PATH]{}; GetModuleFileName(NULL, nppFullPathName, MAX_PATH); Version nppVer; @@ -780,7 +780,7 @@ bool PluginsAdminDlg::initIncompatiblePluginList() for (const auto& i : _incompatibleList._list) { - vector values2Add; + vector values2Add; values2Add.push_back(i->_displayName); Version v = i->_version; values2Add.push_back(v.toString()); @@ -806,7 +806,7 @@ bool PluginsAdminDlg::loadFromPluginInfos() continue; // user file name (without ext. to find whole info in available list - TCHAR fnNoExt[MAX_PATH]{}; + wchar_t fnNoExt[MAX_PATH]{}; wcscpy_s(fnNoExt, i._fileName.c_str()); ::PathRemoveExtension(fnNoExt); @@ -862,7 +862,7 @@ bool PluginsAdminDlg::loadFromPluginInfos() return true; } -PluginUpdateInfo* PluginViewList::findPluginInfoFromFolderName(const generic_string& folderName, int& index) const +PluginUpdateInfo* PluginViewList::findPluginInfoFromFolderName(const wstring& folderName, int& index) const { index = 0; for (const auto& i : _list) @@ -946,17 +946,17 @@ bool PluginViewList::hideFromPluginInfoPtr(PluginUpdateInfo* pluginInfo2hide) return false; } -bool PluginViewList::restore(const generic_string& folderName) +bool PluginViewList::restore(const wstring& folderName) { for (const auto &i : _list) { if (i->_folderName == folderName) { - vector values2Add; + vector values2Add; values2Add.push_back(i->_displayName); Version v = i->_version; values2Add.push_back(v.toString()); - values2Add.push_back(TEXT("Yes")); + values2Add.push_back(L"Yes"); _ui.addLine(values2Add, reinterpret_cast(i)); i->_isVisible = true; @@ -995,7 +995,7 @@ bool PluginsAdminDlg::checkUpdates() bool PluginsAdminDlg::searchInPlugins(bool isNextMode) const { constexpr int maxLen = 256; - TCHAR txt2search[maxLen]{}; + wchar_t txt2search[maxLen]{}; ::GetDlgItemText(_hSelf, IDC_PLUGINADM_SEARCH_EDIT, txt2search, maxLen); if (lstrlen(txt2search) < 2) return false; @@ -1036,7 +1036,7 @@ bool PluginsAdminDlg::searchInPlugins(bool isNextMode) const void PluginsAdminDlg::switchDialog(int indexToSwitch) { - generic_string desc; + wstring desc; bool showAvailable, showUpdate, showInstalled, showIncompatibile; switch (indexToSwitch) { @@ -1322,7 +1322,7 @@ intptr_t CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR else if (pnmv->uNewState & LVIS_SELECTED) { PluginUpdateInfo* pui = pViewList->getPluginInfoFromUiIndex(pnmv->iItem); - generic_string desc = buttonID ? pui->describe() : pui->_description; + wstring desc = buttonID ? pui->describe() : pui->_description; ::SetDlgItemText(_hSelf, IDC_PLUGINADM_EDIT, desc.c_str()); } } diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h index 6bf16fa8d63e..02e51aa9542f 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h @@ -29,10 +29,10 @@ class PluginsManager; struct PluginUpdateInfo { - generic_string _fullFilePath; // only for the installed Plugin + std::wstring _fullFilePath; // only for the installed Plugin - generic_string _folderName; // plugin folder name - should be the same name with plugin and should be uniq among the plugins - generic_string _displayName; // plugin description name + std::wstring _folderName; // plugin folder name - should be the same name with plugin and should be uniq among the plugins + std::wstring _displayName; // plugin description name Version _version; // Optional std::pair _nppCompatibleVersions; // compatible to Notepad++ interval versions: example: @@ -48,17 +48,17 @@ struct PluginUpdateInfo // The 2nd interval versions are for Notepad++ versions // which are compatible with the old plugins' versions given in the 1st interval - generic_string _homepage; - generic_string _sourceUrl; - generic_string _description; - generic_string _author; - generic_string _id; // Plugin package ID: SHA-256 hash - generic_string _repository; + std::wstring _homepage; + std::wstring _sourceUrl; + std::wstring _description; + std::wstring _author; + std::wstring _id; // Plugin package ID: SHA-256 hash + std::wstring _repository; bool _isVisible = true; // if false then it should not be displayed - generic_string describe(); + std::wstring describe(); PluginUpdateInfo() = default; - PluginUpdateInfo(const generic_string& fullFilePath, const generic_string& fileName); + PluginUpdateInfo(const std::wstring& fullFilePath, const std::wstring& fileName); }; struct NppCurrentStatus @@ -70,8 +70,8 @@ struct NppCurrentStatus bool _isAppDataPluginsAllowed = false; // true: install on %APPDATA%, update / remove on %APPDATA% & "Program files" or NPP_INST - generic_string _nppInstallPath; - generic_string _appdataPath; + std::wstring _nppInstallPath; + std::wstring _appdataPath; // it should determinate : // 1. deployment location : %ProgramFile% %appdata% %other% @@ -118,15 +118,15 @@ friend class PluginsAdminDlg; void setViewStyleOption(int32_t extraStyle) { _ui.setStyleOption(extraStyle); }; size_t nbItem() const { return _ui.nbItem(); }; PluginUpdateInfo* getPluginInfoFromUiIndex(size_t index) const { return reinterpret_cast(_ui.getLParamFromIndex(static_cast(index))); }; - PluginUpdateInfo* findPluginInfoFromFolderName(const generic_string& folderName, int& index) const; + PluginUpdateInfo* findPluginInfoFromFolderName(const std::wstring& folderName, int& index) const; bool removeFromListIndex(size_t index2remove); bool hideFromListIndex(size_t index2Hide); - bool removeFromFolderName(const generic_string& folderName); + bool removeFromFolderName(const std::wstring& folderName); bool removeFromUiIndex(size_t index2remove); bool hideFromPluginInfoPtr(PluginUpdateInfo* pluginInfo2hide); - bool restore(const generic_string& folderName); + bool restore(const std::wstring& folderName); bool removeFromPluginInfoPtr(PluginUpdateInfo* pluginInfo2hide); - void changeColumnName(COLUMN_TYPE index, const TCHAR *name2change); + void changeColumnName(COLUMN_TYPE index, const wchar_t *name2change); private: // _list & _ui should keep being synchronized @@ -167,9 +167,9 @@ public : bool updatePlugins(); bool removePlugins(); - void changeTabName(LIST_TYPE index, const TCHAR *name2change); - void changeColumnName(COLUMN_TYPE index, const TCHAR *name2change); - generic_string getPluginListVerStr() const; + void changeTabName(LIST_TYPE index, const wchar_t *name2change); + void changeColumnName(COLUMN_TYPE index, const wchar_t *name2change); + std::wstring getPluginListVerStr() const; const PluginViewList & getAvailablePluginUpdateInfoList() const { return _availableList; }; @@ -182,9 +182,9 @@ public : intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private : - generic_string _updaterDir; - generic_string _updaterFullPath; - generic_string _pluginListFullPath; + std::wstring _updaterDir; + std::wstring _updaterFullPath; + std::wstring _pluginListFullPath; TabBar _tab; @@ -203,13 +203,13 @@ private : bool searchInPlugins(bool isNextMode) const; const bool _inNames = true; const bool _inDescs = false; - bool isFoundInListFromIndex(const PluginViewList& inWhichList,int index, const generic_string& str2search, bool inWhichPart) const; - long searchFromCurrentSel(const PluginViewList& inWhichList, const generic_string& str2search, bool inWhichPart, bool isNextMode) const; - long searchInNamesFromCurrentSel(const PluginViewList& inWhichList, const generic_string& str2search, bool isNextMode) const { + bool isFoundInListFromIndex(const PluginViewList& inWhichList,int index, const std::wstring& str2search, bool inWhichPart) const; + long searchFromCurrentSel(const PluginViewList& inWhichList, const std::wstring& str2search, bool inWhichPart, bool isNextMode) const; + long searchInNamesFromCurrentSel(const PluginViewList& inWhichList, const std::wstring& str2search, bool isNextMode) const { return searchFromCurrentSel(inWhichList, str2search, _inNames, isNextMode); }; - long searchInDescsFromCurrentSel(const PluginViewList& inWhichList, const generic_string& str2search, bool isNextMode) const { + long searchInDescsFromCurrentSel(const PluginViewList& inWhichList, const std::wstring& str2search, bool isNextMode) const { return searchFromCurrentSel(inWhichList, str2search, _inDescs, isNextMode); }; diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp index 057655662a92..f78548075048 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp @@ -31,6 +31,8 @@ #define INDEX_LEAF 5 #define INDEX_LEAF_INVALID 6 +using namespace std; + ProjectPanel::~ProjectPanel() { for (const auto& s : fullPathStrs) @@ -55,8 +57,8 @@ intptr_t CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM TBBUTTON tbButtons[2]{}; NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); - generic_string workspace_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 0, PM_WORKSPACEMENUENTRY); - generic_string edit_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 1, PM_EDITMENUENTRY); + wstring workspace_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 0, PM_WORKSPACEMENUENTRY); + wstring edit_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 1, PM_EDITMENUENTRY); tbButtons[0].idCommand = IDB_PROJECT_BTN; tbButtons[0].iBitmap = I_IMAGENONE; @@ -188,12 +190,12 @@ bool ProjectPanel::checkIfNeedSave() { if (_isDirty) { - const TCHAR * title = _workSpaceFilePath.length() > 0 ? PathFindFileName (_workSpaceFilePath.c_str()) : _panelTitle.c_str(); + const wchar_t * title = _workSpaceFilePath.length() > 0 ? PathFindFileName (_workSpaceFilePath.c_str()) : _panelTitle.c_str(); NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); int res = pNativeSpeaker->messageBox("ProjectPanelChanged", _hSelf, - TEXT("The workspace was modified. Do you want to save it?"), - TEXT("$STR_REPLACE$"), + L"The workspace was modified. Do you want to save it?", + L"$STR_REPLACE$", MB_YESNOCANCEL | MB_ICONQUESTION, 0, title); @@ -222,14 +224,14 @@ void ProjectPanel::initMenus() NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); - generic_string new_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_NEWWS, PM_NEWWORKSPACE); - generic_string open_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_OPENWS, PM_OPENWORKSPACE); - generic_string reload_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_RELOADWS, PM_RELOADWORKSPACE); - generic_string save_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEWS, PM_SAVEWORKSPACE); - generic_string saveas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEASWS, PM_SAVEASWORKSPACE); - generic_string saveacopyas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEACOPYASWS, PM_SAVEACOPYASWORKSPACE); - generic_string newproject_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_NEWPROJECT, PM_NEWPROJECTWORKSPACE); - generic_string findinprojects_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_FINDINPROJECTSWS, PM_FINDINFILESWORKSPACE); + wstring new_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_NEWWS, PM_NEWWORKSPACE); + wstring open_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_OPENWS, PM_OPENWORKSPACE); + wstring reload_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_RELOADWS, PM_RELOADWORKSPACE); + wstring save_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEWS, PM_SAVEWORKSPACE); + wstring saveas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEASWS, PM_SAVEASWORKSPACE); + wstring saveacopyas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEACOPYASWS, PM_SAVEACOPYASWORKSPACE); + wstring newproject_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_NEWPROJECT, PM_NEWPROJECTWORKSPACE); + wstring findinprojects_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_FINDINPROJECTSWS, PM_FINDINFILESWORKSPACE); ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWWS, new_workspace.c_str()); ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_OPENWS, open_workspace.c_str()); @@ -242,13 +244,13 @@ void ProjectPanel::initMenus() ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_FINDINPROJECTSWS, findinprojects_workspace.c_str()); - generic_string edit_moveup = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_MOVEUP, PM_MOVEUPENTRY); - generic_string edit_movedown = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_MOVEDOWN, PM_MOVEDOWNENTRY); - generic_string edit_rename = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_RENAME, PM_EDITRENAME); - generic_string edit_addfolder = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_NEWFOLDER, PM_EDITNEWFOLDER); - generic_string edit_addfiles = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_ADDFILES, PM_EDITADDFILES); - generic_string edit_addfilesRecursive = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_ADDFILESRECUSIVELY, PM_EDITADDFILESRECUSIVELY); - generic_string edit_remove = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_DELETEFOLDER, PM_EDITREMOVE); + wstring edit_moveup = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_MOVEUP, PM_MOVEUPENTRY); + wstring edit_movedown = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_MOVEDOWN, PM_MOVEDOWNENTRY); + wstring edit_rename = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_RENAME, PM_EDITRENAME); + wstring edit_addfolder = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_NEWFOLDER, PM_EDITNEWFOLDER); + wstring edit_addfiles = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_ADDFILES, PM_EDITADDFILES); + wstring edit_addfilesRecursive = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_ADDFILESRECUSIVELY, PM_EDITADDFILESRECUSIVELY); + wstring edit_remove = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_DELETEFOLDER, PM_EDITREMOVE); _hProjectMenu = ::CreatePopupMenu(); ::InsertMenu(_hProjectMenu, 0, MF_BYCOMMAND, IDM_PROJECT_MOVEUP, edit_moveup.c_str()); @@ -282,7 +284,7 @@ void ProjectPanel::initMenus() edit_movedown = pNativeSpeaker->getProjectPanelLangMenuStr("FileMenu", IDM_PROJECT_MOVEDOWN, PM_MOVEDOWNENTRY); edit_rename = pNativeSpeaker->getProjectPanelLangMenuStr("FileMenu", IDM_PROJECT_RENAME, PM_EDITRENAME); edit_remove = pNativeSpeaker->getProjectPanelLangMenuStr("FileMenu", IDM_PROJECT_DELETEFILE, PM_EDITREMOVE); - generic_string edit_modifyfile = pNativeSpeaker->getProjectPanelLangMenuStr("FileMenu", IDM_PROJECT_MODIFYFILEPATH, PM_EDITMODIFYFILE); + wstring edit_modifyfile = pNativeSpeaker->getProjectPanelLangMenuStr("FileMenu", IDM_PROJECT_MODIFYFILEPATH, PM_EDITMODIFYFILE); _hFileMenu = ::CreatePopupMenu(); ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_PROJECT_MOVEUP, edit_moveup.c_str()); @@ -301,11 +303,11 @@ void ProjectPanel::destroyMenus() ::DestroyMenu(_hFileMenu); } -bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName, bool force) +bool ProjectPanel::openWorkSpace(const wchar_t *projectFileName, bool force) { if ((!force) && (_workSpaceFilePath.length() > 0)) { // Return if it is better to keep the current workspace tree - generic_string newWorkspace = projectFileName; + wstring newWorkspace = projectFileName; if (newWorkspace == _workSpaceFilePath) return true; if (!saveWorkspaceRequest()) @@ -320,7 +322,7 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName, bool force) return false; } - TiXmlNode *root = pXmlDocProject->FirstChild(TEXT("NotepadPlus")); + TiXmlNode *root = pXmlDocProject->FirstChild(L"NotepadPlus"); if (!root) { delete pXmlDocProject; @@ -328,7 +330,7 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName, bool force) } - TiXmlNode *childNode = root->FirstChildElement(TEXT("Project")); + TiXmlNode *childNode = root->FirstChildElement(L"Project"); if (!childNode) { delete pXmlDocProject; @@ -344,12 +346,12 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName, bool force) _treeView.removeAllItems(); _workSpaceFilePath = projectFileName; - TCHAR * fileName = PathFindFileName(projectFileName); + wchar_t * fileName = PathFindFileName(projectFileName); HTREEITEM rootItem = _treeView.addItem(fileName, TVI_ROOT, INDEX_CLEAN_ROOT); - for ( ; childNode ; childNode = childNode->NextSibling(TEXT("Project"))) + for ( ; childNode ; childNode = childNode->NextSibling(L"Project")) { - HTREEITEM projectItem = _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), rootItem, INDEX_PROJECT); + HTREEITEM projectItem = _treeView.addItem((childNode->ToElement())->Attribute(L"name"), rootItem, INDEX_PROJECT); buildTreeFrom(childNode, projectItem); } setWorkSpaceDirty(false); @@ -362,15 +364,15 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName, bool force) void ProjectPanel::newWorkSpace() { NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); - generic_string workspace = pNativeSpeaker->getAttrNameStr(PM_WORKSPACEROOTNAME, "ProjectManager", "WorkspaceRootName"); + wstring workspace = pNativeSpeaker->getAttrNameStr(PM_WORKSPACEROOTNAME, "ProjectManager", "WorkspaceRootName"); _treeView.addItem(workspace.c_str(), TVI_ROOT, INDEX_CLEAN_ROOT); setWorkSpaceDirty(false); - _workSpaceFilePath = TEXT(""); + _workSpaceFilePath = L""; } bool ProjectPanel::saveWorkSpace() { - if (_workSpaceFilePath == TEXT("")) + if (_workSpaceFilePath == L"") { return saveWorkSpaceAs(false); } @@ -384,14 +386,14 @@ bool ProjectPanel::saveWorkSpace() } } -bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName, bool doUpdateGUI) +bool ProjectPanel::writeWorkSpace(const wchar_t *projectFileName, bool doUpdateGUI) { //write : use the default file name if new file name is not given - const TCHAR * fn2write = projectFileName?projectFileName:_workSpaceFilePath.c_str(); + const wchar_t * fn2write = projectFileName?projectFileName:_workSpaceFilePath.c_str(); TiXmlDocument projDoc(fn2write); - TiXmlNode *root = projDoc.InsertEndChild(TiXmlElement(TEXT("NotepadPlus"))); + TiXmlNode *root = projDoc.InsertEndChild(TiXmlElement(L"NotepadPlus")); - TCHAR textBuffer[MAX_PATH] = { '\0' }; + wchar_t textBuffer[MAX_PATH] = { '\0' }; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT; tvItem.pszText = textBuffer; @@ -410,25 +412,25 @@ bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName, bool doUpdateGUI SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast(&tvItem)); //printStr(tvItem.pszText); - TiXmlNode *projRoot = root->InsertEndChild(TiXmlElement(TEXT("Project"))); - projRoot->ToElement()->SetAttribute(TEXT("name"), tvItem.pszText); + TiXmlNode *projRoot = root->InsertEndChild(TiXmlElement(L"Project")); + projRoot->ToElement()->SetAttribute(L"name", tvItem.pszText); buildProjectXml(projRoot, tvProj, fn2write); } if (!projDoc.SaveFile()) { - const TCHAR * title = _workSpaceFilePath.length() > 0 ? PathFindFileName (_workSpaceFilePath.c_str()) : _panelTitle.c_str(); + const wchar_t * title = _workSpaceFilePath.length() > 0 ? PathFindFileName (_workSpaceFilePath.c_str()) : _panelTitle.c_str(); NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); pNativeSpeaker->messageBox("ProjectPanelSaveError", _hSelf, - TEXT("An error occurred while writing your workspace file.\nYour workspace has not been saved."), - TEXT("$STR_REPLACE$"), + L"An error occurred while writing your workspace file.\nYour workspace has not been saved.", + L"$STR_REPLACE$", MB_OK | MB_ICONERROR, 0, title); return false; } - TCHAR * fileName = PathFindFileName(fn2write); + wchar_t * fileName = PathFindFileName(fn2write); if (doUpdateGUI) { _treeView.renameItem(tvRoot, fileName); @@ -436,9 +438,9 @@ bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName, bool doUpdateGUI return true; } -void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR* fn2write) +void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const wchar_t* fn2write) { - TCHAR textBuffer[MAX_PATH] = { '\0' }; + wchar_t textBuffer[MAX_PATH] = { '\0' }; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT | TVIF_PARAM; tvItem.pszText = textBuffer; @@ -452,23 +454,23 @@ void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast(&tvItem)); if (tvItem.lParam) { - generic_string *fn = (generic_string *)tvItem.lParam; - generic_string newFn = getRelativePath(*fn, fn2write); - TiXmlNode *fileLeaf = node->InsertEndChild(TiXmlElement(TEXT("File"))); - fileLeaf->ToElement()->SetAttribute(TEXT("name"), newFn.c_str()); + wstring *fn = (wstring *)tvItem.lParam; + wstring newFn = getRelativePath(*fn, fn2write); + TiXmlNode *fileLeaf = node->InsertEndChild(TiXmlElement(L"File")); + fileLeaf->ToElement()->SetAttribute(L"name", newFn.c_str()); } else { - TiXmlNode *folderNode = node->InsertEndChild(TiXmlElement(TEXT("Folder"))); - folderNode->ToElement()->SetAttribute(TEXT("name"), tvItem.pszText); + TiXmlNode *folderNode = node->InsertEndChild(TiXmlElement(L"Folder")); + folderNode->ToElement()->SetAttribute(L"name", tvItem.pszText); buildProjectXml(folderNode, hItemNode, fn2write); } } } -bool ProjectPanel::enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector & patterns, std::vector & fileNames) +bool ProjectPanel::enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector & patterns, std::vector & fileNames) { - TCHAR textBuffer[MAX_PATH] = { '\0' }; + wchar_t textBuffer[MAX_PATH] = { '\0' }; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT | TVIF_PARAM; tvItem.pszText = textBuffer; @@ -487,7 +489,7 @@ bool ProjectPanel::enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vectorNextSibling()) { - const TCHAR *v = childNode->Value(); - if (lstrcmp(TEXT("Folder"), v) == 0) + const wchar_t *v = childNode->Value(); + if (lstrcmp(L"Folder", v) == 0) { - HTREEITEM addedItem = _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem, INDEX_CLOSED_NODE); + HTREEITEM addedItem = _treeView.addItem((childNode->ToElement())->Attribute(L"name"), hParentItem, INDEX_CLOSED_NODE); if (!childNode->NoChildren()) { bool isOK = buildTreeFrom(childNode, addedItem); @@ -531,14 +533,14 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem) return false; } } - else if (lstrcmp(TEXT("File"), v) == 0) + else if (lstrcmp(L"File", v) == 0) { - const TCHAR *strValue = (childNode->ToElement())->Attribute(TEXT("name")); - generic_string fullPath = getAbsoluteFilePath(strValue); - TCHAR *strValueLabel = ::PathFindFileName(strValue); + const wchar_t *strValue = (childNode->ToElement())->Attribute(L"name"); + wstring fullPath = getAbsoluteFilePath(strValue); + wchar_t *strValueLabel = ::PathFindFileName(strValue); int iImage = ::PathFileExists(fullPath.c_str())?INDEX_LEAF:INDEX_LEAF_INVALID; - generic_string* fullPathStr = new generic_string(fullPath); + wstring* fullPathStr = new wstring(fullPath); fullPathStrs.push_back(fullPathStr); LPARAM lParamFullPathStr = reinterpret_cast(fullPathStr); @@ -548,12 +550,12 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem) return true; } -generic_string ProjectPanel::getAbsoluteFilePath(const TCHAR * relativePath) +wstring ProjectPanel::getAbsoluteFilePath(const wchar_t * relativePath) { if (!::PathIsRelative(relativePath)) return relativePath; - TCHAR absolutePath[MAX_PATH] = { '\0' }; + wchar_t absolutePath[MAX_PATH] = { '\0' }; wcscpy_s(absolutePath, _workSpaceFilePath.c_str()); ::PathRemoveFileSpec(absolutePath); ::PathAppend(absolutePath, relativePath); @@ -568,7 +570,7 @@ void ProjectPanel::openSelectFile() ::SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast(&tvItem)); NodeType nType = getNodeType(tvItem.hItem); - generic_string *fn = (generic_string *)tvItem.lParam; + wstring *fn = (wstring *)tvItem.lParam; if (nType == nodeType_file && fn) { tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE; @@ -597,7 +599,7 @@ void ProjectPanel::notified(LPNMHDR notification) } else if (notification->hwndFrom == _treeView.getHSelf()) { - TCHAR textBuffer[MAX_PATH] = { '\0' }; + wchar_t textBuffer[MAX_PATH] = { '\0' }; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT | TVIF_PARAM; tvItem.pszText = textBuffer; @@ -632,11 +634,11 @@ void ProjectPanel::notified(LPNMHDR notification) size_t len = lstrlen(tvItem.pszText); // Find the position of old label in File path - generic_string *filePath = (generic_string *)tvnotif->item.lParam; + wstring *filePath = (wstring *)tvnotif->item.lParam; size_t found = filePath->rfind(tvItem.pszText); // If found the old label, replace it with the modified one - if (found != generic_string::npos) + if (found != wstring::npos) filePath->replace(found, len, tvnotif->item.pszText); // Check the validity of modified file path @@ -663,7 +665,7 @@ void ProjectPanel::notified(LPNMHDR notification) case TVN_GETINFOTIP: { LPNMTVGETINFOTIP lpGetInfoTip = (LPNMTVGETINFOTIP)notification; - generic_string *str = NULL ; + wstring *str = NULL ; if (_treeView.getRoot() == lpGetInfoTip->hItem) { @@ -671,7 +673,7 @@ void ProjectPanel::notified(LPNMHDR notification) } else { - str = (generic_string *)lpGetInfoTip->lParam; + str = (wstring *)lpGetInfoTip->lParam; if (!str) return; } @@ -856,7 +858,7 @@ POINT ProjectPanel::getMenuDisplayPoint(int iButton) return p; } -HTREEITEM ProjectPanel::addFolder(HTREEITEM hTreeItem, const TCHAR *folderName) +HTREEITEM ProjectPanel::addFolder(HTREEITEM hTreeItem, const wchar_t *folderName) { HTREEITEM addedItem = _treeView.addItem(folderName, hTreeItem, INDEX_CLOSED_NODE); @@ -875,8 +877,8 @@ bool ProjectPanel::saveWorkspaceRequest() NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); int res = pNativeSpeaker->messageBox("ProjectPanelOpenDoSaveDirtyWsOrNot", _hSelf, - TEXT("The current workspace was modified. Do you want to save the current project?"), - TEXT("Open Workspace"), + L"The current workspace was modified. Do you want to save the current project?", + L"Open Workspace", MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); if (res == IDYES) @@ -944,7 +946,7 @@ void ProjectPanel::popupMenuCmd(int cmdID) HTREEITEM root = _treeView.getRoot(); NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); - generic_string newProjectLabel = pNativeSpeaker->getAttrNameStr(PM_NEWPROJECTNAME, "ProjectManager", "NewProjectName"); + wstring newProjectLabel = pNativeSpeaker->getAttrNameStr(PM_NEWPROJECTNAME, "ProjectManager", "NewProjectName"); HTREEITEM addedItem = _treeView.addItem(newProjectLabel.c_str(), root, INDEX_PROJECT); setWorkSpaceDirty(true); _treeView.expand(hTreeItem); @@ -959,8 +961,8 @@ void ProjectPanel::popupMenuCmd(int cmdID) NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); int res = pNativeSpeaker->messageBox("ProjectPanelNewDoSaveDirtyWsOrNot", _hSelf, - TEXT("The current workspace was modified. Do you want to save the current project?"), - TEXT("New Workspace"), + L"The current workspace was modified. Do you want to save the current project?", + L"New Workspace", MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); if (res == IDYES) { @@ -989,7 +991,7 @@ void ProjectPanel::popupMenuCmd(int cmdID) case IDM_PROJECT_NEWFOLDER : { NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); - generic_string newFolderLabel = pNativeSpeaker->getAttrNameStr(PM_NEWFOLDERNAME, "ProjectManager", "NewFolderName"); + wstring newFolderLabel = pNativeSpeaker->getAttrNameStr(PM_NEWFOLDERNAME, "ProjectManager", "NewFolderName"); addFolder(hTreeItem, newFolderLabel.c_str()); setWorkSpaceDirty(true); } @@ -1032,7 +1034,7 @@ void ProjectPanel::popupMenuCmd(int cmdID) CustomFileDialog fDlg(_hSelf); setFileExtFilter(fDlg); - const generic_string fn = fDlg.doOpenSingleFileDlg(); + const wstring fn = fDlg.doOpenSingleFileDlg(); if (!fn.empty()) { if (!openWorkSpace(fn.c_str(), true)) @@ -1040,8 +1042,8 @@ void ProjectPanel::popupMenuCmd(int cmdID) NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); pNativeSpeaker->messageBox("ProjectPanelOpenFailed", _hSelf, - TEXT("The workspace could not be opened.\rIt seems the file to open is not a valid project file."), - TEXT("Open Workspace"), + L"The workspace could not be opened.\rIt seems the file to open is not a valid project file.", + L"Open Workspace", MB_OK); return; } @@ -1057,8 +1059,8 @@ void ProjectPanel::popupMenuCmd(int cmdID) { int res = pNativeSpeaker->messageBox("ProjectPanelReloadDirty", _hSelf, - TEXT("The current workspace was modified. Reloading will discard all modifications.\rDo you want to continue?"), - TEXT("Reload Workspace"), + L"The current workspace was modified. Reloading will discard all modifications.\rDo you want to continue?", + L"Reload Workspace", MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); if (res == IDYES) @@ -1079,8 +1081,8 @@ void ProjectPanel::popupMenuCmd(int cmdID) { pNativeSpeaker->messageBox("ProjectPanelReloadError", _hSelf, - TEXT("Cannot find the file to reload."), - TEXT("Reload Workspace"), + L"Cannot find the file to reload.", + L"Reload Workspace", MB_OK); } } @@ -1112,8 +1114,8 @@ void ProjectPanel::popupMenuCmd(int cmdID) NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); int res = pNativeSpeaker->messageBox("ProjectPanelRemoveFolderFromProject", _hSelf, - TEXT("All the sub-items will be removed.\rAre you sure you want to remove this folder from the project?"), - TEXT("Remove folder from project"), + L"All the sub-items will be removed.\rAre you sure you want to remove this folder from the project?", + L"Remove folder from project", MB_YESNO); if (res == IDYES) { @@ -1138,8 +1140,8 @@ void ProjectPanel::popupMenuCmd(int cmdID) NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); int res = pNativeSpeaker->messageBox("ProjectPanelRemoveFileFromProject", _hSelf, - TEXT("Are you sure you want to remove this file from the project?"), - TEXT("Remove file from project"), + L"Are you sure you want to remove this file from the project?", + L"Remove file from project", MB_YESNO); if (res == IDYES) { @@ -1156,7 +1158,7 @@ void ProjectPanel::popupMenuCmd(int cmdID) FileRelocalizerDlg fileRelocalizerDlg; fileRelocalizerDlg.init(_hInst, _hParent); - TCHAR textBuffer[MAX_PATH] = { '\0' }; + wchar_t textBuffer[MAX_PATH] = { '\0' }; TVITEM tvItem{}; tvItem.hItem = hTreeItem; tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; @@ -1166,16 +1168,16 @@ void ProjectPanel::popupMenuCmd(int cmdID) SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast(&tvItem)); if (!tvItem.lParam) return; - generic_string * fn = (generic_string *)tvItem.lParam; + wstring * fn = (wstring *)tvItem.lParam; if (fileRelocalizerDlg.doDialog(fn->c_str()) == 0) { - generic_string newValue = fileRelocalizerDlg.getFullFilePath(); + wstring newValue = fileRelocalizerDlg.getFullFilePath(); if (*fn == newValue) return; *fn = newValue; - TCHAR *strValueLabel = ::PathFindFileName(fn->c_str()); + wchar_t *strValueLabel = ::PathFindFileName(fn->c_str()); wcscpy_s(textBuffer, strValueLabel); int iImage = ::PathFileExists(fn->c_str())?INDEX_LEAF:INDEX_LEAF_INVALID; tvItem.iImage = tvItem.iSelectedImage = iImage; @@ -1194,7 +1196,7 @@ bool ProjectPanel::saveWorkSpaceAs(bool saveCopyAs) fDlg.setExtIndex(0); // 0 index for "custom extention" type if any else for "All types *.*" fDlg.setFolder(getWorkSpaceFilePath()); - const generic_string fn = fDlg.doSaveDlg(); + const wstring fn = fDlg.doSaveDlg(); if (fn.empty()) return false; @@ -1211,23 +1213,23 @@ bool ProjectPanel::saveWorkSpaceAs(bool saveCopyAs) void ProjectPanel::setFileExtFilter(CustomFileDialog & fDlg) { - const TCHAR *ext = NppParameters::getInstance().getNppGUI()._definedWorkspaceExt.c_str(); - generic_string workspaceExt = TEXT(""); + const wchar_t *ext = NppParameters::getInstance().getNppGUI()._definedWorkspaceExt.c_str(); + wstring workspaceExt = L""; if (*ext != '\0') { if (*ext != '.') - workspaceExt += TEXT("."); + workspaceExt += L"."; workspaceExt += ext; - fDlg.setExtFilter(TEXT("Workspace file"), workspaceExt.c_str()); + fDlg.setExtFilter(L"Workspace file", workspaceExt.c_str()); fDlg.setDefExt(ext); } - fDlg.setExtFilter(TEXT("All types"), TEXT(".*")); + fDlg.setExtFilter(L"All types", L".*"); } void ProjectPanel::addFiles(HTREEITEM hTreeItem) { CustomFileDialog fDlg(_hSelf); - fDlg.setExtFilter(TEXT("All types"), TEXT(".*")); + fDlg.setExtFilter(L"All types", L".*"); const auto& fns = fDlg.doOpenMultiFilesDlg(); if (!fns.empty()) @@ -1235,9 +1237,9 @@ void ProjectPanel::addFiles(HTREEITEM hTreeItem) size_t sz = fns.size(); for (size_t i = 0 ; i < sz ; ++i) { - TCHAR *strValueLabel = ::PathFindFileName(fns.at(i).c_str()); + wchar_t *strValueLabel = ::PathFindFileName(fns.at(i).c_str()); - generic_string* pathFileStr = new generic_string(fns.at(i)); + wstring* pathFileStr = new wstring(fns.at(i)); fullPathStrs.push_back(pathFileStr); LPARAM lParamPathFileStr = reinterpret_cast(pathFileStr); @@ -1248,15 +1250,15 @@ void ProjectPanel::addFiles(HTREEITEM hTreeItem) } } -void ProjectPanel::recursiveAddFilesFrom(const TCHAR *folderPath, HTREEITEM hTreeItem) +void ProjectPanel::recursiveAddFilesFrom(const wchar_t *folderPath, HTREEITEM hTreeItem) { - generic_string dirFilter(folderPath); + wstring dirFilter(folderPath); if (folderPath[lstrlen(folderPath)-1] != '\\') - dirFilter += TEXT("\\"); + dirFilter += L"\\"; - dirFilter += TEXT("*.*"); + dirFilter += L"*.*"; WIN32_FIND_DATA foundData; - std::vector files; + std::vector files; HANDLE hFile = ::FindFirstFile(dirFilter.c_str(), &foundData); @@ -1272,13 +1274,13 @@ void ProjectPanel::recursiveAddFilesFrom(const TCHAR *folderPath, HTREEITEM hTre } else // Always recursive { - if ((wcscmp(foundData.cFileName, TEXT(".")) != 0) && (wcscmp(foundData.cFileName, TEXT("..")) != 0)) + if ((wcscmp(foundData.cFileName, L".") != 0) && (wcscmp(foundData.cFileName, L"..") != 0)) { - generic_string pathDir(folderPath); + wstring pathDir(folderPath); if (folderPath[lstrlen(folderPath)-1] != '\\') - pathDir += TEXT("\\"); + pathDir += L"\\"; pathDir += foundData.cFileName; - pathDir += TEXT("\\"); + pathDir += L"\\"; HTREEITEM addedItem = addFolder(hTreeItem, foundData.cFileName); recursiveAddFilesFrom(pathDir.c_str(), addedItem); } @@ -1292,12 +1294,12 @@ void ProjectPanel::recursiveAddFilesFrom(const TCHAR *folderPath, HTREEITEM hTre for (size_t i = 0, len = files.size() ; i < len ; ++i) { - generic_string pathFile(folderPath); + wstring pathFile(folderPath); if (folderPath[lstrlen(folderPath)-1] != '\\') - pathFile += TEXT("\\"); + pathFile += L"\\"; pathFile += files[i]; - generic_string* pathFileStr = new generic_string(pathFile); + wstring* pathFileStr = new wstring(pathFile); fullPathStrs.push_back(pathFileStr); LPARAM lParamPathFileStr = reinterpret_cast(pathFileStr); _treeView.addItem(files[i].c_str(), hTreeItem, INDEX_LEAF, lParamPathFileStr); @@ -1308,20 +1310,20 @@ void ProjectPanel::recursiveAddFilesFrom(const TCHAR *folderPath, HTREEITEM hTre void ProjectPanel::addFilesFromDirectory(HTREEITEM hTreeItem) { - if (_selDirOfFilesFromDirDlg == TEXT("") && _workSpaceFilePath != TEXT("")) + if (_selDirOfFilesFromDirDlg == L"" && _workSpaceFilePath != L"") { - TCHAR dir[MAX_PATH] = { '\0' }; + wchar_t dir[MAX_PATH] = { '\0' }; wcscpy_s(dir, _workSpaceFilePath.c_str()); ::PathRemoveFileSpec(dir); _selDirOfFilesFromDirDlg = dir; } - generic_string dirPath; - if (_selDirOfFilesFromDirDlg != TEXT("")) + wstring dirPath; + if (_selDirOfFilesFromDirDlg != L"") dirPath = getFolderName(_hSelf, _selDirOfFilesFromDirDlg.c_str()); else dirPath = getFolderName(_hSelf); - if (dirPath != TEXT("")) + if (dirPath != L"") { recursiveAddFilesFrom(dirPath.c_str(), hTreeItem); _treeView.expand(hTreeItem); @@ -1384,7 +1386,7 @@ intptr_t CALLBACK FileRelocalizerDlg::run_dlgProc(UINT Message, WPARAM wParam, L { case IDOK : { - TCHAR textBuf[MAX_PATH] = { '\0' }; + wchar_t textBuf[MAX_PATH] = { '\0' }; ::GetDlgItemText(_hSelf, IDC_EDIT_FILEFULLPATHNAME, textBuf, MAX_PATH); _fullFilePath = textBuf; ::EndDialog(_hSelf, 0); @@ -1405,7 +1407,7 @@ intptr_t CALLBACK FileRelocalizerDlg::run_dlgProc(UINT Message, WPARAM wParam, L return FALSE; } -int FileRelocalizerDlg::doDialog(const TCHAR *fn, bool isRTL) +int FileRelocalizerDlg::doDialog(const wchar_t *fn, bool isRTL) { _fullFilePath = fn; diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h index 1fe7bb687fbf..b635954c1a5b 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h @@ -21,32 +21,32 @@ #include "TreeView.h" #include "ProjectPanel_rc.h" -#define PM_PROJECTPANELTITLE TEXT("Project Panel") -#define PM_WORKSPACEROOTNAME TEXT("Workspace") -#define PM_NEWFOLDERNAME TEXT("Folder Name") -#define PM_NEWPROJECTNAME TEXT("Project Name") - -#define PM_NEWWORKSPACE TEXT("New Workspace") -#define PM_OPENWORKSPACE TEXT("Open Workspace") -#define PM_RELOADWORKSPACE TEXT("Reload Workspace") -#define PM_SAVEWORKSPACE TEXT("Save") -#define PM_SAVEASWORKSPACE TEXT("Save As...") -#define PM_SAVEACOPYASWORKSPACE TEXT("Save a Copy As...") -#define PM_NEWPROJECTWORKSPACE TEXT("Add New Project") -#define PM_FINDINFILESWORKSPACE TEXT("Find in Projects...") - -#define PM_EDITRENAME TEXT("Rename") -#define PM_EDITNEWFOLDER TEXT("Add Folder") -#define PM_EDITADDFILES TEXT("Add Files...") -#define PM_EDITADDFILESRECUSIVELY TEXT("Add Files from Directory...") -#define PM_EDITREMOVE TEXT("Remove\tDEL") -#define PM_EDITMODIFYFILE TEXT("Modify File Path") - -#define PM_WORKSPACEMENUENTRY TEXT("Workspace") -#define PM_EDITMENUENTRY TEXT("Edit") - -#define PM_MOVEUPENTRY TEXT("Move Up\tCtrl+Up") -#define PM_MOVEDOWNENTRY TEXT("Move Down\tCtrl+Down") +#define PM_PROJECTPANELTITLE L"Project Panel" +#define PM_WORKSPACEROOTNAME L"Workspace" +#define PM_NEWFOLDERNAME L"Folder Name" +#define PM_NEWPROJECTNAME L"Project Name" + +#define PM_NEWWORKSPACE L"New Workspace" +#define PM_OPENWORKSPACE L"Open Workspace" +#define PM_RELOADWORKSPACE L"Reload Workspace" +#define PM_SAVEWORKSPACE L"Save" +#define PM_SAVEASWORKSPACE L"Save As..." +#define PM_SAVEACOPYASWORKSPACE L"Save a Copy As..." +#define PM_NEWPROJECTWORKSPACE L"Add New Project" +#define PM_FINDINFILESWORKSPACE L"Find in Projects..." + +#define PM_EDITRENAME L"Rename" +#define PM_EDITNEWFOLDER L"Add Folder" +#define PM_EDITADDFILES L"Add Files..." +#define PM_EDITADDFILESRECUSIVELY L"Add Files from Directory..." +#define PM_EDITREMOVE L"Remove\tDEL" +#define PM_EDITMODIFYFILE L"Modify File Path" + +#define PM_WORKSPACEMENUENTRY L"Workspace" +#define PM_EDITMENUENTRY L"Edit" + +#define PM_MOVEUPENTRY L"Move Up\tCtrl+Up" +#define PM_MOVEDOWNENTRY L"Move Down\tCtrl+Down" enum NodeType { nodeType_root = 0, nodeType_project = 1, nodeType_folder = 2, nodeType_file = 3 @@ -69,7 +69,7 @@ class ProjectPanel : public DockingDlgInterface { _hParent = parent2set; }; - void setPanelTitle(generic_string title) { + void setPanelTitle(std::wstring title) { _panelTitle = title; }; const TCHAR * getPanelTitle() const { @@ -98,7 +98,7 @@ class ProjectPanel : public DockingDlgInterface { void setForegroundColor(COLORREF fgColour) override { TreeView_SetTextColor(_treeView.getHSelf(), fgColour); }; - bool enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector & patterns, std::vector & fileNames); + bool enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector & patterns, std::vector & fileNames); protected: TreeView _treeView; @@ -108,9 +108,9 @@ class ProjectPanel : public DockingDlgInterface { HMENU _hProjectMenu = nullptr; HMENU _hFolderMenu = nullptr; HMENU _hFileMenu = nullptr; - generic_string _panelTitle; - generic_string _workSpaceFilePath; - generic_string _selDirOfFilesFromDirDlg; + std::wstring _panelTitle; + std::wstring _workSpaceFilePath; + std::wstring _selDirOfFilesFromDirDlg; bool _isDirty = false; int _panelID = 0; @@ -122,7 +122,7 @@ class ProjectPanel : public DockingDlgInterface { HTREEITEM addFolder(HTREEITEM hTreeItem, const TCHAR *folderName); bool writeWorkSpace(const TCHAR *projectFileName = NULL, bool doUpdateGUI = true); - generic_string getRelativePath(const generic_string & fn, const TCHAR *workSpaceFileName); + std::wstring getRelativePath(const std::wstring & fn, const TCHAR *workSpaceFileName); void buildProjectXml(TiXmlNode *root, HTREEITEM hItem, const TCHAR* fn2write); NodeType getNodeType(HTREEITEM hItem); void setWorkSpaceDirty(bool isDirty); @@ -134,10 +134,10 @@ class ProjectPanel : public DockingDlgInterface { void showContextMenu(int x, int y); void showContextMenuFromMenuKey(HTREEITEM selectedItem, int x, int y); HMENU getMenuHandler(HTREEITEM selectedItem); - generic_string getAbsoluteFilePath(const TCHAR * relativePath); + std::wstring getAbsoluteFilePath(const TCHAR * relativePath); void openSelectFile(); void setFileExtFilter(CustomFileDialog & fDlg); - std::vector fullPathStrs; + std::vector fullPathStrs; }; class FileRelocalizerDlg : public StaticDialog @@ -149,7 +149,7 @@ public : void destroy() override {}; - generic_string getFullFilePath() { + std::wstring getFullFilePath() { return _fullFilePath; }; @@ -157,6 +157,6 @@ protected : intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private : - generic_string _fullFilePath; + std::wstring _fullFilePath; };