From a301ffc774ee6d5179f167e793e9c0a8c08b842a Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 1 Jul 2024 19:55:59 +0200 Subject: [PATCH] Remove ambiguous symbols (part 9) Relace TCHAR, generic_string & TEXT("") par wchar_t, wstring & L"" respectively. Follow up: 94af271 Close #15386 --- PowerEditor/src/MISC/Common/FileInterface.cpp | 25 +-- PowerEditor/src/MISC/sha1/sha1.cpp | 20 +-- PowerEditor/src/MISC/sha1/sha1.h | 20 +-- .../src/ScintillaComponent/FindReplaceDlg.cpp | 2 +- .../src/ScintillaComponent/Printer.cpp | 77 ++++----- .../src/WinControls/AboutDlg/AboutDlg.cpp | 44 ++--- .../src/WinControls/AboutDlg/AboutDlg.h | 14 +- .../OpenSaveFileDialog/CustomFileDialog.cpp | 32 ++-- .../ReadDirectoryChanges.h | 2 +- PowerEditor/src/lastRecentFileList.cpp | 38 ++--- PowerEditor/src/lastRecentFileList.h | 18 +-- PowerEditor/src/localization.cpp | 104 ++++++------ PowerEditor/src/localization.h | 24 +-- PowerEditor/src/winmain.cpp | 152 +++++++++--------- 14 files changed, 282 insertions(+), 290 deletions(-) diff --git a/PowerEditor/src/MISC/Common/FileInterface.cpp b/PowerEditor/src/MISC/Common/FileInterface.cpp index 6634ce2a79d6..86a4ea4e109e 100644 --- a/PowerEditor/src/MISC/Common/FileInterface.cpp +++ b/PowerEditor/src/MISC/Common/FileInterface.cpp @@ -20,6 +20,7 @@ #include "FileInterface.h" #include "Parameters.h" +using namespace std; Win32_IO_File::Win32_IO_File(const wchar_t *fname) { @@ -68,9 +69,9 @@ Win32_IO_File::Win32_IO_File(const wchar_t *fname) NppParameters& nppParam = NppParameters::getInstance(); if (nppParam.isEndSessionStarted() && nppParam.doNppLogNulContentCorruptionIssue()) { - generic_string issueFn = nppLogNulContentCorruptionIssue; - issueFn += TEXT(".log"); - generic_string nppIssueLog = nppParam.getUserPath(); + wstring issueFn = nppLogNulContentCorruptionIssue; + issueFn += L".log"; + wstring nppIssueLog = nppParam.getUserPath(); pathAppend(nppIssueLog, issueFn); std::string msg = _path; @@ -157,9 +158,9 @@ Please try using another storage and also check if your saved data is not corrup if (nppParam.isEndSessionStarted() && nppParam.doNppLogNulContentCorruptionIssue()) { - generic_string issueFn = nppLogNulContentCorruptionIssue; - issueFn += TEXT(".log"); - generic_string nppIssueLog = nppParam.getUserPath(); + wstring issueFn = nppLogNulContentCorruptionIssue; + issueFn += L".log"; + wstring nppIssueLog = nppParam.getUserPath(); pathAppend(nppIssueLog, issueFn); std::string msg; @@ -219,9 +220,9 @@ bool Win32_IO_File::write(const void *wbuf, size_t buf_size) { if (nppParam.isEndSessionStarted() && nppParam.doNppLogNulContentCorruptionIssue()) { - generic_string issueFn = nppLogNulContentCorruptionIssue; - issueFn += TEXT(".log"); - generic_string nppIssueLog = nppParam.getUserPath(); + wstring issueFn = nppLogNulContentCorruptionIssue; + issueFn += L".log"; + wstring nppIssueLog = nppParam.getUserPath(); pathAppend(nppIssueLog, issueFn); std::string msg = _path; @@ -238,9 +239,9 @@ bool Win32_IO_File::write(const void *wbuf, size_t buf_size) { if (nppParam.isEndSessionStarted() && nppParam.doNppLogNulContentCorruptionIssue()) { - generic_string issueFn = nppLogNulContentCorruptionIssue; - issueFn += TEXT(".log"); - generic_string nppIssueLog = nppParam.getUserPath(); + wstring issueFn = nppLogNulContentCorruptionIssue; + issueFn += L".log"; + wstring nppIssueLog = nppParam.getUserPath(); pathAppend(nppIssueLog, issueFn); std::string msg = _path; diff --git a/PowerEditor/src/MISC/sha1/sha1.cpp b/PowerEditor/src/MISC/sha1/sha1.cpp index 669399c6720a..e3a178a3534e 100644 --- a/PowerEditor/src/MISC/sha1/sha1.cpp +++ b/PowerEditor/src/MISC/sha1/sha1.cpp @@ -141,11 +141,11 @@ void CSHA1::Update(const UINT_8* pbData, UINT_32 uLen) } #ifdef SHA1_UTILITY_FUNCTIONS -bool CSHA1::HashFile(const TCHAR* tszFileName) +bool CSHA1::HashFile(const wchar_t* tszFileName) { if(tszFileName == NULL) return false; - FILE* fpIn = _tfopen(tszFileName, _T("rb")); + FILE* fpIn = _tfopen(tszFileName, L"rb"); if(fpIn == NULL) return false; UINT_8* pbData = new UINT_8[SHA1_MAX_FILE_BUFFER]; @@ -203,18 +203,18 @@ void CSHA1::Final() } #ifdef SHA1_UTILITY_FUNCTIONS -bool CSHA1::ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType) const +bool CSHA1::ReportHash(wchar_t* tszReport, REPORT_TYPE rtReportType) const { if(tszReport == NULL) return false; - TCHAR tszTemp[16]{}; + wchar_t tszTemp[16]{}; if((rtReportType == REPORT_HEX) || (rtReportType == REPORT_HEX_SHORT)) { - _sntprintf(tszTemp, 15, _T("%02X"), m_digest[0]); + _sntprintf(tszTemp, 15, L"%02X", m_digest[0]); _tcscpy(tszReport, tszTemp); - const TCHAR* lpFmt = ((rtReportType == REPORT_HEX) ? _T(" %02X") : _T("%02X")); + const wchar_t* lpFmt = ((rtReportType == REPORT_HEX) ? L" %02X" : L"%02X"); for(size_t i = 1; i < 20; ++i) { _sntprintf(tszTemp, 15, lpFmt, m_digest[i]); @@ -223,12 +223,12 @@ bool CSHA1::ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType) const } else if(rtReportType == REPORT_DIGIT) { - _sntprintf(tszTemp, 15, _T("%u"), m_digest[0]); + _sntprintf(tszTemp, 15, L"%u", m_digest[0]); _tcscpy(tszReport, tszTemp); for(size_t i = 1; i < 20; ++i) { - _sntprintf(tszTemp, 15, _T(" %u"), m_digest[i]); + _sntprintf(tszTemp, 15, L" %u", m_digest[i]); _tcscat(tszReport, tszTemp); } } @@ -239,9 +239,9 @@ bool CSHA1::ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType) const #endif #ifdef SHA1_STL_FUNCTIONS -bool CSHA1::ReportHashStl(std::basic_string& strOut, REPORT_TYPE rtReportType) const +bool CSHA1::ReportHashStl(std::basic_string& strOut, REPORT_TYPE rtReportType) const { - TCHAR tszOut[84]{}; + wchar_t tszOut[84]{}; const bool bResult = ReportHash(tszOut, rtReportType); if(bResult) strOut = tszOut; return bResult; diff --git a/PowerEditor/src/MISC/sha1/sha1.h b/PowerEditor/src/MISC/sha1/sha1.h index da32b9f99744..ee9f7d75cf42 100644 --- a/PowerEditor/src/MISC/sha1/sha1.h +++ b/PowerEditor/src/MISC/sha1/sha1.h @@ -153,20 +153,6 @@ #ifdef _MSC_VER #include #else -#ifndef TCHAR -#define TCHAR char -#endif -#ifndef _T -#define _T(__x) (__x) -#define _tmain main -#define _tprintf printf -#define _getts gets -#define _tcslen strlen -#define _tfopen fopen -#define _tcscpy strcpy -#define _tcscat strcat -#define _sntprintf snprintf -#endif #endif #endif @@ -245,18 +231,18 @@ class CSHA1 #ifdef SHA1_UTILITY_FUNCTIONS // Hash in file contents - bool HashFile(const TCHAR* tszFileName); + bool HashFile(const wchar_t* tszFileName); #endif // Finalize hash; call it before using ReportHash(Stl) void Final(); #ifdef SHA1_UTILITY_FUNCTIONS - bool ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType = REPORT_HEX) const; + bool ReportHash(wchar_t* tszReport, REPORT_TYPE rtReportType = REPORT_HEX) const; #endif #ifdef SHA1_STL_FUNCTIONS - bool ReportHashStl(std::basic_string& strOut, REPORT_TYPE rtReportType = + bool ReportHashStl(std::basic_string& strOut, REPORT_TYPE rtReportType = REPORT_HEX) const; #endif diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 75ba177bcf37..3cd9498c0886 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -463,7 +463,7 @@ void FindReplaceDlg::fillComboHistory(int id, const vector & strings) //empty string is not added to CB items, so we need to set it manually if (!strings.empty() && strings.begin()->empty()) { - SetWindowText(hCombo, _T("")); + SetWindowText(hCombo, L""); return; } diff --git a/PowerEditor/src/ScintillaComponent/Printer.cpp b/PowerEditor/src/ScintillaComponent/Printer.cpp index 95e461ec91b7..18f75a4d1bb1 100644 --- a/PowerEditor/src/ScintillaComponent/Printer.cpp +++ b/PowerEditor/src/ScintillaComponent/Printer.cpp @@ -17,9 +17,10 @@ #include "Printer.h" #include "RunDlg.h" -//#include "Parameters.h" -void replaceStr(generic_string & str, generic_string str2BeReplaced, generic_string replacement) +using namespace std; + +void replaceStr(wstring & str, wstring str2BeReplaced, wstring replacement) { size_t pos = str.find(str2BeReplaced); @@ -131,7 +132,7 @@ size_t Printer::doPrint(bool justDoIt) int fontSize = nppGUI._printSettings._headerFontSize?nppGUI._printSettings._headerFontSize:9; int fontWeight = (nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD) ? FW_BOLD : FW_NORMAL; int isFontItalic = (nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC) ? TRUE : FALSE; - const TCHAR *fontFace = (nppGUI._printSettings._headerFontName != TEXT(""))?nppGUI._printSettings._headerFontName.c_str():TEXT("Arial"); + const wchar_t *fontFace = (nppGUI._printSettings._headerFontName != L"")?nppGUI._printSettings._headerFontName.c_str():L"Arial"; int headerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); @@ -151,7 +152,7 @@ size_t Printer::doPrint(bool justDoIt) fontSize = nppGUI._printSettings._footerFontSize?nppGUI._printSettings._footerFontSize:9; fontWeight = (nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD) ? FW_BOLD : FW_NORMAL; isFontItalic = (nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC) ? TRUE : FALSE; - fontFace = (nppGUI._printSettings._footerFontName != TEXT(""))?nppGUI._printSettings._footerFontName.c_str():TEXT("Arial"); + fontFace = (nppGUI._printSettings._footerFontName != L"")?nppGUI._printSettings._footerFontName.c_str():L"Arial"; int footerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); HFONT fontFooter = ::CreateFont(footerLineHeight, @@ -181,7 +182,7 @@ size_t Printer::doPrint(bool justDoIt) if (::StartDoc(_pdlg.hDC, &docInfo) < 0) { - MessageBox(NULL, TEXT("Can not start printer document."), 0, MB_OK); + MessageBox(NULL, L"Can not start printer document.", 0, MB_OK); return 0; } @@ -227,22 +228,22 @@ size_t Printer::doPrint(bool justDoIt) frPrint.rc.right -= printMarge; const int headerSize = 256; - TCHAR headerL[headerSize] = TEXT(""); - TCHAR headerM[headerSize] = TEXT(""); - TCHAR headerR[headerSize] = TEXT(""); - TCHAR footerL[headerSize] = TEXT(""); - TCHAR footerM[headerSize] = TEXT(""); - TCHAR footerR[headerSize] = TEXT(""); + wchar_t headerL[headerSize] = L""; + wchar_t headerM[headerSize] = L""; + wchar_t headerR[headerSize] = L""; + wchar_t footerL[headerSize] = L""; + wchar_t footerM[headerSize] = L""; + wchar_t footerR[headerSize] = L""; - const TCHAR shortDateVar[] = TEXT("$(SHORT_DATE)"); - const TCHAR longDateVar[] = TEXT("$(LONG_DATE)"); - const TCHAR timeVar[] = TEXT("$(TIME)"); + const wchar_t shortDateVar[] = L"$(SHORT_DATE)"; + const wchar_t longDateVar[] = L"$(LONG_DATE)"; + const wchar_t timeVar[] = L"$(TIME)"; const int bufferSize = 64; - TCHAR shortDate[bufferSize]; - TCHAR longDate[bufferSize]; - TCHAR time[bufferSize]; + wchar_t shortDate[bufferSize]; + wchar_t longDate[bufferSize]; + wchar_t time[bufferSize]; SYSTEMTIME st{}; ::GetLocalTime(&st); @@ -254,8 +255,8 @@ size_t Printer::doPrint(bool justDoIt) { frPrint.rc.top += headerLineHeight + headerLineHeight / 2; - generic_string headerLeftPart = nppGUI._printSettings._headerLeft; - if (headerLeftPart != TEXT("")) + wstring headerLeftPart = nppGUI._printSettings._headerLeft; + if (headerLeftPart != L"") { replaceStr(headerLeftPart, shortDateVar, shortDate); replaceStr(headerLeftPart, longDateVar, longDate); @@ -263,8 +264,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(headerLeftPart.c_str(), headerL, headerSize, _pdlg.hwndOwner); } - generic_string headerMiddlePart = nppGUI._printSettings._headerMiddle; - if (headerMiddlePart != TEXT("")) + wstring headerMiddlePart = nppGUI._printSettings._headerMiddle; + if (headerMiddlePart != L"") { replaceStr(headerMiddlePart, shortDateVar, shortDate); replaceStr(headerMiddlePart, longDateVar, longDate); @@ -272,8 +273,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(headerMiddlePart.c_str(), headerM, headerSize, _pdlg.hwndOwner); } - generic_string headerRightPart = nppGUI._printSettings._headerRight; - if (headerRightPart != TEXT("")) + wstring headerRightPart = nppGUI._printSettings._headerRight; + if (headerRightPart != L"") { replaceStr(headerRightPart, shortDateVar, shortDate); replaceStr(headerRightPart, longDateVar, longDate); @@ -287,8 +288,8 @@ size_t Printer::doPrint(bool justDoIt) { frPrint.rc.bottom -= footerLineHeight + footerLineHeight / 2; - generic_string footerLeftPart = nppGUI._printSettings._footerLeft; - if (footerLeftPart != TEXT("")) + wstring footerLeftPart = nppGUI._printSettings._footerLeft; + if (footerLeftPart != L"") { replaceStr(footerLeftPart, shortDateVar, shortDate); replaceStr(footerLeftPart, longDateVar, longDate); @@ -296,8 +297,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(footerLeftPart.c_str(), footerL, headerSize, _pdlg.hwndOwner); } - generic_string footerMiddlePart = nppGUI._printSettings._footerMiddle; - if (footerMiddlePart != TEXT("")) + wstring footerMiddlePart = nppGUI._printSettings._footerMiddle; + if (footerMiddlePart != L"") { replaceStr(footerMiddlePart, shortDateVar, shortDate); replaceStr(footerMiddlePart, longDateVar, longDate); @@ -305,8 +306,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(footerMiddlePart.c_str(), footerM, headerSize, _pdlg.hwndOwner); } - generic_string footerRightPart = nppGUI._printSettings._footerRight; - if (footerRightPart != TEXT("")) + wstring footerRightPart = nppGUI._printSettings._footerRight; + if (footerRightPart != L"") { replaceStr(footerRightPart, shortDateVar, shortDate); replaceStr(footerRightPart, longDateVar, longDate); @@ -321,7 +322,7 @@ size_t Printer::doPrint(bool justDoIt) _pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, false); int pageNum = 1; - const TCHAR pageVar[] = TEXT("$(CURRENT_PRINTING_PAGE)"); + const wchar_t pageVar[] = L"$(CURRENT_PRINTING_PAGE)"; _pSEView->execute(SCI_SETPRINTCOLOURMODE, nppGUI._printSettings._printOption); // setting mode once is enough while (lengthPrinted < lengthDoc) @@ -332,8 +333,8 @@ size_t Printer::doPrint(bool justDoIt) if (!justDoIt) printPage = false; - TCHAR pageString[32]{}; - wsprintf(pageString, TEXT("%0d"), pageNum); + wchar_t pageString[32]{}; + wsprintf(pageString, L"%0d", pageNum); if (printPage) { @@ -357,7 +358,7 @@ size_t Printer::doPrint(bool justDoIt) // Left part if (headerL[0] != '\0') { - generic_string headerLeft(headerL); + wstring headerLeft(headerL); size_t pos = headerLeft.find(pageVar); if (pos != headerLeft.npos) @@ -370,7 +371,7 @@ size_t Printer::doPrint(bool justDoIt) // Middle part if (headerM[0] != '\0') { - generic_string headerMiddle(headerM); + wstring headerMiddle(headerM); size_t pos = headerMiddle.find(pageVar); if (pos != headerMiddle.npos) headerMiddle.replace(pos, lstrlen(pageVar), pageString); @@ -382,7 +383,7 @@ size_t Printer::doPrint(bool justDoIt) // Right part if (headerR[0] != '\0') { - generic_string headerRight(headerR); + wstring headerRight(headerR); size_t pos = headerRight.find(pageVar); if (pos != headerRight.npos) headerRight.replace(pos, lstrlen(pageVar), pageString); @@ -424,7 +425,7 @@ size_t Printer::doPrint(bool justDoIt) // Left part if (footerL[0] != '\0') { - generic_string footerLeft(footerL); + wstring footerLeft(footerL); size_t pos = footerLeft.find(pageVar); if (pos != footerLeft.npos) footerLeft.replace(pos, lstrlen(pageVar), pageString); @@ -436,7 +437,7 @@ size_t Printer::doPrint(bool justDoIt) // Middle part if (footerM[0] != '\0') { - generic_string footerMiddle(footerM); + wstring footerMiddle(footerM); size_t pos = footerMiddle.find(pageVar); if (pos != footerMiddle.npos) footerMiddle.replace(pos, lstrlen(pageVar), pageString); @@ -448,7 +449,7 @@ size_t Printer::doPrint(bool justDoIt) // Right part if (footerR[0] != '\0') { - generic_string footerRight(footerR); + wstring footerRight(footerR); size_t pos = footerRight.find(pageVar); if (pos != footerRight.npos) footerRight.replace(pos, lstrlen(pageVar), pageString); diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp index ff59824125c5..7e25d1ec48e6 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp @@ -19,6 +19,8 @@ #include "Parameters.h" #include "localization.h" +using namespace std; + #ifdef _MSC_VER #pragma warning(disable : 4996) // for GetVersion() #endif @@ -32,7 +34,7 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); HWND compileDateHandle = ::GetDlgItem(_hSelf, IDC_BUILD_DATETIME); - generic_string buildTime = L"Build time: "; + wstring buildTime = L"Build time: "; WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); buildTime += wmc.char2wchar(__DATE__, CP_ACP); @@ -174,7 +176,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM // Build time _debugInfoStr += L"Build time : "; - generic_string buildTime; + wstring buildTime; WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); buildTime += wmc.char2wchar(__DATE__, CP_ACP); buildTime += L" - "; @@ -196,7 +198,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM // Binary path _debugInfoStr += L"Path : "; - TCHAR nppFullPath[MAX_PATH]{}; + wchar_t nppFullPath[MAX_PATH]{}; ::GetModuleFileName(NULL, nppFullPath, MAX_PATH); _debugInfoStr += nppFullPath; _debugInfoStr += L"\r\n"; @@ -220,7 +222,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM // Cloud config directory _debugInfoStr += L"Cloud Config : "; - const generic_string& cloudPath = nppParam.getNppGUI()._cloudPath; + const wstring& cloudPath = nppParam.getNppGUI()._cloudPath; _debugInfoStr += cloudPath.empty() ? L"OFF" : cloudPath; _debugInfoStr += L"\r\n"; @@ -234,20 +236,20 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM DWORD dataSize = 0; constexpr size_t bufSize = 96; - TCHAR szProductName[bufSize] = {'\0'}; + wchar_t szProductName[bufSize] = {'\0'}; constexpr size_t bufSizeBuildNumber = 32; - TCHAR szCurrentBuildNumber[bufSizeBuildNumber] = {'\0'}; - TCHAR szReleaseId[32] = {'\0'}; + wchar_t szCurrentBuildNumber[bufSizeBuildNumber] = {'\0'}; + wchar_t szReleaseId[32] = {'\0'}; DWORD dwUBR = 0; constexpr size_t bufSizeUBR = 12; - TCHAR szUBR[bufSizeUBR] = L"0"; + wchar_t szUBR[bufSizeUBR] = L"0"; // NOTE: RegQueryValueExW is not guaranteed to return null-terminated strings if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { dataSize = sizeof(szProductName); RegQueryValueExW(hKey, L"ProductName", NULL, NULL, reinterpret_cast(szProductName), &dataSize); - szProductName[sizeof(szProductName) / sizeof(TCHAR) - 1] = '\0'; + szProductName[sizeof(szProductName) / sizeof(wchar_t) - 1] = '\0'; dataSize = sizeof(szReleaseId); if(RegQueryValueExW(hKey, L"DisplayVersion", NULL, NULL, reinterpret_cast(szReleaseId), &dataSize) != ERROR_SUCCESS) @@ -255,11 +257,11 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM dataSize = sizeof(szReleaseId); RegQueryValueExW(hKey, L"ReleaseId", NULL, NULL, reinterpret_cast(szReleaseId), &dataSize); } - szReleaseId[sizeof(szReleaseId) / sizeof(TCHAR) - 1] = '\0'; + szReleaseId[sizeof(szReleaseId) / sizeof(wchar_t) - 1] = '\0'; dataSize = sizeof(szCurrentBuildNumber); RegQueryValueExW(hKey, L"CurrentBuildNumber", NULL, NULL, reinterpret_cast(szCurrentBuildNumber), &dataSize); - szCurrentBuildNumber[sizeof(szCurrentBuildNumber) / sizeof(TCHAR) - 1] = '\0'; + szCurrentBuildNumber[sizeof(szCurrentBuildNumber) / sizeof(wchar_t) - 1] = '\0'; dataSize = sizeof(DWORD); if (RegQueryValueExW(hKey, L"UBR", NULL, NULL, reinterpret_cast(&dwUBR), &dataSize) == ERROR_SUCCESS) @@ -277,9 +279,9 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM } else if (NppDarkMode::isWindows11()) { - generic_string tmpProductName = szProductName; + wstring tmpProductName = szProductName; constexpr size_t strLen = 10U; - const TCHAR strWin10[strLen + 1U] = L"Windows 10"; + const wchar_t strWin10[strLen + 1U] = L"Windows 10"; const size_t pos = tmpProductName.find(strWin10); if (pos < (bufSize - strLen - 1U)) { @@ -322,7 +324,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM { constexpr size_t bufSizeACP = 32; - TCHAR szACP[bufSizeACP] = { '\0' }; + wchar_t szACP[bufSizeACP] = { '\0' }; swprintf(szACP, bufSizeACP, L"%u", ::GetACP()); _debugInfoStr += L"Current ANSI codepage : "; _debugInfoStr += szACP; @@ -340,7 +342,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM if (pWGV != nullptr) { constexpr size_t bufSizeWineVer = 32; - TCHAR szWINEVersion[bufSizeWineVer] = { '\0' }; + wchar_t szWINEVersion[bufSizeWineVer] = { '\0' }; swprintf(szWINEVersion, bufSizeWineVer, L"%hs", pWGV()); _debugInfoStr += L"WINE : "; @@ -469,14 +471,14 @@ void DoSaveOrNotBox::doDialog(bool isRTL) void DoSaveOrNotBox::changeLang() { - generic_string msg; - generic_string defaultMessage = L"Save file \"$STR_REPLACE$\" ?"; + wstring msg; + wstring defaultMessage = L"Save file \"$STR_REPLACE$\" ?"; NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); if (nativeLangSpeaker->changeDlgLang(_hSelf, "DoSaveOrNot")) { constexpr unsigned char len = 255; - TCHAR text[len]{}; + wchar_t text[len]{}; ::GetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEXT, text, len); msg = text; } @@ -590,14 +592,14 @@ void DoSaveAllBox::doDialog(bool isRTL) void DoSaveAllBox::changeLang() { - generic_string msg; - generic_string defaultMessage = L"Are you sure you want to save all modified documents?\r\rChoose \"Always Yes\" if you don't want to see this dialog again.\rYou can re-activate this dialog in Preferences later."; + wstring msg; + wstring defaultMessage = L"Are you sure you want to save all modified documents?\r\rChoose \"Always Yes\" if you don't want to see this dialog again.\rYou can re-activate this dialog in Preferences later."; NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); if (nativeLangSpeaker->changeDlgLang(_hSelf, "DoSaveAll")) { constexpr size_t len = 1024; - TCHAR text[len]{}; + wchar_t text[len]{}; ::GetDlgItemText(_hSelf, IDC_DOSAVEALLTEXT, text, len); msg = text; } diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h index 23c04e068bb1..21bdf7e4f582 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h @@ -68,7 +68,7 @@ class DebugInfoDlg : public StaticDialog public: DebugInfoDlg() = default; - void init(HINSTANCE hInst, HWND parent, bool isAdmin, const generic_string& loadedPlugins) { + void init(HINSTANCE hInst, HWND parent, bool isAdmin, const std::wstring& loadedPlugins) { _isAdmin = isAdmin; _loadedPlugins = loadedPlugins; Window::init(hInst, parent); @@ -85,11 +85,11 @@ class DebugInfoDlg : public StaticDialog private: typedef const CHAR * (__cdecl * PWINEGETVERSION)(); - generic_string _debugInfoStr; - generic_string _debugInfoDisplay; - const generic_string _cmdLinePlaceHolder { L"$COMMAND_LINE_PLACEHOLDER$" }; + std::wstring _debugInfoStr; + std::wstring _debugInfoDisplay; + const std::wstring _cmdLinePlaceHolder { L"$COMMAND_LINE_PLACEHOLDER$" }; bool _isAdmin = false; - generic_string _loadedPlugins; + std::wstring _loadedPlugins; }; class DoSaveOrNotBox : public StaticDialog @@ -97,7 +97,7 @@ class DoSaveOrNotBox : public StaticDialog public: DoSaveOrNotBox() = default; - void init(HINSTANCE hInst, HWND parent, const TCHAR* fn, bool isMulti) { + void init(HINSTANCE hInst, HWND parent, const wchar_t* fn, bool isMulti) { Window::init(hInst, parent); if (fn) _fn = fn; @@ -120,7 +120,7 @@ class DoSaveOrNotBox : public StaticDialog private: int clickedButtonId = -1; - generic_string _fn; + std::wstring _fn; bool _isMulti = false; }; diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp index 50ca3fde7af7..01d054e24ef9 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp @@ -451,7 +451,7 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo if (extIndex >= 0 && extIndex < static_cast(_filterSpec.size())) { const wstring ext = get1stExt(_filterSpec[extIndex].ext); - if (!ext.ends_with(_T(".*"))) + if (!ext.ends_with(L".*")) return replaceExt(name, ext); } return false; @@ -493,7 +493,7 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo if (nameChanged) { // Clear the name first to ensure it's updated properly. - _dialog->SetFileName(_T("")); + _dialog->SetFileName(L""); _dialog->SetFileName(fileName.c_str()); } } @@ -530,17 +530,17 @@ class FileDialogEventHandler final : public IFileDialogEvents, public IFileDialo if (IsWindowEnabled(hwnd) && GetClassName(hwnd, buffer, bufferLen) != 0) { - if (lstrcmpi(buffer, _T("ComboBox")) == 0) + if (lstrcmpi(buffer, L"ComboBox") == 0) { // The edit box of interest is a child of the combo box and has empty window text. // We use the first combo box, but there might be the others (file type dropdown, address bar, etc). - HWND hwndChild = FindWindowEx(hwnd, nullptr, _T("Edit"), _T("")); + HWND hwndChild = FindWindowEx(hwnd, nullptr, L"Edit", L""); if (hwndChild && !inst->_hwndNameEdit) { inst->_hwndNameEdit = hwndChild; } } - else if (lstrcmpi(buffer, _T("Button")) == 0) + else if (lstrcmpi(buffer, L"Button") == 0) { // Find the OK button. // Preconditions: @@ -701,7 +701,7 @@ class CustomFileDialog::Impl if (!hasExt(newFileName)) { const wstring ext = get1stExt(_filterSpec[_fileTypeIndex].ext); - if (!ext.ends_with(_T(".*"))) + if (!ext.ends_with(L".*")) newFileName += ext; } } @@ -932,20 +932,20 @@ void CustomFileDialog::setTitle(const wchar_t* title) void CustomFileDialog::setExtFilter(const wchar_t *extText, const wchar_t *exts) { // Add an asterisk before each dot in file patterns - wstring newExts{ exts ? exts : _T("") }; + wstring newExts{ exts ? exts : L"" }; for (size_t pos = 0; pos < newExts.size(); ++pos) { - pos = newExts.find(_T('.'), pos); + pos = newExts.find(L'.', pos); if (pos == wstring::npos) break; - if (pos == 0 || newExts[pos - 1] != _T('*')) + if (pos == 0 || newExts[pos - 1] != L'*') { - newExts.insert(pos, 1, _T('*')); + newExts.insert(pos, 1, L'*'); ++pos; } } - if (newExts.find(_T("*.*")) == 0) + if (newExts.find(L"*.*") == 0) _impl->_wildcardIndex = static_cast(_impl->_filterSpec.size()); _impl->_filterSpec.push_back({ extText, newExts }); @@ -957,7 +957,7 @@ void CustomFileDialog::setExtFilter(const wchar_t *extText, std::initializer_lis for (auto&& x : extList) { exts += x; - exts += _T(';'); + exts += L';'; } exts.pop_back(); // remove the last ';' setExtFilter(extText, exts.c_str()); @@ -975,7 +975,7 @@ void CustomFileDialog::setDefFileName(const wchar_t* fn) void CustomFileDialog::setFolder(const wchar_t* folder) { - _impl->_initialFolder = folder ? folder : _T(""); + _impl->_initialFolder = folder ? folder : L""; } void CustomFileDialog::setCheckbox(const wchar_t* text, bool isActive) @@ -1024,7 +1024,7 @@ wstring CustomFileDialog::doSaveDlg() _impl->addFlags(FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM); bool bOk = _impl->show(); - return bOk ? _impl->getResultFilename() : _T(""); + return bOk ? _impl->getResultFilename() : L""; } wstring CustomFileDialog::doOpenSingleFileDlg() @@ -1036,7 +1036,7 @@ wstring CustomFileDialog::doOpenSingleFileDlg() _impl->addFlags(FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM); bool bOk = _impl->show(); - return bOk ? _impl->getResultFilename() : _T(""); + return bOk ? _impl->getResultFilename() : L""; } std::vector CustomFileDialog::doOpenMultiFilesDlg() @@ -1060,5 +1060,5 @@ wstring CustomFileDialog::pickFolder() _impl->addFlags(FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM | FOS_PICKFOLDERS); bool bOk = _impl->show(); - return bOk ? _impl->getResultFilename() : _T(""); + return bOk ? _impl->getResultFilename() : L""; } diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h index ac5211e895eb..70659a5f9422 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h @@ -72,7 +72,7 @@ namespace ReadDirectoryChangesPrivate /// /// /// CReadDirectoryChanges changes; -/// changes.AddDirectory(_T("C:\\"), false, dwNotificationFlags); +/// changes.AddDirectory(L"C:\\", false, dwNotificationFlags); /// /// const HANDLE handles[] = { hStopEvent, changes.GetWaitHandle() }; /// diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index 9dffb903b257..192b7673486b 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -20,6 +20,8 @@ #include "menuCmdID.h" #include "localization.h" +using namespace std; + void LastRecentFileList::initMenu(HMENU hMenu, int idBase, int posBase, Accelerator *pAccelerator, bool doSubMenu) { if (doSubMenu) @@ -90,19 +92,19 @@ void LastRecentFileList::updateMenu() //add separators NativeLangSpeaker *pNativeLangSpeaker = nppParam.getNativeLangSpeaker(); - generic_string recentFileList = pNativeLangSpeaker->getSubMenuEntryName("file-recentFiles"); - generic_string openRecentClosedFile = pNativeLangSpeaker->getNativeLangMenuString(IDM_FILE_RESTORELASTCLOSEDFILE); - generic_string openAllFiles = pNativeLangSpeaker->getNativeLangMenuString(IDM_OPEN_ALL_RECENT_FILE); - generic_string cleanFileList = pNativeLangSpeaker->getNativeLangMenuString(IDM_CLEAN_RECENT_FILE_LIST); + wstring recentFileList = pNativeLangSpeaker->getSubMenuEntryName("file-recentFiles"); + wstring openRecentClosedFile = pNativeLangSpeaker->getNativeLangMenuString(IDM_FILE_RESTORELASTCLOSEDFILE); + wstring openAllFiles = pNativeLangSpeaker->getNativeLangMenuString(IDM_OPEN_ALL_RECENT_FILE); + wstring cleanFileList = pNativeLangSpeaker->getNativeLangMenuString(IDM_CLEAN_RECENT_FILE_LIST); - if (recentFileList == TEXT("")) - recentFileList = TEXT("&Recent Files"); - if (openRecentClosedFile == TEXT("")) - openRecentClosedFile = TEXT("Restore Recent Closed File"); - if (openAllFiles == TEXT("")) - openAllFiles = TEXT("Open All Recent Files"); - if (cleanFileList == TEXT("")) - cleanFileList = TEXT("Empty Recent Files List"); + if (recentFileList == L"") + recentFileList = L"&Recent Files"; + if (openRecentClosedFile == L"") + openRecentClosedFile = L"Restore Recent Closed File"; + if (openAllFiles == L"") + openAllFiles = L"Open All Recent Files"; + if (cleanFileList == L"") + cleanFileList = L"Empty Recent Files List"; if (!isSubMenuMode()) ::InsertMenu(_hMenu, _posBase + 0, MF_BYPOSITION, static_cast(-1), 0); @@ -149,13 +151,13 @@ void LastRecentFileList::updateMenu() //Then readd them, so everything stays in sync for (int j = 0; j < _size; ++j) { - generic_string strBuffer(BuildMenuFileName(nppParam.getRecentFileCustomLength(), j, _lrfl.at(j)._name)); + wstring strBuffer(BuildMenuFileName(nppParam.getRecentFileCustomLength(), j, _lrfl.at(j)._name)); ::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, strBuffer.c_str()); } } -void LastRecentFileList::add(const TCHAR *fn) +void LastRecentFileList::add(const wchar_t *fn) { if (_userMax == 0 || _locked) return; @@ -183,7 +185,7 @@ void LastRecentFileList::add(const TCHAR *fn) updateMenu(); } -void LastRecentFileList::remove(const TCHAR *fn) +void LastRecentFileList::remove(const wchar_t *fn) { int index = find(fn); if (index != -1) @@ -221,7 +223,7 @@ void LastRecentFileList::clear() } -generic_string & LastRecentFileList::getItem(int id) +wstring & LastRecentFileList::getItem(int id) { int i = 0; for (; i < _size; ++i) @@ -234,7 +236,7 @@ generic_string & LastRecentFileList::getItem(int id) return _lrfl.at(i)._name; //if not found, return first } -generic_string & LastRecentFileList::getIndex(int index) +wstring & LastRecentFileList::getIndex(int index) { return _lrfl.at(index)._name; //if not found, return first } @@ -274,7 +276,7 @@ void LastRecentFileList::saveLRFL() } -int LastRecentFileList::find(const TCHAR *fn) +int LastRecentFileList::find(const wchar_t *fn) { for (int i = 0; i < _size; ++i) { diff --git a/PowerEditor/src/lastRecentFileList.h b/PowerEditor/src/lastRecentFileList.h index 11a3b0cda22c..c075b52ccf87 100644 --- a/PowerEditor/src/lastRecentFileList.h +++ b/PowerEditor/src/lastRecentFileList.h @@ -22,8 +22,8 @@ struct RecentItem { int _id = 0; - generic_string _name; - explicit RecentItem(const TCHAR * name) : _name(name) {}; + std::wstring _name; + explicit RecentItem(const wchar_t * name) : _name(name) {}; }; typedef std::deque recentList; @@ -39,8 +39,8 @@ class LastRecentFileList void switchMode(); void updateMenu(); - void add(const TCHAR *fn); - void remove(const TCHAR *fn); + void add(const wchar_t *fn); + void remove(const wchar_t *fn); void remove(size_t index); void clear(); @@ -57,12 +57,12 @@ class LastRecentFileList return _userMax; }; - generic_string & getItem(int id); //use menu id - generic_string & getIndex(int index); //use menu id + std::wstring & getItem(int id); //use menu id + std::wstring & getIndex(int index); //use menu id - generic_string getFirstItem() const { + std::wstring getFirstItem() const { if (_lrfl.size() == 0) - return TEXT(""); + return L""; return _lrfl.front()._name; }; @@ -98,7 +98,7 @@ class LastRecentFileList bool _hasSeparators = false; bool _locked = false; - int find(const TCHAR *fn); + int find(const wchar_t *fn); int popFirstAvailableID(); void setAvailable(int id); }; diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index d8cc90dd543d..4d77c812ac58 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -180,15 +180,15 @@ void NativeLangSpeaker::init(TiXmlDocumentA *nativeLangDocRootA, bool loadIfEngl } } -generic_string NativeLangSpeaker::getSubMenuEntryName(const char *nodeName) const +wstring NativeLangSpeaker::getSubMenuEntryName(const char *nodeName) const { - if (!_nativeLangA) return TEXT(""); + if (!_nativeLangA) return L""; TiXmlNodeA *mainMenu = _nativeLangA->FirstChild("Menu"); - if (!mainMenu) return TEXT(""); + if (!mainMenu) return L""; mainMenu = mainMenu->FirstChild("Main"); - if (!mainMenu) return TEXT(""); + if (!mainMenu) return L""; TiXmlNodeA *entriesRoot = mainMenu->FirstChild("SubEntries"); - if (!entriesRoot) return TEXT(""); + if (!entriesRoot) return L""; WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); @@ -208,7 +208,7 @@ generic_string NativeLangSpeaker::getSubMenuEntryName(const char *nodeName) cons } } } - return TEXT(""); + return L""; } void purifyMenuString(string& s) @@ -251,7 +251,7 @@ void purifyMenuString(string& s) } -generic_string NativeLangSpeaker::getNativeLangMenuString(int itemID, generic_string inCaseOfFailureStr, bool removeMarkAnd) const +wstring NativeLangSpeaker::getNativeLangMenuString(int itemID, wstring inCaseOfFailureStr, bool removeMarkAnd) const { if (!_nativeLangA) return inCaseOfFailureStr; @@ -291,19 +291,19 @@ generic_string NativeLangSpeaker::getNativeLangMenuString(int itemID, generic_st return inCaseOfFailureStr; } -generic_string NativeLangSpeaker::getShortcutNameString(int itemID) const +wstring NativeLangSpeaker::getShortcutNameString(int itemID) const { if (!_nativeLangA) - return TEXT(""); + return L""; TiXmlNodeA *node = _nativeLangA->FirstChild("Dialog"); - if (!node) return TEXT(""); + if (!node) return L""; node = node->FirstChild("ShortcutMapper"); - if (!node) return TEXT(""); + if (!node) return L""; node = node->FirstChild("MainCommandNames"); - if (!node) return TEXT(""); + if (!node) return L""; WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); @@ -322,10 +322,10 @@ generic_string NativeLangSpeaker::getShortcutNameString(int itemID) const } } } - return TEXT(""); + return L""; } -generic_string NativeLangSpeaker::getLocalizedStrFromID(const char *strID, const generic_string& defaultString) const +wstring NativeLangSpeaker::getLocalizedStrFromID(const char *strID, const wstring& defaultString) const { if (!_nativeLangA) return defaultString; @@ -789,7 +789,7 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) { if (id == IDC_DOCK_BUTTON && userDefineDlg->isDocked()) { - generic_string undockStr = getAttrNameByIdStr(TEXT("Undock"), userDefineDlgNode, std::to_string(IDC_UNDOCK_BUTTON).c_str()); + wstring undockStr = getAttrNameByIdStr(L"Undock", userDefineDlgNode, std::to_string(IDC_UNDOCK_BUTTON).c_str()); ::SetWindowText(hItem, undockStr.c_str()); } else @@ -982,146 +982,146 @@ void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference) if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Global"), nameW); + preference.renameDialogTitle(L"Global", nameW); } changeDlgLang(preference._editingSubDlg.getHSelf(), "Scintillas", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Scintillas"), nameW); + preference.renameDialogTitle(L"Scintillas", nameW); } changeDlgLang(preference._editing2SubDlg.getHSelf(), "Scintillas2", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Scintillas2"), nameW); + preference.renameDialogTitle(L"Scintillas2", nameW); } changeDlgLang(preference._darkModeSubDlg.getHSelf(), "DarkMode", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t* nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("DarkMode"), nameW); + preference.renameDialogTitle(L"DarkMode", nameW); } changeDlgLang(preference._marginsBorderEdgeSubDlg.getHSelf(), "MarginsBorderEdge", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("MarginsBorderEdge"), nameW); + preference.renameDialogTitle(L"MarginsBorderEdge", nameW); } changeDlgLang(preference._newDocumentSubDlg.getHSelf(), "NewDoc", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("NewDoc"), nameW); + preference.renameDialogTitle(L"NewDoc", nameW); } changeDlgLang(preference._defaultDirectorySubDlg.getHSelf(), "DefaultDir", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("DefaultDir"), nameW); + preference.renameDialogTitle(L"DefaultDir", nameW); } changeDlgLang(preference._recentFilesHistorySubDlg.getHSelf(), "RecentFilesHistory", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("RecentFilesHistory"), nameW); + preference.renameDialogTitle(L"RecentFilesHistory", nameW); } changeDlgLang(preference._fileAssocDlg.getHSelf(), "FileAssoc", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("FileAssoc"), nameW); + preference.renameDialogTitle(L"FileAssoc", nameW); } changeDlgLang(preference._languageSubDlg.getHSelf(), "Language", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Language"), nameW); + preference.renameDialogTitle(L"Language", nameW); } changeDlgLang(preference._highlightingSubDlg.getHSelf(), "Highlighting", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Highlighting"), nameW); + preference.renameDialogTitle(L"Highlighting", nameW); } changeDlgLang(preference._printSubDlg.getHSelf(), "Print", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Print"), nameW); + preference.renameDialogTitle(L"Print", nameW); } changeDlgLang(preference._searchingSubDlg.getHSelf(), "Searching", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t* nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Searching"), nameW); + preference.renameDialogTitle(L"Searching", nameW); } changeDlgLang(preference._miscSubDlg.getHSelf(), "MISC", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("MISC"), nameW); + preference.renameDialogTitle(L"MISC", nameW); } changeDlgLang(preference._backupSubDlg.getHSelf(), "Backup", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Backup"), nameW); + preference.renameDialogTitle(L"Backup", nameW); } changeDlgLang(preference._autoCompletionSubDlg.getHSelf(), "AutoCompletion", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("AutoCompletion"), nameW); + preference.renameDialogTitle(L"AutoCompletion", nameW); } changeDlgLang(preference._multiInstanceSubDlg.getHSelf(), "MultiInstance", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("MultiInstance"), nameW); + preference.renameDialogTitle(L"MultiInstance", nameW); } changeDlgLang(preference._delimiterSubDlg.getHSelf(), "Delimiter", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Delimiter"), nameW); + preference.renameDialogTitle(L"Delimiter", nameW); } changeDlgLang(preference._performanceSubDlg.getHSelf(), "Performance", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Performance"), nameW); + preference.renameDialogTitle(L"Performance", nameW); } changeDlgLang(preference._cloudAndLinkSubDlg.getHSelf(), "Cloud", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("Cloud"), nameW); + preference.renameDialogTitle(L"Cloud", nameW); } changeDlgLang(preference._searchEngineSubDlg.getHSelf(), "SearchEngine", titre, titreMaxSize); if (titre[0] != '\0') { const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding); - preference.renameDialogTitle(TEXT("SearchEngine"), nameW); + preference.renameDialogTitle(L"SearchEngine", nameW); } preference.setListSelection(currentSel); @@ -1193,7 +1193,7 @@ void NativeLangSpeaker::changeShortcutLang() } -generic_string NativeLangSpeaker::getShortcutMapperLangStr(const char *nodeName, const TCHAR *defaultStr) const +wstring NativeLangSpeaker::getShortcutMapperLangStr(const char *nodeName, const wchar_t *defaultStr) const { if (!_nativeLangA) return defaultStr; @@ -1231,7 +1231,7 @@ TiXmlNodeA * NativeLangSpeaker::searchDlgNode(TiXmlNodeA *node, const char *dlgT return NULL; } -bool NativeLangSpeaker::getDoSaveOrNotStrings(generic_string& title, generic_string& msg) +bool NativeLangSpeaker::getDoSaveOrNotStrings(wstring& title, wstring& msg) { if (!_nativeLangA) return false; @@ -1322,7 +1322,7 @@ bool NativeLangSpeaker::changeDlgLang(HWND hDlg, const char *dlgTagName, char *t childNode; childNode = childNode->NextSibling("ComboBox")) { - std::vector comboElms; + std::vector comboElms; TiXmlElementA *element = childNode->ToElement(); int id; element->Attribute("id", &id); @@ -1361,10 +1361,10 @@ bool NativeLangSpeaker::changeDlgLang(HWND hDlg, const char *dlgTagName, char *t return true; } -bool NativeLangSpeaker::getMsgBoxLang(const char *msgBoxTagName, generic_string & title, generic_string & message) +bool NativeLangSpeaker::getMsgBoxLang(const char *msgBoxTagName, wstring & title, wstring & message) { - title = TEXT(""); - message = TEXT(""); + title = L""; + message = L""; if (!_nativeLangA) return false; @@ -1388,7 +1388,7 @@ bool NativeLangSpeaker::getMsgBoxLang(const char *msgBoxTagName, generic_string return false; } -generic_string NativeLangSpeaker::getDlgLangMenuStr(const char* firstLevelNodeName, const char* secondLevelNodeName, int cmdID, const TCHAR* defaultStr) const +wstring NativeLangSpeaker::getDlgLangMenuStr(const char* firstLevelNodeName, const char* secondLevelNodeName, int cmdID, const wchar_t* defaultStr) const { if (!_nativeLangA) return defaultStr; @@ -1428,7 +1428,7 @@ generic_string NativeLangSpeaker::getDlgLangMenuStr(const char* firstLevelNodeNa return defaultStr; } -generic_string NativeLangSpeaker::getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const +wstring NativeLangSpeaker::getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const wchar_t *defaultStr) const { if (!_nativeLangA) return defaultStr; @@ -1465,7 +1465,7 @@ generic_string NativeLangSpeaker::getProjectPanelLangMenuStr(const char * nodeNa return defaultStr; } -generic_string NativeLangSpeaker::getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name, const char *nodeL3Name) const +wstring NativeLangSpeaker::getAttrNameStr(const wchar_t *defaultStr, const char *nodeL1Name, const char *nodeL2Name, const char *nodeL3Name) const { if (!_nativeLangA) return defaultStr; @@ -1485,7 +1485,7 @@ generic_string NativeLangSpeaker::getAttrNameStr(const TCHAR *defaultStr, const return defaultStr; } -generic_string NativeLangSpeaker::getAttrNameByIdStr(const TCHAR *defaultStr, TiXmlNodeA *targetNode, const char *nodeL1Value, const char *nodeL1Name, const char *nodeL2Name) const +wstring NativeLangSpeaker::getAttrNameByIdStr(const wchar_t *defaultStr, TiXmlNodeA *targetNode, const char *nodeL1Value, const char *nodeL1Name, const char *nodeL2Name) const { if (!targetNode) return defaultStr; @@ -1508,23 +1508,23 @@ generic_string NativeLangSpeaker::getAttrNameByIdStr(const TCHAR *defaultStr, Ti return defaultStr; } -int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, const TCHAR *defaultMessage, const TCHAR *defaultTitle, int msgBoxType, int intInfo, const TCHAR *strInfo) +int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, const wchar_t *defaultMessage, const wchar_t *defaultTitle, int msgBoxType, int intInfo, const wchar_t *strInfo) { if ((NppParameters::getInstance()).isEndSessionCritical()) return IDCANCEL; // simulate Esc-key or Cancel-button as there should not be any big delay / code-flow block - generic_string msg, title; + wstring msg, title; if (!getMsgBoxLang(msgBoxTagName, title, msg)) { title = defaultTitle; msg = defaultMessage; } - title = stringReplace(title, TEXT("$INT_REPLACE$"), std::to_wstring(intInfo)); - msg = stringReplace(msg, TEXT("$INT_REPLACE$"), std::to_wstring(intInfo)); + title = stringReplace(title, L"$INT_REPLACE$", std::to_wstring(intInfo)); + msg = stringReplace(msg, L"$INT_REPLACE$", std::to_wstring(intInfo)); if (strInfo) { - title = stringReplace(title, TEXT("$STR_REPLACE$"), strInfo); - msg = stringReplace(msg, TEXT("$STR_REPLACE$"), strInfo); + title = stringReplace(title, L"$STR_REPLACE$", strInfo); + msg = stringReplace(msg, L"$STR_REPLACE$", strInfo); } if (_isRTL) { diff --git a/PowerEditor/src/localization.h b/PowerEditor/src/localization.h index ef393dec6129..9df50a10193b 100644 --- a/PowerEditor/src/localization.h +++ b/PowerEditor/src/localization.h @@ -46,9 +46,9 @@ class NativeLangSpeaker { bool changeDlgLang(HWND hDlg, const char *dlgTagName, char *title = NULL, size_t titleMaxSize = 0); void changeLangTabDropContextMenu(HMENU hCM); void changeLangTrayIconContexMenu(HMENU hCM); - generic_string getSubMenuEntryName(const char *nodeName) const; - generic_string getNativeLangMenuString(int itemID, generic_string inCaseOfFailureStr = L"", bool removeMarkAnd = false) const; - generic_string getShortcutNameString(int itemID) const; + std::wstring getSubMenuEntryName(const char *nodeName) const; + std::wstring getNativeLangMenuString(int itemID, std::wstring inCaseOfFailureStr = L"", bool removeMarkAnd = false) const; + std::wstring getShortcutNameString(int itemID) const; void changeMenuLang(HMENU menuHandle); void changeShortcutLang(); @@ -59,7 +59,7 @@ class NativeLangSpeaker { void changePrefereceDlgLang(PreferenceDlg & preference); void changePluginsAdminDlgLang(PluginsAdminDlg & pluginsAdminDlg); - bool getDoSaveOrNotStrings(generic_string& title, generic_string& msg); + bool getDoSaveOrNotStrings(std::wstring& title, std::wstring& msg); bool isRTL() const { return _isRTL; @@ -80,20 +80,20 @@ class NativeLangSpeaker { int getLangEncoding() const { return _nativeLangEncoding; }; - bool getMsgBoxLang(const char *msgBoxTagName, generic_string & title, generic_string & message); - generic_string getShortcutMapperLangStr(const char *nodeName, const TCHAR *defaultStr) const; - generic_string getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const; - generic_string getDlgLangMenuStr(const char* firstLevelNodeName, const char* secondLevelNodeName, int cmdID, const TCHAR *defaultStr) const; - generic_string getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name, const char *nodeL3Name = "name") const; - generic_string getAttrNameByIdStr(const TCHAR *defaultStr, TiXmlNodeA *targetNode, const char *nodeL1Value, const char *nodeL1Name = "id", const char *nodeL2Name = "name") const; - generic_string getLocalizedStrFromID(const char *strID, const generic_string& defaultString) const; + bool getMsgBoxLang(const char *msgBoxTagName, std::wstring & title, std::wstring & message); + std::wstring getShortcutMapperLangStr(const char *nodeName, const wchar_t *defaultStr) const; + std::wstring getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const wchar_t *defaultStr) const; + std::wstring getDlgLangMenuStr(const char* firstLevelNodeName, const char* secondLevelNodeName, int cmdID, const wchar_t *defaultStr) const; + std::wstring getAttrNameStr(const wchar_t *defaultStr, const char *nodeL1Name, const char *nodeL2Name, const char *nodeL3Name = "name") const; + std::wstring getAttrNameByIdStr(const wchar_t *defaultStr, TiXmlNodeA *targetNode, const char *nodeL1Value, const char *nodeL1Name = "id", const char *nodeL2Name = "name") const; + std::wstring getLocalizedStrFromID(const char *strID, const std::wstring& defaultString) const; void getMainMenuEntryName(std::wstring& dest, HMENU hMenu, const char* menuIdStr, const wchar_t* defaultDest); void resetShortcutMenuNameMap() { _shortcutMenuEntryNameMap.clear(); }; - int messageBox(const char *msgBoxTagName, HWND hWnd, const TCHAR *message, const TCHAR *title, int msgBoxType, int intInfo = 0, const TCHAR *strInfo = NULL); + int messageBox(const char *msgBoxTagName, HWND hWnd, const wchar_t *message, const wchar_t *title, int msgBoxType, int intInfo = 0, const wchar_t *strInfo = NULL); private: TiXmlNodeA *_nativeLangA = nullptr; int _nativeLangEncoding = CP_ACP; diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index c43b0150adf0..acd83406253a 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -42,7 +42,7 @@ void allowPrivilegeMessages(const Notepad_plus_Window& notepad_plus_plus, winVer // This (WM_COPYDATA) allows opening new files to already opened elevated Notepad++ process via explorer context menu. if (winVer >= WV_VISTA || winVer == WV_UNKNOWN) { - HMODULE hDll = GetModuleHandle(TEXT("user32.dll")); + HMODULE hDll = GetModuleHandle(L"user32.dll"); if (hDll) { // According to MSDN ChangeWindowMessageFilter may not be supported in future versions of Windows, @@ -83,15 +83,15 @@ void allowPrivilegeMessages(const Notepad_plus_Window& notepad_plus_plus, winVer // 2. "-z" // 3. "C:\WINDOWS\system32\NOTEPAD.EXE" // 4. "C:\my folder\my file with whitespace.txt" -void parseCommandLine(const TCHAR* commandLine, ParamVector& paramVector) +void parseCommandLine(const wchar_t* commandLine, ParamVector& paramVector) { if (!commandLine) return; - TCHAR* cmdLine = new TCHAR[lstrlen(commandLine) + 1]; + wchar_t* cmdLine = new wchar_t[lstrlen(commandLine) + 1]; lstrcpy(cmdLine, commandLine); - TCHAR* cmdLinePtr = cmdLine; + wchar_t* cmdLinePtr = cmdLine; bool isBetweenFileNameQuotes = false; bool isStringInArg = false; @@ -105,7 +105,7 @@ void parseCommandLine(const TCHAR* commandLine, ParamVector& paramVector) // when zArg == 2 shouldBeTerminated will be set to true - it will trigger the treatment which consider the rest as a argument, with or without white space(s). size_t commandLength = lstrlen(cmdLinePtr); - std::vector args; + std::vector args; for (size_t i = 0; i < commandLength && !shouldBeTerminated; ++i) { switch (cmdLinePtr[i]) @@ -156,7 +156,7 @@ void parseCommandLine(const TCHAR* commandLine, ParamVector& paramVector) } break; - default: //default TCHAR, if beginning of word, add it + default: //default wchar_t, if beginning of word, add it { if (!isBetweenFileNameQuotes && !isStringInArg && isInWhiteSpace) { @@ -181,14 +181,14 @@ void convertParamsToNotepadStyle(ParamVector& params) { for (auto it = params.begin(); it != params.end(); ++it) { - if (lstrcmp(it->c_str(), TEXT("/p")) == 0 || lstrcmp(it->c_str(), TEXT("/P")) == 0) + if (lstrcmp(it->c_str(), L"/p") == 0 || lstrcmp(it->c_str(), L"/P") == 0) { - it->assign(TEXT("-quickPrint")); + it->assign(L"-quickPrint"); } } } -bool isInList(const TCHAR *token2Find, ParamVector& params, bool eraseArg = true) +bool isInList(const wchar_t *token2Find, ParamVector& params, bool eraseArg = true) { for (auto it = params.begin(); it != params.end(); ++it) { @@ -201,14 +201,14 @@ bool isInList(const TCHAR *token2Find, ParamVector& params, bool eraseArg = true return false; } -bool getParamVal(TCHAR c, ParamVector & params, std::wstring & value) +bool getParamVal(wchar_t c, ParamVector & params, std::wstring & value) { - value = TEXT(""); + value = L""; size_t nbItems = params.size(); for (size_t i = 0; i < nbItems; ++i) { - const TCHAR * token = params.at(i).c_str(); + const wchar_t * token = params.at(i).c_str(); if (token[0] == '-' && lstrlen(token) >= 2 && token[1] == c) //dash, and enough chars { value = (token+2); @@ -219,14 +219,14 @@ bool getParamVal(TCHAR c, ParamVector & params, std::wstring & value) return false; } -bool getParamValFromString(const TCHAR *str, ParamVector & params, std::wstring & value) +bool getParamValFromString(const wchar_t *str, ParamVector & params, std::wstring & value) { - value = TEXT(""); + value = L""; size_t nbItems = params.size(); for (size_t i = 0; i < nbItems; ++i) { - const TCHAR * token = params.at(i).c_str(); + const wchar_t * token = params.at(i).c_str(); std::wstring tokenStr = token; size_t pos = tokenStr.find(str); if (pos != std::wstring::npos && pos == 0) @@ -251,8 +251,8 @@ std::wstring getLocalizationPathFromParam(ParamVector & params) { std::wstring locStr; if (!getParamVal('L', params, locStr)) - return TEXT(""); - locStr = stringToLower(stringReplace(locStr, TEXT("_"), TEXT("-"))); // convert to lowercase format with "-" as separator + return L""; + locStr = stringToLower(stringReplace(locStr, L"_", L"-")); // convert to lowercase format with "-" as separator return NppParameters::getLocPathFromStr(locStr.c_str()); } @@ -271,12 +271,12 @@ intptr_t getNumberFromParam(char paramName, ParamVector & params, bool & isParam std::wstring getEasterEggNameFromParam(ParamVector & params, unsigned char & type) { std::wstring EasterEggName; - if (!getParamValFromString(TEXT("-qn="), params, EasterEggName)) // get internal easter egg + if (!getParamValFromString(L"-qn=", params, EasterEggName)) // get internal easter egg { - if (!getParamValFromString(TEXT("-qt="), params, EasterEggName)) // get user quote from cmdline argument + if (!getParamValFromString(L"-qt=", params, EasterEggName)) // get user quote from cmdline argument { - if (!getParamValFromString(TEXT("-qf="), params, EasterEggName)) // get user quote from a content of file - return TEXT(""); + if (!getParamValFromString(L"-qf=", params, EasterEggName)) // get user quote from a content of file + return L""; else { type = 2; // quote content in file @@ -302,7 +302,7 @@ std::wstring getEasterEggNameFromParam(ParamVector & params, unsigned char & typ int getGhostTypingSpeedFromParam(ParamVector & params) { std::wstring speedStr; - if (!getParamValFromString(TEXT("-qSpeed"), params, speedStr)) + if (!getParamValFromString(L"-qSpeed", params, speedStr)) return -1; int speed = std::stoi(speedStr, 0); @@ -312,46 +312,46 @@ int getGhostTypingSpeedFromParam(ParamVector & params) return speed; } -const TCHAR FLAG_MULTI_INSTANCE[] = TEXT("-multiInst"); -const TCHAR FLAG_NO_PLUGIN[] = TEXT("-noPlugin"); -const TCHAR FLAG_READONLY[] = TEXT("-ro"); -const TCHAR FLAG_NOSESSION[] = TEXT("-nosession"); -const TCHAR FLAG_NOTABBAR[] = TEXT("-notabbar"); -const TCHAR FLAG_SYSTRAY[] = TEXT("-systemtray"); -const TCHAR FLAG_LOADINGTIME[] = TEXT("-loadingTime"); -const TCHAR FLAG_HELP[] = TEXT("--help"); -const TCHAR FLAG_ALWAYS_ON_TOP[] = TEXT("-alwaysOnTop"); -const TCHAR FLAG_OPENSESSIONFILE[] = TEXT("-openSession"); -const TCHAR FLAG_RECURSIVE[] = TEXT("-r"); -const TCHAR FLAG_FUNCLSTEXPORT[] = TEXT("-export=functionList"); -const TCHAR FLAG_PRINTANDQUIT[] = TEXT("-quickPrint"); -const TCHAR FLAG_NOTEPAD_COMPATIBILITY[] = TEXT("-notepadStyleCmdline"); -const TCHAR FLAG_OPEN_FOLDERS_AS_WORKSPACE[] = TEXT("-openFoldersAsWorkspace"); -const TCHAR FLAG_SETTINGS_DIR[] = TEXT("-settingsDir="); -const TCHAR FLAG_TITLEBAR_ADD[] = TEXT("-titleAdd="); -const TCHAR FLAG_APPLY_UDL[] = TEXT("-udl="); -const TCHAR FLAG_PLUGIN_MESSAGE[] = TEXT("-pluginMessage="); -const TCHAR FLAG_MONITOR_FILES[] = TEXT("-monitor"); +const wchar_t FLAG_MULTI_INSTANCE[] = L"-multiInst"; +const wchar_t FLAG_NO_PLUGIN[] = L"-noPlugin"; +const wchar_t FLAG_READONLY[] = L"-ro"; +const wchar_t FLAG_NOSESSION[] = L"-nosession"; +const wchar_t FLAG_NOTABBAR[] = L"-notabbar"; +const wchar_t FLAG_SYSTRAY[] = L"-systemtray"; +const wchar_t FLAG_LOADINGTIME[] = L"-loadingTime"; +const wchar_t FLAG_HELP[] = L"--help"; +const wchar_t FLAG_ALWAYS_ON_TOP[] = L"-alwaysOnTop"; +const wchar_t FLAG_OPENSESSIONFILE[] = L"-openSession"; +const wchar_t FLAG_RECURSIVE[] = L"-r"; +const wchar_t FLAG_FUNCLSTEXPORT[] = L"-export=functionList"; +const wchar_t FLAG_PRINTANDQUIT[] = L"-quickPrint"; +const wchar_t FLAG_NOTEPAD_COMPATIBILITY[] = L"-notepadStyleCmdline"; +const wchar_t FLAG_OPEN_FOLDERS_AS_WORKSPACE[] = L"-openFoldersAsWorkspace"; +const wchar_t FLAG_SETTINGS_DIR[] = L"-settingsDir="; +const wchar_t FLAG_TITLEBAR_ADD[] = L"-titleAdd="; +const wchar_t FLAG_APPLY_UDL[] = L"-udl="; +const wchar_t FLAG_PLUGIN_MESSAGE[] = L"-pluginMessage="; +const wchar_t FLAG_MONITOR_FILES[] = L"-monitor"; void doException(Notepad_plus_Window & notepad_plus_plus) { Win32Exception::removeHandler(); //disable exception handler after excpetion, we dont want corrupt data structurs to crash the exception handler - ::MessageBox(Notepad_plus_Window::gNppHWND, TEXT("Notepad++ will attempt to save any unsaved data. However, dataloss is very likely."), TEXT("Recovery initiating"), MB_OK | MB_ICONINFORMATION); + ::MessageBox(Notepad_plus_Window::gNppHWND, L"Notepad++ will attempt to save any unsaved data. However, dataloss is very likely.", L"Recovery initiating", MB_OK | MB_ICONINFORMATION); - TCHAR tmpDir[1024]; + wchar_t tmpDir[1024]; GetTempPath(1024, tmpDir); std::wstring emergencySavedDir = tmpDir; - emergencySavedDir += TEXT("\\Notepad++ RECOV"); + emergencySavedDir += L"\\Notepad++ RECOV"; bool res = notepad_plus_plus.emergency(emergencySavedDir); if (res) { - std::wstring displayText = TEXT("Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at :\r\n"); + std::wstring displayText = L"Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at :\r\n"; displayText += emergencySavedDir; - ::MessageBox(Notepad_plus_Window::gNppHWND, displayText.c_str(), TEXT("Recovery success"), MB_OK | MB_ICONINFORMATION); + ::MessageBox(Notepad_plus_Window::gNppHWND, displayText.c_str(), L"Recovery success", MB_OK | MB_ICONINFORMATION); } else - ::MessageBox(Notepad_plus_Window::gNppHWND, TEXT("Unfortunatly, Notepad++ was not able to save your work. We are sorry for any lost data."), TEXT("Recovery failure"), MB_OK | MB_ICONERROR); + ::MessageBox(Notepad_plus_Window::gNppHWND, L"Unfortunatly, Notepad++ was not able to save your work. We are sorry for any lost data.", L"Recovery failure", MB_OK | MB_ICONERROR); } // Looks for -z arguments and strips command line arguments following those, if any @@ -359,7 +359,7 @@ void stripIgnoredParams(ParamVector & params) { for (auto it = params.begin(); it != params.end(); ) { - if (lstrcmp(it->c_str(), TEXT("-z")) == 0) + if (lstrcmp(it->c_str(), L"-z") == 0) { auto nextIt = std::next(it); if ( nextIt != params.end() ) @@ -387,11 +387,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance bool TheFirstOne = true; ::SetLastError(NO_ERROR); - ::CreateMutex(NULL, false, TEXT("nppInstance")); + ::CreateMutex(NULL, false, L"nppInstance"); if (::GetLastError() == ERROR_ALREADY_EXISTS) TheFirstOne = false; - std::wstring cmdLineString = pCmdLine ? pCmdLine : _T(""); + std::wstring cmdLineString = pCmdLine ? pCmdLine : L""; ParamVector params; parseCommandLine(pCmdLine, params); @@ -490,9 +490,9 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance } if (showHelp) - ::MessageBox(NULL, COMMAND_ARG_HELP, TEXT("Notepad++ Command Argument Help"), MB_OK); + ::MessageBox(NULL, COMMAND_ARG_HELP, L"Notepad++ Command Argument Help", MB_OK); - if (cmdLineParams._localizationPath != TEXT("")) + if (cmdLineParams._localizationPath != L"") { // setStartWithLocFileName() should be called before parameters are loaded nppParameters.setStartWithLocFileName(cmdLineParams._localizationPath); @@ -536,20 +536,20 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance cmdLineParams._isNoSession = true; } - std::wstring quotFileName = TEXT(""); + std::wstring quotFileName = L""; // tell the running instance the FULL path to the new files to load size_t nbFilesToOpen = params.size(); for (size_t i = 0; i < nbFilesToOpen; ++i) { - const TCHAR * currentFile = params.at(i).c_str(); + const wchar_t * currentFile = params.at(i).c_str(); if (currentFile[0]) { //check if relative or full path. Relative paths dont have a colon for driveletter - quotFileName += TEXT("\""); + quotFileName += L"\""; quotFileName += relativeFilePathToFullFilePath(currentFile); - quotFileName += TEXT("\" "); + quotFileName += L"\" "; } } @@ -600,13 +600,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance COPYDATASTRUCT cmdLineData{}; cmdLineData.dwData = COPYDATA_FULL_CMDLINE; cmdLineData.lpData = (void*)cmdLineString.c_str(); - cmdLineData.cbData = static_cast((cmdLineString.length() + 1) * sizeof(TCHAR)); + cmdLineData.cbData = static_cast((cmdLineString.length() + 1) * sizeof(wchar_t)); ::SendMessage(hNotepad_plus, WM_COPYDATA, reinterpret_cast(hInstance), reinterpret_cast(&cmdLineData)); COPYDATASTRUCT fileNamesData{}; fileNamesData.dwData = COPYDATA_FILENAMESW; fileNamesData.lpData = (void *)quotFileName.c_str(); - fileNamesData.cbData = static_cast((quotFileName.length() + 1) * sizeof(TCHAR)); + fileNamesData.cbData = static_cast((quotFileName.length() + 1) * sizeof(wchar_t)); ::SendMessage(hNotepad_plus, WM_COPYDATA, reinterpret_cast(hInstance), reinterpret_cast(&fileNamesData)); } return 0; @@ -617,11 +617,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance Notepad_plus_Window & notepad_plus_plus = *upNotepadWindow.get(); std::wstring updaterDir = nppParameters.getNppPath(); - updaterDir += TEXT("\\updater\\"); + updaterDir += L"\\updater\\"; - std::wstring updaterFullPath = updaterDir + TEXT("gup.exe"); + std::wstring updaterFullPath = updaterDir + L"gup.exe"; - std::wstring updaterParams = TEXT("-v"); + std::wstring updaterParams = L"-v"; updaterParams += VERSION_INTERNAL_VALUE; bool isUpExist = nppGui._doesExistUpdater = (::PathFileExists(updaterFullPath.c_str()) == TRUE); @@ -650,11 +650,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance { if (nppParameters.archType() == IMAGE_FILE_MACHINE_AMD64) { - updaterParams += TEXT(" -px64"); + updaterParams += L" -px64"; } else if (nppParameters.archType() == IMAGE_FILE_MACHINE_ARM64) { - updaterParams += TEXT(" -parm64"); + updaterParams += L" -parm64"; } if (doUpdateNpp) @@ -674,22 +674,22 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance if (doUpdatePluginList) { // Update Plugin List - std::wstring upPlParams = TEXT("-v"); + std::wstring upPlParams = L"-v"; upPlParams += notepad_plus_plus.getPluginListVerStr(); if (nppParameters.archType() == IMAGE_FILE_MACHINE_AMD64) { - upPlParams += TEXT(" -px64"); + upPlParams += L" -px64"; } else if (nppParameters.archType() == IMAGE_FILE_MACHINE_ARM64) { - upPlParams += TEXT(" -parm64"); + upPlParams += L" -parm64"; } - upPlParams += TEXT(" -upZip"); + upPlParams += L" -upZip"; // overrided "InfoUrl" in gup.xml - upPlParams += TEXT(" https://notepad-plus-plus.org/update/pluginListDownloadUrl.php"); + upPlParams += L" https://notepad-plus-plus.org/update/pluginListDownloadUrl.php"; // indicate the pluginList installation location upPlParams += nppParameters.getPluginConfDir(); @@ -731,10 +731,10 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance catch (int i) { wchar_t str[50] = L"God Damned Exception:"; - TCHAR code[10]; - wsprintf(code, TEXT("%d"), i); + wchar_t code[10]; + wsprintf(code, L"%d", i); wcscat_s(str, code); - ::MessageBox(Notepad_plus_Window::gNppHWND, str, TEXT("Int Exception"), MB_OK); + ::MessageBox(Notepad_plus_Window::gNppHWND, str, L"Int Exception", MB_OK); doException(notepad_plus_plus); } catch (std::runtime_error & ex) @@ -744,10 +744,10 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance } catch (const Win32Exception & ex) { - TCHAR message[1024]; //TODO: sane number - wsprintf(message, TEXT("An exception occured. Notepad++ cannot recover and must be shut down.\r\nThe exception details are as follows:\r\n") - TEXT("Code:\t0x%08X\r\nType:\t%S\r\nException address: 0x%p"), ex.code(), ex.what(), ex.where()); - ::MessageBox(Notepad_plus_Window::gNppHWND, message, TEXT("Win32Exception"), MB_OK | MB_ICONERROR); + wchar_t message[1024]; //TODO: sane number + wsprintf(message, L"An exception occured. Notepad++ cannot recover and must be shut down.\r\nThe exception details are as follows:\r\n" + L"Code:\t0x%08X\r\nType:\t%S\r\nException address: 0x%p", ex.code(), ex.what(), ex.where()); + ::MessageBox(Notepad_plus_Window::gNppHWND, message, L"Win32Exception", MB_OK | MB_ICONERROR); mdump.writeDump(ex.info()); doException(notepad_plus_plus); }