diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 205a413e..04c8815b 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -513,7 +513,7 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI _multiByteStr.sizeTo(len); len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL); // not needed? - if ((int)*mstart < lstrlenW(wcharStr2Convert) && (int)*mend < lstrlenW(wcharStr2Convert)) + if (*mstart < lstrlenW(wcharStr2Convert) && *mend < lstrlenW(wcharStr2Convert)) { *mstart = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mstart, NULL, 0, NULL, NULL); *mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, NULL, 0, NULL, NULL); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 6e8e025e..c52f5cd0 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -332,12 +332,12 @@ LRESULT Notepad_plus::init(HWND hwnd) if (_toReduceTabBar) { - HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT); + HFONT hf = reinterpret_cast(::GetStockObject(DEFAULT_GUI_FONT)); if (hf) { - ::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0)); - ::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0)); + ::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, reinterpret_cast(hf), MAKELPARAM(TRUE, 0)); + ::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, reinterpret_cast(hf), MAKELPARAM(TRUE, 0)); } int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(22); int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(45); @@ -418,15 +418,15 @@ LRESULT Notepad_plus::init(HWND hwnd) size_t const posBase = 6; size_t nbMacro = macros.size(); if (nbMacro >= 1) - ::InsertMenu(hMacroMenu, posBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); + ::InsertMenu(hMacroMenu, posBase - 1, MF_BYPOSITION, static_cast(-1), 0); for (size_t i = 0 ; i < nbMacro ; ++i) - ::InsertMenu(hMacroMenu, UINT(posBase + i), MF_BYPOSITION, ID_MACRO + i, macros[i].toMenuItemString().c_str()); + ::InsertMenu(hMacroMenu, static_cast(posBase + i), MF_BYPOSITION, ID_MACRO + i, macros[i].toMenuItemString().c_str()); if (nbMacro >= 1) { - ::InsertMenu(hMacroMenu, UINT(posBase + nbMacro + 1), MF_BYPOSITION, (unsigned int)-1, 0); - ::InsertMenu(hMacroMenu, UINT(posBase + nbMacro + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro...")); + ::InsertMenu(hMacroMenu, static_cast(posBase + nbMacro + 1), MF_BYPOSITION, static_cast(-1), 0); + ::InsertMenu(hMacroMenu, static_cast(posBase + nbMacro + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro...")); } // Run Menu @@ -435,17 +435,17 @@ LRESULT Notepad_plus::init(HWND hwnd) int const runPosBase = 2; size_t nbUserCommand = userCommands.size(); if (nbUserCommand >= 1) - ::InsertMenu(hRunMenu, runPosBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); + ::InsertMenu(hRunMenu, runPosBase - 1, MF_BYPOSITION, static_cast(-1), 0); for (size_t i = 0 ; i < nbUserCommand ; ++i) { - ::InsertMenu(hRunMenu, UINT(runPosBase + i), MF_BYPOSITION, ID_USER_CMD + i, userCommands[i].toMenuItemString().c_str()); + ::InsertMenu(hRunMenu, static_cast(runPosBase + i), MF_BYPOSITION, ID_USER_CMD + i, userCommands[i].toMenuItemString().c_str()); } if (nbUserCommand >= 1) { - ::InsertMenu(hRunMenu, UINT(runPosBase + nbUserCommand + 1), MF_BYPOSITION, (unsigned int)-1, 0); - ::InsertMenu(hRunMenu, UINT(runPosBase + nbUserCommand + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, TEXT("Modify Shortcut/Delete Command...")); + ::InsertMenu(hRunMenu, static_cast(runPosBase + nbUserCommand + 1), MF_BYPOSITION, static_cast(-1), 0); + ::InsertMenu(hRunMenu, static_cast(runPosBase + nbUserCommand + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, TEXT("Modify Shortcut/Delete Command...")); } // Updater menu item @@ -2935,11 +2935,11 @@ size_t Notepad_plus::getCurrentDocCharCount(UniMode u) if (u != uniUTF8 && u != uniCookie) { size_t numLines = _pEditView->execute(SCI_GETLINECOUNT); - size_t result = _pEditView->execute(SCI_GETLENGTH); + auto result = _pEditView->execute(SCI_GETLENGTH); size_t lines = numLines==0?0:numLines-1; if (_pEditView->execute(SCI_GETEOLMODE) == SC_EOL_CRLF) lines *= 2; result -= lines; - return ((int)result < 0) ? 0 : result; + return (result < 0) ? 0 : result; } else { @@ -4072,10 +4072,10 @@ bool Notepad_plus::addCurrentMacro() int const posBase = 6; //separator at index 5 if (nbMacro == 0) { - ::InsertMenu(hMacroMenu, posBase-1, MF_BYPOSITION, (unsigned int)-1, 0); //no separator yet, add one + ::InsertMenu(hMacroMenu, posBase-1, MF_BYPOSITION, static_cast(-1), 0); //no separator yet, add one // Insert the separator and modify/delete command - ::InsertMenu(hMacroMenu, posBase + nbMacro + 1, MF_BYPOSITION, (unsigned int)-1, 0); + ::InsertMenu(hMacroMenu, posBase + nbMacro + 1, MF_BYPOSITION, static_cast(-1), 0); NativeLangSpeaker *pNativeLangSpeaker = nppParams->getNativeLangSpeaker(); generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO); @@ -4100,22 +4100,20 @@ void Notepad_plus::changeToolBarIcons() bool Notepad_plus::switchToFile(BufferID id) { - int i = 0; int iView = currentView(); if (id == BUFFER_INVALID) return false; - - if ((i = _pDocTab->getIndexByBuffer(id)) != -1) + int i = _pDocTab->getIndexByBuffer(id); + if (i != -1) { iView = currentView(); } - else if ((i = _pNonDocTab->getIndexByBuffer(id)) != -1) - { - iView = otherView(); - } - + + i = _pNonDocTab->getIndexByBuffer(id); if (i != -1) { + iView = otherView(); + switchEditViewTo(iView); activateBuffer(id, currentView()); return true; @@ -4406,7 +4404,7 @@ void Notepad_plus::postItToggle() NppParameters * pNppParam = NppParameters::getInstance(); if (!_beforeSpecialView.isPostIt) // PostIt disabled, enable it { - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); // get current status before switch to postIt //check these always { @@ -4752,9 +4750,6 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) switch(buffer->getStatus()) { case DOC_UNNAMED: //nothing todo - { - break; - } case DOC_REGULAR: //nothing todo { break; @@ -5960,7 +5955,7 @@ bool isInList(int elem, vector elemList) DWORD WINAPI Notepad_plus::threadTextPlayer(void *params) { // random seed generation needs only one time. - srand((unsigned int)time(NULL)); + srand(static_cast(time(NULL))); TextPlayerParams* textPlayerParams = static_cast(params); HWND hNpp = textPlayerParams->_nppHandle; @@ -6078,7 +6073,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params) WaitForSingleObject(textTrollerParams->_mutex, INFINITE); // random seed generation needs only one time. - srand((unsigned int)time(NULL)); + srand(static_cast(time(NULL))); ScintillaEditView *pCurrentView = textTrollerParams->_pCurrentView; const char *text2display = textTrollerParams->_text2display; @@ -6203,7 +6198,7 @@ int Notepad_plus::getQuoteIndexFrom(const char *quoter) const if (stricmp(quoter, "random") == 0) { - srand((unsigned int)time(NULL)); + srand(static_cast(time(NULL))); return getRandomNumber(nbQuote); } @@ -6445,20 +6440,20 @@ bool Notepad_plus::undoStreamComment() if (selectionStart > posStartComment) { if (selectionStart >= posStartComment+startCommentLength) - selectionStartMove = -(int)startCommentLength; + selectionStartMove = -static_cast(startCommentLength); else - selectionStartMove = -(int)(selectionStart - posStartComment); + selectionStartMove = -static_cast(selectionStart - posStartComment); } else selectionStartMove = 0; // selectionEnd if (selectionEnd >= posEndComment+endCommentLength) - selectionEndMove = -(int)(startCommentLength+endCommentLength); + selectionEndMove = -static_cast(startCommentLength+endCommentLength); else if (selectionEnd <= posEndComment) - selectionEndMove = -(int)startCommentLength; + selectionEndMove = -static_cast(startCommentLength); else - selectionEndMove = -(int)(startCommentLength + (selectionEnd - posEndComment)); + selectionEndMove = -static_cast(startCommentLength + (selectionEnd - posEndComment)); //-- Reset selection of text without deleted stream-comment-string if (move_caret) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 3ce33a7d..f56a47d2 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -82,7 +82,7 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message, { // First message we get the ptr of instantiated object // then stock it into GWLP_USERDATA index in order to retrieve afterward - Notepad_plus_Window *pM30ide = (Notepad_plus_Window *)(((LPCREATESTRUCT)lParam)->lpCreateParams); + Notepad_plus_Window *pM30ide = reinterpret_cast((reinterpret_cast(lParam))->lpCreateParams); pM30ide->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pM30ide); return TRUE; @@ -90,7 +90,7 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message, default: { - return ((Notepad_plus_Window *)::GetWindowLongPtr(hwnd, GWLP_USERDATA))->runProc(hwnd, Message, wParam, lParam); + return (reinterpret_cast(::GetWindowLongPtr(hwnd, GWLP_USERDATA))->runProc(hwnd, Message, wParam, lParam)); } } } @@ -140,7 +140,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_DRAWITEM: { - DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; + DRAWITEMSTRUCT *dis = reinterpret_cast(lParam); if (dis->CtlType == ODT_TAB) return ::SendMessage(dis->hwndItem, WM_DRAWITEM, wParam, lParam); break; @@ -160,7 +160,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_REMOVE_USERLANG: { - TCHAR *userLangName = (TCHAR *)lParam; + TCHAR *userLangName = reinterpret_cast(lParam); if (!userLangName || !userLangName[0]) return FALSE; @@ -178,11 +178,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_RENAME_USERLANG: { - if (!lParam || !(((TCHAR *)lParam)[0]) || !wParam || !(((TCHAR *)wParam)[0])) + if (!lParam || !((reinterpret_cast(lParam))[0]) || !wParam || !((reinterpret_cast(wParam))[0])) return FALSE; - generic_string oldName{(TCHAR *)lParam}; - generic_string newName{(TCHAR *)wParam}; + generic_string oldName{ reinterpret_cast(lParam) }; + generic_string newName{ reinterpret_cast(wParam) }; //loop through buffers and reset the language (L_USER, newName) if (L_USER, oldName) for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i) @@ -225,19 +225,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_FINDALL_INCURRENTFINDER: { - FindersInfo *findInFolderInfo = (FindersInfo *)wParam; + FindersInfo *findInFolderInfo = reinterpret_cast(wParam); Finder * newFinder = _findReplaceDlg.createFinder(); findInFolderInfo->_pDestFinder = newFinder; bool isOK = findInFinderFiles(findInFolderInfo); return isOK; } - /* - case NPPM_INTERNAL_REMOVEFINDER: - { - return _findReplaceDlg.removeFinder((Finder *)wParam); - } - */ + case WM_REPLACEINFILES: { replaceInFiles(); @@ -258,7 +253,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (isFirstTime) _nativeLangSpeaker.changeDlgLang(_findReplaceDlg.getHSelf(), "Find"); _findReplaceDlg.launchFindInFilesDlg(); - setFindReplaceFolderFilter((const TCHAR*) wParam, (const TCHAR*) lParam); + setFindReplaceFolderFilter(reinterpret_cast(wParam), reinterpret_cast(lParam)); return TRUE; } @@ -267,7 +262,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { const int strSize = FINDREPLACE_MAXLENGTH; TCHAR str[strSize]; - Finder *launcher = (Finder *)wParam; + Finder *launcher = reinterpret_cast(wParam); bool isFirstTime = not _findInFinderDlg.isCreated(); @@ -286,7 +281,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DOOPEN: case WM_DOOPEN: { - BufferID id = doOpen((const TCHAR *)lParam); + BufferID id = doOpen(reinterpret_cast(lParam)); if (id != BUFFER_INVALID) return switchToFile(id); break; @@ -299,7 +294,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa BufferID id = (BufferID)wParam; Buffer * b = MainFileManager->getBufferByID(id); if (b && b->getStatus() == DOC_UNNAMED) { - b->setFileName((const TCHAR*)lParam); + b->setFileName(reinterpret_cast(lParam)); return TRUE; } return FALSE; @@ -386,29 +381,29 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa else if (lParam == SUB_VIEW) pView = &_subDocTab; else - return (LRESULT)BUFFER_INVALID; + return reinterpret_cast(BUFFER_INVALID); if ((size_t)wParam < pView->nbItem()) - return (LRESULT)(pView->getBufferByIndex((int)wParam)); + return reinterpret_cast(pView->getBufferByIndex(wParam)); - return (LRESULT)BUFFER_INVALID; + return reinterpret_cast(BUFFER_INVALID); } case NPPM_GETCURRENTBUFFERID: { - return (LRESULT)(_pEditView->getCurrentBufferID()); + return reinterpret_cast(_pEditView->getCurrentBufferID()); } case NPPM_RELOADBUFFERID: { if (!wParam) return FALSE; - return doReload((BufferID)wParam, lParam != 0); + return doReload(reinterpret_cast(wParam), lParam != 0); } case NPPM_RELOADFILE: { - BufferID id = MainFileManager->getBufferFromName((const TCHAR *)lParam); + BufferID id = MainFileManager->getBufferFromName(reinterpret_cast(lParam)); if (id != BUFFER_INVALID) doReload(id, wParam != 0); break; @@ -416,7 +411,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_SWITCHTOFILE : { - BufferID id = MainFileManager->getBufferFromName((const TCHAR *)lParam); + BufferID id = MainFileManager->getBufferFromName(reinterpret_cast(lParam)); if (id != BUFFER_INVALID) return switchToFile(id); return false; @@ -431,7 +426,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { BufferID currentBufferID = _pEditView->getCurrentBufferID(); bool asCopy = wParam == TRUE; - const TCHAR *filename = (const TCHAR *)lParam; + const TCHAR *filename = reinterpret_cast(lParam); if (!filename) return FALSE; return doSave(currentBufferID, filename, asCopy); } @@ -443,7 +438,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_SAVEFILE: { - return fileSaveSpecific((const TCHAR *)lParam); + return fileSaveSpecific(reinterpret_cast(lParam)); } case NPPM_GETCURRENTNATIVELANGENCODING: @@ -458,15 +453,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa // Notify plugins that current file is about to be closed SCNotification scnN; scnN.nmhdr.code = NPPN_DOCORDERCHANGED; - scnN.nmhdr.hwndFrom = (void *)lParam; - scnN.nmhdr.idFrom = (uptr_t)id; + scnN.nmhdr.hwndFrom = reinterpret_cast(lParam); + scnN.nmhdr.idFrom = reinterpret_cast(id); _pluginsManager.notify(&scnN); return TRUE; } case NPPM_DISABLEAUTOUPDATE: { - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); nppGUI._autoUpdateOpt._doAutoUpdate = false; return TRUE; } @@ -523,7 +518,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_COPYDATA: { - COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)lParam; + COPYDATASTRUCT *pCopyData = reinterpret_cast(lParam); switch (pCopyData->dwData) { @@ -549,7 +544,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case COPYDATA_FILENAMESA: { - char *fileNamesA = (char *)pCopyData->lpData; + char *fileNamesA = reinterpret_cast(pCopyData->lpData); CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); const wchar_t *fileNamesW = wmc->char2wchar(fileNamesA, CP_ACP); @@ -559,7 +554,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case COPYDATA_FILENAMESW: { - wchar_t *fileNamesW = (wchar_t *)pCopyData->lpData; + wchar_t *fileNamesW = reinterpret_cast(pCopyData->lpData); CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); loadCommandlineParams(fileNamesW, &cmdLineParams); break; @@ -621,7 +616,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { SCNotification scnN; scnN.nmhdr.code = NPPN_SHORTCUTREMAPPED; - scnN.nmhdr.hwndFrom = (void *)lParam; // ShortcutKey structure + scnN.nmhdr.hwndFrom = reinterpret_cast(lParam); // ShortcutKey structure scnN.nmhdr.idFrom = (uptr_t)wParam; // cmdID _pluginsManager.notify(&scnN); return TRUE; @@ -630,7 +625,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETSHORTCUTBYCMDID: { int cmdID = static_cast(wParam); // cmdID - ShortcutKey *sk = (ShortcutKey *)lParam; // ShortcutKey structure + ShortcutKey *sk = reinterpret_cast(lParam); // ShortcutKey structure return _pluginsManager.getShortcutByCmdID(cmdID, sk); } @@ -674,7 +669,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } } - lstrcpy((TCHAR *)lParam, fileStr); + lstrcpy(reinterpret_cast(lParam), fileStr); return TRUE; } @@ -682,8 +677,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { const int strSize = CURRENTWORD_MAXLENGTH; TCHAR str[strSize]; - - _pEditView->getGenericSelectedText((TCHAR *)str, strSize); + TCHAR *pTchar = reinterpret_cast(lParam); + _pEditView->getGenericSelectedText(str, strSize); // For the compability reason, if wParam is 0, then we assume the size of generic_string buffer (lParam) is large enough. // otherwise we check if the generic_string buffer size is enough for the generic_string to copy. if (wParam != 0) @@ -695,12 +690,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } else //buffer large enough, perform safe copy { - lstrcpyn((TCHAR *)lParam, str, static_cast(wParam)); + lstrcpyn(pTchar, str, static_cast(wParam)); return TRUE; } } - lstrcpy((TCHAR *)lParam, str); + lstrcpy(pTchar, str); return TRUE; } @@ -723,7 +718,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } } - lstrcpy((TCHAR *)lParam, str); + lstrcpy(reinterpret_cast(lParam), str); return TRUE; } @@ -739,24 +734,25 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETCURRENTSCINTILLA: { + int *id = reinterpret_cast(lParam); if (_pEditView == &_mainEditView) - *((int *)lParam) = MAIN_VIEW; + *id = MAIN_VIEW; else if (_pEditView == &_subEditView) - *((int *)lParam) = SUB_VIEW; + *id = SUB_VIEW; else - *((int *)lParam) = -1; + *id = -1; return TRUE; } case NPPM_GETCURRENTLANGTYPE: { - *((LangType *)lParam) = _pEditView->getCurrentBuffer()->getLangType(); + *(reinterpret_cast(lParam)) = _pEditView->getCurrentBuffer()->getLangType(); return TRUE; } case NPPM_SETCURRENTLANGTYPE: { - _pEditView->getCurrentBuffer()->setLangType((LangType)lParam); + _pEditView->getCurrentBuffer()->setLangType(static_cast(lParam)); return TRUE; } @@ -779,7 +775,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (!wParam) return 0; - TCHAR** fileNames = (TCHAR**) wParam; + TCHAR** fileNames = reinterpret_cast(wParam); size_t nbFileNames = static_cast(lParam); size_t j = 0; @@ -880,7 +876,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETNBSESSIONFILES: { - const TCHAR *sessionFileName = (const TCHAR *)lParam; + const TCHAR *sessionFileName = reinterpret_cast(lParam); if ((!sessionFileName) || (sessionFileName[0] == '\0')) return 0; Session session2Load; @@ -891,8 +887,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETSESSIONFILES: { - const TCHAR *sessionFileName = (const TCHAR *)lParam; - TCHAR **sessionFileArray = (TCHAR **)wParam; + const TCHAR *sessionFileName = reinterpret_cast(lParam); + TCHAR **sessionFileArray = reinterpret_cast(wParam); if ((!sessionFileName) || (sessionFileName[0] == '\0')) return FALSE; @@ -1068,7 +1064,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_FRSAVE_STR: { - _macro.push_back(recordedMacroStep(static_cast(wParam), 0, 0, (const TCHAR *)lParam, recordedMacroStep::mtSavedSnR)); + _macro.push_back(recordedMacroStep(static_cast(wParam), 0, 0, reinterpret_cast(lParam), recordedMacroStep::mtSavedSnR)); break; } @@ -1164,7 +1160,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETNBUSERLANG: { if (lParam) - *((int *)lParam) = IDM_LANG_USER; + *(reinterpret_cast(lParam)) = IDM_LANG_USER; return pNppParam->getNbUserLang(); } @@ -1186,7 +1182,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_SETSTATUSBAR: { - TCHAR *str2set = (TCHAR *)lParam; + TCHAR *str2set = reinterpret_cast(lParam); if (!str2set || !str2set[0]) return FALSE; @@ -1217,18 +1213,18 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_LOADSESSION: { - fileLoadSession((const TCHAR *)lParam); + fileLoadSession(reinterpret_cast(lParam)); return TRUE; } case NPPM_SAVECURRENTSESSION: { - return (LRESULT)fileSaveSession(0, NULL, (const TCHAR *)lParam); + return (LRESULT)fileSaveSession(0, NULL, reinterpret_cast(lParam)); } case NPPM_SAVESESSION: { - sessionInfo *pSi = (sessionInfo *)lParam; + sessionInfo *pSi = reinterpret_cast(lParam); return (LRESULT)fileSaveSession(pSi->nbFile, pSi->files, pSi->sessionFilePathName); } @@ -1247,7 +1243,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_CMDLIST_MODIFIED: { - //changeMenuShortcut(lParam, (const TCHAR *)wParam); ::DrawMenuBar(hwnd); return TRUE; } @@ -1422,21 +1417,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_RELOADSCROLLTOEND: { - Buffer *buf = (Buffer *)wParam; + Buffer *buf = reinterpret_cast(wParam); buf->reload(); return TRUE; } case NPPM_INTERNAL_GETCHECKDOCOPT: { - return (LRESULT)((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection; + return (LRESULT)(const_cast(pNppParam->getNppGUI()))._fileAutoDetection; } case NPPM_INTERNAL_SETCHECKDOCOPT: { // If nothing is changed by user, then we allow to set this value - if (((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection == ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetectionOriginalValue) - ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection = (ChangeDetect)wParam; + if ((const_cast(pNppParam->getNppGUI()))._fileAutoDetection == (const_cast(pNppParam->getNppGUI()))._fileAutoDetectionOriginalValue) + (const_cast(pNppParam->getNppGUI()))._fileAutoDetection = (ChangeDetect)wParam; return TRUE; } @@ -1479,12 +1474,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETFULLPATHFROMBUFFERID: { - return MainFileManager->getFileNameFromBuffer((BufferID)wParam, (TCHAR *)lParam); + return MainFileManager->getFileNameFromBuffer(reinterpret_cast(wParam), reinterpret_cast(lParam)); } case NPPM_INTERNAL_ENABLECHECKDOCOPT: { - NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); + NppGUI & nppgui = const_cast((pNppParam->getNppGUI())); if (wParam == CHECKDOCOPT_NONE) nppgui._fileAutoDetection = cdDisabled; else if (wParam == CHECKDOCOPT_UPDATESILENTLY) @@ -1720,7 +1715,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_SYSCOMMAND: { - NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); + NppGUI & nppgui = const_cast((pNppParam->getNppGUI())); if (((nppgui._isMinimizedToTray && !_isAdministrator) || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE)) { if (nullptr == _pTrayIco) @@ -1810,7 +1805,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DMMREGASDCKDLG: { - tTbData *pData = (tTbData *)lParam; + tTbData *pData = reinterpret_cast(lParam); int iCont = -1; bool isVisible = false; @@ -1821,7 +1816,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DMMVIEWOTHERTAB: { - _dockingManager.showDockableDlg((TCHAR*)lParam, SW_SHOW); + _dockingManager.showDockableDlg(reinterpret_cast(lParam), SW_SHOW); return TRUE; } @@ -1830,8 +1825,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (!lParam) return NULL; - TCHAR *moduleName = (TCHAR *)lParam; - TCHAR *windowName = (TCHAR *)wParam; + TCHAR *moduleName = reinterpret_cast(lParam); + TCHAR *windowName = reinterpret_cast(wParam); std::vector dockContainer = _dockingManager.getContainerInfo(); for (size_t i = 0, len = dockContainer.size(); i < len ; ++i) @@ -1854,13 +1849,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_ADDTOOLBARICON: { - _toolBar.registerDynBtn((UINT)wParam, (toolbarIcons*)lParam); + _toolBar.registerDynBtn(static_cast(wParam), reinterpret_cast(lParam)); return TRUE; } case NPPM_SETMENUITEMCHECK: { - ::CheckMenuItem(_mainMenuHandle, (UINT)wParam, MF_BYCOMMAND | ((BOOL)lParam ? MF_CHECKED : MF_UNCHECKED)); + ::CheckMenuItem(_mainMenuHandle, static_cast(wParam), MF_BYCOMMAND | (static_cast(lParam) ? MF_CHECKED : MF_UNCHECKED)); _toolBar.setCheck((int)wParam, bool(lParam != 0)); return TRUE; } @@ -1897,7 +1892,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (len < pluginsConfigDirPrefix.length() + lstrlen(secondPart)) return FALSE; - TCHAR *pluginsConfigDir = (TCHAR *)lParam; + TCHAR *pluginsConfigDir = reinterpret_cast(lParam); lstrcpy(pluginsConfigDir, pluginsConfigDirPrefix.c_str()); ::PathAppend(pluginsConfigDir, secondPart); @@ -1933,7 +1928,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa DocTabView::setHideTabBarStatus(hide); ::SendMessage(hwnd, WM_SIZE, 0, 0); - NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); + NppGUI & nppGUI = const_cast(((NppParameters::getInstance())->getNppGUI())); if (hide) nppGUI._tabStatus |= TAB_HIDE; else @@ -1968,7 +1963,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (hide == isHidden) return isHidden; - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); nppGUI._menuBarShow = !hide; if (nppGUI._menuBarShow) ::SetMenu(hwnd, _mainMenuHandle); @@ -1986,7 +1981,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_HIDESTATUSBAR: { bool show = (lParam != TRUE); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); bool oldVal = nppGUI._statusBarShow; if (show == oldVal) return oldVal; @@ -2002,7 +1997,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_ISSTATUSBARHIDDEN: { - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); return !nppGUI._statusBarShow; } @@ -2064,7 +2059,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_DISABLEAUTOUPDATE: { //printStr(TEXT("you've got me")); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); nppGUI._autoUpdateOpt._doAutoUpdate = false; return TRUE; } @@ -2088,7 +2083,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DOCSWITCHERDISABLECOLUMN: { BOOL isOff = static_cast(lParam); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + NppGUI & nppGUI = const_cast(pNppParam->getNppGUI()); nppGUI._fileSwitcherWithoutExtColumn = isOff == TRUE; if (_pFileSwitcherPanel) @@ -2187,7 +2182,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_ENTERMENULOOP: { - NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); + NppGUI & nppgui = const_cast((pNppParam->getNppGUI())); if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering) ::SetMenu(hwnd, _mainMenuHandle); @@ -2196,7 +2191,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_EXITMENULOOP: { - NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); + NppGUI & nppgui = const_cast((pNppParam->getNppGUI())); if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering) ::SetMenu(hwnd, NULL); _sysMenuEntering = false; @@ -2212,7 +2207,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { if (Message == WDN_NOTIFY) { - NMWINDLG* nmdlg = (NMWINDLG*)lParam; + NMWINDLG* nmdlg = reinterpret_cast(lParam); switch (nmdlg->type) { case WDT_ACTIVATE: @@ -2225,7 +2220,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WDT_SAVE: { //loop through nmdlg->nItems, get index and save it - for (int i = 0; i < (int)nmdlg->nItems; ++i) + for (unsigned int i = 0; i < nmdlg->nItems; ++i) { fileSave(_pDocTab->getBufferByIndex(i)); } @@ -2236,7 +2231,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WDT_CLOSE: { //loop through nmdlg->nItems, get index and close it - for (int i = 0; i < (int)nmdlg->nItems; ++i) + for (unsigned int i = 0; i < nmdlg->nItems; ++i) { bool closed = fileClose(_pDocTab->getBufferByIndex(nmdlg->Items[i]), currentView()); UINT pos = nmdlg->Items[i]; @@ -2246,7 +2241,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa nmdlg->Items[i] = 0xFFFFFFFF; // indicate file was closed // Shift the remaining items downward to fill the gap - for (int j = i + 1; j < (int)nmdlg->nItems; ++j) + for (unsigned int j = i + 1; j < nmdlg->nItems; ++j) { if (nmdlg->Items[j] > pos) nmdlg->Items[j]--; @@ -2264,12 +2259,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa //Collect all buffers std::vector tempBufs; - for (int i = 0; i < (int)nmdlg->nItems; ++i) + for (unsigned int i = 0; i < nmdlg->nItems; ++i) { tempBufs.push_back(_pDocTab->getBufferByIndex(i)); } //Reset buffers - for (int i = 0; i < (int)nmdlg->nItems; ++i) + for (unsigned int i = 0; i < nmdlg->nItems; ++i) { _pDocTab->setBuffer(i, tempBufs[nmdlg->Items[i]]); } diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 2c596135..bc78785a 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -653,7 +653,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) // Note: cast of leftmost_position to unsigned int is safe, since if leftmost_position is not -1 then it is guaranteed to be positive. // If it was possible, leftmost_position and rightmost_position should be of type optional. - if ( matching_leftmost <= position_of_click && i >= position_of_click && (leftmost_position == -1 || matching_leftmost > (unsigned int)leftmost_position) ) + if (matching_leftmost <= position_of_click && i >= position_of_click && (leftmost_position == -1 || matching_leftmost > static_cast(leftmost_position))) { leftmost_position = matching_leftmost; rightmost_position = i; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 89fc071c..4af4a1d8 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2247,8 +2247,8 @@ void NppParameters::feedShortcut(TiXmlNode *node) if (idStr) { //find the commandid that matches this Shortcut sc and alter it, push back its index in the modified list, if not present - int len = (int)_shortcuts.size(); - for(int i = 0; i < len; ++i) + size_t len = _shortcuts.size(); + for(size_t i = 0; i < len; ++i) { if (_shortcuts[i].getID() == (unsigned long)id) { //found our match @@ -2360,8 +2360,8 @@ void NppParameters::feedPluginCustomizedCmds(TiXmlNode *node) continue; //Find the corresponding plugincommand and alter it, put the index in the list - int len = (int)_pluginCommands.size(); - for(int i = 0; i < len; ++i) + size_t len = _pluginCommands.size(); + for(size_t i = 0; i < len; ++i) { PluginCmdShortcut & pscOrig = _pluginCommands[i]; if (!generic_strnicmp(pscOrig.getModuleName(), moduleName, lstrlen(moduleName)) && pscOrig.getInternalID() == internalID) @@ -2977,7 +2977,7 @@ void NppParameters::writeShortcuts() cmdRoot = root->InsertEndChild(TiXmlElement(TEXT("InternalCommands"))); for (size_t i = 0, len = _customizedShortcuts.size(); i < len ; ++i) { - int index = _customizedShortcuts[i]; + size_t index = _customizedShortcuts[i]; CommandShortcut csc = _shortcuts[index]; insertCmd(cmdRoot, csc); } @@ -3506,7 +3506,7 @@ TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const TCHA // 2 restes : L_H, L_USER LangType NppParameters::getLangIDFromStr(const TCHAR *langName) { - int lang = (int)L_TEXT; + int lang = static_cast(L_TEXT); for(; lang < L_EXTERNAL; ++lang) { const TCHAR * name = ScintillaEditView::langNames[lang].lexerName; @@ -5480,8 +5480,8 @@ bool NppParameters::writeGUIParams() } else if (!lstrcmp(nm, TEXT("delimiterSelection"))) { - element->SetAttribute(TEXT("leftmostDelimiter"), (int)_nppGUI._leftmostDelimiter); - element->SetAttribute(TEXT("rightmostDelimiter"), (int)_nppGUI._rightmostDelimiter); + element->SetAttribute(TEXT("leftmostDelimiter"), static_cast(_nppGUI._leftmostDelimiter)); + element->SetAttribute(TEXT("rightmostDelimiter"), static_cast(_nppGUI._rightmostDelimiter)); if(_nppGUI._delimiterSelectionOnEntireDocument) element->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), TEXT("yes")); else @@ -6448,7 +6448,7 @@ void NppParameters::stylerStrOp(bool op) } } -void NppParameters::addUserModifiedIndex(int index) +void NppParameters::addUserModifiedIndex(size_t index) { size_t len = _customizedShortcuts.size(); bool found = false; @@ -6466,7 +6466,7 @@ void NppParameters::addUserModifiedIndex(int index) } } -void NppParameters::addPluginModifiedIndex(int index) +void NppParameters::addPluginModifiedIndex(size_t index) { size_t len = _pluginCustomizedCmds.size(); bool found = false; diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 3d5e7cf3..6224d852 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -1403,14 +1403,14 @@ public: bool isRemappingShortcut() const {return _shortcuts.size() != 0;}; std::vector & getUserShortcuts() { return _shortcuts; }; - std::vector & getUserModifiedShortcuts() { return _customizedShortcuts; }; - void addUserModifiedIndex(int index); + std::vector & getUserModifiedShortcuts() { return _customizedShortcuts; }; + void addUserModifiedIndex(size_t index); std::vector & getMacroList() { return _macros; }; std::vector & getUserCommandList() { return _userCommands; }; std::vector & getPluginCommandList() { return _pluginCommands; }; - std::vector & getPluginModifiedKeyIndices() { return _pluginCustomizedCmds; }; - void addPluginModifiedIndex(int index); + std::vector & getPluginModifiedKeyIndices() { return _pluginCustomizedCmds; }; + void addPluginModifiedIndex(size_t index); std::vector & getScintillaKeyList() { return _scintillaKeyCommands; }; std::vector & getScintillaModifiedKeyIndices() { return _scintillaModifiedKeyIndices; }; @@ -1605,11 +1605,11 @@ public: private: bool _isAnyShortcutModified = false; std::vector _shortcuts; //main menu shortuts. Static size - std::vector _customizedShortcuts; //altered main menu shortcuts. Indices static. Needed when saving alterations + std::vector _customizedShortcuts; //altered main menu shortcuts. Indices static. Needed when saving alterations std::vector _macros; //macro shortcuts, dynamic size, defined on loading macros and adding/deleting them std::vector _userCommands; //run shortcuts, dynamic size, defined on loading run commands and adding/deleting them std::vector _pluginCommands; //plugin commands, dynamic size, defined on loading plugins - std::vector _pluginCustomizedCmds; //plugincommands that have been altered. Indices determined after loading ALL plugins. Needed when saving alterations + std::vector _pluginCustomizedCmds; //plugincommands that have been altered. Indices determined after loading ALL plugins. Needed when saving alterations std::vector _scintillaKeyCommands; //scintilla keycommands. Static size std::vector _scintillaModifiedKeyIndices; //modified scintilla keys. Indices static, determined by searching for commandId. Needed when saving alterations diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp index 89eba93d..246e1686 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp @@ -67,8 +67,8 @@ bool AutoCompletion::showApiComplete() bool AutoCompletion::showApiAndWordComplete() { - int curPos = int(_pEditView->execute(SCI_GETCURRENTPOS)); - int startPos = int(_pEditView->execute(SCI_WORDSTARTPOSITION, curPos, true)); + auto curPos = _pEditView->execute(SCI_GETCURRENTPOS); + auto startPos = _pEditView->execute(SCI_WORDSTARTPOSITION, curPos, true); if (curPos == startPos) return false; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index bbd395c9..c6354f19 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -408,11 +408,11 @@ Lang * Buffer::getCurrentLang() const int Buffer::indexOfReference(const ScintillaEditView * identifier) const { - int size = (int)_referees.size(); - for (int i = 0; i < size; ++i) + size_t size = _referees.size(); + for (size_t i = 0; i < size; ++i) { if (_referees[i] == identifier) - return i; + return static_cast(i); } return -1; //not found } @@ -537,7 +537,7 @@ int FileManager::getBufferIndexByID(BufferID id) for(size_t i = 0; i < _nrBufs; ++i) { if (_buffers[i]->_id == id) - return (int) i; + return static_cast(i); } return -1; } diff --git a/PowerEditor/src/ScitillaComponent/DocTabView.cpp b/PowerEditor/src/ScitillaComponent/DocTabView.cpp index 7dbd5930..c2495947 100644 --- a/PowerEditor/src/ScitillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScitillaComponent/DocTabView.cpp @@ -110,11 +110,11 @@ int DocTabView::getIndexByBuffer(BufferID id) TCITEM tie; tie.lParam = -1; tie.mask = TCIF_PARAM; - for(int i = 0; i < (int)_nbItem; ++i) + for(size_t i = 0; i < _nbItem; ++i) { ::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast(&tie)); if (reinterpret_cast(tie.lParam) == id) - return i; + return static_cast(i); } return -1; } @@ -194,13 +194,13 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask) } -void DocTabView::setBuffer(int index, BufferID id) +void DocTabView::setBuffer(size_t index, BufferID id) { - if (index < 0 || index >= (int)_nbItem) + if (index < 0 || index >= _nbItem) return; TCITEM tie; - tie.lParam = (LPARAM)id; + tie.lParam = reinterpret_cast(id); tie.mask = TCIF_PARAM; ::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast(&tie)); diff --git a/PowerEditor/src/ScitillaComponent/DocTabView.h b/PowerEditor/src/ScitillaComponent/DocTabView.h index a637dd34..a9295141 100644 --- a/PowerEditor/src/ScitillaComponent/DocTabView.h +++ b/PowerEditor/src/ScitillaComponent/DocTabView.h @@ -73,7 +73,7 @@ public : int getIndexByBuffer(BufferID id); BufferID getBufferByIndex(size_t index); - void setBuffer(int index, BufferID id); + void setBuffer(size_t index, BufferID id); static bool setHideTabBarStatus(bool hideOrNot) { bool temp = _hideTabBarStatus; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index c4bdf55b..75d525b1 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -185,29 +185,30 @@ void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditVi { // to make sure the found result is visible //When searching up, the beginning of the (possible multiline) result is important, when scrolling down the end - int testPos = (isDownwards)?posEnd:posStart; + int testPos = isDownwards ? posEnd : posStart; + pEditView->execute(SCI_SETCURRENTPOS, testPos); - int currentlineNumberDoc = (int)pEditView->execute(SCI_LINEFROMPOSITION, testPos); - int currentlineNumberVis = (int)pEditView->execute(SCI_VISIBLEFROMDOCLINE, currentlineNumberDoc); + auto currentlineNumberDoc = pEditView->execute(SCI_LINEFROMPOSITION, testPos); + auto currentlineNumberVis = pEditView->execute(SCI_VISIBLEFROMDOCLINE, currentlineNumberDoc); pEditView->execute(SCI_ENSUREVISIBLE, currentlineNumberDoc); // make sure target line is unfolded - int firstVisibleLineVis = (int)pEditView->execute(SCI_GETFIRSTVISIBLELINE); - int linesVisible = (int)pEditView->execute(SCI_LINESONSCREEN) - 1; //-1 for the scrollbar - int lastVisibleLineVis = (int)linesVisible + firstVisibleLineVis; + auto firstVisibleLineVis = pEditView->execute(SCI_GETFIRSTVISIBLELINE); + auto linesVisible = pEditView->execute(SCI_LINESONSCREEN) - 1; //-1 for the scrollbar + auto lastVisibleLineVis = linesVisible + firstVisibleLineVis; //if out of view vertically, scroll line into (center of) view int linesToScroll = 0; if (currentlineNumberVis < firstVisibleLineVis) { - linesToScroll = currentlineNumberVis - firstVisibleLineVis; + linesToScroll = static_cast(currentlineNumberVis - firstVisibleLineVis); //use center - linesToScroll -= linesVisible/2; + linesToScroll -= static_cast(linesVisible/2); } else if (currentlineNumberVis > lastVisibleLineVis) { - linesToScroll = currentlineNumberVis - lastVisibleLineVis; + linesToScroll = static_cast(currentlineNumberVis - lastVisibleLineVis); //use center - linesToScroll += linesVisible/2; + linesToScroll += static_cast(linesVisible/2); } pEditView->scroll(0, linesToScroll); diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp index 2b4a0d3e..04d923a1 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp @@ -118,7 +118,7 @@ void FunctionCallTip::showNextOverload() { void FunctionCallTip::showPrevOverload() { if (!isVisible()) return; - _currentOverload = _currentOverload > 0?(_currentOverload-1) : _currentNrOverloads-1; + _currentOverload = _currentOverload > 0 ? (_currentOverload-1) : (_currentNrOverloads-1); showCalltip(); } @@ -366,7 +366,7 @@ bool FunctionCallTip::loadFunction() ++_currentNrOverloads; } - _currentNrOverloads = (int)_overloads.size(); + _currentNrOverloads = _overloads.size(); if (_currentNrOverloads == 0) //malformed node return false; diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.h b/PowerEditor/src/ScitillaComponent/FunctionCallTip.h index fa6fe88e..aebc815c 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.h +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.h @@ -59,8 +59,8 @@ private: stringVec _retVals; //vector of overload return values/types std::vector _overloads; //vector of overload params (=vector) stringVec _descriptions; //vecotr of function descriptions - int _currentNrOverloads = 0; //current amount of overloads - int _currentOverload = 0; //current chosen overload + size_t _currentNrOverloads = 0; //current amount of overloads + size_t _currentOverload = 0; //current chosen overload int _currentParam = 0; //current highlighted param TCHAR _start = '('; diff --git a/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp b/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp index bb47da18..a425a888 100644 --- a/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp @@ -137,13 +137,13 @@ void GoToLineDlg::updateLinesNumbers() const if (_mode == go2line) { - current = (unsigned int)((*_ppEditView)->getCurrentLineNumber() + 1); - limit = (unsigned int)((*_ppEditView)->execute(SCI_GETLINECOUNT)); + current = static_cast((*_ppEditView)->getCurrentLineNumber() + 1); + limit = static_cast((*_ppEditView)->execute(SCI_GETLINECOUNT)); } else { - current = (unsigned int)(*_ppEditView)->execute(SCI_GETCURRENTPOS); - limit = (unsigned int)((*_ppEditView)->getCurrentDocLen() - 1); + current = static_cast((*_ppEditView)->execute(SCI_GETCURRENTPOS)); + limit = static_cast((*_ppEditView)->getCurrentDocLen() - 1); } ::SetDlgItemInt(_hSelf, ID_CURRLINE, current, FALSE); ::SetDlgItemInt(_hSelf, ID_LASTLINE, limit, FALSE); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 1e9eadf6..e19cb9d4 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2300,19 +2300,19 @@ void ScintillaEditView::updateLineNumberWidth() { if (_lineNumbersShown) { - int linesVisible = (int) execute(SCI_LINESONSCREEN); + auto linesVisible = execute(SCI_LINESONSCREEN); if (linesVisible) { - int firstVisibleLineVis = (int) execute(SCI_GETFIRSTVISIBLELINE); - int lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1; + auto firstVisibleLineVis = execute(SCI_GETFIRSTVISIBLELINE); + auto lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1; if (execute(SCI_GETWRAPMODE) != SC_WRAP_NONE) { - int numLinesDoc = (int) execute(SCI_GETLINECOUNT); - int prevLineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLineVis); - for (int i = firstVisibleLineVis + 1; i <= lastVisibleLineVis; ++i) + auto numLinesDoc = execute(SCI_GETLINECOUNT); + auto prevLineDoc = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLineVis); + for (auto i = firstVisibleLineVis + 1; i <= lastVisibleLineVis; ++i) { - int lineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, i); + auto lineDoc = execute(SCI_DOCLINEFROMVISIBLE, i); if (lineDoc == numLinesDoc) break; if (lineDoc == prevLineDoc) @@ -2321,7 +2321,7 @@ void ScintillaEditView::updateLineNumberWidth() } } - int lastVisibleLineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, lastVisibleLineVis); + auto lastVisibleLineDoc = execute(SCI_DOCLINEFROMVISIBLE, lastVisibleLineVis); int i = 0; while (lastVisibleLineDoc) @@ -2331,7 +2331,7 @@ void ScintillaEditView::updateLineNumberWidth() } i = max(i, 3); - int pixelWidth = int(8 + i * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"8")); + auto pixelWidth = 8 + i * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"8"); execute(SCI_SETMARGINWIDTHN, _SC_MARGE_LINENUMBER, pixelWidth); } } diff --git a/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp b/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp index c2e8e9aa..77c6d69a 100644 --- a/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp @@ -89,13 +89,13 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView) } // save target locations for other search functions - int originalStartPos = (int)pHighlightView->execute(SCI_GETTARGETSTART); - int originalEndPos = (int)pHighlightView->execute(SCI_GETTARGETEND); + auto originalStartPos = pHighlightView->execute(SCI_GETTARGETSTART); + auto originalEndPos = pHighlightView->execute(SCI_GETTARGETEND); // Get the range of text visible and highlight everything in it - int firstLine = (int)pHighlightView->execute(SCI_GETFIRSTVISIBLELINE); + int firstLine = static_cast(pHighlightView->execute(SCI_GETFIRSTVISIBLELINE)); int nrLines = min((int)pHighlightView->execute(SCI_LINESONSCREEN), MAXLINEHIGHLIGHT ) + 1; - int lastLine = firstLine+nrLines; + int lastLine = firstLine + nrLines; int startPos = 0; int endPos = 0; int currentLine = firstLine; @@ -128,7 +128,7 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView) frInfo._endRange = endPos; if (endPos == -1) { //past EOF - frInfo._endRange = (int)pHighlightView->getCurrentDocLen() - 1; + frInfo._endRange = pHighlightView->getCurrentDocLen() - 1; _pFRDlg->processRange(ProcessMarkAll_2, frInfo, NULL, &fo); break; } diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index c1b47d06..bb03ef0b 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -516,7 +516,7 @@ void CommentStyleDialog::setKeywords2List(int id) IDC_COMMENT_CLOSE_EDIT }; - for (int i=0; iappend( str.c_str() + i, 1 ); ++i; @@ -87,14 +87,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;"), (unsigned) ( c & 0xffff ) ); + TCHAR buf[32]; + wsprintf( buf, TEXT("&#x%04X;"), static_cast(c & 0xffff) ); outString->append( buf, lstrlen( buf ) ); ++i; } else { - TCHAR realc = (TCHAR) c; + TCHAR realc = static_cast(c); outString->append( &realc, 1 ); ++i; } diff --git a/PowerEditor/src/TinyXml/tinyxmlparser.cpp b/PowerEditor/src/TinyXml/tinyxmlparser.cpp index 718b6d89..f593876c 100644 --- a/PowerEditor/src/TinyXml/tinyxmlparser.cpp +++ b/PowerEditor/src/TinyXml/tinyxmlparser.cpp @@ -242,13 +242,13 @@ const TCHAR* TiXmlBase::GetEntity( const TCHAR* p, TCHAR* value ) } // Now try to match it. - for( i=0; i(lstrlen(entity[i].str)) == entity[i].strLength ); *value = entity[i].chr; - return ( p + entity[i].strLength ); + return (p + entity[i].strLength); } } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index d0187196..dafd4404 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -435,7 +435,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l int tabColourIndex; if ((tabColourIndex = whichTabColourIndex()) != -1) { - tabColourIndex = (int)tabColourIndex == TabBarPlus::inactiveText? TabBarPlus::inactiveBg : tabColourIndex; + tabColourIndex = tabColourIndex == (TabBarPlus::inactiveText ? TabBarPlus::inactiveBg : tabColourIndex); TabBarPlus::setColour(_pBgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex); } apply(); @@ -498,16 +498,16 @@ int WordStyleDlg::whichTabColourIndex() ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, (LPARAM)styleName); if (lstrcmp(styleName, TABBAR_ACTIVEFOCUSEDINDCATOR) == 0) - return (int)TabBarPlus::activeFocusedTop; + return TabBarPlus::activeFocusedTop; if (lstrcmp(styleName, TABBAR_ACTIVEUNFOCUSEDINDCATOR) == 0) - return (int)TabBarPlus::activeUnfocusedTop; + return TabBarPlus::activeUnfocusedTop; if (lstrcmp(styleName, TABBAR_ACTIVETEXT) == 0) - return (int)TabBarPlus::activeText; + return TabBarPlus::activeText; if (lstrcmp(styleName, TABBAR_INACTIVETEXT) == 0) - return (int)TabBarPlus::inactiveText; + return TabBarPlus::inactiveText; return -1; } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index 53a26167..67e8680e 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -99,7 +99,7 @@ public : virtual void redraw() const { _pFgColour->redraw(); - _pBgColour->redraw(); + _pBgColour->redraw(); ::InvalidateRect(_hStyleInfoStaticText, NULL, TRUE); ::UpdateWindow(_hStyleInfoStaticText); }; diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index 3166d321..fd2c85cf 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -915,7 +915,7 @@ INT_PTR CALLBACK DockingCont::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP case WM_NCACTIVATE: { // Note: lParam to identify the trigger window - if ((int)lParam != -1) + if (static_cast(lParam) != -1) { ::SendMessage(_hParent, WM_NCACTIVATE, wParam, 0); } @@ -1330,7 +1330,7 @@ void DockingCont::SelectTab(int iTab) nmhdr.idFrom = 0; ::SendMessage(((tTbData*)tcItem.lParam)->hClient, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); - if ((unsigned int)iTab != _prevItem) + if (static_cast(iTab) != _prevItem) { // hide previous dialog ::SendMessage(_hContTab, TCM_GETITEM, _prevItem, (LPARAM)&tcItem); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h index 70246f10..77da5d38 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h @@ -134,7 +134,7 @@ public: }; virtual void destroy() { - for (int iTb = (int)_vTbData.size(); iTb > 0; iTb--) + for (int iTb = static_cast(_vTbData.size()); iTb > 0; iTb--) { delete _vTbData[iTb-1]; } diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index d59294aa..67ea60e3 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -232,7 +232,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l ::SendMessage(_vContainer[iCont]->getHSelf(), WM_NCACTIVATE, wParam, (LPARAM)-1); } - if ((int)lParam != -1) + if (static_cast(lParam) != -1) { ::SendMessage(_hParent, WM_NCACTIVATE, wParam, (LPARAM)-1); } diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index 4f5a1102..79616937 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -42,12 +42,12 @@ #define INDEX_OPEN_ROOT 0 #define INDEX_CLOSE_ROOT 1 #define INDEX_OPEN_NODE 2 -#define INDEX_CLOSE_NODE 3 +#define INDEX_CLOSE_NODE 3 #define INDEX_LEAF 4 -#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) -#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) +#define GET_X_LPARAM(lp) static_cast(LOWORD(lp)) +#define GET_Y_LPARAM(lp) static_cast(HIWORD(lp)) #define FB_ADDFILE (WM_USER + 1024) #define FB_RMFILE (WM_USER + 1025) @@ -724,7 +724,7 @@ void FileBrowser::popupMenuCmd(int cmdID) case IDM_FILEBROWSER_REMOVEALLROOTS: { - for (int i = (int)_folderUpdaters.size() - 1; i >= 0; --i) + for (int i = static_cast(_folderUpdaters.size()) - 1; i >= 0; --i) { _folderUpdaters[i]->stopWatcher(); diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp index 82959d45..84699c45 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp @@ -592,14 +592,14 @@ void FunctionParser::getInvertZones(vector< pair > & destZones, vecto { if (sourceZones.size() == 0) { - destZones.push_back(pair((int)begin, (int)end)); + destZones.push_back(pair(static_cast(begin), static_cast(end))); } else { // check the begin if (int(begin) < sourceZones[0].first) { - destZones.push_back(pair((int)begin, sourceZones[0].first - 1)); + destZones.push_back(pair(static_cast(begin), sourceZones[0].first - 1)); } size_t i = 0; @@ -612,7 +612,7 @@ void FunctionParser::getInvertZones(vector< pair > & destZones, vecto } int lastBegin = sourceZones[i].second + 1; if (lastBegin < int(end)) - destZones.push_back(pair(lastBegin, (int)end)); + destZones.push_back(pair(lastBegin, static_cast(end))); } } diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index fea56ec7..516d1572 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -560,11 +560,11 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe rect.left +=0; rect.right -=0; if((rect.bottom - rect.top)>24) - { + { excess=(rect.bottom - rect.top)-16; - rect.top += (int)(excess/2); - rect.bottom -= (int)(excess/2); - } + rect.top += excess / 2; + rect.bottom -= excess / 2; + } DrawFrameControl(gdc,&rect,DFC_BUTTON,DFCS_BUTTONCHECK|DFCS_CHECKED); } @@ -577,11 +577,11 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe rect.left +=0; rect.right -=0; if((rect.bottom - rect.top)>24) - { + { excess=(rect.bottom - rect.top)-16; - rect.top += (int)(excess/2); - rect.bottom -= (int)(excess/2); - } + rect.top += excess / 2; + rect.bottom -= excess / 2; + } DrawFrameControl(gdc,&rect,DFC_BUTTON,DFCS_BUTTONCHECK); @@ -1183,14 +1183,11 @@ void DisplayEditString(HWND hWnd,int SI,TCHAR* tstring) rt.right +=5; ShowCaret(hWnd); - { - int rh,ah; - rh=BGHS[SI].rowheight; - ah=BGHS[SI].fontascentheight; + + int rh = BGHS[SI].rowheight; + int ah = BGHS[SI].fontascentheight; - SetCaretPos(rt.right-4,rt.top+(int)(rh/2)-ah+2); - - } + SetCaretPos(rt.right - 4, rt.top + (rh / 2)-ah + 2); SelectObject(cdc,holdfont); ReleaseDC(hWnd,cdc); @@ -1413,18 +1410,18 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if(lstrlen(BGHS[SelfIndex].title) > 0) { linecount=1; - for(j=0;j<(int)lstrlen(BGHS[SelfIndex].title);j++) - { - if(BGHS[SelfIndex].title[j]=='\n') - { + for (j = 0; j(lstrlen(BGHS[SelfIndex].title)); j++) + { + if (BGHS[SelfIndex].title[j] == '\n') + { linecount++; - } + } - } + } holdfont=(HFONT)SelectObject(gdc,BGHS[SelfIndex].htitlefont); GetTextExtentPoint32(gdc,BGHS[SelfIndex].title,lstrlen(BGHS[SelfIndex].title),&size); SelectObject(gdc,holdfont); - BGHS[SelfIndex].titleheight = (int)((size.cy*1.2) * linecount); + BGHS[SelfIndex].titleheight = static_cast((size.cy*1.2) * linecount); } else { @@ -3111,7 +3108,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext) if(lbcount < 12) { //not worth doing binary search, do regular search - FindResult = static_cast(SendMessage(lbhWnd, LB_FINDSTRING, (unsigned int)-1, (LPARAM)searchtext)); + FindResult = static_cast(SendMessage(lbhWnd, LB_FINDSTRING, static_cast(-1), reinterpret_cast(searchtext))); ReturnValue = FindResult; return ReturnValue; } @@ -3121,7 +3118,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext) tail = lbcount - 1; //is it the head? - SendMessage(lbhWnd,LB_GETTEXT,head,(LPARAM)headtext); + SendMessage(lbhWnd, LB_GETTEXT, head, reinterpret_cast(headtext)); headtext[9] = 0x00; p=lstrcmp(searchtext,headtext); @@ -3141,7 +3138,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext) //is it the tail? - SendMessage(lbhWnd,LB_GETTEXT,tail,(LPARAM)tailtext); + SendMessage(lbhWnd, LB_GETTEXT, tail, reinterpret_cast(tailtext)); tailtext[9] = 0x00; p=lstrcmp(searchtext,tailtext); if(p==0) @@ -3166,7 +3163,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext) { finger = head + ((tail - head) / 2); - SendMessage(lbhWnd,LB_GETTEXT,finger,(LPARAM)tbuffer); + SendMessage(lbhWnd, LB_GETTEXT, finger, reinterpret_cast(tbuffer)); tbuffer[9] = 0x00; p=lstrcmp(tbuffer,searchtext); if(p==0) diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 975ff95d..1aed85c6 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -639,19 +639,19 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa HWND hBorderWidthSlider = ::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER); if (reinterpret_cast(lParam) == hCaretBlikRateSlider) { - int blinkRate = (int)::SendMessage(hCaretBlikRateSlider, TBM_GETPOS, 0, 0); + auto blinkRate = ::SendMessage(hCaretBlikRateSlider, TBM_GETPOS, 0, 0); if (blinkRate == BLINKRATE_SLOWEST) blinkRate = 0; - nppGUI._caretBlinkRate = blinkRate; + nppGUI._caretBlinkRate = static_cast(blinkRate); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0); } else if (reinterpret_cast(lParam) == hBorderWidthSlider) { - int borderWidth = (int)::SendMessage(hBorderWidthSlider, TBM_GETPOS, 0, 0); + auto borderWidth = ::SendMessage(hBorderWidthSlider, TBM_GETPOS, 0, 0); ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP(); - svp._borderWidth = borderWidth; - ::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, borderWidth, FALSE); + svp._borderWidth = static_cast(borderWidth); + ::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, static_cast(borderWidth), FALSE); ::SendMessage(::GetParent(_hParent), WM_SIZE, 0, 0); } return 0; //return zero when handled diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp index 0d17a726..fbc953fe 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp @@ -44,8 +44,8 @@ #define INDEX_LEAF 5 #define INDEX_LEAF_INVALID 6 -#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) -#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) +#define GET_X_LPARAM(lp) LOWORD(lp) +#define GET_Y_LPARAM(lp) HIWORD(lp) INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index de8a8541..567c2a65 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -245,7 +245,7 @@ INT_PTR CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) int const posBase = 2; if (nbCmd == 0) - ::InsertMenu(hRunMenu, posBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); + ::InsertMenu(hRunMenu, posBase - 1, MF_BYPOSITION, static_cast(-1), 0); theUserCmds.push_back(uc); ::InsertMenu(hRunMenu, posBase + nbCmd, MF_BYPOSITION, cmdID, uc.toMenuItemString().c_str()); @@ -254,7 +254,7 @@ INT_PTR CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) if (nbCmd == 0) { // Insert the separator and modify/delete command - ::InsertMenu(hRunMenu, posBase + nbCmd + 1, MF_BYPOSITION, (unsigned int)-1, 0); + ::InsertMenu(hRunMenu, posBase + nbCmd + 1, MF_BYPOSITION, static_cast(-1), 0); NativeLangSpeaker *pNativeLangSpeaker = nppParams->getNativeLangSpeaker(); generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO); if (nativeLangShortcutMapperMacro == TEXT("")) diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp index f0c483aa..9b978bb0 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp @@ -128,7 +128,7 @@ void StatusBar::adjustParts(int clientWidth) // copy the coordinates to the array. int nWidth = std::max(clientWidth - 20, 0); - for (int i = (int)_partWidthArray.size() - 1; i >= 0; i--) + for (int i = static_cast(_partWidthArray.size()) - 1; i >= 0; i--) { _lpParts[i] = nWidth; nWidth -= _partWidthArray[i]; diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.cpp b/PowerEditor/src/WinControls/TaskList/TaskList.cpp index 567341bf..1d1f81ae 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.cpp +++ b/PowerEditor/src/WinControls/TaskList/TaskList.cpp @@ -25,8 +25,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - #include #include "TaskList.h" #include "TaskListDlg_rc.h" diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.h b/PowerEditor/src/WinControls/TaskList/TaskList.h index a87feed5..7a3ecb42 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.h +++ b/PowerEditor/src/WinControls/TaskList/TaskList.h @@ -26,8 +26,7 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef TASKLIST_H -#define TASKLIST_H +#pragma once #include #include @@ -77,5 +76,3 @@ protected: RECT _rc; }; - -#endif // TASKLIST_H diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp index 77f71d27..454a5a53 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp @@ -455,13 +455,13 @@ bool ReBar::addBand(REBARBANDINFO * rBand, bool useID) void ReBar::reNew(int id, REBARBANDINFO * rBand) { - int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); + auto index = SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); ::SendMessage(_hSelf, RB_SETBANDINFO, (WPARAM)index, (LPARAM)rBand); }; void ReBar::removeBand(int id) { - int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); + auto index = SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); if (id >= REBAR_BAR_EXTERNAL) releaseID(id); ::SendMessage(_hSelf, RB_DELETEBAND, (WPARAM)index, (LPARAM)0); @@ -469,7 +469,7 @@ void ReBar::removeBand(int id) void ReBar::setIDVisible(int id, bool show) { - int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); + auto index = SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); if (index == -1 ) return; //error @@ -489,7 +489,7 @@ void ReBar::setIDVisible(int id, bool show) bool ReBar::getIDVisible(int id) { - int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); + auto index = SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); if (index == -1 ) return false; //error REBARBANDINFO rbBand; @@ -504,7 +504,7 @@ bool ReBar::getIDVisible(int id) void ReBar::setGrayBackground(int id) { - int index = (int)SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); + auto index = SendMessage(_hSelf, RB_IDTOINDEX, (WPARAM)id, 0); if (index == -1 ) return; //error REBARBANDINFO rbBand; diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index 4c4ca114..b34db1b8 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -162,8 +162,8 @@ struct BufferEquivalent } else if (_iColumn == 2) { - int t1 = (int)b1->getLangType(); - int t2 = (int)b2->getLangType(); + auto t1 = b1->getLangType(); + auto t2 = b2->getLangType(); return (t1 < t2); // yeah should be the name } return false; @@ -429,7 +429,7 @@ void WindowsDlg::updateButtonState() int WindowsDlg::doDialog(TiXmlNodeA *dlgNode) { _dlgNode = dlgNode; - return (int)::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, reinterpret_cast(this)); + return static_cast(DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, reinterpret_cast(this))); }; bool WindowsDlg::changeDlgLang() @@ -602,8 +602,8 @@ void WindowsDlg::fitColumnsToSize() if (GetClientRect(_hList, &rc)) { int len = (rc.right - rc.left); - len -= (int)SendMessage(_hList, LVM_GETCOLUMNWIDTH, 0, 0); - len -= (int)SendMessage(_hList, LVM_GETCOLUMNWIDTH, 2, 0); + len -= static_cast(SendMessage(_hList, LVM_GETCOLUMNWIDTH, 0, 0)); + len -= static_cast(SendMessage(_hList, LVM_GETCOLUMNWIDTH, 2, 0)); len -= GetSystemMetrics(SM_CXVSCROLL); len -= 1; SendMessage(_hList, LVM_SETCOLUMNWIDTH, 1, len); @@ -719,7 +719,9 @@ void WindowsDlg::doClose() else { // select first previously selected item (or last one if only the last one was removed) - if (index == (int)_idxMap.size()) index --; + if (index == static_cast(_idxMap.size())) + index -= 1; + if (index >= 0) { ListView_SetItemState(_hList, index, LVIS_SELECTED, LVIS_SELECTED); diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index f5d7d15e..dcf69963 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -585,7 +585,7 @@ void Accelerator::updateFullMenu() { void Accelerator::updateMenuItemByCommand(CommandShortcut csc) { - int cmdID = (int)csc.getID(); + int cmdID = csc.getID(); // Ensure that the menu item checks set prior to this update remain in affect. UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND ); diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index b2b9d80b..8e6ba741 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -195,7 +195,7 @@ void LastRecentFileList::remove(const TCHAR *fn) remove(index); }; -void LastRecentFileList::remove(int index) +void LastRecentFileList::remove(size_t index) { if (_size == 0 || _locked) return; diff --git a/PowerEditor/src/lastRecentFileList.h b/PowerEditor/src/lastRecentFileList.h index 4dc82672..896a6b07 100644 --- a/PowerEditor/src/lastRecentFileList.h +++ b/PowerEditor/src/lastRecentFileList.h @@ -52,7 +52,7 @@ public: void add(const TCHAR *fn); void remove(const TCHAR *fn); - void remove(int index); + void remove(size_t index); void clear(); int getSize() { diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index f91f8763..d62bba70 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -840,8 +840,6 @@ void NativeLangSpeaker::changeShortcutLang() NppParameters * pNppParam = NppParameters::getInstance(); vector & mainshortcuts = pNppParam->getUserShortcuts(); vector & scinshortcuts = pNppParam->getScintillaKeyList(); - int mainSize = (int)mainshortcuts.size(); - int scinSize = (int)scinshortcuts.size(); TiXmlNodeA *shortcuts = _nativeLangA->FirstChild("Shortcuts"); if (!shortcuts) return; @@ -860,7 +858,8 @@ void NativeLangSpeaker::changeShortcutLang() int index, id; if (element->Attribute("index", &index) && element->Attribute("id", &id)) { - if (index > -1 && index < mainSize) { //valid index only + if (index > -1 && static_cast(index) < mainshortcuts.size()) //valid index only + { const char *name = element->Attribute("name"); CommandShortcut & csc = mainshortcuts[index]; if (csc.getID() == (unsigned long)id) @@ -891,7 +890,8 @@ void NativeLangSpeaker::changeShortcutLang() int index; if (element->Attribute("index", &index)) { - if (index > -1 && index < scinSize) { //valid index only + if (index > -1 && static_cast(index) < scinshortcuts.size()) //valid index only + { const char *name = element->Attribute("name"); ScintillaKeyMap & skm = scinshortcuts[index];