From f7d9e7c095e7da50633414b148703afd785c27f8 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 30 Jun 2024 20:51:29 +0200 Subject: [PATCH] Remove ambiguous symbols (part 6) Relace TCHAR, generic_string & TEXT("") par wchar_t, wstring & L"" respectively. Follow up: 94af271 Close #15380 --- PowerEditor/src/MISC/Common/Sorters.h | 80 +++--- PowerEditor/src/ScintillaComponent/Buffer.cpp | 131 ++++----- PowerEditor/src/ScintillaComponent/Buffer.h | 50 ++-- .../ScintillaComponent/UserDefineDialog.cpp | 156 +++++------ .../src/ScintillaComponent/UserDefineDialog.h | 184 ++++++------- PowerEditor/src/TinyXml/tinyxml.cpp | 128 ++++----- PowerEditor/src/TinyXml/tinyxml.h | 230 ++++++++-------- .../WinControls/FileBrowser/fileBrowser.cpp | 250 +++++++++--------- .../src/WinControls/FileBrowser/fileBrowser.h | 102 +++---- 9 files changed, 656 insertions(+), 655 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Sorters.h b/PowerEditor/src/MISC/Common/Sorters.h index be823aad0..f8f0368b7 100644 --- a/PowerEditor/src/MISC/Common/Sorters.h +++ b/PowerEditor/src/MISC/Common/Sorters.h @@ -33,13 +33,13 @@ protected: return _isDescending; }; - generic_string getSortKey(const generic_string& input) { + std::wstring getSortKey(const std::wstring& input) { if (isSortingSpecificColumns()) { if (input.length() < _fromColumn) { // prevent an std::out_of_range exception - return TEXT(""); + return L""; } else if (_fromColumn == _toColumn) { @@ -67,7 +67,7 @@ public: assert(_fromColumn <= _toColumn); }; virtual ~ISorter() { }; - virtual void sort(std::vector& lines) = 0; + virtual void sort(std::vector& lines) = 0; }; // Implementation of lexicographic sorting of lines. @@ -76,13 +76,13 @@ class LexicographicSorter : public ISorter public: LexicographicSorter(bool isDescending, size_t fromColumn, size_t toColumn) : ISorter(isDescending, fromColumn, toColumn) { }; - void sort(std::vector& lines) override { + void sort(std::vector& lines) override { // Note that both branches here are equivalent in the sense that they always give the same answer. // However, if we are *not* sorting specific columns, then we get a 40% speed improvement by not calling // getSortKey() so many times. if (isSortingSpecificColumns()) { - std::stable_sort(lines.begin(), lines.end(), [this](generic_string a, generic_string b) + std::stable_sort(lines.begin(), lines.end(), [this](std::wstring a, std::wstring b) { if (isDescending()) { @@ -97,7 +97,7 @@ public: } else { - std::sort(lines.begin(), lines.end(), [this](generic_string a, generic_string b) + std::sort(lines.begin(), lines.end(), [this](std::wstring a, std::wstring b) { if (isDescending()) { @@ -118,13 +118,13 @@ class LexicographicCaseInsensitiveSorter : public ISorter public: LexicographicCaseInsensitiveSorter(bool isDescending, size_t fromColumn, size_t toColumn) : ISorter(isDescending, fromColumn, toColumn) { }; - void sort(std::vector& lines) override { + void sort(std::vector& lines) override { // Note that both branches here are equivalent in the sense that they always give the same answer. // However, if we are *not* sorting specific columns, then we get a 40% speed improvement by not calling // getSortKey() so many times. if (isSortingSpecificColumns()) { - std::stable_sort(lines.begin(), lines.end(), [this](generic_string a, generic_string b) + std::stable_sort(lines.begin(), lines.end(), [this](std::wstring a, std::wstring b) { if (isDescending()) { @@ -138,7 +138,7 @@ public: } else { - std::sort(lines.begin(), lines.end(), [this](generic_string a, generic_string b) + std::sort(lines.begin(), lines.end(), [this](std::wstring a, std::wstring b) { if (isDescending()) { @@ -158,13 +158,13 @@ class IntegerSorter : public ISorter public: IntegerSorter(bool isDescending, size_t fromColumn, size_t toColumn) : ISorter(isDescending, fromColumn, toColumn) { }; - void sort(std::vector& lines) override { + void sort(std::vector& lines) override { if (isSortingSpecificColumns()) { - std::stable_sort(lines.begin(), lines.end(), [this](generic_string aIn, generic_string bIn) + std::stable_sort(lines.begin(), lines.end(), [this](std::wstring aIn, std::wstring bIn) { - generic_string a = getSortKey(aIn); - generic_string b = getSortKey(bIn); + std::wstring a = getSortKey(aIn); + std::wstring b = getSortKey(bIn); long long compareResult = 0; size_t aNumIndex = 0; @@ -173,7 +173,7 @@ public: { if (aNumIndex >= a.length() || bNumIndex >= b.length()) { - compareResult = a.compare(std::min(aNumIndex, a.length()), generic_string::npos, b, std::min(bNumIndex, b.length()), generic_string::npos); + compareResult = a.compare(std::min(aNumIndex, a.length()), std::wstring::npos, b, std::min(bNumIndex, b.length()), std::wstring::npos); break; } @@ -232,13 +232,13 @@ public: } size_t aNumEnd = a.find_first_not_of(L"1234567890", aNumIndex); - if (aNumEnd == generic_string::npos) + if (aNumEnd == std::wstring::npos) { aNumEnd = a.length(); } size_t bNumEnd = b.find_first_not_of(L"1234567890", bNumIndex); - if (bNumEnd == generic_string::npos) + if (bNumEnd == std::wstring::npos) { bNumEnd = b.length(); } @@ -328,10 +328,10 @@ public: } else { - std::sort(lines.begin(), lines.end(), [this](generic_string aIn, generic_string bIn) + std::sort(lines.begin(), lines.end(), [this](std::wstring aIn, std::wstring bIn) { - generic_string a = aIn; - generic_string b = bIn; + std::wstring a = aIn; + std::wstring b = bIn; long long compareResult = 0; size_t aNumIndex = 0; @@ -340,7 +340,7 @@ public: { if (aNumIndex >= a.length() || bNumIndex >= b.length()) { - compareResult = a.compare(std::min(aNumIndex, a.length()), generic_string::npos, b, std::min(bNumIndex, b.length()), generic_string::npos); + compareResult = a.compare(std::min(aNumIndex, a.length()), std::wstring::npos, b, std::min(bNumIndex, b.length()), std::wstring::npos); break; } @@ -400,13 +400,13 @@ public: } size_t aNumEnd = a.find_first_not_of(L"1234567890", aNumIndex); - if (aNumEnd == generic_string::npos) + if (aNumEnd == std::wstring::npos) { aNumEnd = a.length(); } size_t bNumEnd = b.find_first_not_of(L"1234567890", bNumIndex); - if (bNumEnd == generic_string::npos) + if (bNumEnd == std::wstring::npos) { bNumEnd = b.length(); } @@ -519,15 +519,15 @@ public: #endif } - void sort(std::vector& lines) override { + void sort(std::vector& lines) override { // Note that empty lines are filtered out and added back manually to the output at the end. std::vector> nonEmptyInputAsNumbers; - std::vector empties; + std::vector empties; nonEmptyInputAsNumbers.reserve(lines.size()); for (size_t lineIndex = 0; lineIndex < lines.size(); ++lineIndex) { - const generic_string originalLine = lines[lineIndex]; - const generic_string preparedLine = prepareStringForConversion(originalLine); + const std::wstring originalLine = lines[lineIndex]; + const std::wstring preparedLine = prepareStringForConversion(originalLine); if (considerStringEmpty(preparedLine)) { empties.push_back(originalLine); @@ -559,7 +559,7 @@ public: } }); - std::vector output; + std::vector output; output.reserve(lines.size()); if (!isDescending()) { @@ -581,17 +581,17 @@ public: }; protected: - bool considerStringEmpty(const generic_string& input) { + bool considerStringEmpty(const std::wstring& input) { // String has something else than just whitespace. - return input.find_first_not_of(TEXT(" \t\r\n")) == std::string::npos; + return input.find_first_not_of(L" \t\r\n") == std::string::npos; } // Prepare the string for conversion to number. - virtual generic_string prepareStringForConversion(const generic_string& input) = 0; + virtual std::wstring prepareStringForConversion(const std::wstring& input) = 0; // Should convert the input string to a number of the correct type. // If unable to convert, throw either std::invalid_argument or std::out_of_range. - virtual T_Num convertStringToNumber(const generic_string& input) = 0; + virtual T_Num convertStringToNumber(const std::wstring& input) = 0; // We need a fixed locale so we get the same string-to-double behavior across all computers. // This is the "enUS" locale. @@ -605,12 +605,12 @@ public: DecimalCommaSorter(bool isDescending, size_t fromColumn, size_t toColumn) : NumericSorter(isDescending, fromColumn, toColumn) { }; protected: - generic_string prepareStringForConversion(const generic_string& input) override { - generic_string admissablePart = stringTakeWhileAdmissable(getSortKey(input), TEXT(" \t\r\n0123456789,-")); - return stringReplace(admissablePart, TEXT(","), TEXT(".")); + std::wstring prepareStringForConversion(const std::wstring& input) override { + std::wstring admissablePart = stringTakeWhileAdmissable(getSortKey(input), L" \t\r\n0123456789,-"); + return stringReplace(admissablePart, L",", L"."); }; - double convertStringToNumber(const generic_string& input) override { + double convertStringToNumber(const std::wstring& input) override { return stodLocale(input, _usLocale); }; }; @@ -622,11 +622,11 @@ public: DecimalDotSorter(bool isDescending, size_t fromColumn, size_t toColumn) : NumericSorter(isDescending, fromColumn, toColumn) { }; protected: - generic_string prepareStringForConversion(const generic_string& input) override { - return stringTakeWhileAdmissable(getSortKey(input), TEXT(" \t\r\n0123456789.-")); + std::wstring prepareStringForConversion(const std::wstring& input) override { + return stringTakeWhileAdmissable(getSortKey(input), L" \t\r\n0123456789.-"); }; - double convertStringToNumber(const generic_string& input) override { + double convertStringToNumber(const std::wstring& input) override { return stodLocale(input, _usLocale); }; }; @@ -636,7 +636,7 @@ class ReverseSorter : public ISorter public: ReverseSorter(bool isDescending, size_t fromColumn, size_t toColumn) : ISorter(isDescending, fromColumn, toColumn) { }; - void sort(std::vector& lines) override { + void sort(std::vector& lines) override { std::reverse(lines.begin(), lines.end()); }; }; @@ -650,7 +650,7 @@ public: seed = static_cast(time(NULL)); }; - void sort(std::vector& lines) override { + void sort(std::vector& lines) override { std::shuffle(lines.begin(), lines.end(), std::default_random_engine(seed)); }; }; diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 133852f29..78c81eed7 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -64,8 +64,9 @@ namespace // anonymous } // anonymous namespace +using namespace std; -Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName, bool isLargeFile) +Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const wchar_t *fileName, bool isLargeFile) // type must be either DOC_REGULAR or DOC_UNNAMED : _pManager(pManager) , _id(id), _doc(doc), _lang(L_TEXT), _isLargeFile(isLargeFile) { @@ -123,7 +124,7 @@ void Buffer::setUnicodeMode(UniMode mode) } -void Buffer::setLangType(LangType lang, const TCHAR* userLangName) +void Buffer::setLangType(LangType lang, const wchar_t* userLangName) { if (lang == _lang && lang != L_USER) return; @@ -159,9 +160,9 @@ void Buffer::updateTimeStamp() NppParameters& nppParam = NppParameters::getInstance(); if (nppParam.doNppLogNetworkDriveIssue()) { - generic_string issueFn = nppLogNetworkDriveIssue; - issueFn += TEXT(".log"); - generic_string nppIssueLog = nppParam.getUserPath(); + wstring issueFn = nppLogNetworkDriveIssue; + issueFn += L".log"; + wstring nppIssueLog = nppParam.getUserPath(); pathAppend(nppIssueLog, issueFn); std::wstring_convert> converter; @@ -181,7 +182,7 @@ void Buffer::updateTimeStamp() // Set full path file name in buffer object, // and determinate its language by its extension. -void Buffer::setFileName(const TCHAR *fn) +void Buffer::setFileName(const wchar_t *fn) { NppParameters& nppParamInst = NppParameters::getInstance(); if (_fullPathName == fn) @@ -196,13 +197,13 @@ void Buffer::setFileName(const TCHAR *fn) // for _lang LangType determinatedLang = L_TEXT; - TCHAR *ext = PathFindExtension(_fullPathName.c_str()); + wchar_t *ext = PathFindExtension(_fullPathName.c_str()); if (*ext == '.') // extension found { ext += 1; // Define User Lang firstly - const TCHAR* langName = nppParamInst.getUserDefinedLangNameFromExt(ext, _fileName); + const wchar_t* langName = nppParamInst.getUserDefinedLangNameFromExt(ext, _fileName); if (langName) { determinatedLang = L_USER; @@ -217,15 +218,15 @@ void Buffer::setFileName(const TCHAR *fn) if (determinatedLang == L_TEXT) // language can probably be refined { - if ((wcsicmp(_fileName, TEXT("makefile")) == 0) || (wcsicmp(_fileName, TEXT("GNUmakefile")) == 0)) + if ((wcsicmp(_fileName, L"makefile") == 0) || (wcsicmp(_fileName, L"GNUmakefile") == 0)) determinatedLang = L_MAKEFILE; - else if (wcsicmp(_fileName, TEXT("CmakeLists.txt")) == 0) + else if (wcsicmp(_fileName, L"CmakeLists.txt") == 0) determinatedLang = L_CMAKE; - else if ((wcsicmp(_fileName, TEXT("SConstruct")) == 0) || (wcsicmp(_fileName, TEXT("SConscript")) == 0) || (wcsicmp(_fileName, TEXT("wscript")) == 0)) + else if ((wcsicmp(_fileName, L"SConstruct") == 0) || (wcsicmp(_fileName, L"SConscript") == 0) || (wcsicmp(_fileName, L"wscript") == 0)) determinatedLang = L_PYTHON; - else if ((wcsicmp(_fileName, TEXT("Rakefile")) == 0) || (wcsicmp(_fileName, TEXT("Vagrantfile")) == 0)) + else if ((wcsicmp(_fileName, L"Rakefile") == 0) || (wcsicmp(_fileName, L"Vagrantfile") == 0)) determinatedLang = L_RUBY; - else if ((wcsicmp(_fileName, TEXT("crontab")) == 0) || (wcsicmp(_fileName, TEXT("PKGBUILD")) == 0) || (wcsicmp(_fileName, TEXT("APKBUILD")) == 0)) + else if ((wcsicmp(_fileName, L"crontab") == 0) || (wcsicmp(_fileName, L"PKGBUILD") == 0) || (wcsicmp(_fileName, L"APKBUILD") == 0)) determinatedLang = L_BASH; } @@ -328,9 +329,9 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it NppParameters& nppParam = NppParameters::getInstance(); if (nppParam.doNppLogNetworkDriveIssue()) { - generic_string issueFn = nppLogNetworkDriveIssue; - issueFn += TEXT(".log"); - generic_string nppIssueLog = nppParam.getUserPath(); + wstring issueFn = nppLogNetworkDriveIssue; + issueFn += L".log"; + wstring nppIssueLog = nppParam.getUserPath(); pathAppend(nppIssueLog, issueFn); std::wstring_convert> converter; @@ -398,9 +399,9 @@ int64_t Buffer::getFileLength() const } -generic_string Buffer::getFileTime(fileTimeType ftt) const +wstring Buffer::getFileTime(fileTimeType ftt) const { - generic_string result; + wstring result; if (_currentStatus != DOC_UNNAMED) { @@ -426,12 +427,12 @@ generic_string Buffer::getFileTime(fileTimeType ftt) const SystemTimeToTzSpecificLocalTime(nullptr, &utcSystemTime, &localSystemTime); const size_t dateTimeStrLen = 256; - TCHAR bufDate[dateTimeStrLen] = {'\0'}; + wchar_t bufDate[dateTimeStrLen] = {'\0'}; GetDateFormat(LOCALE_USER_DEFAULT, 0, &localSystemTime, nullptr, bufDate, dateTimeStrLen); result += bufDate; result += ' '; - TCHAR bufTime[dateTimeStrLen] = {'\0'}; + wchar_t bufTime[dateTimeStrLen] = {'\0'}; GetTimeFormat(LOCALE_USER_DEFAULT, 0, &localSystemTime, nullptr, bufTime, dateTimeStrLen); result += bufTime; } @@ -683,14 +684,14 @@ void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier) // backupFileName is sentinel of backup mode: if it's not NULL, then we use it (load it). Otherwise we use filename -BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding, const TCHAR* backupFileName, FILETIME fileNameTimestamp) +BufferID FileManager::loadFile(const wchar_t* filename, Document doc, int encoding, const wchar_t* backupFileName, FILETIME fileNameTimestamp) { if (!filename) return BUFFER_INVALID; //Get file size int64_t fileSize = -1; - const TCHAR* pPath = filename; + const wchar_t* pPath = filename; if (!::PathFileExists(pPath)) { pPath = backupFileName; @@ -698,7 +699,7 @@ BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding if (pPath) { - FILE* fp = _wfopen(pPath, TEXT("rb")); + FILE* fp = _wfopen(pPath, L"rb"); if (fp) { _fseeki64(fp, 0, SEEK_END); @@ -827,7 +828,7 @@ bool FileManager::reloadBuffer(BufferID id) // Set _isLoadedDirty false before calling "_pscratchTilla->execute(SCI_CLEARALL);" in loadFileData() to avoid setDirty in SCN_SAVEPOINTREACHED / SCN_SAVEPOINTLEFT //Get file size - FILE* fp = _wfopen(buf->getFullPathName(), TEXT("rb")); + FILE* fp = _wfopen(buf->getFullPathName(), L"rb"); if (!fp) return false; _fseeki64(fp, 0, SEEK_END); @@ -893,7 +894,7 @@ bool FileManager::reloadBufferDeferred(BufferID id) bool FileManager::deleteFile(BufferID id) { Buffer* buf = getBufferByID(id); - generic_string fileNamePath = buf->getFullPathName(); + wstring fileNamePath = buf->getFullPathName(); // Make sure to form a string with double '\0' terminator. fileNamePath.append(1, '\0'); @@ -915,10 +916,10 @@ bool FileManager::deleteFile(BufferID id) } -bool FileManager::moveFile(BufferID id, const TCHAR * newFileName) +bool FileManager::moveFile(BufferID id, const wchar_t * newFileName) { Buffer* buf = getBufferByID(id); - const TCHAR *fileNamePath = buf->getFullPathName(); + const wchar_t *fileNamePath = buf->getFullPathName(); if (::MoveFileEx(fileNamePath, newFileName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH) == 0) return false; @@ -995,12 +996,12 @@ bool FileManager::backupCurrentBuffer() UnicodeConvertor.setEncoding(mode); int encoding = buffer->getEncoding(); - generic_string backupFilePath = buffer->getBackupFileName(); + wstring backupFilePath = buffer->getBackupFileName(); if (backupFilePath.empty()) { // Create file backupFilePath = NppParameters::getInstance().getUserPath(); - backupFilePath += TEXT("\\backup\\"); + backupFilePath += L"\\backup\\"; // if "backup" folder doesn't exist, create it. if (!PathFileExists(backupFilePath.c_str())) @@ -1011,7 +1012,7 @@ bool FileManager::backupCurrentBuffer() backupFilePath += buffer->getFileName(); const int temBufLen = 32; - TCHAR tmpbuf[temBufLen]; + wchar_t tmpbuf[temBufLen]; time_t ltime = time(0); struct tm* today = localtime(<ime); if (!today) @@ -1029,7 +1030,7 @@ bool FileManager::backupCurrentBuffer() hasModifForSession = true; } - TCHAR fullpath[MAX_PATH]{}; + wchar_t fullpath[MAX_PATH]{}; ::GetFullPathName(backupFilePath.c_str(), MAX_PATH, fullpath, NULL); if (wcschr(fullpath, '~')) { @@ -1096,21 +1097,21 @@ bool FileManager::backupCurrentBuffer() } else // buffer not dirty, sync: delete the backup file { - generic_string backupFilePath = buffer->getBackupFileName(); + wstring backupFilePath = buffer->getBackupFileName(); if (!backupFilePath.empty()) { // delete backup file - generic_string file2Delete = buffer->getBackupFileName(); - buffer->setBackupFileName(generic_string()); + wstring file2Delete = buffer->getBackupFileName(); + buffer->setBackupFileName(wstring()); result = (::DeleteFile(file2Delete.c_str()) != 0); // Session changes, save it hasModifForSession = true; } - //printStr(TEXT("backup deleted in backupCurrentBuffer")); + //printStr(L"backup deleted in backupCurrentBuffer")); result = true; // no backup file to delete } - //printStr(TEXT("backup sync")); + //printStr(L"backup sync")); if (result && hasModifForSession) { @@ -1124,11 +1125,11 @@ bool FileManager::deleteBufferBackup(BufferID id) { Buffer* buffer = getBufferByID(id); bool result = true; - generic_string backupFilePath = buffer->getBackupFileName(); + wstring backupFilePath = buffer->getBackupFileName(); if (!backupFilePath.empty()) { // delete backup file - buffer->setBackupFileName(generic_string()); + buffer->setBackupFileName(wstring()); result = (::DeleteFile(backupFilePath.c_str()) != 0); } @@ -1137,7 +1138,7 @@ bool FileManager::deleteBufferBackup(BufferID id) std::mutex save_mutex; -SavingStatus FileManager::saveBuffer(BufferID id, const TCHAR* filename, bool isCopy) +SavingStatus FileManager::saveBuffer(BufferID id, const wchar_t* filename, bool isCopy) { std::lock_guard lock(save_mutex); @@ -1285,11 +1286,11 @@ SavingStatus FileManager::saveBuffer(BufferID id, const TCHAR* filename, bool is _pscratchTilla->execute(SCI_SETSAVEPOINT); _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); - generic_string backupFilePath = buffer->getBackupFileName(); + wstring backupFilePath = buffer->getBackupFileName(); if (!backupFilePath.empty()) { // delete backup file - buffer->setBackupFileName(generic_string()); + buffer->setBackupFileName(wstring()); ::DeleteFile(backupFilePath.c_str()); } @@ -1312,8 +1313,8 @@ size_t FileManager::nextUntitledNewNumber() const // if untitled document is invisible, then don't put its number into array (so its number is available to be used) if ((buf->_referees[0])->isVisible()) { - generic_string newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); - TCHAR *numberStr = buf->_fileName + newTitle.length(); + wstring newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); + wchar_t *numberStr = buf->_fileName + newTitle.length(); int usedNumber = _wtoi(numberStr); usedNumbers.push_back(usedNumber); } @@ -1349,10 +1350,10 @@ size_t FileManager::nextUntitledNewNumber() const BufferID FileManager::newEmptyDocument() { - generic_string newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); + wstring newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); - TCHAR nb[10]; - wsprintf(nb, TEXT("%d"), static_cast(nextUntitledNewNumber())); + wchar_t nb[10]; + wsprintf(nb, L"%d"), static_cast(nextUntitledNewNumber()); newTitle += nb; Document doc = static_cast(_pscratchTilla->execute(SCI_CREATEDOCUMENT, 0, SC_DOCUMENTOPTION_TEXT_LARGE)); // this already sets a reference for filemanager @@ -1370,7 +1371,7 @@ BufferID FileManager::newEmptyDocument() return id; } -BufferID FileManager::newPlaceholderDocument(const TCHAR* missingFilename, int whichOne, const wchar_t* userCreatedSessionName) +BufferID FileManager::newPlaceholderDocument(const wchar_t* missingFilename, int whichOne, const wchar_t* userCreatedSessionName) { NppParameters& nppParamInst = NppParameters::getInstance(); @@ -1422,7 +1423,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool isMainEditZone) { newTitle = (nppParamInst.getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); wchar_t nb[10]; - wsprintf(nb, TEXT("%d"), static_cast(nextUntitledNewNumber())); + wsprintf(nb, L"%d", static_cast(nextUntitledNewNumber())); newTitle += nb; } @@ -1545,9 +1546,9 @@ LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data, return L_TEXT; } -bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * filename, char* data, Utf8_16_Read * unicodeConvertor, LoadedFileFormat& fileFormat) +bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * filename, char* data, Utf8_16_Read * unicodeConvertor, LoadedFileFormat& fileFormat) { - FILE *fp = _wfopen(filename, TEXT("rb")); + FILE *fp = _wfopen(filename, L"rb"); if (!fp) return false; @@ -1564,8 +1565,8 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil { pNativeSpeaker->messageBox("FileTooBigToOpen", _pNotepadPlus->_pEditView->getHSelf(), - TEXT("File is too big to be opened by Notepad++"), - TEXT("File size problem"), + L"File is too big to be opened by Notepad++", + L"File size problem", MB_OK | MB_APPLMODAL); fclose(fp); @@ -1578,8 +1579,8 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil { int res = pNativeSpeaker->messageBox("WantToOpenHugeFile", _pNotepadPlus->_pEditView->getHSelf(), - TEXT("Opening a huge file of 2GB+ could take several minutes.\nDo you want to open it?"), - TEXT("Opening huge file warning"), + L"Opening a huge file of 2GB+ could take several minutes.\nDo you want to open it?", + L"Opening huge file warning", MB_YESNO | MB_APPLMODAL); if (res == IDYES) @@ -1627,7 +1628,7 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil bool success = true; EolType format = EolType::unknown; int sciStatus = SC_STATUS_OK; - TCHAR szException[64] = { '\0' }; + wchar_t szException[64] = { '\0' }; __try { // First allocate enough memory for the whole file (this will reduce memory copy during loading) @@ -1725,31 +1726,31 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil #if defined(__GNUC__) // there is the std::current_exception() possibility, but getting the real exception code from there requires an ugly hack, // because of the std::exception_ptr has its members _Data1 (GetExceptionCode) and _Data2 (GetExceptionInformation) private - _stprintf_s(szException, _countof(szException), TEXT("unknown exception")); + _stprintf_s(szException, _countof(szException), L"unknown exception"); #else - _stprintf_s(szException, _countof(szException), TEXT("0x%X (SEH)"), ::GetExceptionCode()); + _stprintf_s(szException, _countof(szException), L"0x%X (SEH)", ::GetExceptionCode()); #endif break; case SC_STATUS_BADALLOC: { pNativeSpeaker->messageBox("FileMemoryAllocationFailed", _pNotepadPlus->_pEditView->getHSelf(), - TEXT("There is probably not enough contiguous free memory for the file being loaded by Notepad++."), - TEXT("Exception: File memory allocation failed"), + L"There is probably not enough contiguous free memory for the file being loaded by Notepad++.", + L"Exception: File memory allocation failed", MB_OK | MB_APPLMODAL); } [[fallthrough]]; case SC_STATUS_FAILURE: default: - _stprintf_s(szException, _countof(szException), TEXT("%d (Scintilla)"), sciStatus); + _stprintf_s(szException, _countof(szException), L"%d (Scintilla)", sciStatus); break; } if (sciStatus != SC_STATUS_BADALLOC) { pNativeSpeaker->messageBox("FileLoadingException", _pNotepadPlus->_pEditView->getHSelf(), - TEXT("An error occurred while loading the file!"), - TEXT("Exception code: $STR_REPLACE$"), + L"An error occurred while loading the file!", + L"Exception code: $STR_REPLACE$", MB_OK | MB_APPLMODAL, 0, szException); @@ -1791,7 +1792,7 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil } -BufferID FileManager::getBufferFromName(const TCHAR* name) +BufferID FileManager::getBufferFromName(const wchar_t* name) { for (auto buf : _buffers) { @@ -1818,14 +1819,14 @@ BufferID FileManager::getBufferFromDocument(Document doc) } -bool FileManager::createEmptyFile(const TCHAR * path) +bool FileManager::createEmptyFile(const wchar_t * path) { Win32_IO_File file(path); return file.isOpened(); } -int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy) +int FileManager::getFileNameFromBuffer(BufferID id, wchar_t * fn2copy) { if (getBufferIndexByID(id) == -1) return -1; diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index 9c7671fbd..44fdca34a 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -66,7 +66,7 @@ struct BufferViewInfo { BufferViewInfo(BufferID buf, int view) : _bufID(buf), _iView(view) {}; }; -const TCHAR UNTITLED_STR[] = TEXT("new "); +const wchar_t UNTITLED_STR[] = L"new "; //File manager class maintains all buffers class FileManager final { @@ -87,31 +87,31 @@ public: void addBufferReference(BufferID id, ScintillaEditView * identifer); //called by Scintilla etc indirectly - BufferID loadFile(const TCHAR * filename, Document doc = static_cast(NULL), int encoding = -1, const TCHAR *backupFileName = nullptr, FILETIME fileNameTimestamp = {}); //ID == BUFFER_INVALID on failure. If Doc == NULL, a new file is created, otherwise data is loaded in given document + BufferID loadFile(const wchar_t * filename, Document doc = static_cast(NULL), int encoding = -1, const wchar_t *backupFileName = nullptr, FILETIME fileNameTimestamp = {}); //ID == BUFFER_INVALID on failure. If Doc == NULL, a new file is created, otherwise data is loaded in given document BufferID newEmptyDocument(); // create an empty placeholder for a missing file when loading session - BufferID newPlaceholderDocument(const TCHAR * missingFilename, int whichOne, const wchar_t* userCreatedSessionName); + BufferID newPlaceholderDocument(const wchar_t * missingFilename, int whichOne, const wchar_t* userCreatedSessionName); //create Buffer from existing Scintilla, used from new Scintillas. BufferID bufferFromDocument(Document doc, bool isMainEditZone); - BufferID getBufferFromName(const TCHAR * name); + BufferID getBufferFromName(const wchar_t * name); BufferID getBufferFromDocument(Document doc); void setLoadedBufferEncodingAndEol(Buffer* buf, const Utf8_16_Read& UnicodeConvertor, int encoding, EolType bkformat); bool reloadBuffer(BufferID id); bool reloadBufferDeferred(BufferID id); - SavingStatus saveBuffer(BufferID id, const TCHAR* filename, bool isCopy = false); + SavingStatus saveBuffer(BufferID id, const wchar_t* filename, bool isCopy = false); bool backupCurrentBuffer(); bool deleteBufferBackup(BufferID id); bool deleteFile(BufferID id); - bool moveFile(BufferID id, const TCHAR * newFilename); - bool createEmptyFile(const TCHAR * path); + bool moveFile(BufferID id, const wchar_t * newFilename); + bool createEmptyFile(const wchar_t * path); static FileManager& getInstance() { static FileManager instance; return instance; }; - int getFileNameFromBuffer(BufferID id, TCHAR * fn2copy); + int getFileNameFromBuffer(BufferID id, wchar_t * fn2copy); size_t docLength(Buffer * buffer) const; size_t nextUntitledNewNumber() const; @@ -135,7 +135,7 @@ private: FileManager& operator=(FileManager&&) = delete; int detectCodepage(char* buf, size_t len); - bool loadFileData(Document doc, int64_t fileSize, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LoadedFileFormat& fileFormat); + bool loadFileData(Document doc, int64_t fileSize, const wchar_t* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LoadedFileFormat& fileFormat); LangType detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen); Notepad_plus* _pNotepadPlus = nullptr; @@ -158,16 +158,16 @@ public: //Load the document into Scintilla/add to TabBar //The entire lifetime if the buffer, the Document has reference count of _atleast_ one //Destructor makes sure its purged - Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName, bool isLargeFile); + Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const wchar_t *fileName, bool isLargeFile); // this method 1. copies the file name // 2. determinates the language from the ext of file name // 3. gets the last modified time - void setFileName(const TCHAR *fn); + void setFileName(const wchar_t *fn); - const TCHAR * getFullPathName() const { return _fullPathName.c_str(); } + const wchar_t * getFullPathName() const { return _fullPathName.c_str(); } - const TCHAR * getFileName() const { return _fileName; } + const wchar_t * getFileName() const { return _fileName; } BufferID getID() const { return _id; } @@ -212,7 +212,7 @@ public: LangType getLangType() const { return _lang; } - void setLangType(LangType lang, const TCHAR * userLangName = TEXT("")); + void setLangType(LangType lang, const wchar_t * userLangName = L""); UniMode getUnicodeMode() const { return _unicodeMode; } @@ -236,23 +236,23 @@ public: bool isUserDefineLangExt() const { return (_userLangExt[0] != '\0'); } - const TCHAR * getUserDefineLangName() const { return _userLangExt.c_str(); } + const wchar_t * getUserDefineLangName() const { return _userLangExt.c_str(); } - const TCHAR * getCommentLineSymbol() const { + const wchar_t * getCommentLineSymbol() const { Lang *l = getCurrentLang(); if (!l) return NULL; return l->_pCommentLineSymbol; } - const TCHAR * getCommentStart() const { + const wchar_t * getCommentStart() const { Lang *l = getCurrentLang(); if (!l) return NULL; return l->_pCommentStart; } - const TCHAR * getCommentEnd() const { + const wchar_t * getCommentEnd() const { Lang *l = getCurrentLang(); if (!l) return NULL; @@ -285,15 +285,15 @@ public: int64_t getFileLength() const; // return file length. -1 if file is not existing. enum fileTimeType { ft_created, ft_modified, ft_accessed }; - generic_string getFileTime(fileTimeType ftt) const; + std::wstring getFileTime(fileTimeType ftt) const; Lang * getCurrentLang() const; bool isModified() const { return _isModified; } void setModifiedStatus(bool isModified) { _isModified = isModified; } - generic_string getBackupFileName() const { return _backupFileName; } - void setBackupFileName(const generic_string& fileName) { _backupFileName = fileName; } + std::wstring getBackupFileName() const { return _backupFileName; } + void setBackupFileName(const std::wstring& fileName) { _backupFileName = fileName; } FILETIME getLastModifiedTimestamp() const { return _timeStamp; } @@ -368,7 +368,7 @@ private: //document properties Document _doc; //invariable LangType _lang = L_TEXT; - generic_string _userLangExt; // it's useful if only (_lang == L_USER) + std::wstring _userLangExt; // it's useful if only (_lang == L_USER) bool _isDirty = false; EolType _eolFormat = EolType::osdefault; UniMode _unicodeMode = uniUTF8; @@ -387,8 +387,8 @@ private: FILETIME _timeStamp = {}; // 0 if it's a new doc bool _isFileReadOnly = false; - generic_string _fullPathName; - TCHAR * _fileName = nullptr; // points to filename part in _fullPathName + std::wstring _fullPathName; + wchar_t * _fileName = nullptr; // points to filename part in _fullPathName bool _needReloading = false; // True if Buffer needs to be reloaded on activation long _recentTag = -1; @@ -397,7 +397,7 @@ private: int _docColorId = -1; // For backup system - generic_string _backupFileName; + std::wstring _backupFileName; bool _isModified = false; bool _isLoadedDirty = false; // it's the indicator for finding buffer's initial state diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp index 3370139b5..8a6f998a7 100644 --- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp @@ -37,7 +37,7 @@ GlobalMappers & globalMappper() return gm; } -void convertTo(TCHAR *dest, int destLen, const TCHAR *toConvert, const TCHAR *prefix) +void convertTo(wchar_t *dest, int destLen, const wchar_t *toConvert, const wchar_t *prefix) { bool inGroup = false; int index = lstrlen(dest); @@ -154,7 +154,7 @@ intptr_t CALLBACK FolderStyleDialog::run_dlgProc(UINT Message, WPARAM wParam, LP case WM_INITDIALOG: { _pageLink.init(_hInst, _hSelf); - _pageLink.create(::GetDlgItem(_hSelf, IDC_WEB_HELP_LINK), TEXT("https://ivan-radic.github.io/udl-documentation/")); + _pageLink.create(::GetDlgItem(_hSelf, IDC_WEB_HELP_LINK), L"https://ivan-radic.github.io/udl-documentation/"); return SharedParametersDialog::run_dlgProc(Message, wParam, lParam); } @@ -243,7 +243,7 @@ void FolderStyleDialog::updateDlg() ::SendDlgItemMessage(_hSelf, IDC_FOLDER_IN_COMMENT_CLOSE_EDIT, WM_SETTEXT, 0, reinterpret_cast(_pUserLang->_keywordLists[SCE_USER_KWLIST_FOLDERS_IN_COMMENT_CLOSE])); } -void FolderStyleDialog::retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const +void FolderStyleDialog::retrieve(wchar_t *dest, const wchar_t *toRetrieve, wchar_t *prefix) const { int j = 0; bool begin2Copy = false; @@ -276,7 +276,7 @@ intptr_t CALLBACK KeyWordsStyleDialog::run_dlgProc(UINT Message, WPARAM wParam, { case WM_INITDIALOG: { - // extend Keyword edit boxes to hold 128k of TCHARs + // extend Keyword edit boxes to hold 128k of wchar_t ::SendMessage(::GetDlgItem(_hSelf,IDC_KEYWORD1_EDIT), EM_LIMITTEXT, WPARAM(128*1024), 0); ::SendMessage(::GetDlgItem(_hSelf,IDC_KEYWORD2_EDIT), EM_LIMITTEXT, WPARAM(128*1024), 0); ::SendMessage(::GetDlgItem(_hSelf,IDC_KEYWORD3_EDIT), EM_LIMITTEXT, WPARAM(128*1024), 0); @@ -524,9 +524,9 @@ void CommentStyleDialog::setKeywords2List(int id) } if (index != -1) { - TCHAR* newList = new TCHAR[max_char]; + wchar_t* newList = new wchar_t[max_char]; newList[0] = '\0'; - TCHAR* buffer = new TCHAR[max_char]; + wchar_t* buffer = new wchar_t[max_char]; buffer[0] = '\0'; const int list[] = { @@ -537,7 +537,7 @@ void CommentStyleDialog::setKeywords2List(int id) IDC_COMMENT_CLOSE_EDIT }; - TCHAR intBuffer[10] = { '0', 0 }; + wchar_t intBuffer[10] = { '0', 0 }; for (int i = 0; static_cast(i) < sizeof(list) / sizeof(int); ++i) { _itow(i, intBuffer + 1, 10); @@ -551,7 +551,7 @@ void CommentStyleDialog::setKeywords2List(int id) } } -void CommentStyleDialog::retrieve(TCHAR *dest, const TCHAR *toRetrieve, const TCHAR *prefix) const +void CommentStyleDialog::retrieve(wchar_t *dest, const wchar_t *toRetrieve, const wchar_t *prefix) const { int j = 0; bool begin2Copy = false; @@ -589,7 +589,7 @@ void CommentStyleDialog::retrieve(TCHAR *dest, const TCHAR *toRetrieve, const TC void CommentStyleDialog::updateDlg() { - TCHAR* buffer = new TCHAR[max_char]; + wchar_t* buffer = new wchar_t[max_char]; buffer[0] = '\0'; const int list[] = { @@ -600,7 +600,7 @@ void CommentStyleDialog::updateDlg() IDC_COMMENT_CLOSE_EDIT }; - TCHAR intBuffer[10] = { '0', 0 }; + wchar_t intBuffer[10] = { '0', 0 }; for (int i = 0; static_cast(i) < sizeof(list) / sizeof(int); ++i) { _itow(i, intBuffer + 1, 10); @@ -631,7 +631,7 @@ void CommentStyleDialog::updateDlg() void SymbolsStyleDialog::updateDlg() { - TCHAR* buffer = new TCHAR[max_char]; + wchar_t* buffer = new wchar_t[max_char]; buffer[0] = '\0'; const int list[] = { IDC_DELIMITER1_BOUNDARYOPEN_EDIT, @@ -659,7 +659,7 @@ void SymbolsStyleDialog::updateDlg() IDC_DELIMITER8_ESCAPE_EDIT, IDC_DELIMITER8_BOUNDARYCLOSE_EDIT }; - TCHAR intBuffer[10] = {'0', 0}; + wchar_t intBuffer[10] = {'0', 0}; for (int i = 0; static_cast(i) < sizeof(list)/sizeof(int); ++i) { @@ -750,7 +750,7 @@ intptr_t CALLBACK SymbolsStyleDialog::run_dlgProc(UINT Message, WPARAM wParam, L } -void SymbolsStyleDialog::retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const +void SymbolsStyleDialog::retrieve(wchar_t *dest, const wchar_t *toRetrieve, wchar_t *prefix) const { int j = 0; bool begin2Copy = false; @@ -822,11 +822,11 @@ void SymbolsStyleDialog::setKeywords2List(int id) case IDC_DELIMITER8_ESCAPE_EDIT : case IDC_DELIMITER8_BOUNDARYCLOSE_EDIT : { - TCHAR* newList = new TCHAR[max_char]; + wchar_t* newList = new wchar_t[max_char]; newList[0] = '\0'; - TCHAR* buffer = new TCHAR[max_char]; + wchar_t* buffer = new wchar_t[max_char]; buffer[0] = '\0'; - TCHAR intBuffer[10] = {'0', 0}; + wchar_t intBuffer[10] = {'0', 0}; const int list[] = { IDC_DELIMITER1_BOUNDARYOPEN_EDIT, @@ -916,7 +916,7 @@ void UserDefineDialog::reloadLangCombo() { NppParameters& nppParam = NppParameters::getInstance(); ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_RESETCONTENT, 0, 0); - ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_ADDSTRING, 0, reinterpret_cast(TEXT("User Defined Language"))); + ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_ADDSTRING, 0, reinterpret_cast(L"User Defined Language")); for (int i = 0, nb = nppParam.getNbUserLang(); i < nb ; ++i) { UserLangContainer & userLangContainer = nppParam.getULCFromIndex(i); @@ -935,17 +935,17 @@ void UserDefineDialog::changeStyle() if (targetNode) targetNode = targetNode->FirstChildElement("UserDefine"); } - generic_string dockButtonLabel; - generic_string defauleLabel; + wstring dockButtonLabel; + wstring defauleLabel; string idStr; if (_status == DOCK) { - defauleLabel = TEXT("Undock"); + defauleLabel = L"Undock"; idStr = std::to_string(IDC_UNDOCK_BUTTON); } else { - defauleLabel = TEXT("Dock"); + defauleLabel = L"Dock"; idStr = std::to_string(IDC_DOCK_BUTTON); } @@ -954,7 +954,7 @@ void UserDefineDialog::changeStyle() auto style = ::GetWindowLongPtr(_hSelf, GWL_STYLE); if (!style) - ::MessageBox(NULL, TEXT("GetWindowLongPtr failed in UserDefineDialog::changeStyle()"), TEXT(""), MB_OK); + ::MessageBox(NULL, L"GetWindowLongPtr failed in UserDefineDialog::changeStyle()", L"", MB_OK); style = (_status == DOCK)? ((style & ~WS_POPUP) & ~DS_MODALFRAME & ~WS_CAPTION) | WS_CHILD : @@ -962,7 +962,7 @@ void UserDefineDialog::changeStyle() auto result = ::SetWindowLongPtr(_hSelf, GWL_STYLE, style); if (!result) - ::MessageBox(NULL, TEXT("SetWindowLongPtr failed in UserDefineDialog::changeStyle()"), TEXT(""), MB_OK); + ::MessageBox(NULL, L"SetWindowLongPtr failed in UserDefineDialog::changeStyle()", L"", MB_OK); if (_status == DOCK) getActualPosSize(); @@ -1031,10 +1031,10 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA _symbolsStyleDlg.create(IDD_SYMBOL_STYLE_DLG); _symbolsStyleDlg.display(false); - _wVector.push_back(DlgInfo(&_folderStyleDlg, TEXT("Folder && Default"))); - _wVector.push_back(DlgInfo(&_keyWordsStyleDlg, TEXT("Keywords Lists"))); - _wVector.push_back(DlgInfo(&_commentStyleDlg, TEXT("Comment && Number"))); - _wVector.push_back(DlgInfo(&_symbolsStyleDlg, TEXT("Operators && Delimiters"))); + _wVector.push_back(DlgInfo(&_folderStyleDlg, L"Folder && Default")); + _wVector.push_back(DlgInfo(&_keyWordsStyleDlg, L"Keywords Lists")); + _wVector.push_back(DlgInfo(&_commentStyleDlg, L"Comment && Number")); + _wVector.push_back(DlgInfo(&_symbolsStyleDlg, L"Operators && Delimiters")); _ctrlTab.createTabs(_wVector); _ctrlTab.display(); @@ -1080,14 +1080,14 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA si.nMax = 0; ::SetScrollInfo(_hSelf, SB_VERT, &si, TRUE); - TCHAR temp[32] = { '\0' }; - generic_string udlVersion = TEXT("User Defined Language v."); + wchar_t temp[32] = { '\0' }; + wstring udlVersion = L"User Defined Language v."; udlVersion += _itow(SCE_UDL_VERSION_MAJOR, temp, 10); - udlVersion += TEXT("."); + udlVersion += L"."; udlVersion += _itow(SCE_UDL_VERSION_MINOR, temp, 10); - udlVersion += TEXT("."); + udlVersion += L"."; udlVersion += _itow(SCE_UDL_VERSION_BUILD, temp, 10); - udlVersion += TEXT("."); + udlVersion += L"."; udlVersion += _itow(SCE_UDL_VERSION_REVISION, temp, 10); ::SetWindowText(_hSelf, udlVersion.c_str()); @@ -1166,7 +1166,7 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA { if (HIWORD(wParam) == EN_CHANGE) { - TCHAR ext[extsLenMax] = { '\0' }; + wchar_t ext[extsLenMax] = { '\0' }; ::SendDlgItemMessage(_hSelf, IDC_EXT_EDIT, WM_GETTEXT, extsLenMax, reinterpret_cast(ext)); _pUserLang->_ext = ext; return TRUE; @@ -1248,15 +1248,15 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA { int result = nppParam.getNativeLangSpeaker()->messageBox("UDLRemoveCurrentLang", _hSelf, - TEXT("Are you sure?"), - TEXT("Remove the current language"), + L"Are you sure?", + L"Remove the current language", MB_YESNO); if (result == IDYES) { auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); const size_t langNameLen = 256; - TCHAR langName[langNameLen + 1] = { '\0' }; + wchar_t langName[langNameLen + 1] = { '\0' }; auto cbTextLen = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXTLEN, i, 0); if (static_cast(cbTextLen) > langNameLen) return TRUE; @@ -1285,20 +1285,20 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA { auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); const size_t langNameLen = 256; - TCHAR langName[langNameLen + 1] = { '\0' }; + wchar_t langName[langNameLen + 1] = { '\0' }; auto cbTextLen = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXTLEN, i, 0); if (static_cast(cbTextLen) > langNameLen) return TRUE; ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, reinterpret_cast(langName)); - generic_string strName = pNativeSpeaker->getLocalizedStrFromID("common-name", TEXT("Name")); - generic_string strTitle = pNativeSpeaker->getLocalizedStrFromID("userdefined-title-rename", TEXT("Rename Current Language Name")); + wstring strName = pNativeSpeaker->getLocalizedStrFromID("common-name", L"Name"); + wstring strTitle = pNativeSpeaker->getLocalizedStrFromID("userdefined-title-rename", L"Rename Current Language Name"); StringDlg strDlg; strDlg.init(_hInst, _hSelf, strTitle.c_str(), strName.c_str(), langName, langNameLenMax - 1); - TCHAR *newName = (TCHAR *)strDlg.doDialog(); + wchar_t *newName = (wchar_t *)strDlg.doDialog(); if (newName) { @@ -1306,8 +1306,8 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA { nppParam.getNativeLangSpeaker()->messageBox("UDLNewNameError", _hSelf, - TEXT("This name is used by another language,\rplease give another one."), - TEXT("UDL Error"), + L"This name is used by another language,\rplease give another one.", + L"UDL Error", MB_OK); ::PostMessage(_hSelf, WM_COMMAND, IDC_RENAME_BUTTON, 0); return TRUE; @@ -1344,27 +1344,27 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA wParam = IDC_ADDNEW_BUTTON; - generic_string strName = pNativeSpeaker->getLocalizedStrFromID("common-name", TEXT("Name")); - generic_string strTitle = (wParam == IDC_SAVEAS_BUTTON) ? - pNativeSpeaker->getLocalizedStrFromID("userdefined-title-save", TEXT("Save Current Language Name As...")) : - pNativeSpeaker->getLocalizedStrFromID("userdefined-title-new", TEXT("Create New Language...")); + wstring strName = pNativeSpeaker->getLocalizedStrFromID("common-name", L"Name"); + wstring strTitle = (wParam == IDC_SAVEAS_BUTTON) ? + pNativeSpeaker->getLocalizedStrFromID("userdefined-title-save", L"Save Current Language Name As...") : + pNativeSpeaker->getLocalizedStrFromID("userdefined-title-new", L"Create New Language..."); StringDlg strDlg; - strDlg.init(_hInst, _hSelf, strTitle.c_str(), strName.c_str(), TEXT(""), langNameLenMax - 1); + strDlg.init(_hInst, _hSelf, strTitle.c_str(), strName.c_str(), L"", langNameLenMax - 1); - TCHAR *tmpName = reinterpret_cast(strDlg.doDialog()); + wchar_t *tmpName = reinterpret_cast(strDlg.doDialog()); if (tmpName && tmpName[0]) { - generic_string newNameString(tmpName); - const TCHAR *newName = newNameString.c_str(); + wstring newNameString(tmpName); + const wchar_t *newName = newNameString.c_str(); if (nppParam.isExistingUserLangName(newName)) { pNativeSpeaker->messageBox("UDLNewNameError", _hSelf, - TEXT("This name is used by another language,\rplease give another one."), - TEXT("UDL Error"), + L"This name is used by another language,\rplease give another one.", + L"UDL Error", MB_OK); ::PostMessage(_hSelf, WM_COMMAND, IDC_RENAME_BUTTON, 0); return TRUE; @@ -1393,8 +1393,8 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA case IDC_IMPORT_BUTTON : { CustomFileDialog fDlg(_hSelf); - fDlg.setExtFilter(TEXT("UDL"), TEXT(".xml")); - generic_string sourceFile = fDlg.doOpenSingleFileDlg(); + fDlg.setExtFilter(L"UDL", L".xml"); + wstring sourceFile = fDlg.doOpenSingleFileDlg(); if (sourceFile.empty()) break; bool isSuccessful = nppParam.importUDLFromFile(sourceFile); @@ -1403,11 +1403,11 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); reloadLangCombo(); ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_SETCURSEL, i, 0); - printStr(TEXT("Import successful.")); + printStr(L"Import successful."); } else { - printStr(TEXT("Fail to import.")); + printStr(L"Fail to import."); } break; } @@ -1418,14 +1418,14 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA if (i2Export == 0) { // maybe a better option would be to simply send IDC_SAVEAS_BUTTON message, and display "Save As..." dialog? - printStr(TEXT("Before exporting, save your language definition by clicking \"Save As...\" button")); + printStr(L"Before exporting, save your language definition by clicking \"Save As...\" button"); break; } CustomFileDialog fDlg(_hSelf); - fDlg.setExtFilter(TEXT("UDL"), TEXT(".xml")); + fDlg.setExtFilter(L"UDL", L".xml"); fDlg.setExtIndex(0); // 0 Default index else file will be saved without extension - generic_string fileName2save = fDlg.doSaveDlg(); + wstring fileName2save = fDlg.doSaveDlg(); if (fileName2save.empty()) break; if (i2Export > 0) @@ -1433,11 +1433,11 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA bool isSuccessful = nppParam.exportUDLToFile(i2Export - 1, fileName2save); if (isSuccessful) { - printStr(TEXT("Export successful")); + printStr(L"Export successful"); } else { - printStr(TEXT("Fail to export.")); + printStr(L"Fail to export."); } } break; @@ -1590,8 +1590,8 @@ intptr_t CALLBACK StringDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); if (pNativeSpeaker) { - generic_string ok = pNativeSpeaker->getLocalizedStrFromID("common-ok", TEXT("OK")); - generic_string cancel = pNativeSpeaker->getLocalizedStrFromID("common-cancel", TEXT("Cancel")); + wstring ok = pNativeSpeaker->getLocalizedStrFromID("common-ok", L"OK"); + wstring cancel = pNativeSpeaker->getLocalizedStrFromID("common-cancel", L"Cancel"); ::SetDlgItemText(_hSelf, IDOK, ok.c_str()); ::SetDlgItemText(_hSelf, IDCANCEL, cancel.c_str()); @@ -1655,7 +1655,7 @@ intptr_t CALLBACK StringDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa { case IDOK : { - TCHAR tmpName[langNameLenMax] = { '\0' }; + wchar_t tmpName[langNameLenMax] = { '\0' }; ::GetDlgItemText(_hSelf, IDC_STRING_EDIT, tmpName, langNameLenMax); _textValue = tmpName; ::EndDialog(_hSelf, reinterpret_cast(_textValue.c_str())); @@ -1705,7 +1705,7 @@ LRESULT StringDlg::customEditProc(HWND hEdit, UINT msg, WPARAM wParam, LPARAM lP else { // If Key pressed not permitted, then return 0 - if (!pSelf->isAllowed(reinterpret_cast(&wParam))) + if (!pSelf->isAllowed(reinterpret_cast(&wParam))) return 0; } break; @@ -1720,7 +1720,7 @@ LRESULT StringDlg::customEditProc(HWND hEdit, UINT msg, WPARAM wParam, LPARAM lP return CallWindowProc(pSelf->_oldEditProc, hEdit, msg, wParam, lParam); } -bool StringDlg::isAllowed([[maybe_unused]] const generic_string & txt) +bool StringDlg::isAllowed([[maybe_unused]] const wstring & txt) { #ifndef __MINGW32__ for (auto ch : txt) @@ -1771,7 +1771,7 @@ void StylerDlg::move2CtrlRight(HWND hwndDlg, int ctrlID, HWND handle2Move, int h intptr_t CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - StylerDlg * dlg = (StylerDlg *)::GetProp(hwnd, TEXT("Styler dialog prop")); + StylerDlg * dlg = (StylerDlg *)::GetProp(hwnd, L"Styler dialog prop"); NppParameters& nppParam = NppParameters::getInstance(); switch (message) @@ -1784,8 +1784,8 @@ intptr_t CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPA NativeLangSpeaker *pNativeLangSpeaker = nppParam.getNativeLangSpeaker(); pNativeLangSpeaker->changeUserDefineLangPopupDlg(hwnd); - ::SetProp(hwnd, TEXT("Styler dialog prop"), (HANDLE)lParam); - dlg = (StylerDlg *)::GetProp(hwnd, TEXT("Styler dialog prop")); + ::SetProp(hwnd, L"Styler dialog prop", (HANDLE)lParam); + dlg = (StylerDlg *)::GetProp(hwnd, L"Styler dialog prop"); Style & style = SharedParametersDialog::_pUserLang->_styles.getStyler(dlg->_stylerIndex); // move dialog over UDL GUI (position 0,0 of UDL window) so it wouldn't cover the code @@ -1801,14 +1801,14 @@ intptr_t CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPA // for the font size combo HWND hFontSizeCombo = ::GetDlgItem(hwnd, IDC_STYLER_COMBO_FONT_SIZE); - for (size_t j = 0 ; j < int(sizeof(fontSizeStrs))/(3*sizeof(TCHAR)) ; ++j) + for (size_t j = 0 ; j < int(sizeof(fontSizeStrs))/(3*sizeof(wchar_t)) ; ++j) ::SendMessage(hFontSizeCombo, CB_ADDSTRING, 0, reinterpret_cast(fontSizeStrs[j])); - TCHAR size[10] = { '\0' }; + wchar_t size[10] = { '\0' }; if (style._fontSize == -1) size[0] = '\0'; else - wsprintf(size, TEXT("%d"),style._fontSize); + wsprintf(size, L"%d",style._fontSize); auto i = ::SendMessage(hFontSizeCombo, CB_FINDSTRINGEXACT, static_cast(-1), reinterpret_cast(size)); if (i != CB_ERR) @@ -1816,7 +1816,7 @@ intptr_t CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPA // for the font name combo HWND hFontNameCombo = ::GetDlgItem(hwnd, IDC_STYLER_COMBO_FONT_NAME); - const std::vector & fontlist = nppParam.getFontList(); + const std::vector & fontlist = nppParam.getFontList(); for (size_t j = 0, len = fontlist.size() ; j < len ; ++j) { auto k = ::SendMessage(hFontNameCombo, CB_ADDSTRING, 0, reinterpret_cast(fontlist[j].c_str())); @@ -1919,7 +1919,7 @@ intptr_t CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPA if (i != 0) { const size_t intStrLen = 3; - TCHAR intStr[intStrLen] = { '\0' }; + wchar_t intStr[intStrLen] = { '\0' }; auto lbTextLen = ::SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETLBTEXTLEN, i, 0); if (static_cast(lbTextLen) > intStrLen - 1) return TRUE; @@ -1929,7 +1929,7 @@ intptr_t CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPA style._fontSize = -1; else { - TCHAR *finStr = nullptr; + wchar_t *finStr = nullptr; style._fontSize = wcstol(intStr, &finStr, 10); if (*finStr != '\0') style._fontSize = -1; @@ -1942,7 +1942,7 @@ intptr_t CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPA } else if (LOWORD(wParam) == IDC_STYLER_COMBO_FONT_NAME) { - style._fontName = (TCHAR *)::SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETITEMDATA, i, 0); + style._fontName = (wchar_t *)::SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETITEMDATA, i, 0); } // show changes to user, re-color document @@ -1960,14 +1960,14 @@ intptr_t CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPA if (SharedParametersDialog::_pScintilla->getCurrentBuffer()->getLangType() == L_USER) SharedParametersDialog::_pScintilla->styleChange(); - ::RemoveProp(hwnd, TEXT("Styler dialog prop")); + ::RemoveProp(hwnd, L"Styler dialog prop"); ::EndDialog(hwnd, IDCANCEL); return TRUE; } if (wParam == IDOK) { - ::RemoveProp(hwnd, TEXT("Styler dialog prop")); + ::RemoveProp(hwnd, L"Styler dialog prop"); ::EndDialog(hwnd, IDOK); return TRUE; } diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.h b/PowerEditor/src/ScintillaComponent/UserDefineDialog.h index 91b67aa62..24c982428 100644 --- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.h +++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.h @@ -37,14 +37,14 @@ class GlobalMappers { public: - std::unordered_map keywordIdMapper; - std::unordered_map keywordNameMapper; + std::unordered_map keywordIdMapper; + std::unordered_map keywordNameMapper; - std::unordered_map styleIdMapper; - std::unordered_map styleNameMapper; + std::unordered_map styleIdMapper; + std::unordered_map styleNameMapper; - std::unordered_map temp; - std::unordered_map::iterator iter; + std::unordered_map temp; + std::unordered_map::iterator iter; std::unordered_map nestingMapper; std::unordered_map dialogMapper; @@ -54,13 +54,13 @@ class GlobalMappers GlobalMappers() { // pre 2.0 - temp[TEXT("Operators")] = SCE_USER_KWLIST_OPERATORS1; - temp[TEXT("Folder+")] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_OPEN; - temp[TEXT("Folder-")] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_CLOSE; - temp[TEXT("Words1")] = SCE_USER_KWLIST_KEYWORDS1; - temp[TEXT("Words2")] = SCE_USER_KWLIST_KEYWORDS2; - temp[TEXT("Words3")] = SCE_USER_KWLIST_KEYWORDS3; - temp[TEXT("Words4")] = SCE_USER_KWLIST_KEYWORDS4; + temp[L"Operators"] = SCE_USER_KWLIST_OPERATORS1; + temp[L"Folder+"] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_OPEN; + temp[L"Folder-"] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_CLOSE; + temp[L"Words1"] = SCE_USER_KWLIST_KEYWORDS1; + temp[L"Words2"] = SCE_USER_KWLIST_KEYWORDS2; + temp[L"Words3"] = SCE_USER_KWLIST_KEYWORDS3; + temp[L"Words4"] = SCE_USER_KWLIST_KEYWORDS4; // in case of duplicate entries, newer string should overwrite old one ! for (iter = temp.begin(); iter != temp.end(); ++iter) @@ -69,31 +69,31 @@ class GlobalMappers temp.clear(); // 2.0 - temp[TEXT("Comments")] = SCE_USER_KWLIST_COMMENTS; - temp[TEXT("Numbers, additional")] = SCE_USER_KWLIST_NUMBER_RANGE; - temp[TEXT("Numbers, prefixes")] = SCE_USER_KWLIST_NUMBER_PREFIX2; - temp[TEXT("Numbers, extras with prefixes")] = SCE_USER_KWLIST_NUMBER_EXTRAS2; - temp[TEXT("Numbers, suffixes")] = SCE_USER_KWLIST_NUMBER_SUFFIX2; - temp[TEXT("Operators1")] = SCE_USER_KWLIST_OPERATORS1; - temp[TEXT("Operators2")] = SCE_USER_KWLIST_OPERATORS2; - temp[TEXT("Folders in code1, open")] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_OPEN; - temp[TEXT("Folders in code1, middle")] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_MIDDLE; - temp[TEXT("Folders in code1, close")] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_CLOSE; - temp[TEXT("Folders in code2, open")] = SCE_USER_KWLIST_FOLDERS_IN_CODE2_OPEN; - temp[TEXT("Folders in code2, middle")] = SCE_USER_KWLIST_FOLDERS_IN_CODE2_MIDDLE; - temp[TEXT("Folders in code2, close")] = SCE_USER_KWLIST_FOLDERS_IN_CODE2_CLOSE; - temp[TEXT("Folders in comment, open")] = SCE_USER_KWLIST_FOLDERS_IN_COMMENT_OPEN; - temp[TEXT("Folders in comment, middle")] = SCE_USER_KWLIST_FOLDERS_IN_COMMENT_MIDDLE; - temp[TEXT("Folders in comment, close")] = SCE_USER_KWLIST_FOLDERS_IN_COMMENT_CLOSE; - temp[TEXT("Keywords1")] = SCE_USER_KWLIST_KEYWORDS1; - temp[TEXT("Keywords2")] = SCE_USER_KWLIST_KEYWORDS2; - temp[TEXT("Keywords3")] = SCE_USER_KWLIST_KEYWORDS3; - temp[TEXT("Keywords4")] = SCE_USER_KWLIST_KEYWORDS4; - temp[TEXT("Keywords5")] = SCE_USER_KWLIST_KEYWORDS5; - temp[TEXT("Keywords6")] = SCE_USER_KWLIST_KEYWORDS6; - temp[TEXT("Keywords7")] = SCE_USER_KWLIST_KEYWORDS7; - temp[TEXT("Keywords8")] = SCE_USER_KWLIST_KEYWORDS8; - temp[TEXT("Delimiters")] = SCE_USER_KWLIST_DELIMITERS; + temp[L"Comments"] = SCE_USER_KWLIST_COMMENTS; + temp[L"Numbers, additional"] = SCE_USER_KWLIST_NUMBER_RANGE; + temp[L"Numbers, prefixes"] = SCE_USER_KWLIST_NUMBER_PREFIX2; + temp[L"Numbers, extras with prefixes"] = SCE_USER_KWLIST_NUMBER_EXTRAS2; + temp[L"Numbers, suffixes"] = SCE_USER_KWLIST_NUMBER_SUFFIX2; + temp[L"Operators1"] = SCE_USER_KWLIST_OPERATORS1; + temp[L"Operators2"] = SCE_USER_KWLIST_OPERATORS2; + temp[L"Folders in code1, open"] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_OPEN; + temp[L"Folders in code1, middle"] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_MIDDLE; + temp[L"Folders in code1, close"] = SCE_USER_KWLIST_FOLDERS_IN_CODE1_CLOSE; + temp[L"Folders in code2, open"] = SCE_USER_KWLIST_FOLDERS_IN_CODE2_OPEN; + temp[L"Folders in code2, middle"] = SCE_USER_KWLIST_FOLDERS_IN_CODE2_MIDDLE; + temp[L"Folders in code2, close"] = SCE_USER_KWLIST_FOLDERS_IN_CODE2_CLOSE; + temp[L"Folders in comment, open"] = SCE_USER_KWLIST_FOLDERS_IN_COMMENT_OPEN; + temp[L"Folders in comment, middle"] = SCE_USER_KWLIST_FOLDERS_IN_COMMENT_MIDDLE; + temp[L"Folders in comment, close"] = SCE_USER_KWLIST_FOLDERS_IN_COMMENT_CLOSE; + temp[L"Keywords1"] = SCE_USER_KWLIST_KEYWORDS1; + temp[L"Keywords2"] = SCE_USER_KWLIST_KEYWORDS2; + temp[L"Keywords3"] = SCE_USER_KWLIST_KEYWORDS3; + temp[L"Keywords4"] = SCE_USER_KWLIST_KEYWORDS4; + temp[L"Keywords5"] = SCE_USER_KWLIST_KEYWORDS5; + temp[L"Keywords6"] = SCE_USER_KWLIST_KEYWORDS6; + temp[L"Keywords7"] = SCE_USER_KWLIST_KEYWORDS7; + temp[L"Keywords8"] = SCE_USER_KWLIST_KEYWORDS8; + temp[L"Delimiters"] = SCE_USER_KWLIST_DELIMITERS; // in case of duplicate entries, newer string should overwrite old one ! for (iter = temp.begin(); iter != temp.end(); ++iter) @@ -102,13 +102,13 @@ class GlobalMappers temp.clear(); // 2.1 - temp[TEXT("Numbers, prefix1")] = SCE_USER_KWLIST_NUMBER_PREFIX1; - temp[TEXT("Numbers, prefix2")] = SCE_USER_KWLIST_NUMBER_PREFIX2; - temp[TEXT("Numbers, extras1")] = SCE_USER_KWLIST_NUMBER_EXTRAS1; - temp[TEXT("Numbers, extras2")] = SCE_USER_KWLIST_NUMBER_EXTRAS2; - temp[TEXT("Numbers, suffix1")] = SCE_USER_KWLIST_NUMBER_SUFFIX1; - temp[TEXT("Numbers, suffix2")] = SCE_USER_KWLIST_NUMBER_SUFFIX2; - temp[TEXT("Numbers, range")] = SCE_USER_KWLIST_NUMBER_RANGE; + temp[L"Numbers, prefix1"] = SCE_USER_KWLIST_NUMBER_PREFIX1; + temp[L"Numbers, prefix2"] = SCE_USER_KWLIST_NUMBER_PREFIX2; + temp[L"Numbers, extras1"] = SCE_USER_KWLIST_NUMBER_EXTRAS1; + temp[L"Numbers, extras2"] = SCE_USER_KWLIST_NUMBER_EXTRAS2; + temp[L"Numbers, suffix1"] = SCE_USER_KWLIST_NUMBER_SUFFIX1; + temp[L"Numbers, suffix2"] = SCE_USER_KWLIST_NUMBER_SUFFIX2; + temp[L"Numbers, range"] = SCE_USER_KWLIST_NUMBER_RANGE; // in case of duplicate entries, newer string should overwrite old one ! for (iter = temp.begin(); iter != temp.end(); ++iter) @@ -117,19 +117,19 @@ class GlobalMappers temp.clear(); // pre 2.0 - temp[TEXT("FOLDEROPEN")] = SCE_USER_STYLE_FOLDER_IN_CODE1; - temp[TEXT("FOLDERCLOSE")] = SCE_USER_STYLE_FOLDER_IN_CODE1; - temp[TEXT("KEYWORD1")] = SCE_USER_STYLE_KEYWORD1; - temp[TEXT("KEYWORD2")] = SCE_USER_STYLE_KEYWORD2; - temp[TEXT("KEYWORD3")] = SCE_USER_STYLE_KEYWORD3; - temp[TEXT("KEYWORD4")] = SCE_USER_STYLE_KEYWORD4; - temp[TEXT("COMMENT")] = SCE_USER_STYLE_COMMENT; - temp[TEXT("COMMENT LINE")] = SCE_USER_STYLE_COMMENTLINE; - temp[TEXT("NUMBER")] = SCE_USER_STYLE_NUMBER; - temp[TEXT("OPERATOR")] = SCE_USER_STYLE_OPERATOR; - temp[TEXT("DELIMINER1")] = SCE_USER_STYLE_DELIMITER1; - temp[TEXT("DELIMINER2")] = SCE_USER_STYLE_DELIMITER2; - temp[TEXT("DELIMINER3")] = SCE_USER_STYLE_DELIMITER3; + temp[L"FOLDEROPEN"] = SCE_USER_STYLE_FOLDER_IN_CODE1; + temp[L"FOLDERCLOSE"] = SCE_USER_STYLE_FOLDER_IN_CODE1; + temp[L"KEYWORD1"] = SCE_USER_STYLE_KEYWORD1; + temp[L"KEYWORD2"] = SCE_USER_STYLE_KEYWORD2; + temp[L"KEYWORD3"] = SCE_USER_STYLE_KEYWORD3; + temp[L"KEYWORD4"] = SCE_USER_STYLE_KEYWORD4; + temp[L"COMMENT"] = SCE_USER_STYLE_COMMENT; + temp[L"COMMENT LINE"] = SCE_USER_STYLE_COMMENTLINE; + temp[L"NUMBER"] = SCE_USER_STYLE_NUMBER; + temp[L"OPERATOR"] = SCE_USER_STYLE_OPERATOR; + temp[L"DELIMINER1"] = SCE_USER_STYLE_DELIMITER1; + temp[L"DELIMINER2"] = SCE_USER_STYLE_DELIMITER2; + temp[L"DELIMINER3"] = SCE_USER_STYLE_DELIMITER3; // in case of duplicate entries, newer string should overwrite old one ! for (iter = temp.begin(); iter != temp.end(); ++iter) @@ -138,30 +138,30 @@ class GlobalMappers temp.clear(); // post 2.0 - temp[TEXT("DEFAULT")] = SCE_USER_STYLE_DEFAULT; - temp[TEXT("COMMENTS")] = SCE_USER_STYLE_COMMENT; - temp[TEXT("LINE COMMENTS")] = SCE_USER_STYLE_COMMENTLINE; - temp[TEXT("NUMBERS")] = SCE_USER_STYLE_NUMBER; - temp[TEXT("KEYWORDS1")] = SCE_USER_STYLE_KEYWORD1; - temp[TEXT("KEYWORDS2")] = SCE_USER_STYLE_KEYWORD2; - temp[TEXT("KEYWORDS3")] = SCE_USER_STYLE_KEYWORD3; - temp[TEXT("KEYWORDS4")] = SCE_USER_STYLE_KEYWORD4; - temp[TEXT("KEYWORDS5")] = SCE_USER_STYLE_KEYWORD5; - temp[TEXT("KEYWORDS6")] = SCE_USER_STYLE_KEYWORD6; - temp[TEXT("KEYWORDS7")] = SCE_USER_STYLE_KEYWORD7; - temp[TEXT("KEYWORDS8")] = SCE_USER_STYLE_KEYWORD8; - temp[TEXT("OPERATORS")] = SCE_USER_STYLE_OPERATOR; - temp[TEXT("FOLDER IN CODE1")] = SCE_USER_STYLE_FOLDER_IN_CODE1; - temp[TEXT("FOLDER IN CODE2")] = SCE_USER_STYLE_FOLDER_IN_CODE2; - temp[TEXT("FOLDER IN COMMENT")] = SCE_USER_STYLE_FOLDER_IN_COMMENT; - temp[TEXT("DELIMITERS1")] = SCE_USER_STYLE_DELIMITER1; - temp[TEXT("DELIMITERS2")] = SCE_USER_STYLE_DELIMITER2; - temp[TEXT("DELIMITERS3")] = SCE_USER_STYLE_DELIMITER3; - temp[TEXT("DELIMITERS4")] = SCE_USER_STYLE_DELIMITER4; - temp[TEXT("DELIMITERS5")] = SCE_USER_STYLE_DELIMITER5; - temp[TEXT("DELIMITERS6")] = SCE_USER_STYLE_DELIMITER6; - temp[TEXT("DELIMITERS7")] = SCE_USER_STYLE_DELIMITER7; - temp[TEXT("DELIMITERS8")] = SCE_USER_STYLE_DELIMITER8; + temp[L"DEFAULT"] = SCE_USER_STYLE_DEFAULT; + temp[L"COMMENTS"] = SCE_USER_STYLE_COMMENT; + temp[L"LINE COMMENTS"] = SCE_USER_STYLE_COMMENTLINE; + temp[L"NUMBERS"] = SCE_USER_STYLE_NUMBER; + temp[L"KEYWORDS1"] = SCE_USER_STYLE_KEYWORD1; + temp[L"KEYWORDS2"] = SCE_USER_STYLE_KEYWORD2; + temp[L"KEYWORDS3"] = SCE_USER_STYLE_KEYWORD3; + temp[L"KEYWORDS4"] = SCE_USER_STYLE_KEYWORD4; + temp[L"KEYWORDS5"] = SCE_USER_STYLE_KEYWORD5; + temp[L"KEYWORDS6"] = SCE_USER_STYLE_KEYWORD6; + temp[L"KEYWORDS7"] = SCE_USER_STYLE_KEYWORD7; + temp[L"KEYWORDS8"] = SCE_USER_STYLE_KEYWORD8; + temp[L"OPERATORS"] = SCE_USER_STYLE_OPERATOR; + temp[L"FOLDER IN CODE1"] = SCE_USER_STYLE_FOLDER_IN_CODE1; + temp[L"FOLDER IN CODE2"] = SCE_USER_STYLE_FOLDER_IN_CODE2; + temp[L"FOLDER IN COMMENT"] = SCE_USER_STYLE_FOLDER_IN_COMMENT; + temp[L"DELIMITERS1"] = SCE_USER_STYLE_DELIMITER1; + temp[L"DELIMITERS2"] = SCE_USER_STYLE_DELIMITER2; + temp[L"DELIMITERS3"] = SCE_USER_STYLE_DELIMITER3; + temp[L"DELIMITERS4"] = SCE_USER_STYLE_DELIMITER4; + temp[L"DELIMITERS5"] = SCE_USER_STYLE_DELIMITER5; + temp[L"DELIMITERS6"] = SCE_USER_STYLE_DELIMITER6; + temp[L"DELIMITERS7"] = SCE_USER_STYLE_DELIMITER7; + temp[L"DELIMITERS8"] = SCE_USER_STYLE_DELIMITER8; // in case of duplicate entries, newer string should overwrite old one ! for (iter = temp.begin(); iter != temp.end(); ++iter) @@ -260,7 +260,7 @@ protected : intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) override; void setKeywords2List(int ctrlID) override; private : - void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const; + void retrieve(wchar_t *dest, const wchar_t *toRetrieve, wchar_t *prefix) const; URLCtrl _pageLink; }; @@ -283,7 +283,7 @@ protected : intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) override; void setKeywords2List(int id) override; private : - void retrieve(TCHAR *dest, const TCHAR *toRetrieve, const TCHAR *prefix) const; + void retrieve(wchar_t *dest, const wchar_t *toRetrieve, const wchar_t *prefix) const; }; class SymbolsStyleDialog : public SharedParametersDialog @@ -295,7 +295,7 @@ protected : intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) override; void setKeywords2List(int id) override; private : - void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const; + void retrieve(wchar_t *dest, const wchar_t *toRetrieve, wchar_t *prefix) const; }; class UserDefineDialog : public SharedParametersDialog @@ -351,7 +351,7 @@ public : HWND getSymbolHandle() const { return _symbolsStyleDlg.getHSelf(); }; - void setTabName(int index, const TCHAR *name2set) { + void setTabName(int index, const wchar_t *name2set) { _ctrlTab.renameTab(index, name2set); }; protected : @@ -385,7 +385,7 @@ class StringDlg : public StaticDialog { public : StringDlg() = default; - void init(HINSTANCE hInst, HWND parent, const TCHAR *title, const TCHAR *staticName, const TCHAR *text2Set, int txtLen = 0, const TCHAR* restrictedChars = nullptr, bool bGotoCenter = false) { + void init(HINSTANCE hInst, HWND parent, const wchar_t *title, const wchar_t *staticName, const wchar_t *text2Set, int txtLen = 0, const wchar_t* restrictedChars = nullptr, bool bGotoCenter = false) { Window::init(hInst, parent); _title = title; _static = staticName; @@ -410,14 +410,14 @@ protected : // Custom proc to subclass edit control LRESULT static CALLBACK customEditProc(HWND hEdit, UINT msg, WPARAM wParam, LPARAM lParam); - bool isAllowed(const generic_string& txt); + bool isAllowed(const std::wstring& txt); void HandlePaste(HWND hEdit); private : - generic_string _title; - generic_string _textValue; - generic_string _static; - generic_string _restrictedChars; + std::wstring _title; + std::wstring _textValue; + std::wstring _static; + std::wstring _restrictedChars; int _txtLen = 0; bool _shouldGotoCenter = false; WNDPROC _oldEditProc = nullptr; diff --git a/PowerEditor/src/TinyXml/tinyxml.cpp b/PowerEditor/src/TinyXml/tinyxml.cpp index 2f75b8ce5..35c86adfa 100644 --- a/PowerEditor/src/TinyXml/tinyxml.cpp +++ b/PowerEditor/src/TinyXml/tinyxml.cpp @@ -88,14 +88,14 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) { // Easy pass at non-alpha/numeric/symbol // 127 is the delete key. Below 32 is symbolic. - TCHAR buf[32]; - wsprintf( buf, TEXT("&#x%04X;"), static_cast(c & 0xffff) ); + wchar_t buf[32]; + wsprintf( buf, L"&#x%04X;", static_cast(c & 0xffff) ); outString->append( buf, lstrlen( buf ) ); ++i; } else { - TCHAR realc = static_cast(c); + wchar_t realc = static_cast(c); outString->append( &realc, 1 ); ++i; } @@ -107,7 +107,7 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) TiXmlBase::StringToBuffer::StringToBuffer( const TIXML_STRING& str ) { const size_t strLen = str.length() + 1; - buffer = new TCHAR[strLen]; + buffer = new wchar_t[strLen]; if (buffer) { wcscpy_s(buffer, strLen, str.c_str()); @@ -294,7 +294,7 @@ bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) return true; } -TiXmlNode* TiXmlNode::FirstChild( const TCHAR * _value ) const +TiXmlNode* TiXmlNode::FirstChild( const wchar_t * _value ) const { TiXmlNode* node; for ( node = firstChild; node; node = node->next ) @@ -305,7 +305,7 @@ TiXmlNode* TiXmlNode::FirstChild( const TCHAR * _value ) const return 0; } -TiXmlNode* TiXmlNode::LastChild( const TCHAR * _value ) const +TiXmlNode* TiXmlNode::LastChild( const wchar_t * _value ) const { TiXmlNode* node; for ( node = lastChild; node; node = node->prev ) @@ -329,7 +329,7 @@ TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous ) const } } -TiXmlNode* TiXmlNode::IterateChildren( const TCHAR * val, TiXmlNode* previous ) const +TiXmlNode* TiXmlNode::IterateChildren( const wchar_t * val, TiXmlNode* previous ) const { if ( !previous ) { @@ -342,7 +342,7 @@ TiXmlNode* TiXmlNode::IterateChildren( const TCHAR * val, TiXmlNode* previous ) } } -TiXmlNode* TiXmlNode::NextSibling( const TCHAR * _value ) const +TiXmlNode* TiXmlNode::NextSibling( const wchar_t * _value ) const { TiXmlNode* node; for ( node = next; node; node = node->next ) @@ -354,7 +354,7 @@ TiXmlNode* TiXmlNode::NextSibling( const TCHAR * _value ) const } -TiXmlNode* TiXmlNode::PreviousSibling( const TCHAR * _value ) const +TiXmlNode* TiXmlNode::PreviousSibling( const wchar_t * _value ) const { TiXmlNode* node; for ( node = prev; node; node = node->prev ) @@ -365,7 +365,7 @@ TiXmlNode* TiXmlNode::PreviousSibling( const TCHAR * _value ) const return 0; } -void TiXmlElement::RemoveAttribute( const TCHAR * name ) +void TiXmlElement::RemoveAttribute( const wchar_t * name ) { TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) @@ -389,7 +389,7 @@ TiXmlElement* TiXmlNode::FirstChildElement() const return 0; } -TiXmlElement* TiXmlNode::FirstChildElement( const TCHAR * _value ) const +TiXmlElement* TiXmlNode::FirstChildElement( const wchar_t * _value ) const { TiXmlNode* node; @@ -418,7 +418,7 @@ TiXmlElement* TiXmlNode::NextSiblingElement() const return 0; } -TiXmlElement* TiXmlNode::NextSiblingElement( const TCHAR * _value ) const +TiXmlElement* TiXmlNode::NextSiblingElement( const wchar_t * _value ) const { TiXmlNode* node; @@ -447,7 +447,7 @@ TiXmlDocument* TiXmlNode::GetDocument() const } -TiXmlElement::TiXmlElement (const TCHAR * _value) +TiXmlElement::TiXmlElement (const wchar_t * _value) : TiXmlNode( TiXmlNode::ELEMENT ) { firstChild = lastChild = 0; @@ -464,7 +464,7 @@ TiXmlElement::~TiXmlElement() } } -const TCHAR * TiXmlElement::Attribute( const TCHAR * name ) const +const wchar_t * TiXmlElement::Attribute( const wchar_t * name ) const { TiXmlAttribute* node = attributeSet.Find( name ); @@ -475,9 +475,9 @@ const TCHAR * TiXmlElement::Attribute( const TCHAR * name ) const } -const TCHAR * TiXmlElement::Attribute( const TCHAR * name, int* i ) const +const wchar_t * TiXmlElement::Attribute( const wchar_t * name, int* i ) const { - const TCHAR * s = Attribute( name ); + const wchar_t * s = Attribute( name ); if ( i ) { if ( s ) @@ -489,9 +489,9 @@ const TCHAR * TiXmlElement::Attribute( const TCHAR * name, int* i ) const } -const TCHAR * TiXmlElement::Attribute( const TCHAR * name, double* d ) const +const wchar_t * TiXmlElement::Attribute( const wchar_t * name, double* d ) const { - const TCHAR * s = Attribute( name ); + const wchar_t * s = Attribute( name ); if ( d ) { if ( s ) @@ -503,7 +503,7 @@ const TCHAR * TiXmlElement::Attribute( const TCHAR * name, double* d ) const } -int TiXmlElement::QueryIntAttribute( const TCHAR* name, int* ival ) const +int TiXmlElement::QueryIntAttribute( const wchar_t* name, int* ival ) const { TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) @@ -513,7 +513,7 @@ int TiXmlElement::QueryIntAttribute( const TCHAR* name, int* ival ) const } -int TiXmlElement::QueryDoubleAttribute( const TCHAR* name, double* dval ) const +int TiXmlElement::QueryDoubleAttribute( const wchar_t* name, double* dval ) const { TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) @@ -523,15 +523,15 @@ int TiXmlElement::QueryDoubleAttribute( const TCHAR* name, double* dval ) const } -void TiXmlElement::SetAttribute( const TCHAR * name, int val ) +void TiXmlElement::SetAttribute( const wchar_t * name, int val ) { - TCHAR buf[64]; - wsprintf( buf, TEXT("%d"), val ); + wchar_t buf[64]; + wsprintf( buf, L"%d", val ); SetAttribute( name, buf ); } -void TiXmlElement::SetAttribute( const TCHAR * name, const TCHAR * _value ) +void TiXmlElement::SetAttribute( const wchar_t * name, const wchar_t * _value ) { TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) @@ -614,12 +614,12 @@ void TiXmlElement::Print( std::string& outputStream, int depth ) const void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << TEXT("<") << value; + (*stream) << L"<" << value; TiXmlAttribute* attrib; for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) { - (*stream) << TEXT(" "); + (*stream) << L" "; attrib->StreamOut( stream ); } @@ -628,17 +628,17 @@ void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const TiXmlNode* node; if ( firstChild ) { - (*stream) << TEXT(">"); + (*stream) << L">"; for ( node = firstChild; node; node=node->NextSibling() ) { node->StreamOut( stream ); } - (*stream) << TEXT(""); + (*stream) << L""; } else { - (*stream) << TEXT(" />"); + (*stream) << L" />"; } } @@ -674,7 +674,7 @@ TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) ClearError(); } -TiXmlDocument::TiXmlDocument( const TCHAR * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) +TiXmlDocument::TiXmlDocument( const wchar_t * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { tabsize = 4; value = documentName; @@ -704,7 +704,7 @@ bool TiXmlDocument::SaveFile() const return false; } -bool TiXmlDocument::LoadFile( const TCHAR* filename ) +bool TiXmlDocument::LoadFile( const wchar_t* filename ) { // Delete the existing data: Clear(); @@ -720,7 +720,7 @@ bool TiXmlDocument::LoadFile( const TCHAR* filename ) // Fixed with the StringToBuffer class. value = filename; - FILE* file = _wfopen( value.c_str (), TEXT("r") ); + FILE* file = _wfopen( value.c_str (), L"r" ); if ( file ) { @@ -762,11 +762,11 @@ bool TiXmlDocument::LoadFile( const TCHAR* filename ) return false; } -bool TiXmlDocument::SaveFile( const TCHAR * filename ) const +bool TiXmlDocument::SaveFile( const wchar_t * filename ) const { /* // The old c stuff lives on... - FILE* fp = _wfopen( filename, TEXT("wc") ); + FILE* fp = _wfopen( filename, L"wc") ); if ( fp ) { Print( fp, 0 ); @@ -886,16 +886,16 @@ void TiXmlAttribute::StreamOut( TIXML_OSTREAM * stream ) const if (value.find( '\"' ) != TIXML_STRING::npos) { PutString( name, stream ); - (*stream) << TEXT("=") << TEXT("'"); + (*stream) << L"=" << L"'"; PutString( value, stream ); - (*stream) << TEXT("'"); + (*stream) << L"'"; } else { PutString( name, stream ); - (*stream) << TEXT("=") << TEXT("\""); + (*stream) << L"=" << L"\""; PutString( value, stream ); - (*stream) << TEXT("\""); + (*stream) << L"\""; } } @@ -915,15 +915,15 @@ int TiXmlAttribute::QueryDoubleValue( double* dval ) const void TiXmlAttribute::SetIntValue( int _value ) { - TCHAR buf [64]; - wsprintf (buf, TEXT("%d"), _value); + wchar_t buf [64]; + wsprintf (buf, L"%d", _value); SetValue (buf); } void TiXmlAttribute::SetDoubleValue( double _value ) { - TCHAR buf [64]; - wsprintf (buf, TEXT("%lf"), _value); + wchar_t buf [64]; + wsprintf (buf, L"%lf", _value); SetValue (buf); } @@ -952,9 +952,9 @@ void TiXmlComment::Print( std::string& outputStream, int depth ) const void TiXmlComment::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << TEXT(""); + (*stream) << L"-->"; } TiXmlNode* TiXmlComment::Clone() const @@ -987,7 +987,7 @@ void TiXmlText::StreamOut( TIXML_OSTREAM * stream ) const TiXmlNode* TiXmlText::Clone() const { TiXmlText* clone = 0; - clone = new TiXmlText( TEXT("") ); + clone = new TiXmlText( L"" ); if ( !clone ) return 0; @@ -997,9 +997,9 @@ TiXmlNode* TiXmlText::Clone() const } -TiXmlDeclaration::TiXmlDeclaration( const TCHAR * _version, - const TCHAR * _encoding, - const TCHAR * _standalone ) +TiXmlDeclaration::TiXmlDeclaration( const wchar_t * _version, + const wchar_t * _encoding, + const wchar_t * _standalone ) : TiXmlNode( TiXmlNode::DECLARATION ) { version = _version; @@ -1037,27 +1037,27 @@ void TiXmlDeclaration::Print( std::string& outputStream, int /*depth*/ ) const void TiXmlDeclaration::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << TEXT(""); + (*stream) << L"?>"; } TiXmlNode* TiXmlDeclaration::Clone() const @@ -1085,7 +1085,7 @@ void TiXmlUnknown::Print( std::string& outputStream, int depth ) const void TiXmlUnknown::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << TEXT("<") << value << TEXT(">"); // Don't use entities hear! It is unknown. + (*stream) << L"<" << value << L">"; // Don't use entities hear! It is unknown. } TiXmlNode* TiXmlUnknown::Clone() const @@ -1143,7 +1143,7 @@ void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) assert( 0 ); // we tried to remove a non-linked attribute. } -TiXmlAttribute* TiXmlAttributeSet::Find( const TCHAR * name ) const +TiXmlAttribute* TiXmlAttributeSet::Find( const wchar_t * name ) const { TiXmlAttribute* node; @@ -1177,11 +1177,11 @@ TIXML_OSTREAM & operator<< (TIXML_OSTREAM & out, const TiXmlNode & base) #ifdef TIXML_USE_STL -generic_string & operator<< (generic_string& out, const TiXmlNode& base ) +std::wstring & operator<< (std::wstring& out, const TiXmlNode& base ) { //std::ostringstream os_stream( std::ostringstream::out ); - std::basic_ostringstream os_stream( std::ostringstream::out ); + std::basic_ostringstream os_stream( std::ostringstream::out ); base.StreamOut( &os_stream ); out.append( os_stream.str() ); @@ -1202,7 +1202,7 @@ TiXmlHandle TiXmlHandle::FirstChild() const } -TiXmlHandle TiXmlHandle::FirstChild( const TCHAR * value ) const +TiXmlHandle TiXmlHandle::FirstChild( const wchar_t * value ) const { if ( node ) { @@ -1226,7 +1226,7 @@ TiXmlHandle TiXmlHandle::FirstChildElement() const } -TiXmlHandle TiXmlHandle::FirstChildElement( const TCHAR * value ) const +TiXmlHandle TiXmlHandle::FirstChildElement( const wchar_t * value ) const { if ( node ) { @@ -1256,7 +1256,7 @@ TiXmlHandle TiXmlHandle::Child( int count ) const } -TiXmlHandle TiXmlHandle::Child( const TCHAR* value, int count ) const +TiXmlHandle TiXmlHandle::Child( const wchar_t* value, int count ) const { if ( node ) { @@ -1294,7 +1294,7 @@ TiXmlHandle TiXmlHandle::ChildElement( int count ) const } -TiXmlHandle TiXmlHandle::ChildElement( const TCHAR* value, int count ) const +TiXmlHandle TiXmlHandle::ChildElement( const wchar_t* value, int count ) const { if ( node ) { diff --git a/PowerEditor/src/TinyXml/tinyxml.h b/PowerEditor/src/TinyXml/tinyxml.h index 413e93385..fc0a749b2 100644 --- a/PowerEditor/src/TinyXml/tinyxml.h +++ b/PowerEditor/src/TinyXml/tinyxml.h @@ -47,9 +47,9 @@ distribution. #endif #ifdef TIXML_USE_STL - #define TIXML_STRING generic_string - #define TIXML_ISTREAM std::basic_istream - #define TIXML_OSTREAM std::basic_ostream + #define TIXML_STRING std::wstring + #define TIXML_ISTREAM std::basic_istream + #define TIXML_OSTREAM std::basic_ostream #else #include "tinystr.h" #define TIXML_STRING TiXmlString @@ -174,11 +174,11 @@ protected: public: StringToBuffer( const TIXML_STRING& str ); ~StringToBuffer(); - TCHAR* buffer; + wchar_t* buffer; }; - static const TCHAR* SkipWhiteSpace( const TCHAR* ); - inline static bool IsWhiteSpace( int c ) { return ( _istspace( static_cast(c) ) || c == '\n' || c == '\r' ); } + static const wchar_t* SkipWhiteSpace( const wchar_t* ); + inline static bool IsWhiteSpace( int c ) { return ( _istspace( static_cast(c) ) || c == '\n' || c == '\r' ); } virtual void StreamOut (TIXML_OSTREAM *) const = 0; @@ -187,28 +187,28 @@ protected: static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag ); #endif - /* Reads an XML name into the generic_string provided. Returns + /* Reads an XML name into the std::wstring provided. Returns a pointer just past the last character of the name, or 0 if the function has an error. */ - static const TCHAR* ReadName( const TCHAR* p, TIXML_STRING* name ); + static const wchar_t* ReadName( const wchar_t* p, TIXML_STRING* name ); /* Reads text. Returns a pointer past the given end tag. Wickedly complex options, but it keeps the (sensitive) code in one place. */ - static const TCHAR* ReadText( const TCHAR* in, // where to start - TIXML_STRING* text, // the generic_string read + static const wchar_t* ReadText( const wchar_t* in, // where to start + TIXML_STRING* text, // the std::wstring read bool ignoreWhiteSpace, // whether to keep the white space - const TCHAR* endTag, // what ends this text + const wchar_t* endTag, // what ends this text bool ignoreCase ); // whether to ignore case in the end tag - virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ) = 0; + virtual const wchar_t* Parse( const wchar_t* p, TiXmlParsingData* data ) = 0; // If an entity has been found, transform it into a character. - static const TCHAR* GetEntity( const TCHAR* in, TCHAR* value ); + static const wchar_t* GetEntity( const wchar_t* in, wchar_t* value ); // Get a character, while interpreting entities. - inline static const TCHAR* GetChar( const TCHAR* p, TCHAR* _value ) + inline static const wchar_t* GetChar( const wchar_t* p, wchar_t* _value ) { assert( p ); if ( *p == '&' ) @@ -222,15 +222,15 @@ protected: } } - // Puts a generic_string to a stream, expanding entities as it goes. + // Puts a std::wstring to a stream, expanding entities as it goes. // Note this should not contian the '<', '>', etc, or they will be transformed into entities! static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out ); static void PutString( const TIXML_STRING& str, TIXML_STRING* out ); // Return true if the next characters in the stream are any of the endTag sequences. - static bool StringEqual( const TCHAR* p, - const TCHAR* endTag, + static bool StringEqual( const wchar_t* p, + const wchar_t* endTag, bool ignoreCase ); @@ -253,16 +253,16 @@ protected: TIXML_ERROR_STRING_COUNT }; - static const TCHAR* errorString[ TIXML_ERROR_STRING_COUNT ]; + static const wchar_t* errorString[ TIXML_ERROR_STRING_COUNT ]; TiXmlCursor location; private: struct Entity { - const TCHAR* str; + const wchar_t* str; unsigned int strLength; - TCHAR chr; + wchar_t chr; }; enum { @@ -292,7 +292,7 @@ public: /** An input stream operator, for every class. Tolerant of newlines and formatting, but doesn't expect them. */ - friend std::basic_istream& operator >> (std::basic_istream& in, TiXmlNode& base); + friend std::basic_istream& operator >> (std::basic_istream& in, TiXmlNode& base); /** An output stream operator, for every class. Note that this outputs without any newlines or formatting, as opposed to Print(), which @@ -310,10 +310,10 @@ public: A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element. */ - friend std::basic_ostream& operator<< (std::basic_ostream& out, const TiXmlNode& base); + friend std::basic_ostream& operator<< (std::basic_ostream& out, const TiXmlNode& base); /// Appends the XML node or attribute to a string. - friend generic_string& operator<< (generic_string& out, const TiXmlNode& base ); + friend std::wstring& operator<< (std::wstring& out, const TiXmlNode& base ); #else // Used internally, not part of the public API. @@ -343,12 +343,12 @@ public: Element: name of the element Comment: the comment text Unknown: the tag contents - Text: the text generic_string + Text: the text std::wstring @endverbatim The subclasses will wrap this function. */ - const TCHAR * Value() const { return value.c_str (); } + const wchar_t * Value() const { return value.c_str (); } /** Changes the value of the node. Defined as: @verbatim @@ -356,14 +356,14 @@ public: Element: name of the element Comment: the comment text Unknown: the tag contents - Text: the text generic_string + Text: the text std::wstring @endverbatim */ - void SetValue(const TCHAR * _value) { value = _value;} + void SetValue(const wchar_t * _value) { value = _value;} #ifdef TIXML_USE_STL /// STL string form. - void SetValue( const generic_string& _value ) + void SetValue( const std::wstring& _value ) { StringToBuffer buf( _value ); SetValue( buf.buffer ? buf.buffer : TEXT("") ); @@ -377,14 +377,14 @@ public: TiXmlNode* Parent() const { return parent; } TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild( const TCHAR * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const wchar_t * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild( const TCHAR * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const wchar_t * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. #ifdef TIXML_USE_STL - TiXmlNode* FirstChild( const generic_string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::generic_string form. - TiXmlNode* LastChild( const generic_string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::generic_string form. + TiXmlNode* FirstChild( const std::wstring& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::std::wstring form. + TiXmlNode* LastChild( const std::wstring& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::std::wstring form. #endif /** An alternate way to walk the children of a node. @@ -406,10 +406,10 @@ public: TiXmlNode* IterateChildren( TiXmlNode* previous ) const; /// This flavor of IterateChildren searches for children with a particular 'value' - TiXmlNode* IterateChildren( const TCHAR * value, TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const wchar_t * value, TiXmlNode* previous ) const; #ifdef TIXML_USE_STL - TiXmlNode* IterateChildren( const generic_string& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::generic_string form. + TiXmlNode* IterateChildren( const std::wstring& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::std::wstring form. #endif /** Add a new node related to this. Adds a child past the LastChild. @@ -451,18 +451,18 @@ public: TiXmlNode* PreviousSibling() const { return prev; } /// Navigate to a sibling node. - TiXmlNode* PreviousSibling( const TCHAR * ) const; + TiXmlNode* PreviousSibling( const wchar_t * ) const; #ifdef TIXML_USE_STL - TiXmlNode* PreviousSibling( const generic_string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::generic_string form. - TiXmlNode* NextSibling( const generic_string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::generic_string form. + TiXmlNode* PreviousSibling( const std::wstring& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::std::wstring form. + TiXmlNode* NextSibling( const std::wstring& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::std::wstring form. #endif /// Navigate to a sibling node. TiXmlNode* NextSibling() const { return next; } /// Navigate to a sibling node with the given 'value'. - TiXmlNode* NextSibling( const TCHAR * ) const; + TiXmlNode* NextSibling( const wchar_t * ) const; /** Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element @@ -474,20 +474,20 @@ public: Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. */ - TiXmlElement* NextSiblingElement( const TCHAR * ) const; + TiXmlElement* NextSiblingElement( const wchar_t * ) const; #ifdef TIXML_USE_STL - TiXmlElement* NextSiblingElement( const generic_string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::generic_string form. + TiXmlElement* NextSiblingElement( const std::wstring& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::std::wstring form. #endif /// Convenience function to get through elements. TiXmlElement* FirstChildElement() const; /// Convenience function to get through elements. - TiXmlElement* FirstChildElement( const TCHAR * value ) const; + TiXmlElement* FirstChildElement( const wchar_t * value ) const; #ifdef TIXML_USE_STL - TiXmlElement* FirstChildElement( const generic_string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::generic_string form. + TiXmlElement* FirstChildElement( const std::wstring& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::std::wstring form. #endif /** Query the type (as an enumerated value, above) of this node. @@ -525,7 +525,7 @@ protected: #endif // Figure out what is at *p, and parse it. Returns null if it is not an xml node. - TiXmlNode* Identify( const TCHAR* start ); + TiXmlNode* Identify( const wchar_t* start ); void CopyToClone( TiXmlNode* target ) const { target->SetValue (value.c_str() ); target->userData = userData; } @@ -567,7 +567,7 @@ public: #ifdef TIXML_USE_STL /// string constructor. - TiXmlAttribute( const generic_string& _name, const generic_string& _value ) + TiXmlAttribute( const std::wstring& _name, const std::wstring& _value ) { name = _name; value = _value; @@ -577,7 +577,7 @@ public: #endif /// Construct an attribute with a name and value. - TiXmlAttribute( const TCHAR * _name, const TCHAR * _value ) + TiXmlAttribute( const wchar_t * _name, const wchar_t * _value ) { name = _name; value = _value; @@ -585,12 +585,12 @@ public: prev = next = 0; } - const TCHAR* Name() const { return name.c_str (); } ///< Return the name of this attribute. - const TCHAR* Value() const { return value.c_str (); } ///< Return the value of this attribute. + const wchar_t* Name() const { return name.c_str (); } ///< Return the name of this attribute. + const wchar_t* Value() const { return value.c_str (); } ///< Return the value of this attribute. int IntValue() const; ///< Return the value of this attribute, converted to an integer. double DoubleValue() const; ///< Return the value of this attribute, converted to a double. - /** QueryIntValue examines the value generic_string. It is an alternative to the + /** QueryIntValue examines the value std::wstring. It is an alternative to the IntValue() method with richer error checking. If the value is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not @@ -600,24 +600,24 @@ public: which is the opposite of almost all other TinyXml calls. */ int QueryIntValue( int* value ) const; - /// QueryDoubleValue examines the value generic_string. See QueryIntValue(). + /// QueryDoubleValue examines the value std::wstring. See QueryIntValue(). int QueryDoubleValue( double* value ) const; - void SetName( const TCHAR* _name ) { name = _name; } ///< Set the name of this attribute. - void SetValue( const TCHAR* _value ) { value = _value; } ///< Set the value. + void SetName( const wchar_t* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const wchar_t* _value ) { value = _value; } ///< Set the value. void SetIntValue( int value ); ///< Set the value from an integer. void SetDoubleValue( double value ); ///< Set the value from a double. #ifdef TIXML_USE_STL /// STL string form. - void SetName( const generic_string& _name ) + void SetName( const std::wstring& _name ) { StringToBuffer buf( _name ); SetName ( buf.buffer ? buf.buffer : TEXT("error") ); } /// STL string form. - void SetValue( const generic_string& _value ) + void SetValue( const std::wstring& _value ) { StringToBuffer buf( _value ); SetValue( buf.buffer ? buf.buffer : TEXT("error") ); @@ -635,9 +635,9 @@ public: /* [internal use] Attribtue parsing starts: first letter of the name - returns: the next TCHAR after the value end quote + returns: the next wchar_t after the value end quote */ - virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); + virtual const wchar_t* Parse( const wchar_t* p, TiXmlParsingData* data ); // [internal use] virtual void Print( std::string& outputStream, int depth ) const; @@ -679,7 +679,7 @@ public: TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Find( const TCHAR * name ) const; + TiXmlAttribute* Find( const wchar_t * name ) const; private: TiXmlAttribute sentinel; @@ -694,11 +694,11 @@ class TiXmlElement : public TiXmlNode { public: /// Construct an element. - TiXmlElement (const TCHAR * in_value); + TiXmlElement (const wchar_t * in_value); #ifdef TIXML_USE_STL /// string constructor. - TiXmlElement( const generic_string& _value ) : TiXmlNode( TiXmlNode::ELEMENT ) + TiXmlElement( const std::wstring& _value ) : TiXmlNode( TiXmlNode::ELEMENT ) { firstChild = lastChild = 0; value = _value; @@ -710,7 +710,7 @@ public: /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. */ - const TCHAR* Attribute( const TCHAR* name ) const; + const wchar_t* Attribute( const wchar_t* name ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. @@ -718,7 +718,7 @@ public: the integer value will be put in the return 'i', if 'i' is non-null. */ - const TCHAR* Attribute( const TCHAR* name, int* i ) const; + const wchar_t* Attribute( const wchar_t* name, int* i ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. @@ -726,7 +726,7 @@ public: the double value will be put in the return 'd', if 'd' is non-null. */ - const TCHAR* Attribute( const TCHAR* name, double* d ) const; + const wchar_t* Attribute( const wchar_t* name, double* d ) const; /** QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking. @@ -735,21 +735,21 @@ public: an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned. */ - int QueryIntAttribute( const TCHAR* name, int* value ) const; + int QueryIntAttribute( const wchar_t* name, int* value ) const; /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). - int QueryDoubleAttribute( const TCHAR* name, double* value ) const; + int QueryDoubleAttribute( const wchar_t* name, double* value ) const; /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ - void SetAttribute( const TCHAR* name, const TCHAR * value ); + void SetAttribute( const wchar_t* name, const wchar_t * value ); #ifdef TIXML_USE_STL - const TCHAR* Attribute( const generic_string& name ) const { return Attribute( name.c_str() ); } - const TCHAR* Attribute( const generic_string& name, int* i ) const { return Attribute( name.c_str(), i ); } + const wchar_t* Attribute( const std::wstring& name ) const { return Attribute( name.c_str() ); } + const wchar_t* Attribute( const std::wstring& name, int* i ) const { return Attribute( name.c_str(), i ); } /// STL string form. - void SetAttribute( const generic_string& name, const generic_string& _value ) + void SetAttribute( const std::wstring& name, const std::wstring& _value ) { StringToBuffer n( name ); StringToBuffer v( _value ); @@ -757,7 +757,7 @@ public: SetAttribute (n.buffer, v.buffer ); } ///< STL string form. - void SetAttribute( const generic_string& name, int _value ) + void SetAttribute( const std::wstring& name, int _value ) { StringToBuffer n( name ); if ( n.buffer ) @@ -768,13 +768,13 @@ public: /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ - void SetAttribute( const TCHAR * name, int value ); + void SetAttribute( const wchar_t * name, int value ); /** Deletes an attribute with the given name. */ - void RemoveAttribute( const TCHAR * name ); + void RemoveAttribute( const wchar_t * name ); #ifdef TIXML_USE_STL - void RemoveAttribute( const generic_string& name ) { RemoveAttribute (name.c_str ()); } ///< STL string form. + void RemoveAttribute( const std::wstring& name ) { RemoveAttribute (name.c_str ()); } ///< STL string form. #endif TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. @@ -795,16 +795,16 @@ protected: virtual void StreamOut( TIXML_OSTREAM * out ) const; /* [internal use] - Attribtue parsing starts: next TCHAR past '<' - returns: next TCHAR past '>' + Attribtue parsing starts: next wchar_t past '<' + returns: next wchar_t past '>' */ - virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); + virtual const wchar_t* Parse( const wchar_t* p, TiXmlParsingData* data ); /* [internal use] Reads the "value" of the element -- another element, or text. This should terminate with the current end tag. */ - const TCHAR* ReadValue( const TCHAR* in, TiXmlParsingData* prevData ); + const wchar_t* ReadValue( const wchar_t* in, TiXmlParsingData* prevData ); private: TiXmlAttributeSet attributeSet; @@ -832,9 +832,9 @@ protected: virtual void StreamOut( TIXML_OSTREAM * out ) const; /* [internal use] Attribtue parsing starts: at the ! of the !-- - returns: next TCHAR past '>' + returns: next wchar_t past '>' */ - virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); + virtual const wchar_t* Parse( const wchar_t* p, TiXmlParsingData* data ); }; @@ -845,7 +845,7 @@ class TiXmlText : public TiXmlNode friend class TiXmlElement; public: /// Constructor. - TiXmlText (const TCHAR * initValue) : TiXmlNode (TiXmlNode::TEXT) + TiXmlText (const wchar_t * initValue) : TiXmlNode (TiXmlNode::TEXT) { SetValue( initValue ); } @@ -853,7 +853,7 @@ public: #ifdef TIXML_USE_STL /// Constructor. - TiXmlText( const generic_string& initValue ) : TiXmlNode (TiXmlNode::TEXT) + TiXmlText( const std::wstring& initValue ) : TiXmlNode (TiXmlNode::TEXT) { SetValue( initValue ); } @@ -869,10 +869,10 @@ protected : // [internal use] bool Blank() const; // returns true if all white space and new lines /* [internal use] - Attribtue parsing starts: First TCHAR of the text - returns: next TCHAR past '>' + Attribtue parsing starts: First wchar_t of the text + returns: next wchar_t past '>' */ - virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); + virtual const wchar_t* Parse( const wchar_t* p, TiXmlParsingData* data ); // [internal use] #ifdef TIXML_USE_STL virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); @@ -901,9 +901,9 @@ public: #ifdef TIXML_USE_STL /// Constructor. - TiXmlDeclaration( const generic_string& _version, - const generic_string& _encoding, - const generic_string& _standalone ) + TiXmlDeclaration( const std::wstring& _version, + const std::wstring& _encoding, + const std::wstring& _standalone ) : TiXmlNode( TiXmlNode::DECLARATION ) { version = _version; @@ -913,18 +913,18 @@ public: #endif /// Construct. - TiXmlDeclaration( const TCHAR* _version, - const TCHAR* _encoding, - const TCHAR* _standalone ); + TiXmlDeclaration( const wchar_t* _version, + const wchar_t* _encoding, + const wchar_t* _standalone ); virtual ~TiXmlDeclaration() {} /// Version. Will return empty if none was found. - const TCHAR * Version() const { return version.c_str (); } + const wchar_t * Version() const { return version.c_str (); } /// Encoding. Will return empty if none was found. - const TCHAR * Encoding() const { return encoding.c_str (); } + const wchar_t * Encoding() const { return encoding.c_str (); } /// Is this a standalone document? - const TCHAR * Standalone() const { return standalone.c_str (); } + const wchar_t * Standalone() const { return standalone.c_str (); } // [internal use] Creates a new Element and returs it. virtual TiXmlNode* Clone() const; @@ -938,10 +938,10 @@ protected: #endif virtual void StreamOut ( TIXML_OSTREAM * out) const; // [internal use] - // Attribtue parsing starts: next TCHAR past '<' - // returns: next TCHAR past '>' + // Attribtue parsing starts: next wchar_t past '<' + // returns: next wchar_t past '>' - virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); + virtual const wchar_t* Parse( const wchar_t* p, TiXmlParsingData* data ); private: TIXML_STRING version; @@ -971,10 +971,10 @@ protected: #endif virtual void StreamOut ( TIXML_OSTREAM * out ) const; /* [internal use] - Attribute parsing starts: First TCHAR of the text - returns: next TCHAR past '>' + Attribute parsing starts: First wchar_t of the text + returns: next wchar_t past '>' */ - virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); + virtual const wchar_t* Parse( const wchar_t* p, TiXmlParsingData* data ); }; @@ -988,11 +988,11 @@ public: /// Create an empty document, that has no name. TiXmlDocument(); /// Create a document with a name. The name of the document is also the filename of the xml. - TiXmlDocument( const TCHAR * documentName ); + TiXmlDocument( const wchar_t * documentName ); #ifdef TIXML_USE_STL /// Constructor. - TiXmlDocument( const generic_string& documentName ) : + TiXmlDocument( const std::wstring& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { tabsize = 4; @@ -1011,17 +1011,17 @@ public: /// Save a file using the current document value. Returns true if successful. bool SaveFile() const; /// Load a file using the given filename. Returns true if successful. - bool LoadFile( const TCHAR * filename ); + bool LoadFile( const wchar_t * filename ); /// Save a file using the given filename. Returns true if successful. - bool SaveFile( const TCHAR * filename ) const; + bool SaveFile( const wchar_t * filename ) const; #ifdef TIXML_USE_STL - bool LoadFile( const generic_string& filename ) ///< STL string version. + bool LoadFile( const std::wstring& filename ) ///< STL string version. { StringToBuffer f( filename ); return ( f.buffer && LoadFile( f.buffer )); } - bool SaveFile( const generic_string& filename ) const ///< STL string version. + bool SaveFile( const std::wstring& filename ) const ///< STL string version. { StringToBuffer f( filename ); return ( f.buffer && SaveFile( f.buffer )); @@ -1030,7 +1030,7 @@ public: /** Parse the given null terminated block of xml data. */ - virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data = 0 ); + virtual const wchar_t* Parse( const wchar_t* p, TiXmlParsingData* data = 0 ); /** Get the root element -- the only top level element -- of the document. In well formed XML, there should only be one. TinyXml is tolerant of @@ -1046,9 +1046,9 @@ public: bool Error() const { return error; } /// Contains a textual (english) description of the error if one occurs. - const TCHAR * ErrorDesc() const { return errorDesc.c_str (); } + const wchar_t * ErrorDesc() const { return errorDesc.c_str (); } - /** Generally, you probably want the error generic_string ( ErrorDesc() ). But if you + /** Generally, you probably want the error std::wstring ( ErrorDesc() ). But if you prefer the ErrorId, this function will fetch it. */ int ErrorId() const { return errorId; } @@ -1103,7 +1103,7 @@ public: // [internal use] virtual void Print( std::string& outputStream, int depth = 0 ) const; // [internal use] - void SetError( int err, const TCHAR* errorLocation, TiXmlParsingData* prevData ); + void SetError( int err, const wchar_t* errorLocation, TiXmlParsingData* prevData ); protected : virtual void StreamOut ( TIXML_OSTREAM * out) const; @@ -1213,16 +1213,16 @@ public: /// Return a handle to the first child node. TiXmlHandle FirstChild() const; /// Return a handle to the first child node with the given name. - TiXmlHandle FirstChild( const TCHAR * value ) const; + TiXmlHandle FirstChild( const wchar_t * value ) const; /// Return a handle to the first child element. TiXmlHandle FirstChildElement() const; /// Return a handle to the first child element with the given name. - TiXmlHandle FirstChildElement( const TCHAR * value ) const; + TiXmlHandle FirstChildElement( const wchar_t * value ) const; /** Return a handle to the "index" child with the given name. The first child is 0, the second 1, etc. */ - TiXmlHandle Child( const TCHAR* value, int index ) const; + TiXmlHandle Child( const wchar_t* value, int index ) const; /** Return a handle to the "index" child. The first child is 0, the second 1, etc. */ @@ -1231,7 +1231,7 @@ public: The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. */ - TiXmlHandle ChildElement( const TCHAR* value, int index ) const; + TiXmlHandle ChildElement( const wchar_t* value, int index ) const; /** Return a handle to the "index" child element. The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. @@ -1239,11 +1239,11 @@ public: TiXmlHandle ChildElement( int index ) const; #ifdef TIXML_USE_STL - TiXmlHandle FirstChild( const generic_string& _value ) const { return FirstChild( _value.c_str() ); } - TiXmlHandle FirstChildElement( const generic_string& _value ) const { return FirstChildElement( _value.c_str() ); } + TiXmlHandle FirstChild( const std::wstring& _value ) const { return FirstChild( _value.c_str() ); } + TiXmlHandle FirstChildElement( const std::wstring& _value ) const { return FirstChildElement( _value.c_str() ); } - TiXmlHandle Child( const generic_string& _value, int index ) const { return Child( _value.c_str(), index ); } - TiXmlHandle ChildElement( const generic_string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } + TiXmlHandle Child( const std::wstring& _value, int index ) const { return Child( _value.c_str(), index ); } + TiXmlHandle ChildElement( const std::wstring& _value, int index ) const { return ChildElement( _value.c_str(), index ); } #endif /// Return the handle as a TiXmlNode. This may return null. diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index fc863b12b..e01f254fd 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -65,9 +65,9 @@ FileBrowser::~FileBrowser() _iconListVector.clear(); } -vector split(const generic_string & string2split, TCHAR sep) +vector split(const wstring & string2split, wchar_t sep) { - vector splitedStrings; + vector splitedStrings; size_t len = string2split.length(); size_t beginPos = 0; for (size_t i = 0; i < len + 1; ++i) @@ -81,7 +81,7 @@ vector split(const generic_string & string2split, TCHAR sep) return splitedStrings; } -bool isRelatedRootFolder(const generic_string & relatedRoot, const generic_string & subFolder) +bool isRelatedRootFolder(const wstring & relatedRoot, const wstring & subFolder) { if (relatedRoot.empty()) return false; @@ -93,8 +93,8 @@ bool isRelatedRootFolder(const generic_string & relatedRoot, const generic_strin if (pos != 0) // pos == 0 is the necessary condition, but not enough return false; - vector relatedRootArray = split(relatedRoot, '\\'); - vector subFolderArray = split(subFolder, '\\'); + vector relatedRootArray = split(relatedRoot, '\\'); + vector subFolderArray = split(subFolder, '\\'); size_t index2Compare = relatedRootArray.size() - 1; @@ -319,31 +319,31 @@ intptr_t CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM l case FB_RNFILE: { - const std::vector file2Change = *(std::vector *)lParam; - generic_string separator = TEXT("\\\\"); + const std::vector file2Change = *(std::vector *)lParam; + wstring separator = L"\\\\"; size_t sepPos = file2Change[0].find(separator); - if (sepPos == generic_string::npos) + if (sepPos == wstring::npos) return false; - generic_string pathSuffix = file2Change[0].substr(sepPos + separator.length(), file2Change[0].length() - 1); + wstring pathSuffix = file2Change[0].substr(sepPos + separator.length(), file2Change[0].length() - 1); // remove prefix of file/folder in changeInfo, splite the remained path - vector linarPathArray = split(pathSuffix, '\\'); + vector linarPathArray = split(pathSuffix, '\\'); - generic_string rootPath = file2Change[0].substr(0, sepPos); + wstring rootPath = file2Change[0].substr(0, sepPos); size_t sepPos2 = file2Change[1].find(separator); - if (sepPos2 == generic_string::npos) + if (sepPos2 == wstring::npos) return false; - generic_string pathSuffix2 = file2Change[1].substr(sepPos2 + separator.length(), file2Change[1].length() - 1); - vector linarPathArray2 = split(pathSuffix2, '\\'); + wstring pathSuffix2 = file2Change[1].substr(sepPos2 + separator.length(), file2Change[1].length() - 1); + vector linarPathArray2 = split(pathSuffix2, '\\'); bool isRenamed = renameInTree(rootPath, nullptr, linarPathArray, linarPathArray2[linarPathArray2.size() - 1]); if (!isRenamed) { - //MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK); + //MessageBox(NULL, file2Change[0].c_str(), L"file/folder is not removed", MB_OK); } break; } @@ -358,16 +358,16 @@ void FileBrowser::initPopupMenus() { NativeLangSpeaker* pNativeSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); - generic_string addRoot = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_ADDROOT, FB_ADDROOT); - generic_string removeAllRoot = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_REMOVEALLROOTS, FB_REMOVEALLROOTS); - generic_string removeRootFolder = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_REMOVEROOTFOLDER, FB_REMOVEROOTFOLDER); - generic_string copyPath = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_COPYPATH, FB_COPYPATH); - generic_string copyFileName = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_COPYFILENAME, FB_COPYFILENAME); - generic_string findInFile = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_FINDINFILES, FB_FINDINFILES); - generic_string explorerHere = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_EXPLORERHERE, FB_EXPLORERHERE); - generic_string cmdHere = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_CMDHERE, FB_CMDHERE); - generic_string openInNpp = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_OPENINNPP, FB_OPENINNPP); - generic_string shellExecute = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_SHELLEXECUTE, FB_SHELLEXECUTE); + wstring addRoot = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_ADDROOT, FB_ADDROOT); + wstring removeAllRoot = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_REMOVEALLROOTS, FB_REMOVEALLROOTS); + wstring removeRootFolder = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_REMOVEROOTFOLDER, FB_REMOVEROOTFOLDER); + wstring copyPath = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_COPYPATH, FB_COPYPATH); + wstring copyFileName = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_COPYFILENAME, FB_COPYFILENAME); + wstring findInFile = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_FINDINFILES, FB_FINDINFILES); + wstring explorerHere = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_EXPLORERHERE, FB_EXPLORERHERE); + wstring cmdHere = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_CMDHERE, FB_CMDHERE); + wstring openInNpp = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_OPENINNPP, FB_OPENINNPP); + wstring shellExecute = pNativeSpeaker->getDlgLangMenuStr(FOLDERASWORKSPACE_NODE, nullptr, IDM_FILEBROWSER_SHELLEXECUTE, FB_SHELLEXECUTE); _hGlobalMenu = ::CreatePopupMenu(); ::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_ADDROOT, addRoot.c_str()); @@ -400,7 +400,7 @@ void FileBrowser::initPopupMenus() ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, cmdHere.c_str()); } -bool FileBrowser::selectItemFromPath(const generic_string& itemPath) const +bool FileBrowser::selectItemFromPath(const wstring& itemPath) const { if (itemPath.empty()) return false; @@ -411,19 +411,19 @@ bool FileBrowser::selectItemFromPath(const generic_string& itemPath) const { if (isRelatedRootFolder(f->_rootFolder._rootPath, itemPath)) { - generic_string rootPath = f->_rootFolder._rootPath; + wstring rootPath = f->_rootFolder._rootPath; size_t rootPathLen = rootPath.size(); if (rootPathLen > itemPathLen) // It should never happen return false; - vector linarPathArray; + vector linarPathArray; if (rootPathLen == itemPathLen) { // Do nothing and use empty linarPathArray } else { - generic_string pathSuffix = itemPath.substr(rootPathLen + 1, itemPathLen - rootPathLen); + wstring pathSuffix = itemPath.substr(rootPathLen + 1, itemPathLen - rootPathLen); linarPathArray = split(pathSuffix, '\\'); } HTREEITEM foundItem = findInTree(rootPath, nullptr, linarPathArray); @@ -441,9 +441,9 @@ bool FileBrowser::selectItemFromPath(const generic_string& itemPath) const bool FileBrowser::selectCurrentEditingFile() const { - TCHAR currentDocPath[MAX_PATH] = { '\0' }; + wchar_t currentDocPath[MAX_PATH] = { '\0' }; ::SendMessage(_hParent, NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast(currentDocPath)); - generic_string currentDocPathStr = currentDocPath; + wstring currentDocPathStr = currentDocPath; return selectItemFromPath(currentDocPathStr); } @@ -456,18 +456,18 @@ void FileBrowser::destroyMenus() ::DestroyMenu(_hFileMenu); } -generic_string FileBrowser::getNodePath(HTREEITEM node) const +wstring FileBrowser::getNodePath(HTREEITEM node) const { - if (!node) return TEXT(""); + if (!node) return L""; - vector fullPathArray; - generic_string fullPath; + vector fullPathArray; + wstring fullPath; // go up until to root, then get the full path HTREEITEM parent = node; for (; parent != nullptr;) { - generic_string folderName = _treeView.getItemDisplayName(parent); + wstring folderName = _treeView.getItemDisplayName(parent); HTREEITEM temp = _treeView.getParent(parent); if (temp == nullptr) @@ -484,15 +484,15 @@ generic_string FileBrowser::getNodePath(HTREEITEM node) const { fullPath += fullPathArray[i]; if (i != 0) - fullPath += TEXT("\\"); + fullPath += L"\\"; } return fullPath; } -generic_string FileBrowser::getNodeName(HTREEITEM node) const +wstring FileBrowser::getNodeName(HTREEITEM node) const { - return node ? _treeView.getItemDisplayName(node) : TEXT(""); + return node ? _treeView.getItemDisplayName(node) : L""; } void FileBrowser::openSelectFile() @@ -539,7 +539,7 @@ void FileBrowser::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; @@ -571,11 +571,11 @@ void FileBrowser::notified(LPNMHDR notification) // Find the position of old label in File path SortingData4lParam* customData = reinterpret_cast(tvnotif->item.lParam); - generic_string *filePath = &(customData->_rootPath); + wstring *filePath = &(customData->_rootPath); 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 @@ -600,11 +600,11 @@ void FileBrowser::notified(LPNMHDR notification) case TVN_GETINFOTIP: { LPNMTVGETINFOTIP lpGetInfoTip = (LPNMTVGETINFOTIP)notification; - static generic_string tipStr; + static wstring tipStr; BrowserNodeType nType = getNodeType(lpGetInfoTip->hItem); if (nType == browserNodeType_root) { - tipStr = *((generic_string *)lpGetInfoTip->lParam); + tipStr = *((wstring *)lpGetInfoTip->lParam); } else if (nType == browserNodeType_file) { @@ -801,14 +801,14 @@ void FileBrowser::popupMenuCmd(int cmdID) { if (!selectedNode) return; - generic_string path = getNodePath(selectedNode); + wstring path = getNodePath(selectedNode); if (::PathFileExists(path.c_str())) { - TCHAR cmdStr[1024] = {}; + wchar_t cmdStr[1024] = {}; if (getNodeType(selectedNode) == browserNodeType_file) - wsprintf(cmdStr, TEXT("explorer /select,\"%s\""), path.c_str()); + wsprintf(cmdStr, L"explorer /select,\"%s\"", path.c_str()); else - wsprintf(cmdStr, TEXT("explorer \"%s\""), path.c_str()); + wsprintf(cmdStr, L"explorer \"%s\"", path.c_str()); Command cmd(cmdStr); cmd.run(nullptr); } @@ -822,7 +822,7 @@ void FileBrowser::popupMenuCmd(int cmdID) if (getNodeType(selectedNode) == browserNodeType_file) selectedNode = _treeView.getParent(selectedNode); - generic_string path = getNodePath(selectedNode); + wstring path = getNodePath(selectedNode); if (::PathFileExists(path.c_str())) { Command cmd(NppParameters::getInstance().getNppGUI()._commandLineInterpreter.c_str()); @@ -834,7 +834,7 @@ void FileBrowser::popupMenuCmd(int cmdID) case IDM_FILEBROWSER_COPYPATH: { if (!selectedNode) return; - generic_string path = getNodePath(selectedNode); + wstring path = getNodePath(selectedNode); str2Clipboard(path, _hParent); } break; @@ -842,7 +842,7 @@ void FileBrowser::popupMenuCmd(int cmdID) case IDM_FILEBROWSER_COPYFILENAME: { if (!selectedNode) return; - generic_string fileName = getNodeName(selectedNode); + wstring fileName = getNodeName(selectedNode); str2Clipboard(fileName, _hParent); } break; @@ -850,7 +850,7 @@ void FileBrowser::popupMenuCmd(int cmdID) case IDM_FILEBROWSER_FINDINFILES: { if (!selectedNode) return; - generic_string path = getNodePath(selectedNode); + wstring path = getNodePath(selectedNode); ::SendMessage(_hParent, NPPM_LAUNCHFINDINFILESDLG, reinterpret_cast(path.c_str()), 0); } break; @@ -879,8 +879,8 @@ void FileBrowser::popupMenuCmd(int cmdID) case IDM_FILEBROWSER_ADDROOT: { NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); - generic_string openWorkspaceStr = pNativeSpeaker->getAttrNameStr(TEXT("Select a folder to add in Folder as Workspace panel"), FOLDERASWORKSPACE_NODE, "SelectFolderFromBrowserString"); - generic_string folderPath = folderBrowser(_hParent, openWorkspaceStr); + wstring openWorkspaceStr = pNativeSpeaker->getAttrNameStr(L"Select a folder to add in Folder as Workspace panel", FOLDERASWORKSPACE_NODE, "SelectFolderFromBrowserString"); + wstring folderPath = folderBrowser(_hParent, openWorkspaceStr); if (!folderPath.empty()) { addRootFolder(folderPath); @@ -891,10 +891,10 @@ void FileBrowser::popupMenuCmd(int cmdID) case IDM_FILEBROWSER_SHELLEXECUTE: { if (!selectedNode) return; - generic_string path = getNodePath(selectedNode); + wstring path = getNodePath(selectedNode); if (::PathFileExists(path.c_str())) - ::ShellExecute(NULL, TEXT("open"), path.c_str(), NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, L"open", path.c_str(), NULL, NULL, SW_SHOWNORMAL); } break; } @@ -902,15 +902,15 @@ void FileBrowser::popupMenuCmd(int cmdID) -void FileBrowser::getDirectoryStructure(const TCHAR *dir, const std::vector & patterns, FolderInfo & directoryStructure, bool isRecursive, bool isInHiddenDir) +void FileBrowser::getDirectoryStructure(const wchar_t *dir, const std::vector & patterns, FolderInfo & directoryStructure, bool isRecursive, bool isInHiddenDir) { if (directoryStructure._parent == nullptr) // Root! directoryStructure.setRootPath(dir); - generic_string dirFilter(dir); + wstring dirFilter(dir); if (dirFilter[dirFilter.length() - 1] != '\\') - dirFilter += TEXT("\\"); - dirFilter += TEXT("*.*"); + dirFilter += L"\\"; + dirFilter += L"*.*"; WIN32_FIND_DATA foundData; HANDLE hFindFile = ::FindFirstFile(dirFilter.c_str(), &foundData); @@ -926,14 +926,14 @@ void FileBrowser::getDirectoryStructure(const TCHAR *dir, const std::vector_rootFolder._rootPath, rootFolderPath)) { //do nothing, go down to select the dir - generic_string rootPath = f->_rootFolder._rootPath; - generic_string pathSuffix = rootFolderPath.substr(rootPath.size() + 1, rootFolderPath.size() - rootPath.size()); - vector linarPathArray = split(pathSuffix, '\\'); + wstring rootPath = f->_rootFolder._rootPath; + wstring pathSuffix = rootFolderPath.substr(rootPath.size() + 1, rootFolderPath.size() - rootPath.size()); + vector linarPathArray = split(pathSuffix, '\\'); HTREEITEM foundItem = findInTree(rootPath, nullptr, linarPathArray); if (foundItem) @@ -990,8 +990,8 @@ void FileBrowser::addRootFolder(generic_string rootFolderPath) { NppParameters::getInstance().getNativeLangSpeaker()->messageBox("FolderAsWorspaceSubfolderExists", _hParent, - TEXT("A sub-folder of the folder you want to add exists.\rPlease remove its root from the panel before you add folder \"$STR_REPLACE$\"."), - TEXT("Folder as Workspace adding folder problem"), + L"A sub-folder of the folder you want to add exists.\rPlease remove its root from the panel before you add folder \"$STR_REPLACE$\".", + L"Folder as Workspace adding folder problem", MB_OK, 0, // not used rootFolderPath.c_str()); @@ -1000,11 +1000,11 @@ void FileBrowser::addRootFolder(generic_string rootFolderPath) } } - std::vector patterns2Match; - patterns2Match.push_back(TEXT("*.*")); + std::vector patterns2Match; + patterns2Match.push_back(L"*.*"); - TCHAR *label = ::PathFindFileName(rootFolderPath.c_str()); - TCHAR rootLabel[MAX_PATH] = {'\0'}; + wchar_t *label = ::PathFindFileName(rootFolderPath.c_str()); + wchar_t rootLabel[MAX_PATH] = {'\0'}; wcscpy_s(rootLabel, label); size_t len = lstrlen(rootLabel); if (rootLabel[len - 1] == '\\') @@ -1023,20 +1023,20 @@ HTREEITEM FileBrowser::createFolderItemsFromDirStruct(HTREEITEM hParentItem, con HTREEITEM hFolderItem = nullptr; if (directoryStructure._parent == nullptr && hParentItem == nullptr) { - TCHAR rootPath[MAX_PATH] = { '\0' }; + wchar_t rootPath[MAX_PATH] = { '\0' }; wcscpy_s(rootPath, directoryStructure._rootPath.c_str()); size_t len = lstrlen(rootPath); if (rootPath[len - 1] == '\\') rootPath[len - 1] = '\0'; - SortingData4lParam* customData = new SortingData4lParam(rootPath, TEXT(""), true); + SortingData4lParam* customData = new SortingData4lParam(rootPath, L"", true); sortingDataArray.push_back(customData); hFolderItem = _treeView.addItem(directoryStructure._name.c_str(), TVI_ROOT, INDEX_CLOSE_ROOT, reinterpret_cast(customData)); } else { - SortingData4lParam* customData = new SortingData4lParam(TEXT(""), directoryStructure._name, true); + SortingData4lParam* customData = new SortingData4lParam(L"", directoryStructure._name, true); sortingDataArray.push_back(customData); hFolderItem = _treeView.addItem(directoryStructure._name.c_str(), hParentItem, INDEX_CLOSE_NODE, reinterpret_cast(customData)); @@ -1049,7 +1049,7 @@ HTREEITEM FileBrowser::createFolderItemsFromDirStruct(HTREEITEM hParentItem, con for (const auto& file : directoryStructure._files) { - SortingData4lParam* customData = new SortingData4lParam(TEXT(""), file._name, false); + SortingData4lParam* customData = new SortingData4lParam(L"", file._name, false); sortingDataArray.push_back(customData); _treeView.addItem(file._name.c_str(), hFolderItem, INDEX_LEAF, reinterpret_cast(customData)); @@ -1060,7 +1060,7 @@ HTREEITEM FileBrowser::createFolderItemsFromDirStruct(HTREEITEM hParentItem, con return hFolderItem; } -HTREEITEM FileBrowser::getRootFromFullPath(const generic_string & rootPath) const +HTREEITEM FileBrowser::getRootFromFullPath(const wstring & rootPath) const { HTREEITEM node = nullptr; for (HTREEITEM hItemNode = _treeView.getRoot(); @@ -1079,13 +1079,13 @@ HTREEITEM FileBrowser::getRootFromFullPath(const generic_string & rootPath) cons return node; } -HTREEITEM FileBrowser::findChildNodeFromName(HTREEITEM parent, const generic_string& label) const +HTREEITEM FileBrowser::findChildNodeFromName(HTREEITEM parent, const wstring& label) const { for (HTREEITEM hItemNode = _treeView.getChildFrom(parent); hItemNode != NULL; hItemNode = _treeView.getNextSibling(hItemNode)) { - TCHAR textBuffer[MAX_PATH] = { '\0' }; + wchar_t textBuffer[MAX_PATH] = { '\0' }; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT; tvItem.pszText = textBuffer; @@ -1101,9 +1101,9 @@ HTREEITEM FileBrowser::findChildNodeFromName(HTREEITEM parent, const generic_str return nullptr; } -vector FileBrowser::getRoots() const +vector FileBrowser::getRoots() const { - vector roots; + vector roots; for (HTREEITEM hItemNode = _treeView.getRoot(); hItemNode != nullptr; @@ -1120,9 +1120,9 @@ vector FileBrowser::getRoots() const return roots; } -generic_string FileBrowser::getSelectedItemPath() const +wstring FileBrowser::getSelectedItemPath() const { - generic_string itemPath; + wstring itemPath; HTREEITEM hItemNode = _treeView.getSelection(); if (hItemNode) { @@ -1133,38 +1133,38 @@ generic_string FileBrowser::getSelectedItemPath() const std::vector FileBrowser::getFilesFromParam(LPARAM lParam) const { - const std::vector filesToChange = *(std::vector*)lParam; - const generic_string separator = TEXT("\\\\"); + const std::vector filesToChange = *(std::vector*)lParam; + const wstring separator = L"\\\\"; const size_t separatorLength = separator.length(); std::vector groupedFiles; for (size_t i = 0; i < filesToChange.size(); i++) { const size_t sepPos = filesToChange[i].find(separator); - if (sepPos == generic_string::npos) + if (sepPos == wstring::npos) continue; - const generic_string pathSuffix = filesToChange[i].substr(sepPos + separatorLength, filesToChange[i].length() - 1); + const wstring pathSuffix = filesToChange[i].substr(sepPos + separatorLength, filesToChange[i].length() - 1); // remove prefix of file/folder in changeInfo, split the remained path - vector linarPathArray = split(pathSuffix, '\\'); + vector linarPathArray = split(pathSuffix, '\\'); - const generic_string lastElement = linarPathArray.back(); + const wstring lastElement = linarPathArray.back(); linarPathArray.pop_back(); - const generic_string rootPath = filesToChange[i].substr(0, sepPos); + const wstring rootPath = filesToChange[i].substr(0, sepPos); - const generic_string addedFilePath = filesToChange[i].substr(0, sepPos + 1) + pathSuffix; + const wstring addedFilePath = filesToChange[i].substr(0, sepPos + 1) + pathSuffix; - generic_string commonPath = rootPath; + wstring commonPath = rootPath; for (const auto & element : linarPathArray) { - commonPath.append(TEXT("\\")); + commonPath.append(L"\\"); commonPath.append(element); } - commonPath.append(TEXT("\\")); + commonPath.append(L"\\"); const auto it = std::find_if(groupedFiles.begin(), groupedFiles.end(), [&commonPath](const auto & group) { return group._commonPath == commonPath; }); @@ -1223,14 +1223,14 @@ bool FileBrowser::addToTree(FilesToChange & group, HTREEITEM node) for (auto & file : group._files) { if (::PathIsDirectory((group._commonPath + file).c_str())) { - SortingData4lParam* customData = new SortingData4lParam(TEXT(""), file, true); + SortingData4lParam* customData = new SortingData4lParam(L"", file, true); sortingDataArray.push_back(customData); _treeView.addItem(file.c_str(), node, INDEX_CLOSE_NODE, reinterpret_cast(customData)); } else { - SortingData4lParam* customData = new SortingData4lParam(TEXT(""), file, false); + SortingData4lParam* customData = new SortingData4lParam(L"", file, false); sortingDataArray.push_back(customData); _treeView.addItem(file.c_str(), node, INDEX_LEAF, reinterpret_cast(customData)); @@ -1245,7 +1245,7 @@ bool FileBrowser::addToTree(FilesToChange & group, HTREEITEM node) hItemNode != NULL; hItemNode = _treeView.getNextSibling(hItemNode)) { - TCHAR textBuffer[MAX_PATH] = { '\0' }; + wchar_t textBuffer[MAX_PATH] = { '\0' }; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT; tvItem.pszText = textBuffer; @@ -1282,7 +1282,7 @@ bool FileBrowser::deleteFromTree(FilesToChange & group) return true; } -HTREEITEM FileBrowser::findInTree(const generic_string& rootPath, HTREEITEM node, std::vector linarPathArray) const +HTREEITEM FileBrowser::findInTree(const wstring& rootPath, HTREEITEM node, std::vector linarPathArray) const { if (node == nullptr) // it's a root. Search the right root with rootPath { @@ -1306,7 +1306,7 @@ HTREEITEM FileBrowser::findInTree(const generic_string& rootPath, HTREEITEM node hItemNode != NULL; hItemNode = _treeView.getNextSibling(hItemNode)) { - TCHAR textBuffer[MAX_PATH] = { '\0' }; + wchar_t textBuffer[MAX_PATH] = { '\0' }; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT; tvItem.pszText = textBuffer; @@ -1347,7 +1347,7 @@ std::vector FileBrowser::findInTree(FilesToChange & group, HTREEITEM hItemNode != NULL; hItemNode = _treeView.getNextSibling(hItemNode)) { - TCHAR textBuffer[MAX_PATH] = {'\0'}; + wchar_t textBuffer[MAX_PATH] = {'\0'}; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT; tvItem.pszText = textBuffer; @@ -1366,7 +1366,7 @@ std::vector FileBrowser::findInTree(FilesToChange & group, HTREEITEM } } -std::vector FileBrowser::findChildNodesFromNames(HTREEITEM parent, std::vector & labels) const +std::vector FileBrowser::findChildNodesFromNames(HTREEITEM parent, std::vector & labels) const { std::vector itemNodes; @@ -1375,7 +1375,7 @@ std::vector FileBrowser::findChildNodesFromNames(HTREEITEM parent, st hItemNode = _treeView.getNextSibling(hItemNode) ) { - TCHAR textBuffer[MAX_PATH]{}; + wchar_t textBuffer[MAX_PATH]{}; TVITEM tvItem{}; tvItem.mask = TVIF_TEXT; tvItem.pszText = textBuffer; @@ -1393,7 +1393,7 @@ std::vector FileBrowser::findChildNodesFromNames(HTREEITEM parent, st return itemNodes; } -void FileBrowser::removeNamesAlreadyInNode(HTREEITEM parent, std::vector & labels) const +void FileBrowser::removeNamesAlreadyInNode(HTREEITEM parent, std::vector & labels) const { // We have to search for the labels in the child nodes of parent, and remove the ones that already exist for (HTREEITEM hItemNode = _treeView.getChildFrom(parent); @@ -1401,7 +1401,7 @@ void FileBrowser::removeNamesAlreadyInNode(HTREEITEM parent, std::vector& linarPathArrayFrom, const generic_string & renameTo) +bool FileBrowser::renameInTree(const wstring& rootPath, HTREEITEM node, const std::vector& linarPathArrayFrom, const wstring & renameTo) { HTREEITEM foundItem = findInTree(rootPath, node, linarPathArrayFrom); if (foundItem == nullptr) @@ -1448,11 +1448,11 @@ int CALLBACK FileBrowser::categorySortFunc(LPARAM lParam1, LPARAM lParam2, LPARA return lstrcmpi(item1->_label.c_str(), item2->_label.c_str()); } -bool FolderInfo::addToStructure(generic_string & fullpath, std::vector linarPathArray) +bool FolderInfo::addToStructure(wstring & fullpath, std::vector linarPathArray) { if (linarPathArray.size() == 1) // could be file or folder { - fullpath += TEXT("\\"); + fullpath += L"\\"; fullpath += linarPathArray[0]; if (PathIsDirectory(fullpath.c_str())) { @@ -1483,7 +1483,7 @@ bool FolderInfo::addToStructure(generic_string & fullpath, std::vector linarPathArray) +bool FolderInfo::removeFromStructure(std::vector linarPathArray) { if (linarPathArray.size() == 1) // could be file or folder { @@ -1531,7 +1531,7 @@ bool FolderInfo::removeFromStructure(std::vector linarPathArray) return false; } -bool FolderInfo::renameInStructure(std::vector linarPathArrayFrom, std::vector linarPathArrayTo) +bool FolderInfo::renameInStructure(std::vector linarPathArrayFrom, std::vector linarPathArrayTo) { if (linarPathArrayFrom.size() == 1) // could be file or folder { @@ -1609,9 +1609,9 @@ DWORD WINAPI FolderUpdater::watching(void *params) { FolderUpdater *thisFolderUpdater = (FolderUpdater *)params; - generic_string dir2Watch = (thisFolderUpdater->_rootFolder)._rootPath; + wstring dir2Watch = (thisFolderUpdater->_rootFolder)._rootPath; if (dir2Watch[dir2Watch.length() - 1] != '\\') - dir2Watch += TEXT("\\"); // CReadDirectoryChanges will add another '\' so we will get "\\" as a separator (of monitored root) in the notification + dir2Watch += L"\\"; // CReadDirectoryChanges will add another '\' so we will get "\\" as a separator (of monitored root) in the notification const DWORD dwNotificationFlags = FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_FILE_NAME; @@ -1640,9 +1640,9 @@ DWORD WINAPI FolderUpdater::watching(void *params) DWORD dwPreviousAction = 0; DWORD dwAction; - generic_string wstrFilename; + wstring wstrFilename; - std::vector filesToChange; + std::vector filesToChange; // Process all available changes, ignore User actions while (changes.Pop(dwAction, wstrFilename)) { @@ -1703,26 +1703,26 @@ DWORD WINAPI FolderUpdater::watching(void *params) return EXIT_SUCCESS; } -void FolderUpdater::processChange(DWORD dwAction, std::vector filesToChange, FolderUpdater* thisFolderUpdater) +void FolderUpdater::processChange(DWORD dwAction, std::vector filesToChange, FolderUpdater* thisFolderUpdater) { - static generic_string oldName; + static wstring oldName; switch (dwAction) { case FILE_ACTION_ADDED: ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_ADDFILE, reinterpret_cast(nullptr), reinterpret_cast(&filesToChange)); - oldName = TEXT(""); + oldName = L""; break; case FILE_ACTION_REMOVED: ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_RMFILE, reinterpret_cast(nullptr), reinterpret_cast(&filesToChange)); - oldName = TEXT(""); + oldName = L""; break; case FILE_ACTION_MODIFIED: - oldName = TEXT(""); + oldName = L""; break; case FILE_ACTION_RENAMED_OLD_NAME: @@ -1732,17 +1732,17 @@ void FolderUpdater::processChange(DWORD dwAction, std::vector fi case FILE_ACTION_RENAMED_NEW_NAME: if (!oldName.empty()) { - std::vector fileRename; + std::vector fileRename; fileRename.push_back(oldName); fileRename.push_back(filesToChange.back()); //thisFolderUpdater->updateTree(dwAction, fileRename); ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_RNFILE, reinterpret_cast(nullptr), reinterpret_cast(&fileRename)); } - oldName = TEXT(""); + oldName = L""; break; default: - oldName = TEXT(""); + oldName = L""; break; } } diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h index 570125431..34b4575d5 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h @@ -21,17 +21,17 @@ #include "TreeView.h" #include "fileBrowser_rc.h" -#define FB_PANELTITLE TEXT("Folder as Workspace") -#define FB_ADDROOT TEXT("Add") -#define FB_REMOVEALLROOTS TEXT("Remove All") -#define FB_REMOVEROOTFOLDER TEXT("Remove") -#define FB_COPYPATH TEXT("Copy path") -#define FB_COPYFILENAME TEXT("Copy file name") -#define FB_FINDINFILES TEXT("Find in Files...") -#define FB_EXPLORERHERE TEXT("Explorer here") -#define FB_CMDHERE TEXT("CMD here") -#define FB_OPENINNPP TEXT("Open") -#define FB_SHELLEXECUTE TEXT("Run by system") +#define FB_PANELTITLE L"Folder as Workspace" +#define FB_ADDROOT L"Add" +#define FB_REMOVEALLROOTS L"Remove All" +#define FB_REMOVEROOTFOLDER L"Remove" +#define FB_COPYPATH L"Copy path" +#define FB_COPYFILENAME L"Copy file name" +#define FB_FINDINFILES L"Find in Files..." +#define FB_EXPLORERHERE L"Explorer here" +#define FB_CMDHERE L"CMD here" +#define FB_OPENINNPP L"Open" +#define FB_SHELLEXECUTE L"Run by system" #define FOLDERASWORKSPACE_NODE "FolderAsWorkspace" @@ -47,12 +47,12 @@ friend class FolderInfo; public: FileInfo() = delete; // constructor by default is forbidden - FileInfo(const generic_string & name, FolderInfo *parent) : _name(name), _parent(parent) {}; - generic_string getName() const { return _name; }; - void setName(generic_string name) { _name = name; }; + FileInfo(const std::wstring & name, FolderInfo *parent) : _name(name), _parent(parent) {}; + std::wstring getName() const { return _name; }; + void setName(std::wstring name) { _name = name; }; private: - generic_string _name; + std::wstring _name; FolderInfo *_parent = nullptr; }; @@ -64,24 +64,24 @@ friend class FolderUpdater; public: FolderInfo() = delete; // constructor by default is forbidden - FolderInfo(const generic_string & name, FolderInfo *parent) : _name(name), _parent(parent) {}; - void setRootPath(const generic_string& rootPath) { _rootPath = rootPath; }; - generic_string getRootPath() const { return _rootPath; }; - void setName(const generic_string& name) { _name = name; }; - generic_string getName() const { return _name; }; - void addFile(const generic_string& fn) { _files.push_back(FileInfo(fn, this)); }; + FolderInfo(const std::wstring & name, FolderInfo *parent) : _name(name), _parent(parent) {}; + void setRootPath(const std::wstring& rootPath) { _rootPath = rootPath; }; + std::wstring getRootPath() const { return _rootPath; }; + void setName(const std::wstring& name) { _name = name; }; + std::wstring getName() const { return _name; }; + void addFile(const std::wstring& fn) { _files.push_back(FileInfo(fn, this)); }; void addSubFolder(FolderInfo subDirectoryStructure) { _subFolders.push_back(subDirectoryStructure); }; - bool addToStructure(generic_string & fullpath, std::vector linarPathArray); - bool removeFromStructure(std::vector linarPathArray); - bool renameInStructure(std::vector linarPathArrayFrom, std::vector linarPathArrayTo); + bool addToStructure(std::wstring & fullpath, std::vector linarPathArray); + bool removeFromStructure(std::vector linarPathArray); + bool renameInStructure(std::vector linarPathArrayFrom, std::vector linarPathArrayTo); private: std::vector _subFolders; std::vector _files; - generic_string _name; + std::wstring _name; FolderInfo* _parent = nullptr; - generic_string _rootPath; // set only for root folder; empty for normal folder + std::wstring _rootPath; // set only for root folder; empty for normal folder }; enum BrowserNodeType { @@ -104,15 +104,15 @@ private: HANDLE _EventHandle = nullptr; static DWORD WINAPI watching(void *param); - static void processChange(DWORD dwAction, std::vector filesToChange, FolderUpdater* thisFolderUpdater); + static void processChange(DWORD dwAction, std::vector filesToChange, FolderUpdater* thisFolderUpdater); }; struct SortingData4lParam { - generic_string _rootPath; // Only for the root. It should be empty if it's not root - generic_string _label; // TreeView item label + std::wstring _rootPath; // Only for the root. It should be empty if it's not root + std::wstring _label; // TreeView item label bool _isFolder = false; // if it's not a folder, then it's a file - SortingData4lParam(generic_string rootPath, generic_string label, bool isFolder) : _rootPath(rootPath), _label(label), _isFolder(isFolder) {} + SortingData4lParam(std::wstring rootPath, std::wstring label, bool isFolder) : _rootPath(rootPath), _label(label), _isFolder(isFolder) {} }; @@ -133,25 +133,25 @@ public: TreeView_SetTextColor(_treeView.getHSelf(), fgColour); }; - generic_string getNodePath(HTREEITEM node) const; - generic_string getNodeName(HTREEITEM node) const; - void addRootFolder(generic_string rootFolderPath); + std::wstring getNodePath(HTREEITEM node) const; + std::wstring getNodeName(HTREEITEM node) const; + void addRootFolder(std::wstring rootFolderPath); - HTREEITEM getRootFromFullPath(const generic_string & rootPath) const; - HTREEITEM findChildNodeFromName(HTREEITEM parent, const generic_string& label) const; + HTREEITEM getRootFromFullPath(const std::wstring & rootPath) const; + HTREEITEM findChildNodeFromName(HTREEITEM parent, const std::wstring& label) const; - HTREEITEM findInTree(const generic_string& rootPath, HTREEITEM node, std::vector linarPathArray) const; + HTREEITEM findInTree(const std::wstring& rootPath, HTREEITEM node, std::vector linarPathArray) const; void deleteAllFromTree() { popupMenuCmd(IDM_FILEBROWSER_REMOVEALLROOTS); }; - bool renameInTree(const generic_string& rootPath, HTREEITEM node, const std::vector& linarPathArrayFrom, const generic_string & renameTo); + bool renameInTree(const std::wstring& rootPath, HTREEITEM node, const std::vector& linarPathArrayFrom, const std::wstring & renameTo); - std::vector getRoots() const; - generic_string getSelectedItemPath() const; + std::vector getRoots() const; + std::wstring getSelectedItemPath() const; - bool selectItemFromPath(const generic_string& itemPath) const; + bool selectItemFromPath(const std::wstring& itemPath) const; protected: HWND _hToolbarMenu = nullptr; @@ -166,13 +166,13 @@ protected: HMENU _hFileMenu = NULL; std::vector _folderUpdaters; - generic_string _selectedNodeFullPath; // this member is used only for PostMessage call + std::wstring _selectedNodeFullPath; // this member is used only for PostMessage call std::vector sortingDataArray; - generic_string _expandAllFolders = TEXT("Unfold all"); - generic_string _collapseAllFolders = TEXT("Fold all"); - generic_string _locateCurrentFile = TEXT("Locate current file"); + std::wstring _expandAllFolders = L"Unfold all"; + std::wstring _collapseAllFolders = L"Fold all"; + std::wstring _locateCurrentFile = L"Locate current file"; void initPopupMenus(); void destroyMenus(); @@ -183,10 +183,10 @@ protected: bool selectCurrentEditingFile() const; struct FilesToChange { - generic_string _commonPath; // Common path between all the files. _rootPath + _linarWithoutLastPathElement - generic_string _rootPath; - std::vector _linarWithoutLastPathElement; - std::vector _files; // file/folder names + std::wstring _commonPath; // Common path between all the files. _rootPath + _linarWithoutLastPathElement + std::wstring _rootPath; + std::vector _linarWithoutLastPathElement; + std::vector _files; // file/folder names }; std::vector getFilesFromParam(LPARAM lParam) const; @@ -197,15 +197,15 @@ protected: std::vector findInTree(FilesToChange & group, HTREEITEM node) const; - std::vector findChildNodesFromNames(HTREEITEM parent, std::vector & labels) const; + std::vector findChildNodesFromNames(HTREEITEM parent, std::vector & labels) const; - void removeNamesAlreadyInNode(HTREEITEM parent, std::vector & labels) const; + void removeNamesAlreadyInNode(HTREEITEM parent, std::vector & labels) const; intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; void notified(LPNMHDR notification); void showContextMenu(int x, int y); void openSelectFile(); - void getDirectoryStructure(const TCHAR *dir, const std::vector & patterns, FolderInfo & directoryStructure, bool isRecursive, bool isInHiddenDir); + void getDirectoryStructure(const wchar_t *dir, const std::vector & patterns, FolderInfo & directoryStructure, bool isRecursive, bool isInHiddenDir); HTREEITEM createFolderItemsFromDirStruct(HTREEITEM hParentItem, const FolderInfo & directoryStructure); static int CALLBACK categorySortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); };