Use C++ conversion instead of C style cast

This commit is contained in:
Don HO 2016-07-23 11:37:58 +02:00
parent 797765173d
commit 30bd15f04a
39 changed files with 258 additions and 273 deletions

View File

@ -513,7 +513,7 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
_multiByteStr.sizeTo(len); _multiByteStr.sizeTo(len);
len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL); // not needed? 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); *mstart = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mstart, NULL, 0, NULL, NULL);
*mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, NULL, 0, NULL, NULL); *mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, NULL, 0, NULL, NULL);

View File

@ -332,12 +332,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
if (_toReduceTabBar) if (_toReduceTabBar)
{ {
HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT); HFONT hf = reinterpret_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
if (hf) if (hf)
{ {
::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0)); ::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0)); ::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
} }
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(22); int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(22);
int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(45); int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(45);
@ -418,15 +418,15 @@ LRESULT Notepad_plus::init(HWND hwnd)
size_t const posBase = 6; size_t const posBase = 6;
size_t nbMacro = macros.size(); size_t nbMacro = macros.size();
if (nbMacro >= 1) if (nbMacro >= 1)
::InsertMenu(hMacroMenu, posBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hMacroMenu, posBase - 1, MF_BYPOSITION, static_cast<UINT>(-1), 0);
for (size_t i = 0 ; i < nbMacro ; ++i) 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<UINT>(posBase + i), MF_BYPOSITION, ID_MACRO + i, macros[i].toMenuItemString().c_str());
if (nbMacro >= 1) if (nbMacro >= 1)
{ {
::InsertMenu(hMacroMenu, UINT(posBase + nbMacro + 1), MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hMacroMenu, static_cast<UINT>(posBase + nbMacro + 1), MF_BYPOSITION, static_cast<UINT>(-1), 0);
::InsertMenu(hMacroMenu, UINT(posBase + nbMacro + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro...")); ::InsertMenu(hMacroMenu, static_cast<UINT>(posBase + nbMacro + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro..."));
} }
// Run Menu // Run Menu
@ -435,17 +435,17 @@ LRESULT Notepad_plus::init(HWND hwnd)
int const runPosBase = 2; int const runPosBase = 2;
size_t nbUserCommand = userCommands.size(); size_t nbUserCommand = userCommands.size();
if (nbUserCommand >= 1) if (nbUserCommand >= 1)
::InsertMenu(hRunMenu, runPosBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hRunMenu, runPosBase - 1, MF_BYPOSITION, static_cast<UINT>(-1), 0);
for (size_t i = 0 ; i < nbUserCommand ; ++i) 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<UINT>(runPosBase + i), MF_BYPOSITION, ID_USER_CMD + i, userCommands[i].toMenuItemString().c_str());
} }
if (nbUserCommand >= 1) if (nbUserCommand >= 1)
{ {
::InsertMenu(hRunMenu, UINT(runPosBase + nbUserCommand + 1), MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hRunMenu, static_cast<UINT>(runPosBase + nbUserCommand + 1), MF_BYPOSITION, static_cast<UINT>(-1), 0);
::InsertMenu(hRunMenu, UINT(runPosBase + nbUserCommand + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, TEXT("Modify Shortcut/Delete Command...")); ::InsertMenu(hRunMenu, static_cast<UINT>(runPosBase + nbUserCommand + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, TEXT("Modify Shortcut/Delete Command..."));
} }
// Updater menu item // Updater menu item
@ -2935,11 +2935,11 @@ size_t Notepad_plus::getCurrentDocCharCount(UniMode u)
if (u != uniUTF8 && u != uniCookie) if (u != uniUTF8 && u != uniCookie)
{ {
size_t numLines = _pEditView->execute(SCI_GETLINECOUNT); 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; size_t lines = numLines==0?0:numLines-1;
if (_pEditView->execute(SCI_GETEOLMODE) == SC_EOL_CRLF) lines *= 2; if (_pEditView->execute(SCI_GETEOLMODE) == SC_EOL_CRLF) lines *= 2;
result -= lines; result -= lines;
return ((int)result < 0) ? 0 : result; return (result < 0) ? 0 : result;
} }
else else
{ {
@ -4072,10 +4072,10 @@ bool Notepad_plus::addCurrentMacro()
int const posBase = 6; //separator at index 5 int const posBase = 6; //separator at index 5
if (nbMacro == 0) 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<UINT>(-1), 0); //no separator yet, add one
// Insert the separator and modify/delete command // 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<UINT>(-1), 0);
NativeLangSpeaker *pNativeLangSpeaker = nppParams->getNativeLangSpeaker(); NativeLangSpeaker *pNativeLangSpeaker = nppParams->getNativeLangSpeaker();
generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO); generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO);
@ -4100,22 +4100,20 @@ void Notepad_plus::changeToolBarIcons()
bool Notepad_plus::switchToFile(BufferID id) bool Notepad_plus::switchToFile(BufferID id)
{ {
int i = 0;
int iView = currentView(); int iView = currentView();
if (id == BUFFER_INVALID) if (id == BUFFER_INVALID)
return false; return false;
int i = _pDocTab->getIndexByBuffer(id);
if ((i = _pDocTab->getIndexByBuffer(id)) != -1) if (i != -1)
{ {
iView = currentView(); iView = currentView();
} }
else if ((i = _pNonDocTab->getIndexByBuffer(id)) != -1)
{ i = _pNonDocTab->getIndexByBuffer(id);
iView = otherView();
}
if (i != -1) if (i != -1)
{ {
iView = otherView();
switchEditViewTo(iView); switchEditViewTo(iView);
activateBuffer(id, currentView()); activateBuffer(id, currentView());
return true; return true;
@ -4406,7 +4404,7 @@ void Notepad_plus::postItToggle()
NppParameters * pNppParam = NppParameters::getInstance(); NppParameters * pNppParam = NppParameters::getInstance();
if (!_beforeSpecialView.isPostIt) // PostIt disabled, enable it if (!_beforeSpecialView.isPostIt) // PostIt disabled, enable it
{ {
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); NppGUI & nppGUI = const_cast<NppGUI &>(pNppParam->getNppGUI());
// get current status before switch to postIt // get current status before switch to postIt
//check these always //check these always
{ {
@ -4752,9 +4750,6 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
switch(buffer->getStatus()) switch(buffer->getStatus())
{ {
case DOC_UNNAMED: //nothing todo case DOC_UNNAMED: //nothing todo
{
break;
}
case DOC_REGULAR: //nothing todo case DOC_REGULAR: //nothing todo
{ {
break; break;
@ -5960,7 +5955,7 @@ bool isInList(int elem, vector<int> elemList)
DWORD WINAPI Notepad_plus::threadTextPlayer(void *params) DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
{ {
// random seed generation needs only one time. // random seed generation needs only one time.
srand((unsigned int)time(NULL)); srand(static_cast<UINT>(time(NULL)));
TextPlayerParams* textPlayerParams = static_cast<TextPlayerParams*>(params); TextPlayerParams* textPlayerParams = static_cast<TextPlayerParams*>(params);
HWND hNpp = textPlayerParams->_nppHandle; HWND hNpp = textPlayerParams->_nppHandle;
@ -6078,7 +6073,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params)
WaitForSingleObject(textTrollerParams->_mutex, INFINITE); WaitForSingleObject(textTrollerParams->_mutex, INFINITE);
// random seed generation needs only one time. // random seed generation needs only one time.
srand((unsigned int)time(NULL)); srand(static_cast<UINT>(time(NULL)));
ScintillaEditView *pCurrentView = textTrollerParams->_pCurrentView; ScintillaEditView *pCurrentView = textTrollerParams->_pCurrentView;
const char *text2display = textTrollerParams->_text2display; const char *text2display = textTrollerParams->_text2display;
@ -6203,7 +6198,7 @@ int Notepad_plus::getQuoteIndexFrom(const char *quoter) const
if (stricmp(quoter, "random") == 0) if (stricmp(quoter, "random") == 0)
{ {
srand((unsigned int)time(NULL)); srand(static_cast<UINT>(time(NULL)));
return getRandomNumber(nbQuote); return getRandomNumber(nbQuote);
} }
@ -6445,20 +6440,20 @@ bool Notepad_plus::undoStreamComment()
if (selectionStart > posStartComment) if (selectionStart > posStartComment)
{ {
if (selectionStart >= posStartComment+startCommentLength) if (selectionStart >= posStartComment+startCommentLength)
selectionStartMove = -(int)startCommentLength; selectionStartMove = -static_cast<int>(startCommentLength);
else else
selectionStartMove = -(int)(selectionStart - posStartComment); selectionStartMove = -static_cast<int>(selectionStart - posStartComment);
} }
else else
selectionStartMove = 0; selectionStartMove = 0;
// selectionEnd // selectionEnd
if (selectionEnd >= posEndComment+endCommentLength) if (selectionEnd >= posEndComment+endCommentLength)
selectionEndMove = -(int)(startCommentLength+endCommentLength); selectionEndMove = -static_cast<int>(startCommentLength+endCommentLength);
else if (selectionEnd <= posEndComment) else if (selectionEnd <= posEndComment)
selectionEndMove = -(int)startCommentLength; selectionEndMove = -static_cast<int>(startCommentLength);
else else
selectionEndMove = -(int)(startCommentLength + (selectionEnd - posEndComment)); selectionEndMove = -static_cast<int>(startCommentLength + (selectionEnd - posEndComment));
//-- Reset selection of text without deleted stream-comment-string //-- Reset selection of text without deleted stream-comment-string
if (move_caret) if (move_caret)

View File

@ -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 // First message we get the ptr of instantiated object
// then stock it into GWLP_USERDATA index in order to retrieve afterward // 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<Notepad_plus_Window *>((reinterpret_cast<LPCREATESTRUCT>(lParam))->lpCreateParams);
pM30ide->_hSelf = hwnd; pM30ide->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pM30ide); ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pM30ide);
return TRUE; return TRUE;
@ -90,7 +90,7 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message,
default: default:
{ {
return ((Notepad_plus_Window *)::GetWindowLongPtr(hwnd, GWLP_USERDATA))->runProc(hwnd, Message, wParam, lParam); return (reinterpret_cast<Notepad_plus_Window *>(::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: case WM_DRAWITEM:
{ {
DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; DRAWITEMSTRUCT *dis = reinterpret_cast<DRAWITEMSTRUCT *>(lParam);
if (dis->CtlType == ODT_TAB) if (dis->CtlType == ODT_TAB)
return ::SendMessage(dis->hwndItem, WM_DRAWITEM, wParam, lParam); return ::SendMessage(dis->hwndItem, WM_DRAWITEM, wParam, lParam);
break; break;
@ -160,7 +160,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_REMOVE_USERLANG: case WM_REMOVE_USERLANG:
{ {
TCHAR *userLangName = (TCHAR *)lParam; TCHAR *userLangName = reinterpret_cast<TCHAR *>(lParam);
if (!userLangName || !userLangName[0]) if (!userLangName || !userLangName[0])
return FALSE; return FALSE;
@ -178,11 +178,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_RENAME_USERLANG: case WM_RENAME_USERLANG:
{ {
if (!lParam || !(((TCHAR *)lParam)[0]) || !wParam || !(((TCHAR *)wParam)[0])) if (!lParam || !((reinterpret_cast<TCHAR *>(lParam))[0]) || !wParam || !((reinterpret_cast<TCHAR *>(wParam))[0]))
return FALSE; return FALSE;
generic_string oldName{(TCHAR *)lParam}; generic_string oldName{ reinterpret_cast<TCHAR *>(lParam) };
generic_string newName{(TCHAR *)wParam}; generic_string newName{ reinterpret_cast<TCHAR *>(wParam) };
//loop through buffers and reset the language (L_USER, newName) if (L_USER, oldName) //loop through buffers and reset the language (L_USER, newName) if (L_USER, oldName)
for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i) 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: case WM_FINDALL_INCURRENTFINDER:
{ {
FindersInfo *findInFolderInfo = (FindersInfo *)wParam; FindersInfo *findInFolderInfo = reinterpret_cast<FindersInfo *>(wParam);
Finder * newFinder = _findReplaceDlg.createFinder(); Finder * newFinder = _findReplaceDlg.createFinder();
findInFolderInfo->_pDestFinder = newFinder; findInFolderInfo->_pDestFinder = newFinder;
bool isOK = findInFinderFiles(findInFolderInfo); bool isOK = findInFinderFiles(findInFolderInfo);
return isOK; return isOK;
} }
/*
case NPPM_INTERNAL_REMOVEFINDER:
{
return _findReplaceDlg.removeFinder((Finder *)wParam);
}
*/
case WM_REPLACEINFILES: case WM_REPLACEINFILES:
{ {
replaceInFiles(); replaceInFiles();
@ -258,7 +253,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (isFirstTime) if (isFirstTime)
_nativeLangSpeaker.changeDlgLang(_findReplaceDlg.getHSelf(), "Find"); _nativeLangSpeaker.changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
_findReplaceDlg.launchFindInFilesDlg(); _findReplaceDlg.launchFindInFilesDlg();
setFindReplaceFolderFilter((const TCHAR*) wParam, (const TCHAR*) lParam); setFindReplaceFolderFilter(reinterpret_cast<const TCHAR*>(wParam), reinterpret_cast<const TCHAR*>(lParam));
return TRUE; return TRUE;
} }
@ -267,7 +262,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{ {
const int strSize = FINDREPLACE_MAXLENGTH; const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize]; TCHAR str[strSize];
Finder *launcher = (Finder *)wParam; Finder *launcher = reinterpret_cast<Finder *>(wParam);
bool isFirstTime = not _findInFinderDlg.isCreated(); 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 NPPM_DOOPEN:
case WM_DOOPEN: case WM_DOOPEN:
{ {
BufferID id = doOpen((const TCHAR *)lParam); BufferID id = doOpen(reinterpret_cast<const TCHAR *>(lParam));
if (id != BUFFER_INVALID) if (id != BUFFER_INVALID)
return switchToFile(id); return switchToFile(id);
break; break;
@ -299,7 +294,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
BufferID id = (BufferID)wParam; BufferID id = (BufferID)wParam;
Buffer * b = MainFileManager->getBufferByID(id); Buffer * b = MainFileManager->getBufferByID(id);
if (b && b->getStatus() == DOC_UNNAMED) { if (b && b->getStatus() == DOC_UNNAMED) {
b->setFileName((const TCHAR*)lParam); b->setFileName(reinterpret_cast<const TCHAR*>(lParam));
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -386,29 +381,29 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
else if (lParam == SUB_VIEW) else if (lParam == SUB_VIEW)
pView = &_subDocTab; pView = &_subDocTab;
else else
return (LRESULT)BUFFER_INVALID; return reinterpret_cast<LRESULT>(BUFFER_INVALID);
if ((size_t)wParam < pView->nbItem()) if ((size_t)wParam < pView->nbItem())
return (LRESULT)(pView->getBufferByIndex((int)wParam)); return reinterpret_cast<LRESULT>(pView->getBufferByIndex(wParam));
return (LRESULT)BUFFER_INVALID; return reinterpret_cast<LRESULT>(BUFFER_INVALID);
} }
case NPPM_GETCURRENTBUFFERID: case NPPM_GETCURRENTBUFFERID:
{ {
return (LRESULT)(_pEditView->getCurrentBufferID()); return reinterpret_cast<LRESULT>(_pEditView->getCurrentBufferID());
} }
case NPPM_RELOADBUFFERID: case NPPM_RELOADBUFFERID:
{ {
if (!wParam) if (!wParam)
return FALSE; return FALSE;
return doReload((BufferID)wParam, lParam != 0); return doReload(reinterpret_cast<BufferID>(wParam), lParam != 0);
} }
case NPPM_RELOADFILE: case NPPM_RELOADFILE:
{ {
BufferID id = MainFileManager->getBufferFromName((const TCHAR *)lParam); BufferID id = MainFileManager->getBufferFromName(reinterpret_cast<const TCHAR *>(lParam));
if (id != BUFFER_INVALID) if (id != BUFFER_INVALID)
doReload(id, wParam != 0); doReload(id, wParam != 0);
break; break;
@ -416,7 +411,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_SWITCHTOFILE : case NPPM_SWITCHTOFILE :
{ {
BufferID id = MainFileManager->getBufferFromName((const TCHAR *)lParam); BufferID id = MainFileManager->getBufferFromName(reinterpret_cast<const TCHAR *>(lParam));
if (id != BUFFER_INVALID) if (id != BUFFER_INVALID)
return switchToFile(id); return switchToFile(id);
return false; return false;
@ -431,7 +426,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{ {
BufferID currentBufferID = _pEditView->getCurrentBufferID(); BufferID currentBufferID = _pEditView->getCurrentBufferID();
bool asCopy = wParam == TRUE; bool asCopy = wParam == TRUE;
const TCHAR *filename = (const TCHAR *)lParam; const TCHAR *filename = reinterpret_cast<const TCHAR *>(lParam);
if (!filename) return FALSE; if (!filename) return FALSE;
return doSave(currentBufferID, filename, asCopy); return doSave(currentBufferID, filename, asCopy);
} }
@ -443,7 +438,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_SAVEFILE: case NPPM_SAVEFILE:
{ {
return fileSaveSpecific((const TCHAR *)lParam); return fileSaveSpecific(reinterpret_cast<const TCHAR *>(lParam));
} }
case NPPM_GETCURRENTNATIVELANGENCODING: 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 // Notify plugins that current file is about to be closed
SCNotification scnN; SCNotification scnN;
scnN.nmhdr.code = NPPN_DOCORDERCHANGED; scnN.nmhdr.code = NPPN_DOCORDERCHANGED;
scnN.nmhdr.hwndFrom = (void *)lParam; scnN.nmhdr.hwndFrom = reinterpret_cast<void *>(lParam);
scnN.nmhdr.idFrom = (uptr_t)id; scnN.nmhdr.idFrom = reinterpret_cast<uptr_t>(id);
_pluginsManager.notify(&scnN); _pluginsManager.notify(&scnN);
return TRUE; return TRUE;
} }
case NPPM_DISABLEAUTOUPDATE: case NPPM_DISABLEAUTOUPDATE:
{ {
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); NppGUI & nppGUI = const_cast<NppGUI &>(pNppParam->getNppGUI());
nppGUI._autoUpdateOpt._doAutoUpdate = false; nppGUI._autoUpdateOpt._doAutoUpdate = false;
return TRUE; return TRUE;
} }
@ -523,7 +518,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_COPYDATA: case WM_COPYDATA:
{ {
COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)lParam; COPYDATASTRUCT *pCopyData = reinterpret_cast<COPYDATASTRUCT *>(lParam);
switch (pCopyData->dwData) switch (pCopyData->dwData)
{ {
@ -549,7 +544,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case COPYDATA_FILENAMESA: case COPYDATA_FILENAMESA:
{ {
char *fileNamesA = (char *)pCopyData->lpData; char *fileNamesA = reinterpret_cast<char *>(pCopyData->lpData);
CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams();
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const wchar_t *fileNamesW = wmc->char2wchar(fileNamesA, CP_ACP); 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: case COPYDATA_FILENAMESW:
{ {
wchar_t *fileNamesW = (wchar_t *)pCopyData->lpData; wchar_t *fileNamesW = reinterpret_cast<wchar_t *>(pCopyData->lpData);
CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams();
loadCommandlineParams(fileNamesW, &cmdLineParams); loadCommandlineParams(fileNamesW, &cmdLineParams);
break; break;
@ -621,7 +616,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{ {
SCNotification scnN; SCNotification scnN;
scnN.nmhdr.code = NPPN_SHORTCUTREMAPPED; scnN.nmhdr.code = NPPN_SHORTCUTREMAPPED;
scnN.nmhdr.hwndFrom = (void *)lParam; // ShortcutKey structure scnN.nmhdr.hwndFrom = reinterpret_cast<void *>(lParam); // ShortcutKey structure
scnN.nmhdr.idFrom = (uptr_t)wParam; // cmdID scnN.nmhdr.idFrom = (uptr_t)wParam; // cmdID
_pluginsManager.notify(&scnN); _pluginsManager.notify(&scnN);
return TRUE; return TRUE;
@ -630,7 +625,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETSHORTCUTBYCMDID: case NPPM_GETSHORTCUTBYCMDID:
{ {
int cmdID = static_cast<int32_t>(wParam); // cmdID int cmdID = static_cast<int32_t>(wParam); // cmdID
ShortcutKey *sk = (ShortcutKey *)lParam; // ShortcutKey structure ShortcutKey *sk = reinterpret_cast<ShortcutKey *>(lParam); // ShortcutKey structure
return _pluginsManager.getShortcutByCmdID(cmdID, sk); 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<TCHAR *>(lParam), fileStr);
return TRUE; return TRUE;
} }
@ -682,8 +677,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{ {
const int strSize = CURRENTWORD_MAXLENGTH; const int strSize = CURRENTWORD_MAXLENGTH;
TCHAR str[strSize]; TCHAR str[strSize];
TCHAR *pTchar = reinterpret_cast<TCHAR *>(lParam);
_pEditView->getGenericSelectedText((TCHAR *)str, strSize); _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. // 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. // otherwise we check if the generic_string buffer size is enough for the generic_string to copy.
if (wParam != 0) 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 else //buffer large enough, perform safe copy
{ {
lstrcpyn((TCHAR *)lParam, str, static_cast<int32_t>(wParam)); lstrcpyn(pTchar, str, static_cast<int32_t>(wParam));
return TRUE; return TRUE;
} }
} }
lstrcpy((TCHAR *)lParam, str); lstrcpy(pTchar, str);
return TRUE; 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<TCHAR *>(lParam), str);
return TRUE; return TRUE;
} }
@ -739,24 +734,25 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETCURRENTSCINTILLA: case NPPM_GETCURRENTSCINTILLA:
{ {
int *id = reinterpret_cast<int *>(lParam);
if (_pEditView == &_mainEditView) if (_pEditView == &_mainEditView)
*((int *)lParam) = MAIN_VIEW; *id = MAIN_VIEW;
else if (_pEditView == &_subEditView) else if (_pEditView == &_subEditView)
*((int *)lParam) = SUB_VIEW; *id = SUB_VIEW;
else else
*((int *)lParam) = -1; *id = -1;
return TRUE; return TRUE;
} }
case NPPM_GETCURRENTLANGTYPE: case NPPM_GETCURRENTLANGTYPE:
{ {
*((LangType *)lParam) = _pEditView->getCurrentBuffer()->getLangType(); *(reinterpret_cast<LangType *>(lParam)) = _pEditView->getCurrentBuffer()->getLangType();
return TRUE; return TRUE;
} }
case NPPM_SETCURRENTLANGTYPE: case NPPM_SETCURRENTLANGTYPE:
{ {
_pEditView->getCurrentBuffer()->setLangType((LangType)lParam); _pEditView->getCurrentBuffer()->setLangType(static_cast<LangType>(lParam));
return TRUE; return TRUE;
} }
@ -779,7 +775,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (!wParam) if (!wParam)
return 0; return 0;
TCHAR** fileNames = (TCHAR**) wParam; TCHAR** fileNames = reinterpret_cast<TCHAR**>(wParam);
size_t nbFileNames = static_cast<size_t>(lParam); size_t nbFileNames = static_cast<size_t>(lParam);
size_t j = 0; size_t j = 0;
@ -880,7 +876,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETNBSESSIONFILES: case NPPM_GETNBSESSIONFILES:
{ {
const TCHAR *sessionFileName = (const TCHAR *)lParam; const TCHAR *sessionFileName = reinterpret_cast<const TCHAR *>(lParam);
if ((!sessionFileName) || (sessionFileName[0] == '\0')) if ((!sessionFileName) || (sessionFileName[0] == '\0'))
return 0; return 0;
Session session2Load; Session session2Load;
@ -891,8 +887,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETSESSIONFILES: case NPPM_GETSESSIONFILES:
{ {
const TCHAR *sessionFileName = (const TCHAR *)lParam; const TCHAR *sessionFileName = reinterpret_cast<const TCHAR *>(lParam);
TCHAR **sessionFileArray = (TCHAR **)wParam; TCHAR **sessionFileArray = reinterpret_cast<TCHAR **>(wParam);
if ((!sessionFileName) || (sessionFileName[0] == '\0')) if ((!sessionFileName) || (sessionFileName[0] == '\0'))
return FALSE; return FALSE;
@ -1068,7 +1064,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_FRSAVE_STR: case WM_FRSAVE_STR:
{ {
_macro.push_back(recordedMacroStep(static_cast<int32_t>(wParam), 0, 0, (const TCHAR *)lParam, recordedMacroStep::mtSavedSnR)); _macro.push_back(recordedMacroStep(static_cast<int32_t>(wParam), 0, 0, reinterpret_cast<const TCHAR *>(lParam), recordedMacroStep::mtSavedSnR));
break; break;
} }
@ -1164,7 +1160,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETNBUSERLANG: case NPPM_GETNBUSERLANG:
{ {
if (lParam) if (lParam)
*((int *)lParam) = IDM_LANG_USER; *(reinterpret_cast<int *>(lParam)) = IDM_LANG_USER;
return pNppParam->getNbUserLang(); return pNppParam->getNbUserLang();
} }
@ -1186,7 +1182,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_SETSTATUSBAR: case NPPM_SETSTATUSBAR:
{ {
TCHAR *str2set = (TCHAR *)lParam; TCHAR *str2set = reinterpret_cast<TCHAR *>(lParam);
if (!str2set || !str2set[0]) if (!str2set || !str2set[0])
return FALSE; return FALSE;
@ -1217,18 +1213,18 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_LOADSESSION: case NPPM_LOADSESSION:
{ {
fileLoadSession((const TCHAR *)lParam); fileLoadSession(reinterpret_cast<const TCHAR *>(lParam));
return TRUE; return TRUE;
} }
case NPPM_SAVECURRENTSESSION: case NPPM_SAVECURRENTSESSION:
{ {
return (LRESULT)fileSaveSession(0, NULL, (const TCHAR *)lParam); return (LRESULT)fileSaveSession(0, NULL, reinterpret_cast<const TCHAR *>(lParam));
} }
case NPPM_SAVESESSION: case NPPM_SAVESESSION:
{ {
sessionInfo *pSi = (sessionInfo *)lParam; sessionInfo *pSi = reinterpret_cast<sessionInfo *>(lParam);
return (LRESULT)fileSaveSession(pSi->nbFile, pSi->files, pSi->sessionFilePathName); 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: case NPPM_INTERNAL_CMDLIST_MODIFIED:
{ {
//changeMenuShortcut(lParam, (const TCHAR *)wParam);
::DrawMenuBar(hwnd); ::DrawMenuBar(hwnd);
return TRUE; return TRUE;
} }
@ -1422,21 +1417,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_INTERNAL_RELOADSCROLLTOEND: case NPPM_INTERNAL_RELOADSCROLLTOEND:
{ {
Buffer *buf = (Buffer *)wParam; Buffer *buf = reinterpret_cast<Buffer *>(wParam);
buf->reload(); buf->reload();
return TRUE; return TRUE;
} }
case NPPM_INTERNAL_GETCHECKDOCOPT: case NPPM_INTERNAL_GETCHECKDOCOPT:
{ {
return (LRESULT)((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection; return (LRESULT)(const_cast<NppGUI &>(pNppParam->getNppGUI()))._fileAutoDetection;
} }
case NPPM_INTERNAL_SETCHECKDOCOPT: case NPPM_INTERNAL_SETCHECKDOCOPT:
{ {
// If nothing is changed by user, then we allow to set this value // If nothing is changed by user, then we allow to set this value
if (((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection == ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetectionOriginalValue) if ((const_cast<NppGUI &>(pNppParam->getNppGUI()))._fileAutoDetection == (const_cast<NppGUI &>(pNppParam->getNppGUI()))._fileAutoDetectionOriginalValue)
((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection = (ChangeDetect)wParam; (const_cast<NppGUI &>(pNppParam->getNppGUI()))._fileAutoDetection = (ChangeDetect)wParam;
return TRUE; return TRUE;
} }
@ -1479,12 +1474,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETFULLPATHFROMBUFFERID: case NPPM_GETFULLPATHFROMBUFFERID:
{ {
return MainFileManager->getFileNameFromBuffer((BufferID)wParam, (TCHAR *)lParam); return MainFileManager->getFileNameFromBuffer(reinterpret_cast<BufferID>(wParam), reinterpret_cast<TCHAR *>(lParam));
} }
case NPPM_INTERNAL_ENABLECHECKDOCOPT: case NPPM_INTERNAL_ENABLECHECKDOCOPT:
{ {
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); NppGUI & nppgui = const_cast<NppGUI &>((pNppParam->getNppGUI()));
if (wParam == CHECKDOCOPT_NONE) if (wParam == CHECKDOCOPT_NONE)
nppgui._fileAutoDetection = cdDisabled; nppgui._fileAutoDetection = cdDisabled;
else if (wParam == CHECKDOCOPT_UPDATESILENTLY) else if (wParam == CHECKDOCOPT_UPDATESILENTLY)
@ -1720,7 +1715,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
{ {
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); NppGUI & nppgui = const_cast<NppGUI &>((pNppParam->getNppGUI()));
if (((nppgui._isMinimizedToTray && !_isAdministrator) || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE)) if (((nppgui._isMinimizedToTray && !_isAdministrator) || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE))
{ {
if (nullptr == _pTrayIco) if (nullptr == _pTrayIco)
@ -1810,7 +1805,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_DMMREGASDCKDLG: case NPPM_DMMREGASDCKDLG:
{ {
tTbData *pData = (tTbData *)lParam; tTbData *pData = reinterpret_cast<tTbData *>(lParam);
int iCont = -1; int iCont = -1;
bool isVisible = false; bool isVisible = false;
@ -1821,7 +1816,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_DMMVIEWOTHERTAB: case NPPM_DMMVIEWOTHERTAB:
{ {
_dockingManager.showDockableDlg((TCHAR*)lParam, SW_SHOW); _dockingManager.showDockableDlg(reinterpret_cast<TCHAR *>(lParam), SW_SHOW);
return TRUE; return TRUE;
} }
@ -1830,8 +1825,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (!lParam) if (!lParam)
return NULL; return NULL;
TCHAR *moduleName = (TCHAR *)lParam; TCHAR *moduleName = reinterpret_cast<TCHAR *>(lParam);
TCHAR *windowName = (TCHAR *)wParam; TCHAR *windowName = reinterpret_cast<TCHAR *>(wParam);
std::vector<DockingCont *> dockContainer = _dockingManager.getContainerInfo(); std::vector<DockingCont *> dockContainer = _dockingManager.getContainerInfo();
for (size_t i = 0, len = dockContainer.size(); i < len ; ++i) 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: case NPPM_ADDTOOLBARICON:
{ {
_toolBar.registerDynBtn((UINT)wParam, (toolbarIcons*)lParam); _toolBar.registerDynBtn(static_cast<UINT>(wParam), reinterpret_cast<toolbarIcons*>(lParam));
return TRUE; return TRUE;
} }
case NPPM_SETMENUITEMCHECK: case NPPM_SETMENUITEMCHECK:
{ {
::CheckMenuItem(_mainMenuHandle, (UINT)wParam, MF_BYCOMMAND | ((BOOL)lParam ? MF_CHECKED : MF_UNCHECKED)); ::CheckMenuItem(_mainMenuHandle, static_cast<UINT>(wParam), MF_BYCOMMAND | (static_cast<BOOL>(lParam) ? MF_CHECKED : MF_UNCHECKED));
_toolBar.setCheck((int)wParam, bool(lParam != 0)); _toolBar.setCheck((int)wParam, bool(lParam != 0));
return TRUE; return TRUE;
} }
@ -1897,7 +1892,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (len < pluginsConfigDirPrefix.length() + lstrlen(secondPart)) if (len < pluginsConfigDirPrefix.length() + lstrlen(secondPart))
return FALSE; return FALSE;
TCHAR *pluginsConfigDir = (TCHAR *)lParam; TCHAR *pluginsConfigDir = reinterpret_cast<TCHAR *>(lParam);
lstrcpy(pluginsConfigDir, pluginsConfigDirPrefix.c_str()); lstrcpy(pluginsConfigDir, pluginsConfigDirPrefix.c_str());
::PathAppend(pluginsConfigDir, secondPart); ::PathAppend(pluginsConfigDir, secondPart);
@ -1933,7 +1928,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
DocTabView::setHideTabBarStatus(hide); DocTabView::setHideTabBarStatus(hide);
::SendMessage(hwnd, WM_SIZE, 0, 0); ::SendMessage(hwnd, WM_SIZE, 0, 0);
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); NppGUI & nppGUI = const_cast<NppGUI &>(((NppParameters::getInstance())->getNppGUI()));
if (hide) if (hide)
nppGUI._tabStatus |= TAB_HIDE; nppGUI._tabStatus |= TAB_HIDE;
else else
@ -1968,7 +1963,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (hide == isHidden) if (hide == isHidden)
return isHidden; return isHidden;
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); NppGUI & nppGUI = const_cast<NppGUI &>(pNppParam->getNppGUI());
nppGUI._menuBarShow = !hide; nppGUI._menuBarShow = !hide;
if (nppGUI._menuBarShow) if (nppGUI._menuBarShow)
::SetMenu(hwnd, _mainMenuHandle); ::SetMenu(hwnd, _mainMenuHandle);
@ -1986,7 +1981,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_HIDESTATUSBAR: case NPPM_HIDESTATUSBAR:
{ {
bool show = (lParam != TRUE); bool show = (lParam != TRUE);
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); NppGUI & nppGUI = const_cast<NppGUI &>(pNppParam->getNppGUI());
bool oldVal = nppGUI._statusBarShow; bool oldVal = nppGUI._statusBarShow;
if (show == oldVal) if (show == oldVal)
return oldVal; return oldVal;
@ -2002,7 +1997,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_ISSTATUSBARHIDDEN: case NPPM_ISSTATUSBARHIDDEN:
{ {
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); NppGUI & nppGUI = const_cast<NppGUI &>(pNppParam->getNppGUI());
return !nppGUI._statusBarShow; return !nppGUI._statusBarShow;
} }
@ -2064,7 +2059,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_INTERNAL_DISABLEAUTOUPDATE: case NPPM_INTERNAL_DISABLEAUTOUPDATE:
{ {
//printStr(TEXT("you've got me")); //printStr(TEXT("you've got me"));
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); NppGUI & nppGUI = const_cast<NppGUI &>(pNppParam->getNppGUI());
nppGUI._autoUpdateOpt._doAutoUpdate = false; nppGUI._autoUpdateOpt._doAutoUpdate = false;
return TRUE; return TRUE;
} }
@ -2088,7 +2083,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_DOCSWITCHERDISABLECOLUMN: case NPPM_DOCSWITCHERDISABLECOLUMN:
{ {
BOOL isOff = static_cast<BOOL>(lParam); BOOL isOff = static_cast<BOOL>(lParam);
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); NppGUI & nppGUI = const_cast<NppGUI &>(pNppParam->getNppGUI());
nppGUI._fileSwitcherWithoutExtColumn = isOff == TRUE; nppGUI._fileSwitcherWithoutExtColumn = isOff == TRUE;
if (_pFileSwitcherPanel) if (_pFileSwitcherPanel)
@ -2187,7 +2182,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_ENTERMENULOOP: case WM_ENTERMENULOOP:
{ {
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); NppGUI & nppgui = const_cast<NppGUI &>((pNppParam->getNppGUI()));
if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering) if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering)
::SetMenu(hwnd, _mainMenuHandle); ::SetMenu(hwnd, _mainMenuHandle);
@ -2196,7 +2191,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_EXITMENULOOP: case WM_EXITMENULOOP:
{ {
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); NppGUI & nppgui = const_cast<NppGUI &>((pNppParam->getNppGUI()));
if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering) if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering)
::SetMenu(hwnd, NULL); ::SetMenu(hwnd, NULL);
_sysMenuEntering = false; _sysMenuEntering = false;
@ -2212,7 +2207,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{ {
if (Message == WDN_NOTIFY) if (Message == WDN_NOTIFY)
{ {
NMWINDLG* nmdlg = (NMWINDLG*)lParam; NMWINDLG* nmdlg = reinterpret_cast<NMWINDLG*>(lParam);
switch (nmdlg->type) switch (nmdlg->type)
{ {
case WDT_ACTIVATE: case WDT_ACTIVATE:
@ -2225,7 +2220,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WDT_SAVE: case WDT_SAVE:
{ {
//loop through nmdlg->nItems, get index and save it //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)); fileSave(_pDocTab->getBufferByIndex(i));
} }
@ -2236,7 +2231,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WDT_CLOSE: case WDT_CLOSE:
{ {
//loop through nmdlg->nItems, get index and close it //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()); bool closed = fileClose(_pDocTab->getBufferByIndex(nmdlg->Items[i]), currentView());
UINT pos = nmdlg->Items[i]; 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 nmdlg->Items[i] = 0xFFFFFFFF; // indicate file was closed
// Shift the remaining items downward to fill the gap // 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) if (nmdlg->Items[j] > pos)
nmdlg->Items[j]--; nmdlg->Items[j]--;
@ -2264,12 +2259,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
//Collect all buffers //Collect all buffers
std::vector<BufferID> tempBufs; std::vector<BufferID> 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)); tempBufs.push_back(_pDocTab->getBufferByIndex(i));
} }
//Reset buffers //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]]); _pDocTab->setBuffer(i, tempBufs[nmdlg->Items[i]]);
} }

View File

@ -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. // 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<unsigned int>. // If it was possible, leftmost_position and rightmost_position should be of type optional<unsigned int>.
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<unsigned int>(leftmost_position)))
{ {
leftmost_position = matching_leftmost; leftmost_position = matching_leftmost;
rightmost_position = i; rightmost_position = i;

View File

@ -2247,8 +2247,8 @@ void NppParameters::feedShortcut(TiXmlNode *node)
if (idStr) if (idStr)
{ {
//find the commandid that matches this Shortcut sc and alter it, push back its index in the modified list, if not present //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(); size_t len = _shortcuts.size();
for(int i = 0; i < len; ++i) for(size_t i = 0; i < len; ++i)
{ {
if (_shortcuts[i].getID() == (unsigned long)id) if (_shortcuts[i].getID() == (unsigned long)id)
{ //found our match { //found our match
@ -2360,8 +2360,8 @@ void NppParameters::feedPluginCustomizedCmds(TiXmlNode *node)
continue; continue;
//Find the corresponding plugincommand and alter it, put the index in the list //Find the corresponding plugincommand and alter it, put the index in the list
int len = (int)_pluginCommands.size(); size_t len = _pluginCommands.size();
for(int i = 0; i < len; ++i) for(size_t i = 0; i < len; ++i)
{ {
PluginCmdShortcut & pscOrig = _pluginCommands[i]; PluginCmdShortcut & pscOrig = _pluginCommands[i];
if (!generic_strnicmp(pscOrig.getModuleName(), moduleName, lstrlen(moduleName)) && pscOrig.getInternalID() == internalID) if (!generic_strnicmp(pscOrig.getModuleName(), moduleName, lstrlen(moduleName)) && pscOrig.getInternalID() == internalID)
@ -2977,7 +2977,7 @@ void NppParameters::writeShortcuts()
cmdRoot = root->InsertEndChild(TiXmlElement(TEXT("InternalCommands"))); cmdRoot = root->InsertEndChild(TiXmlElement(TEXT("InternalCommands")));
for (size_t i = 0, len = _customizedShortcuts.size(); i < len ; ++i) for (size_t i = 0, len = _customizedShortcuts.size(); i < len ; ++i)
{ {
int index = _customizedShortcuts[i]; size_t index = _customizedShortcuts[i];
CommandShortcut csc = _shortcuts[index]; CommandShortcut csc = _shortcuts[index];
insertCmd(cmdRoot, csc); insertCmd(cmdRoot, csc);
} }
@ -3506,7 +3506,7 @@ TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const TCHA
// 2 restes : L_H, L_USER // 2 restes : L_H, L_USER
LangType NppParameters::getLangIDFromStr(const TCHAR *langName) LangType NppParameters::getLangIDFromStr(const TCHAR *langName)
{ {
int lang = (int)L_TEXT; int lang = static_cast<int>(L_TEXT);
for(; lang < L_EXTERNAL; ++lang) for(; lang < L_EXTERNAL; ++lang)
{ {
const TCHAR * name = ScintillaEditView::langNames[lang].lexerName; const TCHAR * name = ScintillaEditView::langNames[lang].lexerName;
@ -5480,8 +5480,8 @@ bool NppParameters::writeGUIParams()
} }
else if (!lstrcmp(nm, TEXT("delimiterSelection"))) else if (!lstrcmp(nm, TEXT("delimiterSelection")))
{ {
element->SetAttribute(TEXT("leftmostDelimiter"), (int)_nppGUI._leftmostDelimiter); element->SetAttribute(TEXT("leftmostDelimiter"), static_cast<int>(_nppGUI._leftmostDelimiter));
element->SetAttribute(TEXT("rightmostDelimiter"), (int)_nppGUI._rightmostDelimiter); element->SetAttribute(TEXT("rightmostDelimiter"), static_cast<int>(_nppGUI._rightmostDelimiter));
if(_nppGUI._delimiterSelectionOnEntireDocument) if(_nppGUI._delimiterSelectionOnEntireDocument)
element->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), TEXT("yes")); element->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), TEXT("yes"));
else 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(); size_t len = _customizedShortcuts.size();
bool found = false; 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(); size_t len = _pluginCustomizedCmds.size();
bool found = false; bool found = false;

View File

@ -1403,14 +1403,14 @@ public:
bool isRemappingShortcut() const {return _shortcuts.size() != 0;}; bool isRemappingShortcut() const {return _shortcuts.size() != 0;};
std::vector<CommandShortcut> & getUserShortcuts() { return _shortcuts; }; std::vector<CommandShortcut> & getUserShortcuts() { return _shortcuts; };
std::vector<int> & getUserModifiedShortcuts() { return _customizedShortcuts; }; std::vector<size_t> & getUserModifiedShortcuts() { return _customizedShortcuts; };
void addUserModifiedIndex(int index); void addUserModifiedIndex(size_t index);
std::vector<MacroShortcut> & getMacroList() { return _macros; }; std::vector<MacroShortcut> & getMacroList() { return _macros; };
std::vector<UserCommand> & getUserCommandList() { return _userCommands; }; std::vector<UserCommand> & getUserCommandList() { return _userCommands; };
std::vector<PluginCmdShortcut> & getPluginCommandList() { return _pluginCommands; }; std::vector<PluginCmdShortcut> & getPluginCommandList() { return _pluginCommands; };
std::vector<int> & getPluginModifiedKeyIndices() { return _pluginCustomizedCmds; }; std::vector<size_t> & getPluginModifiedKeyIndices() { return _pluginCustomizedCmds; };
void addPluginModifiedIndex(int index); void addPluginModifiedIndex(size_t index);
std::vector<ScintillaKeyMap> & getScintillaKeyList() { return _scintillaKeyCommands; }; std::vector<ScintillaKeyMap> & getScintillaKeyList() { return _scintillaKeyCommands; };
std::vector<int> & getScintillaModifiedKeyIndices() { return _scintillaModifiedKeyIndices; }; std::vector<int> & getScintillaModifiedKeyIndices() { return _scintillaModifiedKeyIndices; };
@ -1605,11 +1605,11 @@ public:
private: private:
bool _isAnyShortcutModified = false; bool _isAnyShortcutModified = false;
std::vector<CommandShortcut> _shortcuts; //main menu shortuts. Static size std::vector<CommandShortcut> _shortcuts; //main menu shortuts. Static size
std::vector<int> _customizedShortcuts; //altered main menu shortcuts. Indices static. Needed when saving alterations std::vector<size_t> _customizedShortcuts; //altered main menu shortcuts. Indices static. Needed when saving alterations
std::vector<MacroShortcut> _macros; //macro shortcuts, dynamic size, defined on loading macros and adding/deleting them std::vector<MacroShortcut> _macros; //macro shortcuts, dynamic size, defined on loading macros and adding/deleting them
std::vector<UserCommand> _userCommands; //run shortcuts, dynamic size, defined on loading run commands and adding/deleting them std::vector<UserCommand> _userCommands; //run shortcuts, dynamic size, defined on loading run commands and adding/deleting them
std::vector<PluginCmdShortcut> _pluginCommands; //plugin commands, dynamic size, defined on loading plugins std::vector<PluginCmdShortcut> _pluginCommands; //plugin commands, dynamic size, defined on loading plugins
std::vector<int> _pluginCustomizedCmds; //plugincommands that have been altered. Indices determined after loading ALL plugins. Needed when saving alterations std::vector<size_t> _pluginCustomizedCmds; //plugincommands that have been altered. Indices determined after loading ALL plugins. Needed when saving alterations
std::vector<ScintillaKeyMap> _scintillaKeyCommands; //scintilla keycommands. Static size std::vector<ScintillaKeyMap> _scintillaKeyCommands; //scintilla keycommands. Static size
std::vector<int> _scintillaModifiedKeyIndices; //modified scintilla keys. Indices static, determined by searching for commandId. Needed when saving alterations std::vector<int> _scintillaModifiedKeyIndices; //modified scintilla keys. Indices static, determined by searching for commandId. Needed when saving alterations

View File

@ -67,8 +67,8 @@ bool AutoCompletion::showApiComplete()
bool AutoCompletion::showApiAndWordComplete() bool AutoCompletion::showApiAndWordComplete()
{ {
int curPos = int(_pEditView->execute(SCI_GETCURRENTPOS)); auto curPos = _pEditView->execute(SCI_GETCURRENTPOS);
int startPos = int(_pEditView->execute(SCI_WORDSTARTPOSITION, curPos, true)); auto startPos = _pEditView->execute(SCI_WORDSTARTPOSITION, curPos, true);
if (curPos == startPos) if (curPos == startPos)
return false; return false;

View File

@ -408,11 +408,11 @@ Lang * Buffer::getCurrentLang() const
int Buffer::indexOfReference(const ScintillaEditView * identifier) const int Buffer::indexOfReference(const ScintillaEditView * identifier) const
{ {
int size = (int)_referees.size(); size_t size = _referees.size();
for (int i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i)
{ {
if (_referees[i] == identifier) if (_referees[i] == identifier)
return i; return static_cast<int>(i);
} }
return -1; //not found return -1; //not found
} }
@ -537,7 +537,7 @@ int FileManager::getBufferIndexByID(BufferID id)
for(size_t i = 0; i < _nrBufs; ++i) for(size_t i = 0; i < _nrBufs; ++i)
{ {
if (_buffers[i]->_id == id) if (_buffers[i]->_id == id)
return (int) i; return static_cast<int>(i);
} }
return -1; return -1;
} }

View File

@ -110,11 +110,11 @@ int DocTabView::getIndexByBuffer(BufferID id)
TCITEM tie; TCITEM tie;
tie.lParam = -1; tie.lParam = -1;
tie.mask = TCIF_PARAM; 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<LPARAM>(&tie)); ::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
if (reinterpret_cast<BufferID>(tie.lParam) == id) if (reinterpret_cast<BufferID>(tie.lParam) == id)
return i; return static_cast<int>(i);
} }
return -1; 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; return;
TCITEM tie; TCITEM tie;
tie.lParam = (LPARAM)id; tie.lParam = reinterpret_cast<LPARAM>(id);
tie.mask = TCIF_PARAM; tie.mask = TCIF_PARAM;
::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast<LPARAM>(&tie)); ::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast<LPARAM>(&tie));

View File

@ -73,7 +73,7 @@ public :
int getIndexByBuffer(BufferID id); int getIndexByBuffer(BufferID id);
BufferID getBufferByIndex(size_t index); BufferID getBufferByIndex(size_t index);
void setBuffer(int index, BufferID id); void setBuffer(size_t index, BufferID id);
static bool setHideTabBarStatus(bool hideOrNot) { static bool setHideTabBarStatus(bool hideOrNot) {
bool temp = _hideTabBarStatus; bool temp = _hideTabBarStatus;

View File

@ -185,29 +185,30 @@ void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditVi
{ {
// to make sure the found result is visible // 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 //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); pEditView->execute(SCI_SETCURRENTPOS, testPos);
int currentlineNumberDoc = (int)pEditView->execute(SCI_LINEFROMPOSITION, testPos); auto currentlineNumberDoc = pEditView->execute(SCI_LINEFROMPOSITION, testPos);
int currentlineNumberVis = (int)pEditView->execute(SCI_VISIBLEFROMDOCLINE, currentlineNumberDoc); auto currentlineNumberVis = pEditView->execute(SCI_VISIBLEFROMDOCLINE, currentlineNumberDoc);
pEditView->execute(SCI_ENSUREVISIBLE, currentlineNumberDoc); // make sure target line is unfolded pEditView->execute(SCI_ENSUREVISIBLE, currentlineNumberDoc); // make sure target line is unfolded
int firstVisibleLineVis = (int)pEditView->execute(SCI_GETFIRSTVISIBLELINE); auto firstVisibleLineVis = pEditView->execute(SCI_GETFIRSTVISIBLELINE);
int linesVisible = (int)pEditView->execute(SCI_LINESONSCREEN) - 1; //-1 for the scrollbar auto linesVisible = pEditView->execute(SCI_LINESONSCREEN) - 1; //-1 for the scrollbar
int lastVisibleLineVis = (int)linesVisible + firstVisibleLineVis; auto lastVisibleLineVis = linesVisible + firstVisibleLineVis;
//if out of view vertically, scroll line into (center of) view //if out of view vertically, scroll line into (center of) view
int linesToScroll = 0; int linesToScroll = 0;
if (currentlineNumberVis < firstVisibleLineVis) if (currentlineNumberVis < firstVisibleLineVis)
{ {
linesToScroll = currentlineNumberVis - firstVisibleLineVis; linesToScroll = static_cast<int>(currentlineNumberVis - firstVisibleLineVis);
//use center //use center
linesToScroll -= linesVisible/2; linesToScroll -= static_cast<int>(linesVisible/2);
} }
else if (currentlineNumberVis > lastVisibleLineVis) else if (currentlineNumberVis > lastVisibleLineVis)
{ {
linesToScroll = currentlineNumberVis - lastVisibleLineVis; linesToScroll = static_cast<int>(currentlineNumberVis - lastVisibleLineVis);
//use center //use center
linesToScroll += linesVisible/2; linesToScroll += static_cast<int>(linesVisible/2);
} }
pEditView->scroll(0, linesToScroll); pEditView->scroll(0, linesToScroll);

View File

@ -118,7 +118,7 @@ void FunctionCallTip::showNextOverload() {
void FunctionCallTip::showPrevOverload() { void FunctionCallTip::showPrevOverload() {
if (!isVisible()) if (!isVisible())
return; return;
_currentOverload = _currentOverload > 0?(_currentOverload-1) : _currentNrOverloads-1; _currentOverload = _currentOverload > 0 ? (_currentOverload-1) : (_currentNrOverloads-1);
showCalltip(); showCalltip();
} }
@ -366,7 +366,7 @@ bool FunctionCallTip::loadFunction()
++_currentNrOverloads; ++_currentNrOverloads;
} }
_currentNrOverloads = (int)_overloads.size(); _currentNrOverloads = _overloads.size();
if (_currentNrOverloads == 0) //malformed node if (_currentNrOverloads == 0) //malformed node
return false; return false;

View File

@ -59,8 +59,8 @@ private:
stringVec _retVals; //vector of overload return values/types stringVec _retVals; //vector of overload return values/types
std::vector<stringVec> _overloads; //vector of overload params (=vector) std::vector<stringVec> _overloads; //vector of overload params (=vector)
stringVec _descriptions; //vecotr of function descriptions stringVec _descriptions; //vecotr of function descriptions
int _currentNrOverloads = 0; //current amount of overloads size_t _currentNrOverloads = 0; //current amount of overloads
int _currentOverload = 0; //current chosen overload size_t _currentOverload = 0; //current chosen overload
int _currentParam = 0; //current highlighted param int _currentParam = 0; //current highlighted param
TCHAR _start = '('; TCHAR _start = '(';

View File

@ -137,13 +137,13 @@ void GoToLineDlg::updateLinesNumbers() const
if (_mode == go2line) if (_mode == go2line)
{ {
current = (unsigned int)((*_ppEditView)->getCurrentLineNumber() + 1); current = static_cast<unsigned int>((*_ppEditView)->getCurrentLineNumber() + 1);
limit = (unsigned int)((*_ppEditView)->execute(SCI_GETLINECOUNT)); limit = static_cast<unsigned int>((*_ppEditView)->execute(SCI_GETLINECOUNT));
} }
else else
{ {
current = (unsigned int)(*_ppEditView)->execute(SCI_GETCURRENTPOS); current = static_cast<unsigned int>((*_ppEditView)->execute(SCI_GETCURRENTPOS));
limit = (unsigned int)((*_ppEditView)->getCurrentDocLen() - 1); limit = static_cast<unsigned int>((*_ppEditView)->getCurrentDocLen() - 1);
} }
::SetDlgItemInt(_hSelf, ID_CURRLINE, current, FALSE); ::SetDlgItemInt(_hSelf, ID_CURRLINE, current, FALSE);
::SetDlgItemInt(_hSelf, ID_LASTLINE, limit, FALSE); ::SetDlgItemInt(_hSelf, ID_LASTLINE, limit, FALSE);

View File

@ -2300,19 +2300,19 @@ void ScintillaEditView::updateLineNumberWidth()
{ {
if (_lineNumbersShown) if (_lineNumbersShown)
{ {
int linesVisible = (int) execute(SCI_LINESONSCREEN); auto linesVisible = execute(SCI_LINESONSCREEN);
if (linesVisible) if (linesVisible)
{ {
int firstVisibleLineVis = (int) execute(SCI_GETFIRSTVISIBLELINE); auto firstVisibleLineVis = execute(SCI_GETFIRSTVISIBLELINE);
int lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1; auto lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1;
if (execute(SCI_GETWRAPMODE) != SC_WRAP_NONE) if (execute(SCI_GETWRAPMODE) != SC_WRAP_NONE)
{ {
int numLinesDoc = (int) execute(SCI_GETLINECOUNT); auto numLinesDoc = execute(SCI_GETLINECOUNT);
int prevLineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLineVis); auto prevLineDoc = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLineVis);
for (int i = firstVisibleLineVis + 1; i <= lastVisibleLineVis; ++i) for (auto i = firstVisibleLineVis + 1; i <= lastVisibleLineVis; ++i)
{ {
int lineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, i); auto lineDoc = execute(SCI_DOCLINEFROMVISIBLE, i);
if (lineDoc == numLinesDoc) if (lineDoc == numLinesDoc)
break; break;
if (lineDoc == prevLineDoc) 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; int i = 0;
while (lastVisibleLineDoc) while (lastVisibleLineDoc)
@ -2331,7 +2331,7 @@ void ScintillaEditView::updateLineNumberWidth()
} }
i = max(i, 3); 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); execute(SCI_SETMARGINWIDTHN, _SC_MARGE_LINENUMBER, pixelWidth);
} }
} }

View File

@ -89,13 +89,13 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView)
} }
// save target locations for other search functions // save target locations for other search functions
int originalStartPos = (int)pHighlightView->execute(SCI_GETTARGETSTART); auto originalStartPos = pHighlightView->execute(SCI_GETTARGETSTART);
int originalEndPos = (int)pHighlightView->execute(SCI_GETTARGETEND); auto originalEndPos = pHighlightView->execute(SCI_GETTARGETEND);
// Get the range of text visible and highlight everything in it // Get the range of text visible and highlight everything in it
int firstLine = (int)pHighlightView->execute(SCI_GETFIRSTVISIBLELINE); int firstLine = static_cast<int>(pHighlightView->execute(SCI_GETFIRSTVISIBLELINE));
int nrLines = min((int)pHighlightView->execute(SCI_LINESONSCREEN), MAXLINEHIGHLIGHT ) + 1; int nrLines = min((int)pHighlightView->execute(SCI_LINESONSCREEN), MAXLINEHIGHLIGHT ) + 1;
int lastLine = firstLine+nrLines; int lastLine = firstLine + nrLines;
int startPos = 0; int startPos = 0;
int endPos = 0; int endPos = 0;
int currentLine = firstLine; int currentLine = firstLine;
@ -128,7 +128,7 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView)
frInfo._endRange = endPos; frInfo._endRange = endPos;
if (endPos == -1) if (endPos == -1)
{ //past EOF { //past EOF
frInfo._endRange = (int)pHighlightView->getCurrentDocLen() - 1; frInfo._endRange = pHighlightView->getCurrentDocLen() - 1;
_pFRDlg->processRange(ProcessMarkAll_2, frInfo, NULL, &fo); _pFRDlg->processRange(ProcessMarkAll_2, frInfo, NULL, &fo);
break; break;
} }

View File

@ -516,7 +516,7 @@ void CommentStyleDialog::setKeywords2List(int id)
IDC_COMMENT_CLOSE_EDIT IDC_COMMENT_CLOSE_EDIT
}; };
for (int i=0; i<sizeof(list)/sizeof(int); ++i) for (auto i = 0; i < sizeof(list)/sizeof(int); ++i)
{ {
generic_itoa(i, intBuffer+1, 10); generic_itoa(i, intBuffer+1, 10);
::GetDlgItemText(_hSelf, list[i], buffer, max_char); ::GetDlgItemText(_hSelf, list[i], buffer, max_char);
@ -918,7 +918,7 @@ void SymbolsStyleDialog::setKeywords2List(int id)
IDC_DELIMITER8_BOUNDARYCLOSE_EDIT IDC_DELIMITER8_BOUNDARYCLOSE_EDIT
}; };
for (int i=0; i<sizeof(list)/sizeof(int); ++i) for (int i = 0; i < sizeof(list)/sizeof(int); ++i)
{ {
if (i < 10) if (i < 10)
generic_itoa(i, intBuffer+1, 10); generic_itoa(i, intBuffer+1, 10);
@ -1491,7 +1491,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
case SB_THUMBTRACK: case SB_THUMBTRACK:
case SB_THUMBPOSITION: case SB_THUMBPOSITION:
_yScrollPos = (int)HIWORD(wParam); _yScrollPos = HIWORD(wParam);
break; break;
default : default :

View File

@ -36,21 +36,21 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_OSTREAM* stream )
void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString )
{ {
int i=0; size_t i = 0;
while( i<(int)str.length() ) while (i < str.length())
{ {
int c = str[i]; int c = str[i];
if ( c == '&' if (c == '&'
&& i < ( (int)str.length() - 2 ) && i < ( str.length() - 2 )
&& str[i+1] == '#' && str[i+1] == '#'
&& str[i+2] == 'x' ) && str[i+2] == 'x' )
{ {
// Hexadecimal character reference. // Hexadecimal character reference.
// Pass through unchanged. // Pass through unchanged.
// &#xA9; -- copyright symbol, for example. // &#xA9; -- copyright symbol, for example.
while ( i<(int)str.length() ) while ( i < str.length() )
{ {
outString->append( str.c_str() + i, 1 ); outString->append( str.c_str() + i, 1 );
++i; ++i;
@ -87,14 +87,14 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString )
{ {
// Easy pass at non-alpha/numeric/symbol // Easy pass at non-alpha/numeric/symbol
// 127 is the delete key. Below 32 is symbolic. // 127 is the delete key. Below 32 is symbolic.
TCHAR buf[ 32 ]; TCHAR buf[32];
wsprintf( buf, TEXT("&#x%04X;"), (unsigned) ( c & 0xffff ) ); wsprintf( buf, TEXT("&#x%04X;"), static_cast<unsigned int>(c & 0xffff) );
outString->append( buf, lstrlen( buf ) ); outString->append( buf, lstrlen( buf ) );
++i; ++i;
} }
else else
{ {
TCHAR realc = (TCHAR) c; TCHAR realc = static_cast<TCHAR>(c);
outString->append( &realc, 1 ); outString->append( &realc, 1 );
++i; ++i;
} }

View File

@ -242,13 +242,13 @@ const TCHAR* TiXmlBase::GetEntity( const TCHAR* p, TCHAR* value )
} }
// Now try to match it. // Now try to match it.
for( i=0; i<NUM_ENTITY; ++i ) for (i=0; i<NUM_ENTITY; ++i)
{ {
if ( generic_strncmp( entity[i].str, p, entity[i].strLength ) == 0 ) if ( generic_strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
{ {
assert( (unsigned int)lstrlen( entity[i].str ) == entity[i].strLength ); assert(static_cast<unsigned int>(lstrlen(entity[i].str)) == entity[i].strLength );
*value = entity[i].chr; *value = entity[i].chr;
return ( p + entity[i].strLength ); return (p + entity[i].strLength);
} }
} }

View File

@ -435,7 +435,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
int tabColourIndex; int tabColourIndex;
if ((tabColourIndex = whichTabColourIndex()) != -1) 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); TabBarPlus::setColour(_pBgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex);
} }
apply(); apply();
@ -498,16 +498,16 @@ int WordStyleDlg::whichTabColourIndex()
::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, (LPARAM)styleName); ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, (LPARAM)styleName);
if (lstrcmp(styleName, TABBAR_ACTIVEFOCUSEDINDCATOR) == 0) if (lstrcmp(styleName, TABBAR_ACTIVEFOCUSEDINDCATOR) == 0)
return (int)TabBarPlus::activeFocusedTop; return TabBarPlus::activeFocusedTop;
if (lstrcmp(styleName, TABBAR_ACTIVEUNFOCUSEDINDCATOR) == 0) if (lstrcmp(styleName, TABBAR_ACTIVEUNFOCUSEDINDCATOR) == 0)
return (int)TabBarPlus::activeUnfocusedTop; return TabBarPlus::activeUnfocusedTop;
if (lstrcmp(styleName, TABBAR_ACTIVETEXT) == 0) if (lstrcmp(styleName, TABBAR_ACTIVETEXT) == 0)
return (int)TabBarPlus::activeText; return TabBarPlus::activeText;
if (lstrcmp(styleName, TABBAR_INACTIVETEXT) == 0) if (lstrcmp(styleName, TABBAR_INACTIVETEXT) == 0)
return (int)TabBarPlus::inactiveText; return TabBarPlus::inactiveText;
return -1; return -1;
} }

View File

@ -99,7 +99,7 @@ public :
virtual void redraw() const { virtual void redraw() const {
_pFgColour->redraw(); _pFgColour->redraw();
_pBgColour->redraw(); _pBgColour->redraw();
::InvalidateRect(_hStyleInfoStaticText, NULL, TRUE); ::InvalidateRect(_hStyleInfoStaticText, NULL, TRUE);
::UpdateWindow(_hStyleInfoStaticText); ::UpdateWindow(_hStyleInfoStaticText);
}; };

View File

@ -915,7 +915,7 @@ INT_PTR CALLBACK DockingCont::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP
case WM_NCACTIVATE: case WM_NCACTIVATE:
{ {
// Note: lParam to identify the trigger window // Note: lParam to identify the trigger window
if ((int)lParam != -1) if (static_cast<int>(lParam) != -1)
{ {
::SendMessage(_hParent, WM_NCACTIVATE, wParam, 0); ::SendMessage(_hParent, WM_NCACTIVATE, wParam, 0);
} }
@ -1330,7 +1330,7 @@ void DockingCont::SelectTab(int iTab)
nmhdr.idFrom = 0; nmhdr.idFrom = 0;
::SendMessage(((tTbData*)tcItem.lParam)->hClient, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); ::SendMessage(((tTbData*)tcItem.lParam)->hClient, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
if ((unsigned int)iTab != _prevItem) if (static_cast<unsigned int>(iTab) != _prevItem)
{ {
// hide previous dialog // hide previous dialog
::SendMessage(_hContTab, TCM_GETITEM, _prevItem, (LPARAM)&tcItem); ::SendMessage(_hContTab, TCM_GETITEM, _prevItem, (LPARAM)&tcItem);

View File

@ -134,7 +134,7 @@ public:
}; };
virtual void destroy() { virtual void destroy() {
for (int iTb = (int)_vTbData.size(); iTb > 0; iTb--) for (int iTb = static_cast<int>(_vTbData.size()); iTb > 0; iTb--)
{ {
delete _vTbData[iTb-1]; delete _vTbData[iTb-1];
} }

View File

@ -232,7 +232,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
::SendMessage(_vContainer[iCont]->getHSelf(), WM_NCACTIVATE, wParam, (LPARAM)-1); ::SendMessage(_vContainer[iCont]->getHSelf(), WM_NCACTIVATE, wParam, (LPARAM)-1);
} }
if ((int)lParam != -1) if (static_cast<int>(lParam) != -1)
{ {
::SendMessage(_hParent, WM_NCACTIVATE, wParam, (LPARAM)-1); ::SendMessage(_hParent, WM_NCACTIVATE, wParam, (LPARAM)-1);
} }

View File

@ -42,12 +42,12 @@
#define INDEX_OPEN_ROOT 0 #define INDEX_OPEN_ROOT 0
#define INDEX_CLOSE_ROOT 1 #define INDEX_CLOSE_ROOT 1
#define INDEX_OPEN_NODE 2 #define INDEX_OPEN_NODE 2
#define INDEX_CLOSE_NODE 3 #define INDEX_CLOSE_NODE 3
#define INDEX_LEAF 4 #define INDEX_LEAF 4
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) #define GET_X_LPARAM(lp) static_cast<short>(LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) #define GET_Y_LPARAM(lp) static_cast<short>(HIWORD(lp))
#define FB_ADDFILE (WM_USER + 1024) #define FB_ADDFILE (WM_USER + 1024)
#define FB_RMFILE (WM_USER + 1025) #define FB_RMFILE (WM_USER + 1025)
@ -724,7 +724,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
case IDM_FILEBROWSER_REMOVEALLROOTS: case IDM_FILEBROWSER_REMOVEALLROOTS:
{ {
for (int i = (int)_folderUpdaters.size() - 1; i >= 0; --i) for (int i = static_cast<int>(_folderUpdaters.size()) - 1; i >= 0; --i)
{ {
_folderUpdaters[i]->stopWatcher(); _folderUpdaters[i]->stopWatcher();

View File

@ -592,14 +592,14 @@ void FunctionParser::getInvertZones(vector< pair<int, int> > & destZones, vecto
{ {
if (sourceZones.size() == 0) if (sourceZones.size() == 0)
{ {
destZones.push_back(pair<int, int>((int)begin, (int)end)); destZones.push_back(pair<int, int>(static_cast<int>(begin), static_cast<int>(end)));
} }
else else
{ {
// check the begin // check the begin
if (int(begin) < sourceZones[0].first) if (int(begin) < sourceZones[0].first)
{ {
destZones.push_back(pair<int, int>((int)begin, sourceZones[0].first - 1)); destZones.push_back(pair<int, int>(static_cast<int>(begin), sourceZones[0].first - 1));
} }
size_t i = 0; size_t i = 0;
@ -612,7 +612,7 @@ void FunctionParser::getInvertZones(vector< pair<int, int> > & destZones, vecto
} }
int lastBegin = sourceZones[i].second + 1; int lastBegin = sourceZones[i].second + 1;
if (lastBegin < int(end)) if (lastBegin < int(end))
destZones.push_back(pair<int, int>(lastBegin, (int)end)); destZones.push_back(pair<int, int>(lastBegin, static_cast<int>(end)));
} }
} }

View File

@ -560,11 +560,11 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe
rect.left +=0; rect.left +=0;
rect.right -=0; rect.right -=0;
if((rect.bottom - rect.top)>24) if((rect.bottom - rect.top)>24)
{ {
excess=(rect.bottom - rect.top)-16; excess=(rect.bottom - rect.top)-16;
rect.top += (int)(excess/2); rect.top += excess / 2;
rect.bottom -= (int)(excess/2); rect.bottom -= excess / 2;
} }
DrawFrameControl(gdc,&rect,DFC_BUTTON,DFCS_BUTTONCHECK|DFCS_CHECKED); 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.left +=0;
rect.right -=0; rect.right -=0;
if((rect.bottom - rect.top)>24) if((rect.bottom - rect.top)>24)
{ {
excess=(rect.bottom - rect.top)-16; excess=(rect.bottom - rect.top)-16;
rect.top += (int)(excess/2); rect.top += excess / 2;
rect.bottom -= (int)(excess/2); rect.bottom -= excess / 2;
} }
DrawFrameControl(gdc,&rect,DFC_BUTTON,DFCS_BUTTONCHECK); DrawFrameControl(gdc,&rect,DFC_BUTTON,DFCS_BUTTONCHECK);
@ -1183,14 +1183,11 @@ void DisplayEditString(HWND hWnd,int SI,TCHAR* tstring)
rt.right +=5; rt.right +=5;
ShowCaret(hWnd); ShowCaret(hWnd);
{
int rh,ah; int rh = BGHS[SI].rowheight;
rh=BGHS[SI].rowheight; int ah = BGHS[SI].fontascentheight;
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); SelectObject(cdc,holdfont);
ReleaseDC(hWnd,cdc); ReleaseDC(hWnd,cdc);
@ -1413,18 +1410,18 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if(lstrlen(BGHS[SelfIndex].title) > 0) if(lstrlen(BGHS[SelfIndex].title) > 0)
{ {
linecount=1; linecount=1;
for(j=0;j<(int)lstrlen(BGHS[SelfIndex].title);j++) for (j = 0; j<static_cast<int>(lstrlen(BGHS[SelfIndex].title)); j++)
{ {
if(BGHS[SelfIndex].title[j]=='\n') if (BGHS[SelfIndex].title[j] == '\n')
{ {
linecount++; linecount++;
} }
} }
holdfont=(HFONT)SelectObject(gdc,BGHS[SelfIndex].htitlefont); holdfont=(HFONT)SelectObject(gdc,BGHS[SelfIndex].htitlefont);
GetTextExtentPoint32(gdc,BGHS[SelfIndex].title,lstrlen(BGHS[SelfIndex].title),&size); GetTextExtentPoint32(gdc,BGHS[SelfIndex].title,lstrlen(BGHS[SelfIndex].title),&size);
SelectObject(gdc,holdfont); SelectObject(gdc,holdfont);
BGHS[SelfIndex].titleheight = (int)((size.cy*1.2) * linecount); BGHS[SelfIndex].titleheight = static_cast<int>((size.cy*1.2) * linecount);
} }
else else
{ {
@ -3111,7 +3108,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext)
if(lbcount < 12) if(lbcount < 12)
{ {
//not worth doing binary search, do regular search //not worth doing binary search, do regular search
FindResult = static_cast<int32_t>(SendMessage(lbhWnd, LB_FINDSTRING, (unsigned int)-1, (LPARAM)searchtext)); FindResult = static_cast<int32_t>(SendMessage(lbhWnd, LB_FINDSTRING, static_cast<unsigned int>(-1), reinterpret_cast<LPARAM>(searchtext)));
ReturnValue = FindResult; ReturnValue = FindResult;
return ReturnValue; return ReturnValue;
} }
@ -3121,7 +3118,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext)
tail = lbcount - 1; tail = lbcount - 1;
//is it the head? //is it the head?
SendMessage(lbhWnd,LB_GETTEXT,head,(LPARAM)headtext); SendMessage(lbhWnd, LB_GETTEXT, head, reinterpret_cast<LPARAM>(headtext));
headtext[9] = 0x00; headtext[9] = 0x00;
p=lstrcmp(searchtext,headtext); p=lstrcmp(searchtext,headtext);
@ -3141,7 +3138,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext)
//is it the tail? //is it the tail?
SendMessage(lbhWnd,LB_GETTEXT,tail,(LPARAM)tailtext); SendMessage(lbhWnd, LB_GETTEXT, tail, reinterpret_cast<LPARAM>(tailtext));
tailtext[9] = 0x00; tailtext[9] = 0x00;
p=lstrcmp(searchtext,tailtext); p=lstrcmp(searchtext,tailtext);
if(p==0) if(p==0)
@ -3166,7 +3163,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext)
{ {
finger = head + ((tail - head) / 2); finger = head + ((tail - head) / 2);
SendMessage(lbhWnd,LB_GETTEXT,finger,(LPARAM)tbuffer); SendMessage(lbhWnd, LB_GETTEXT, finger, reinterpret_cast<LPARAM>(tbuffer));
tbuffer[9] = 0x00; tbuffer[9] = 0x00;
p=lstrcmp(tbuffer,searchtext); p=lstrcmp(tbuffer,searchtext);
if(p==0) if(p==0)

View File

@ -639,19 +639,19 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
HWND hBorderWidthSlider = ::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER); HWND hBorderWidthSlider = ::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER);
if (reinterpret_cast<HWND>(lParam) == hCaretBlikRateSlider) if (reinterpret_cast<HWND>(lParam) == hCaretBlikRateSlider)
{ {
int blinkRate = (int)::SendMessage(hCaretBlikRateSlider, TBM_GETPOS, 0, 0); auto blinkRate = ::SendMessage(hCaretBlikRateSlider, TBM_GETPOS, 0, 0);
if (blinkRate == BLINKRATE_SLOWEST) if (blinkRate == BLINKRATE_SLOWEST)
blinkRate = 0; blinkRate = 0;
nppGUI._caretBlinkRate = blinkRate; nppGUI._caretBlinkRate = static_cast<int>(blinkRate);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0);
} }
else if (reinterpret_cast<HWND>(lParam) == hBorderWidthSlider) else if (reinterpret_cast<HWND>(lParam) == hBorderWidthSlider)
{ {
int borderWidth = (int)::SendMessage(hBorderWidthSlider, TBM_GETPOS, 0, 0); auto borderWidth = ::SendMessage(hBorderWidthSlider, TBM_GETPOS, 0, 0);
ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP(); ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP();
svp._borderWidth = borderWidth; svp._borderWidth = static_cast<int>(borderWidth);
::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, borderWidth, FALSE); ::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, static_cast<UINT>(borderWidth), FALSE);
::SendMessage(::GetParent(_hParent), WM_SIZE, 0, 0); ::SendMessage(::GetParent(_hParent), WM_SIZE, 0, 0);
} }
return 0; //return zero when handled return 0; //return zero when handled

View File

@ -44,8 +44,8 @@
#define INDEX_LEAF 5 #define INDEX_LEAF 5
#define INDEX_LEAF_INVALID 6 #define INDEX_LEAF_INVALID 6
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) #define GET_X_LPARAM(lp) LOWORD(lp)
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) #define GET_Y_LPARAM(lp) HIWORD(lp)
INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {

View File

@ -245,7 +245,7 @@ INT_PTR CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
int const posBase = 2; int const posBase = 2;
if (nbCmd == 0) if (nbCmd == 0)
::InsertMenu(hRunMenu, posBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hRunMenu, posBase - 1, MF_BYPOSITION, static_cast<unsigned int>(-1), 0);
theUserCmds.push_back(uc); theUserCmds.push_back(uc);
::InsertMenu(hRunMenu, posBase + nbCmd, MF_BYPOSITION, cmdID, uc.toMenuItemString().c_str()); ::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) if (nbCmd == 0)
{ {
// Insert the separator and modify/delete command // 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<unsigned int>(-1), 0);
NativeLangSpeaker *pNativeLangSpeaker = nppParams->getNativeLangSpeaker(); NativeLangSpeaker *pNativeLangSpeaker = nppParams->getNativeLangSpeaker();
generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO); generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO);
if (nativeLangShortcutMapperMacro == TEXT("")) if (nativeLangShortcutMapperMacro == TEXT(""))

View File

@ -128,7 +128,7 @@ void StatusBar::adjustParts(int clientWidth)
// copy the coordinates to the array. // copy the coordinates to the array.
int nWidth = std::max<int>(clientWidth - 20, 0); int nWidth = std::max<int>(clientWidth - 20, 0);
for (int i = (int)_partWidthArray.size() - 1; i >= 0; i--) for (int i = static_cast<int>(_partWidthArray.size()) - 1; i >= 0; i--)
{ {
_lpParts[i] = nWidth; _lpParts[i] = nWidth;
nWidth -= _partWidthArray[i]; nWidth -= _partWidthArray[i];

View File

@ -25,8 +25,6 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <stdexcept> #include <stdexcept>
#include "TaskList.h" #include "TaskList.h"
#include "TaskListDlg_rc.h" #include "TaskListDlg_rc.h"

View File

@ -26,8 +26,7 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef TASKLIST_H #pragma once
#define TASKLIST_H
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
@ -77,5 +76,3 @@ protected:
RECT _rc; RECT _rc;
}; };
#endif // TASKLIST_H

View File

@ -455,13 +455,13 @@ bool ReBar::addBand(REBARBANDINFO * rBand, bool useID)
void ReBar::reNew(int id, REBARBANDINFO * rBand) 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); ::SendMessage(_hSelf, RB_SETBANDINFO, (WPARAM)index, (LPARAM)rBand);
}; };
void ReBar::removeBand(int id) 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) if (id >= REBAR_BAR_EXTERNAL)
releaseID(id); releaseID(id);
::SendMessage(_hSelf, RB_DELETEBAND, (WPARAM)index, (LPARAM)0); ::SendMessage(_hSelf, RB_DELETEBAND, (WPARAM)index, (LPARAM)0);
@ -469,7 +469,7 @@ void ReBar::removeBand(int id)
void ReBar::setIDVisible(int id, bool show) 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 ) if (index == -1 )
return; //error return; //error
@ -489,7 +489,7 @@ void ReBar::setIDVisible(int id, bool show)
bool ReBar::getIDVisible(int id) 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 ) if (index == -1 )
return false; //error return false; //error
REBARBANDINFO rbBand; REBARBANDINFO rbBand;
@ -504,7 +504,7 @@ bool ReBar::getIDVisible(int id)
void ReBar::setGrayBackground(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 ) if (index == -1 )
return; //error return; //error
REBARBANDINFO rbBand; REBARBANDINFO rbBand;

View File

@ -162,8 +162,8 @@ struct BufferEquivalent
} }
else if (_iColumn == 2) else if (_iColumn == 2)
{ {
int t1 = (int)b1->getLangType(); auto t1 = b1->getLangType();
int t2 = (int)b2->getLangType(); auto t2 = b2->getLangType();
return (t1 < t2); // yeah should be the name return (t1 < t2); // yeah should be the name
} }
return false; return false;
@ -429,7 +429,7 @@ void WindowsDlg::updateButtonState()
int WindowsDlg::doDialog(TiXmlNodeA *dlgNode) int WindowsDlg::doDialog(TiXmlNodeA *dlgNode)
{ {
_dlgNode = dlgNode; _dlgNode = dlgNode;
return (int)::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, reinterpret_cast<LPARAM>(this)); return static_cast<int>(DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, reinterpret_cast<LPARAM>(this)));
}; };
bool WindowsDlg::changeDlgLang() bool WindowsDlg::changeDlgLang()
@ -602,8 +602,8 @@ void WindowsDlg::fitColumnsToSize()
if (GetClientRect(_hList, &rc)) if (GetClientRect(_hList, &rc))
{ {
int len = (rc.right - rc.left); int len = (rc.right - rc.left);
len -= (int)SendMessage(_hList, LVM_GETCOLUMNWIDTH, 0, 0); len -= static_cast<int>(SendMessage(_hList, LVM_GETCOLUMNWIDTH, 0, 0));
len -= (int)SendMessage(_hList, LVM_GETCOLUMNWIDTH, 2, 0); len -= static_cast<int>(SendMessage(_hList, LVM_GETCOLUMNWIDTH, 2, 0));
len -= GetSystemMetrics(SM_CXVSCROLL); len -= GetSystemMetrics(SM_CXVSCROLL);
len -= 1; len -= 1;
SendMessage(_hList, LVM_SETCOLUMNWIDTH, 1, len); SendMessage(_hList, LVM_SETCOLUMNWIDTH, 1, len);
@ -719,7 +719,9 @@ void WindowsDlg::doClose()
else else
{ {
// select first previously selected item (or last one if only the last one was removed) // 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<int>(_idxMap.size()))
index -= 1;
if (index >= 0) if (index >= 0)
{ {
ListView_SetItemState(_hList, index, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(_hList, index, LVIS_SELECTED, LVIS_SELECTED);

View File

@ -585,7 +585,7 @@ void Accelerator::updateFullMenu() {
void Accelerator::updateMenuItemByCommand(CommandShortcut csc) 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. // Ensure that the menu item checks set prior to this update remain in affect.
UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND ); UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND );

View File

@ -195,7 +195,7 @@ void LastRecentFileList::remove(const TCHAR *fn)
remove(index); remove(index);
}; };
void LastRecentFileList::remove(int index) void LastRecentFileList::remove(size_t index)
{ {
if (_size == 0 || _locked) if (_size == 0 || _locked)
return; return;

View File

@ -52,7 +52,7 @@ public:
void add(const TCHAR *fn); void add(const TCHAR *fn);
void remove(const TCHAR *fn); void remove(const TCHAR *fn);
void remove(int index); void remove(size_t index);
void clear(); void clear();
int getSize() { int getSize() {

View File

@ -840,8 +840,6 @@ void NativeLangSpeaker::changeShortcutLang()
NppParameters * pNppParam = NppParameters::getInstance(); NppParameters * pNppParam = NppParameters::getInstance();
vector<CommandShortcut> & mainshortcuts = pNppParam->getUserShortcuts(); vector<CommandShortcut> & mainshortcuts = pNppParam->getUserShortcuts();
vector<ScintillaKeyMap> & scinshortcuts = pNppParam->getScintillaKeyList(); vector<ScintillaKeyMap> & scinshortcuts = pNppParam->getScintillaKeyList();
int mainSize = (int)mainshortcuts.size();
int scinSize = (int)scinshortcuts.size();
TiXmlNodeA *shortcuts = _nativeLangA->FirstChild("Shortcuts"); TiXmlNodeA *shortcuts = _nativeLangA->FirstChild("Shortcuts");
if (!shortcuts) return; if (!shortcuts) return;
@ -860,7 +858,8 @@ void NativeLangSpeaker::changeShortcutLang()
int index, id; int index, id;
if (element->Attribute("index", &index) && element->Attribute("id", &id)) if (element->Attribute("index", &index) && element->Attribute("id", &id))
{ {
if (index > -1 && index < mainSize) { //valid index only if (index > -1 && static_cast<size_t>(index) < mainshortcuts.size()) //valid index only
{
const char *name = element->Attribute("name"); const char *name = element->Attribute("name");
CommandShortcut & csc = mainshortcuts[index]; CommandShortcut & csc = mainshortcuts[index];
if (csc.getID() == (unsigned long)id) if (csc.getID() == (unsigned long)id)
@ -891,7 +890,8 @@ void NativeLangSpeaker::changeShortcutLang()
int index; int index;
if (element->Attribute("index", &index)) if (element->Attribute("index", &index))
{ {
if (index > -1 && index < scinSize) { //valid index only if (index > -1 && static_cast<size_t>(index) < scinshortcuts.size()) //valid index only
{
const char *name = element->Attribute("name"); const char *name = element->Attribute("name");
ScintillaKeyMap & skm = scinshortcuts[index]; ScintillaKeyMap & skm = scinshortcuts[index];