x64 ready

1. Remove all warning while compiling in x64
2. Treat warning as error (W4) while compiling in x64
This commit is contained in:
Don HO 2016-06-05 20:29:21 +02:00
parent 80219be9ac
commit 64d7535be1
86 changed files with 1200 additions and 1102 deletions

4
.gitignore vendored
View File

@ -52,6 +52,7 @@ UpgradeLog*.htm
.builds .builds
*.pidb *.pidb
PowerEditor/bin/notepad++.exe PowerEditor/bin/notepad++.exe
PowerEditor/bin/notepad++.exe
PowerEditor/bin/SciLexer.dll PowerEditor/bin/SciLexer.dll
PowerEditor/bin/config.xml PowerEditor/bin/config.xml
PowerEditor/bin/stylers.xml PowerEditor/bin/stylers.xml
@ -67,12 +68,15 @@ PowerEditor/bin/shortcuts.xml
PowerEditor/bin/backup/ PowerEditor/bin/backup/
PowerEditor/bin/localization PowerEditor/bin/localization
PowerEditor/bin/plugins/ PowerEditor/bin/plugins/
PowerEditor/bin64/
PowerEditor/installer/build/ PowerEditor/installer/build/
PowerEditor/installer/minimalist/ PowerEditor/installer/minimalist/
PowerEditor/installer/zipped.package.release/ PowerEditor/installer/zipped.package.release/
PowerEditor/visual.net/Unicode Debug/ PowerEditor/visual.net/Unicode Debug/
PowerEditor/visual.net/Unicode Release/ PowerEditor/visual.net/Unicode Release/
PowerEditor/visual.net/notepadPlus.sln PowerEditor/visual.net/notepadPlus.sln
PowerEditor/visual.net/x64/Unicode Debug/
PowerEditor/visual.net/x64/Unicode Release/
# scintilla - generated files # scintilla - generated files

View File

@ -124,9 +124,9 @@ int EncodingMapper::getEncodingFromIndex(int index) const
int EncodingMapper::getIndexFromEncoding(int encoding) const int EncodingMapper::getIndexFromEncoding(int encoding) const
{ {
bool found = false; bool found = false;
size_t nbItem = sizeof(encodings)/sizeof(EncodingUnit); int nbItem = sizeof(encodings)/sizeof(EncodingUnit);
size_t i = 0; int i = 0;
for ( ; i < nbItem ; ++i) for ( ; i < nbItem; ++i)
{ {
if (encodings[i]._codePage == encoding) if (encodings[i]._codePage == encoding)
{ {
@ -134,7 +134,7 @@ int EncodingMapper::getIndexFromEncoding(int encoding) const
break; break;
} }
} }
return found?i:-1; return found ? i : -1;
} }
int EncodingMapper::getEncodingFromString(const char *encodingAlias) const int EncodingMapper::getEncodingFromString(const char *encodingAlias) const

View File

@ -781,8 +781,8 @@ generic_string stringReplace(generic_string subject, const generic_string& searc
std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter) std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter)
{ {
auto start = 0U; size_t start = 0U;
auto end = input.find(delimiter); size_t end = input.find(delimiter);
std::vector<generic_string> output; std::vector<generic_string> output;
const size_t delimiterLength = delimiter.length(); const size_t delimiterLength = delimiter.length();
while (end != std::string::npos) while (end != std::string::npos)
@ -849,7 +849,7 @@ double stodLocale(const generic_string& str, _locale_t loc, size_t* idx)
bool str2Clipboard(const generic_string &str2cpy, HWND hwnd) bool str2Clipboard(const generic_string &str2cpy, HWND hwnd)
{ {
int len2Allocate = (str2cpy.size() + 1) * sizeof(TCHAR); size_t len2Allocate = (str2cpy.size() + 1) * sizeof(TCHAR);
HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, len2Allocate); HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, len2Allocate);
if (hglbCopy == NULL) if (hglbCopy == NULL)
{ {

View File

@ -98,7 +98,7 @@ public:
const wchar_t * char2wchar(const char *mbStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL); const wchar_t * char2wchar(const char *mbStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL);
const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend); const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend);
const char * wchar2char(const wchar_t *wcStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL); const char * wchar2char(const wchar_t *wcStr, UINT codepage, int lenIn = -1, int *pLenOut = NULL);
const char * wchar2char(const wchar_t *wcStr, UINT codepage, long *mstart, long *mend); const char * wchar2char(const wchar_t *wcStr, UINT codepage, long *mstart, long *mend);
const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL) const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL)

View File

@ -218,7 +218,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
} }
addInLoadedDlls(pluginFileName); addInLoadedDlls(pluginFileName);
_pluginInfos.push_back(pi); _pluginInfos.push_back(pi);
return (_pluginInfos.size() - 1); return static_cast<int32_t>(_pluginInfos.size() - 1);
} }
catch (std::exception e) catch (std::exception e)
{ {
@ -347,7 +347,7 @@ void PluginsManager::addInMenuFromPMIndex(int i)
_pluginsCommands.push_back(PluginCommand(_pluginInfos[i]->_moduleName.c_str(), j, _pluginInfos[i]->_funcItems[j]._pFunc)); _pluginsCommands.push_back(PluginCommand(_pluginInfos[i]->_moduleName.c_str(), j, _pluginInfos[i]->_funcItems[j]._pFunc));
int cmdID = ID_PLUGINS_CMD + (_pluginsCommands.size() - 1); int cmdID = ID_PLUGINS_CMD + static_cast<int32_t>(_pluginsCommands.size() - 1);
_pluginInfos[i]->_funcItems[j]._cmdID = cmdID; _pluginInfos[i]->_funcItems[j]._cmdID = cmdID;
generic_string itemName = _pluginInfos[i]->_funcItems[j]._itemName; generic_string itemName = _pluginInfos[i]->_funcItems[j]._itemName;
@ -390,7 +390,7 @@ HMENU PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName)
for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i) for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i)
{ {
addInMenuFromPMIndex(i); addInMenuFromPMIndex(static_cast<int32_t>(i));
} }
return _hPluginsMenu; return _hPluginsMenu;
} }

View File

@ -130,7 +130,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
TCHAR ext2Add[extNameMax] = TEXT(""); TCHAR ext2Add[extNameMax] = TEXT("");
if (!_isCustomize) if (!_isCustomize)
{ {
int index2Add = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCURSEL, 0, 0); auto index2Add = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCURSEL, 0, 0);
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETTEXT, index2Add, (LPARAM)ext2Add); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETTEXT, index2Add, (LPARAM)ext2Add);
addExt(ext2Add); addExt(ext2Add);
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, index2Add, 0); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, index2Add, 0);
@ -138,7 +138,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
else else
{ {
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)ext2Add); ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)ext2Add);
int i = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)ext2Add); auto i = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)ext2Add);
if (i != LB_ERR) if (i != LB_ERR)
return TRUE; return TRUE;
addExt(ext2Add); addExt(ext2Add);
@ -152,11 +152,11 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
case IDC_REMOVEEXT_BUTTON : case IDC_REMOVEEXT_BUTTON :
{ {
TCHAR ext2Sup[extNameMax] = TEXT(""); TCHAR ext2Sup[extNameMax] = TEXT("");
int index2Sup = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_GETCURSEL, 0, 0); auto index2Sup = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_GETCURSEL, 0, 0);
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_GETTEXT, index2Sup, (LPARAM)ext2Sup); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_GETTEXT, index2Sup, (LPARAM)ext2Sup);
if (deleteExts(ext2Sup)) if (deleteExts(ext2Sup))
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_DELETESTRING, index2Sup, 0); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_DELETESTRING, index2Sup, 0);
int langIndex = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANG_LIST, LB_GETCURSEL, 0, 0); auto langIndex = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANG_LIST, LB_GETCURSEL, 0, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false);
@ -199,7 +199,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
if (HIWORD(wParam) == LBN_SELCHANGE) if (HIWORD(wParam) == LBN_SELCHANGE)
{ {
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (LOWORD(wParam) == IDC_REGEXT_LANG_LIST) if (LOWORD(wParam) == IDC_REGEXT_LANG_LIST)
{ {
if (i != LB_ERR) if (i != LB_ERR)
@ -222,7 +222,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
_isCustomize = false; _isCustomize = false;
} }
int count = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCOUNT, 0, 0); auto count = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCOUNT, 0, 0);
for (count -= 1 ; count >= 0 ; count--) for (count -= 1 ; count >= 0 ; count--)
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0);
@ -230,7 +230,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
{ {
if (lstrcmp(TEXT(""), defExtArray[i][j])) if (lstrcmp(TEXT(""), defExtArray[i][j]))
{ {
int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]); auto index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]);
if (index == -1) if (index == -1)
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]);
} }

View File

@ -306,7 +306,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_mainEditView.performGlobalStyles(); _mainEditView.performGlobalStyles();
_subEditView.performGlobalStyles(); _subEditView.performGlobalStyles();
_zoomOriginalValue = _pEditView->execute(SCI_GETZOOM); _zoomOriginalValue = static_cast<int32_t>(_pEditView->execute(SCI_GETZOOM));
_mainEditView.execute(SCI_SETZOOM, svp1._zoom); _mainEditView.execute(SCI_SETZOOM, svp1._zoom);
_subEditView.execute(SCI_SETZOOM, svp1._zoom2); _subEditView.execute(SCI_SETZOOM, svp1._zoom2);
@ -421,12 +421,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
::InsertMenu(hMacroMenu, posBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hMacroMenu, posBase - 1, MF_BYPOSITION, (unsigned int)-1, 0);
for (size_t i = 0 ; i < nbMacro ; ++i) for (size_t i = 0 ; i < nbMacro ; ++i)
::InsertMenu(hMacroMenu, posBase + i, MF_BYPOSITION, ID_MACRO + i, macros[i].toMenuItemString().c_str()); ::InsertMenu(hMacroMenu, UINT(posBase + i), MF_BYPOSITION, ID_MACRO + i, macros[i].toMenuItemString().c_str());
if (nbMacro >= 1) if (nbMacro >= 1)
{ {
::InsertMenu(hMacroMenu, posBase + nbMacro + 1, MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hMacroMenu, UINT(posBase + nbMacro + 1), MF_BYPOSITION, (unsigned int)-1, 0);
::InsertMenu(hMacroMenu, posBase + nbMacro + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro...")); ::InsertMenu(hMacroMenu, UINT(posBase + nbMacro + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro..."));
} }
// Run Menu // Run Menu
@ -439,13 +439,13 @@ LRESULT Notepad_plus::init(HWND hwnd)
for (size_t i = 0 ; i < nbUserCommand ; ++i) for (size_t i = 0 ; i < nbUserCommand ; ++i)
{ {
::InsertMenu(hRunMenu, runPosBase + i, MF_BYPOSITION, ID_USER_CMD + i, userCommands[i].toMenuItemString().c_str()); ::InsertMenu(hRunMenu, UINT(runPosBase + i), MF_BYPOSITION, ID_USER_CMD + i, userCommands[i].toMenuItemString().c_str());
} }
if (nbUserCommand >= 1) if (nbUserCommand >= 1)
{ {
::InsertMenu(hRunMenu, runPosBase + nbUserCommand + 1, MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hRunMenu, UINT(runPosBase + nbUserCommand + 1), MF_BYPOSITION, (unsigned int)-1, 0);
::InsertMenu(hRunMenu, runPosBase + nbUserCommand + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, TEXT("Modify Shortcut/Delete Command...")); ::InsertMenu(hRunMenu, UINT(runPosBase + nbUserCommand + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, TEXT("Modify Shortcut/Delete Command..."));
} }
// Updater menu item // Updater menu item
@ -842,7 +842,7 @@ void Notepad_plus::saveDockingParams()
{ {
if (vDataVis[j]->pszName && vDataVis[j]->pszName[0]) if (vDataVis[j]->pszName && vDataVis[j]->pszName[0])
{ {
PluginDlgDockingInfo pddi(vDataVis[j]->pszModuleName, vDataVis[j]->dlgID, i, vDataVis[j]->iPrevCont, true); PluginDlgDockingInfo pddi(vDataVis[j]->pszModuleName, vDataVis[j]->dlgID, int32_t(i), vDataVis[j]->iPrevCont, true);
vPluginDockInfo.push_back(pddi); vPluginDockInfo.push_back(pddi);
} }
} }
@ -854,7 +854,7 @@ void Notepad_plus::saveDockingParams()
{ {
if ((vDataAll[j]->pszName && vDataAll[j]->pszName[0]) && (!vCont[i]->isTbVis(vDataAll[j]))) if ((vDataAll[j]->pszName && vDataAll[j]->pszName[0]) && (!vCont[i]->isTbVis(vDataAll[j])))
{ {
PluginDlgDockingInfo pddi(vDataAll[j]->pszModuleName, vDataAll[j]->dlgID, i, vDataAll[j]->iPrevCont, false); PluginDlgDockingInfo pddi(vDataAll[j]->pszModuleName, vDataAll[j]->dlgID, int32_t(i), vDataAll[j]->iPrevCont, false);
vPluginDockInfo.push_back(pddi); vPluginDockInfo.push_back(pddi);
} }
} }
@ -864,12 +864,12 @@ void Notepad_plus::saveDockingParams()
{ {
RECT rc; RECT rc;
vCont[i]->getWindowRect(rc); vCont[i]->getWindowRect(rc);
FloatingWindowInfo fwi(i, rc.left, rc.top, rc.right, rc.bottom); FloatingWindowInfo fwi(int32_t(i), rc.left, rc.top, rc.right, rc.bottom);
vFloatingWindowInfo.push_back(fwi); vFloatingWindowInfo.push_back(fwi);
} }
// save the active tab // save the active tab
ContainerTabInfo act(i, vCont[i]->getActiveTb()); ContainerTabInfo act(int32_t(i), vCont[i]->getActiveTb());
nppGUI._dockingData._containerTabInfo.push_back(act); nppGUI._dockingData._containerTabInfo.push_back(act);
} }
@ -961,7 +961,7 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
return -1; return -1;
const int blockSize = 1024; // To ensure that length is long enough to capture the encoding in html const int blockSize = 1024; // To ensure that length is long enough to capture the encoding in html
char data[blockSize]; char data[blockSize];
int lenFile = fread(data, 1, blockSize, f); size_t lenFile = fread(data, 1, blockSize, f);
fclose(f); fclose(f);
// Put data in _invisibleEditView // Put data in _invisibleEditView
@ -976,13 +976,13 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
const char *xmlHeaderRegExpr = "<?xml[ \\t]+version[ \\t]*=[ \\t]*\"[^\"]+\"[ \\t]+encoding[ \\t]*=[ \\t]*\"[^\"]+\"[ \\t]*.*?>"; const char *xmlHeaderRegExpr = "<?xml[ \\t]+version[ \\t]*=[ \\t]*\"[^\"]+\"[ \\t]+encoding[ \\t]*=[ \\t]*\"[^\"]+\"[ \\t]*.*?>";
int startPos = 0; size_t startPos = 0;
int endPos = lenFile-1; size_t endPos = lenFile-1;
_invisibleEditView.execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX); _invisibleEditView.execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX);
_invisibleEditView.execute(SCI_SETTARGETRANGE, startPos, endPos); _invisibleEditView.execute(SCI_SETTARGETRANGE, startPos, endPos);
int posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(xmlHeaderRegExpr), (LPARAM)xmlHeaderRegExpr); auto posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(xmlHeaderRegExpr), (LPARAM)xmlHeaderRegExpr);
if (posFound != -1 && posFound != -2) if (posFound != -1 && posFound != -2)
{ {
const char *encodingBlockRegExpr = "encoding[ \\t]*=[ \\t]*\"[^\".]+\""; const char *encodingBlockRegExpr = "encoding[ \\t]*=[ \\t]*\"[^\".]+\"";
@ -994,7 +994,7 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingAliasRegExpr), (LPARAM)encodingAliasRegExpr); _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingAliasRegExpr), (LPARAM)encodingAliasRegExpr);
startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART)); startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART));
endPos = int(_invisibleEditView.execute(SCI_GETTARGETEND)); endPos = _invisibleEditView.execute(SCI_GETTARGETEND);
char encodingStr[128]; char encodingStr[128];
_invisibleEditView.getText(encodingStr, startPos, endPos); _invisibleEditView.getText(encodingStr, startPos, endPos);
@ -1014,16 +1014,16 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
const char *encodingStrRE = "[^ \\t=]+"; const char *encodingStrRE = "[^ \\t=]+";
int startPos = 0; int startPos = 0;
int endPos = lenFile-1; auto endPos = lenFile - 1;
_invisibleEditView.execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX); _invisibleEditView.execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX);
_invisibleEditView.execute(SCI_SETTARGETRANGE, startPos, endPos); _invisibleEditView.execute(SCI_SETTARGETRANGE, startPos, endPos);
int posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr), (LPARAM)htmlHeaderRegExpr); int posFound = static_cast<int32_t>(_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr), (LPARAM)htmlHeaderRegExpr));
if (posFound == -1 || posFound == -2) if (posFound == -1 || posFound == -2)
{ {
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr2), (LPARAM)htmlHeaderRegExpr2); posFound = static_cast<int32_t>(_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr2), (LPARAM)htmlHeaderRegExpr2));
if (posFound == -1 || posFound == -2) if (posFound == -1 || posFound == -2)
return -1; return -1;
} }
@ -1032,7 +1032,7 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingStrRE), (LPARAM)encodingStrRE); _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingStrRE), (LPARAM)encodingStrRE);
startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART)); startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART));
endPos = int(_invisibleEditView.execute(SCI_GETTARGETEND)); endPos = _invisibleEditView.execute(SCI_GETTARGETEND);
char encodingStr[128]; char encodingStr[128];
_invisibleEditView.getText(encodingStr, startPos, endPos); _invisibleEditView.getText(encodingStr, startPos, endPos);
@ -1058,13 +1058,13 @@ bool Notepad_plus::replaceInOpenedFiles() {
if (_mainWindowStatus & WindowMainActive) if (_mainWindowStatus & WindowMainActive)
{ {
for (int i = 0, len = _mainDocTab.nbItem(); i < len ; ++i) for (size_t i = 0, len = _mainDocTab.nbItem(); i < len ; ++i)
{ {
pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i)); pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i));
if (pBuf->isReadOnly()) if (pBuf->isReadOnly())
continue; continue;
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
int cp = _invisibleEditView.execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(_invisibleEditView.execute(SCI_GETCODEPAGE));
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8); _invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
_invisibleEditView.setCurrentBuffer(pBuf); _invisibleEditView.setCurrentBuffer(pBuf);
_invisibleEditView.execute(SCI_BEGINUNDOACTION); _invisibleEditView.execute(SCI_BEGINUNDOACTION);
@ -1075,13 +1075,13 @@ bool Notepad_plus::replaceInOpenedFiles() {
if (_mainWindowStatus & WindowSubActive) if (_mainWindowStatus & WindowSubActive)
{ {
for (int i = 0, len = _subDocTab.nbItem(); i < len; ++i) for (size_t i = 0, len = _subDocTab.nbItem(); i < len; ++i)
{ {
pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i)); pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i));
if (pBuf->isReadOnly()) if (pBuf->isReadOnly())
continue; continue;
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
int cp = _invisibleEditView.execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(_invisibleEditView.execute(SCI_GETCODEPAGE));
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8); _invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
_invisibleEditView.setCurrentBuffer(pBuf); _invisibleEditView.setCurrentBuffer(pBuf);
_invisibleEditView.execute(SCI_BEGINUNDOACTION); _invisibleEditView.execute(SCI_BEGINUNDOACTION);
@ -1111,10 +1111,10 @@ bool Notepad_plus::replaceInOpenedFiles() {
void Notepad_plus::wsTabConvert(spaceTab whichWay) void Notepad_plus::wsTabConvert(spaceTab whichWay)
{ {
int tabWidth = _pEditView->execute(SCI_GETTABWIDTH); int tabWidth = static_cast<int32_t>(_pEditView->execute(SCI_GETTABWIDTH));
int currentPos = _pEditView->execute(SCI_GETCURRENTPOS); int currentPos = static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS));
int lastLine = _pEditView->lastZeroBasedLineNumber(); int lastLine = _pEditView->lastZeroBasedLineNumber();
int docLength = int(_pEditView->execute(SCI_GETLENGTH)) + 1; int docLength = static_cast<int32_t>(_pEditView->execute(SCI_GETLENGTH) + 1);
if (docLength < 2) if (docLength < 2)
return; return;
@ -1122,7 +1122,7 @@ void Notepad_plus::wsTabConvert(spaceTab whichWay)
int column = 0; int column = 0;
int counter = 0; int counter = 0;
int newCurrentPos = 0; int newCurrentPos = 0;
int tabStop = tabWidth - 1; // remember, counting from zero ! int tabStop = static_cast<int32_t>(tabWidth - 1); // remember, counting from zero !
bool onlyLeading = false; bool onlyLeading = false;
bool nonSpaceFound = false; bool nonSpaceFound = false;
vector<int> bookmarks; vector<int> bookmarks;
@ -1176,8 +1176,8 @@ void Notepad_plus::wsTabConvert(spaceTab whichWay)
{ {
if (source[i] == '\t') if (source[i] == '\t')
{ {
size_t insertTabs = tabWidth - (column % tabWidth); int insertTabs = tabWidth - (column % tabWidth);
for (size_t j = 0; j<insertTabs; ++j) for (int j = 0; j < insertTabs; ++j)
{ {
*dest++ = ' '; *dest++ = ' ';
if (i <= currentPos) if (i <= currentPos)
@ -1499,7 +1499,7 @@ bool Notepad_plus::replaceInFiles()
{ {
Buffer * pBuf = MainFileManager->getBufferByID(id); Buffer * pBuf = MainFileManager->getBufferByID(id);
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
int cp = _invisibleEditView.execute(SCI_GETCODEPAGE); auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8); _invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
_invisibleEditView.setCurrentBuffer(pBuf); _invisibleEditView.setCurrentBuffer(pBuf);
@ -1518,7 +1518,7 @@ bool Notepad_plus::replaceInFiles()
if (i == updateOnCount) if (i == updateOnCount)
{ {
updateOnCount += filesPerPercent; updateOnCount += filesPerPercent;
progress.setPercent((i * 100) / filesCount, fileNames.at(i).c_str()); progress.setPercent(int32_t((i * 100) / filesCount), fileNames.at(i).c_str());
} }
else else
{ {
@ -1587,7 +1587,7 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo)
{ {
Buffer * pBuf = MainFileManager->getBufferByID(id); Buffer * pBuf = MainFileManager->getBufferByID(id);
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
int cp = _invisibleEditView.execute(SCI_GETCODEPAGE); auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8); _invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
findInFolderInfo->_pFileName = fileNames.at(i).c_str(); findInFolderInfo->_pFileName = fileNames.at(i).c_str();
@ -1598,7 +1598,7 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo)
if (i == updateOnCount) if (i == updateOnCount)
{ {
updateOnCount += filesPerPercent; updateOnCount += filesPerPercent;
progress.setPercent((i * 100) / filesCount, fileNames.at(i).c_str()); progress.setPercent(int32_t((i * 100) / filesCount), fileNames.at(i).c_str());
} }
else else
{ {
@ -1672,7 +1672,7 @@ bool Notepad_plus::findInFiles()
{ {
Buffer * pBuf = MainFileManager->getBufferByID(id); Buffer * pBuf = MainFileManager->getBufferByID(id);
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
int cp = _invisibleEditView.execute(SCI_GETCODEPAGE); auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8); _invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
FindersInfo findersInfo; FindersInfo findersInfo;
findersInfo._pFileName = fileNames.at(i).c_str(); findersInfo._pFileName = fileNames.at(i).c_str();
@ -1683,7 +1683,7 @@ bool Notepad_plus::findInFiles()
if (i == updateOnCount) if (i == updateOnCount)
{ {
updateOnCount += filesPerPercent; updateOnCount += filesPerPercent;
progress.setPercent((i * 100) / filesCount, fileNames.at(i).c_str()); progress.setPercent(int32_t((i * 100) / filesCount), fileNames.at(i).c_str());
} }
else else
{ {
@ -1722,11 +1722,11 @@ bool Notepad_plus::findInOpenedFiles()
if (_mainWindowStatus & WindowMainActive) if (_mainWindowStatus & WindowMainActive)
{ {
for (int i = 0, len = _mainDocTab.nbItem(); i < len ; ++i) for (size_t i = 0, len = _mainDocTab.nbItem(); i < len ; ++i)
{ {
pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i)); pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i));
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
int cp = _invisibleEditView.execute(SCI_GETCODEPAGE); auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8); _invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
FindersInfo findersInfo; FindersInfo findersInfo;
findersInfo._pFileName = pBuf->getFullPathName(); findersInfo._pFileName = pBuf->getFullPathName();
@ -1736,11 +1736,11 @@ bool Notepad_plus::findInOpenedFiles()
if (_mainWindowStatus & WindowSubActive) if (_mainWindowStatus & WindowSubActive)
{ {
for (int i = 0, len2 = _subDocTab.nbItem(); i < len2 ; ++i) for (size_t i = 0, len2 = _subDocTab.nbItem(); i < len2 ; ++i)
{ {
pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i)); pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i));
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
int cp = _invisibleEditView.execute(SCI_GETCODEPAGE); auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8); _invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
FindersInfo findersInfo; FindersInfo findersInfo;
findersInfo._pFileName = pBuf->getFullPathName(); findersInfo._pFileName = pBuf->getFullPathName();
@ -1775,7 +1775,7 @@ bool Notepad_plus::findInCurrentFile()
_findReplaceDlg.beginNewFilesSearch(); _findReplaceDlg.beginNewFilesSearch();
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
int cp = _invisibleEditView.execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(_invisibleEditView.execute(SCI_GETCODEPAGE));
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8); _invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
FindersInfo findersInfo; FindersInfo findersInfo;
findersInfo._pFileName = pBuf->getFullPathName(); findersInfo._pFileName = pBuf->getFullPathName();
@ -1884,7 +1884,7 @@ void Notepad_plus::checkDocState()
bool isFileExisting = PathFileExists(curBuf->getFullPathName()) != FALSE; bool isFileExisting = PathFileExists(curBuf->getFullPathName()) != FALSE;
if (!isCurrentDirty) if (!isCurrentDirty)
{ {
for (int i = 0; i < MainFileManager->getNrBuffers(); ++i) for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i)
{ {
if (MainFileManager->getBufferByIndex(i)->isDirty()) if (MainFileManager->getBufferByIndex(i)->isDirty())
{ {
@ -2112,8 +2112,8 @@ void Notepad_plus::pasteToMarkedLines()
void Notepad_plus::deleteMarkedline(int ln) void Notepad_plus::deleteMarkedline(int ln)
{ {
int lineLen = _pEditView->execute(SCI_LINELENGTH, ln); int lineLen = static_cast<int32_t>(_pEditView->execute(SCI_LINELENGTH, ln));
int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln); int lineBegin = static_cast<int32_t>(_pEditView->execute(SCI_POSITIONFROMLINE, ln));
bookmarkDelete(ln); bookmarkDelete(ln);
TCHAR emptyString[2] = TEXT(""); TCHAR emptyString[2] = TEXT("");
@ -2138,16 +2138,16 @@ void Notepad_plus::inverseMarks()
void Notepad_plus::replaceMarkedline(int ln, const TCHAR *str) void Notepad_plus::replaceMarkedline(int ln, const TCHAR *str)
{ {
int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln); int lineBegin = static_cast<int32_t>(_pEditView->execute(SCI_POSITIONFROMLINE, ln));
int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, ln); int lineEnd = static_cast<int32_t>(_pEditView->execute(SCI_GETLINEENDPOSITION, ln));
_pEditView->replaceTarget(str, lineBegin, lineEnd); _pEditView->replaceTarget(str, lineBegin, lineEnd);
} }
generic_string Notepad_plus::getMarkedLine(int ln) generic_string Notepad_plus::getMarkedLine(int ln)
{ {
int lineLen = _pEditView->execute(SCI_LINELENGTH, ln); auto lineLen = _pEditView->execute(SCI_LINELENGTH, ln);
int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln); auto lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln);
TCHAR * buf = new TCHAR[lineLen+1]; TCHAR * buf = new TCHAR[lineLen+1];
_pEditView->getGenericText(buf, lineLen + 1, lineBegin, lineBegin + lineLen); _pEditView->getGenericText(buf, lineLen + 1, lineBegin, lineBegin + lineLen);
@ -2292,7 +2292,7 @@ void Notepad_plus::addHotSpot()
{ {
int startPos = 0; int startPos = 0;
int endPos = -1; int endPos = -1;
int endStyle = _pEditView->execute(SCI_GETENDSTYLED); auto endStyle = _pEditView->execute(SCI_GETENDSTYLED);
_pEditView->getVisibleStartAndEndPosition(&startPos, &endPos); _pEditView->getVisibleStartAndEndPosition(&startPos, &endPos);
@ -2323,7 +2323,7 @@ void Notepad_plus::addHotSpot()
else if (type == L_PS) else if (type == L_PS)
mask = 16; mask = 16;
int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR); int posFound = static_cast<int32_t>(_pEditView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR));
while (posFound != -1 && posFound != -2) while (posFound != -1 && posFound != -2)
{ {
@ -2369,13 +2369,13 @@ void Notepad_plus::addHotSpot()
lstrcpy(generic_fontname, fontNameW); lstrcpy(generic_fontname, fontNameW);
hotspotStyle._fontName = generic_fontname; hotspotStyle._fontName = generic_fontname;
hotspotStyle._fgColor = _pEditView->execute(SCI_STYLEGETFORE, idStyleMSBunset); hotspotStyle._fgColor = static_cast<COLORREF>(_pEditView->execute(SCI_STYLEGETFORE, idStyleMSBunset));
hotspotStyle._bgColor = _pEditView->execute(SCI_STYLEGETBACK, idStyleMSBunset); hotspotStyle._bgColor = static_cast<COLORREF>(_pEditView->execute(SCI_STYLEGETBACK, idStyleMSBunset));
hotspotStyle._fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyleMSBunset); hotspotStyle._fontSize = static_cast<int32_t>(_pEditView->execute(SCI_STYLEGETSIZE, idStyleMSBunset));
int isBold = _pEditView->execute(SCI_STYLEGETBOLD, idStyleMSBunset); auto isBold = _pEditView->execute(SCI_STYLEGETBOLD, idStyleMSBunset);
int isItalic = _pEditView->execute(SCI_STYLEGETITALIC, idStyleMSBunset); auto isItalic = _pEditView->execute(SCI_STYLEGETITALIC, idStyleMSBunset);
int isUnderline = _pEditView->execute(SCI_STYLEGETUNDERLINE, idStyleMSBunset); auto isUnderline = _pEditView->execute(SCI_STYLEGETUNDERLINE, idStyleMSBunset);
hotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); hotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0);
int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL;
@ -2399,7 +2399,7 @@ void Notepad_plus::addHotSpot()
_pEditView->execute(SCI_SETTARGETRANGE, posFound + foundTextLen, endPos); _pEditView->execute(SCI_SETTARGETRANGE, posFound + foundTextLen, endPos);
posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR); posFound = static_cast<int32_t>(_pEditView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR));
} }
_pEditView->execute(SCI_STARTSTYLING, endStyle, 0xFF); _pEditView->execute(SCI_STARTSTYLING, endStyle, 0xFF);
@ -2411,17 +2411,17 @@ bool Notepad_plus::isConditionExprLine(int lineNumber)
if (lineNumber < 0 || lineNumber > _pEditView->execute(SCI_GETLINECOUNT)) if (lineNumber < 0 || lineNumber > _pEditView->execute(SCI_GETLINECOUNT))
return false; return false;
int startPos = _pEditView->execute(SCI_POSITIONFROMLINE, lineNumber); auto startPos = _pEditView->execute(SCI_POSITIONFROMLINE, lineNumber);
int endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, lineNumber); auto endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, lineNumber);
_pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP | SCFIND_POSIX); _pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP | SCFIND_POSIX);
_pEditView->execute(SCI_SETTARGETRANGE, startPos, endPos); _pEditView->execute(SCI_SETTARGETRANGE, startPos, endPos);
const char ifElseForWhileExpr[] = "((else[ \t]+)?if|for|while)[ \t]*[(].*[)][ \t]*|else[ \t]*"; const char ifElseForWhileExpr[] = "((else[ \t]+)?if|for|while)[ \t]*[(].*[)][ \t]*|else[ \t]*";
int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(ifElseForWhileExpr), (LPARAM)ifElseForWhileExpr); auto posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(ifElseForWhileExpr), (LPARAM)ifElseForWhileExpr);
if (posFound != -1 && posFound != -2) if (posFound != -1 && posFound != -2)
{ {
int end = int(_pEditView->execute(SCI_GETTARGETEND)); auto end = _pEditView->execute(SCI_GETTARGETEND);
if (end == endPos) if (end == endPos)
return true; return true;
} }
@ -2438,7 +2438,7 @@ int Notepad_plus::findMachedBracePos(size_t startPos, size_t endPos, char target
if (startPos > endPos) // backward if (startPos > endPos) // backward
{ {
for (int i = startPos; i >= int(endPos); --i) for (int i = int(startPos); i >= int(endPos); --i)
{ {
char aChar = (char)_pEditView->execute(SCI_GETCHARAT, i); char aChar = (char)_pEditView->execute(SCI_GETCHARAT, i);
if (aChar == targetSymbol) if (aChar == targetSymbol)
@ -2461,11 +2461,11 @@ int Notepad_plus::findMachedBracePos(size_t startPos, size_t endPos, char target
void Notepad_plus::maintainIndentation(TCHAR ch) void Notepad_plus::maintainIndentation(TCHAR ch)
{ {
int eolMode = int(_pEditView->execute(SCI_GETEOLMODE)); int eolMode = static_cast<int32_t>((_pEditView->execute(SCI_GETEOLMODE)));
int curLine = int(_pEditView->getCurrentLineNumber()); int curLine = static_cast<int32_t>((_pEditView->getCurrentLineNumber()));
int prevLine = curLine - 1; int prevLine = curLine - 1;
int indentAmountPrevLine = 0; int indentAmountPrevLine = 0;
int tabWidth = _pEditView->execute(SCI_GETTABWIDTH); int tabWidth = static_cast<int32_t>(_pEditView->execute(SCI_GETTABWIDTH));
LangType type = _pEditView->getCurrentBuffer()->getLangType(); LangType type = _pEditView->getCurrentBuffer()->getLangType();
@ -2486,9 +2486,9 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
} }
// get previous char from current line // get previous char from current line
int prevPos = _pEditView->execute(SCI_GETCURRENTPOS) - (eolMode == SC_EOL_CRLF ? 3 : 2); int prevPos = static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS)) - (eolMode == SC_EOL_CRLF ? 3 : 2);
UCHAR prevChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, prevPos); UCHAR prevChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, prevPos);
int curPos = _pEditView->execute(SCI_GETCURRENTPOS); auto curPos = _pEditView->execute(SCI_GETCURRENTPOS);
UCHAR nextChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, curPos); UCHAR nextChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, curPos);
if (prevChar == '{') if (prevChar == '{')
@ -2530,10 +2530,10 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
else if (ch == '{') else if (ch == '{')
{ {
// if no character in front of {, aligned with prev line's indentation // if no character in front of {, aligned with prev line's indentation
int startPos = _pEditView->execute(SCI_POSITIONFROMLINE, curLine); auto startPos = _pEditView->execute(SCI_POSITIONFROMLINE, curLine);
int endPos = _pEditView->execute(SCI_GETCURRENTPOS); auto endPos = _pEditView->execute(SCI_GETCURRENTPOS);
for (int i = endPos - 2; i > 0 && i > startPos; --i) for (auto i = endPos - 2; i > 0 && i > startPos; --i)
{ {
UCHAR aChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, i); UCHAR aChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, i);
if (aChar != ' ' && aChar != '\t') if (aChar != ' ' && aChar != '\t')
@ -2549,14 +2549,14 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
{ {
indentAmountPrevLine = _pEditView->getLineIndent(prevLine); indentAmountPrevLine = _pEditView->getLineIndent(prevLine);
int startPos = _pEditView->execute(SCI_POSITIONFROMLINE, prevLine); auto startPos = _pEditView->execute(SCI_POSITIONFROMLINE, prevLine);
int endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, prevLine); auto endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, prevLine);
_pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP | SCFIND_POSIX); _pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP | SCFIND_POSIX);
_pEditView->execute(SCI_SETTARGETRANGE, startPos, endPos); _pEditView->execute(SCI_SETTARGETRANGE, startPos, endPos);
const char braceExpr[] = "[ \t]*\\{.*"; const char braceExpr[] = "[ \t]*\\{.*";
int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(braceExpr), (LPARAM)braceExpr); int posFound = static_cast<int32_t>(_pEditView->execute(SCI_SEARCHINTARGET, strlen(braceExpr), (LPARAM)braceExpr));
if (posFound != -1 && posFound != -2) if (posFound != -1 && posFound != -2)
{ {
int end = int(_pEditView->execute(SCI_GETTARGETEND)); int end = int(_pEditView->execute(SCI_GETTARGETEND));
@ -2571,7 +2571,7 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
else if (ch == '}') else if (ch == '}')
{ {
// Look backward for the pair { // Look backward for the pair {
int startPos = _pEditView->execute(SCI_GETCURRENTPOS); int startPos = static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS));
if (startPos != 0) if (startPos != 0)
startPos -= 1; startPos -= 1;
int posFound = findMachedBracePos(startPos - 1, 0, '{', '}'); int posFound = findMachedBracePos(startPos - 1, 0, '{', '}');
@ -2581,7 +2581,7 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
return; return;
// if { is in the same line, do nothing // if { is in the same line, do nothing
int matchedPairLine = _pEditView->execute(SCI_LINEFROMPOSITION, posFound); int matchedPairLine = static_cast<int32_t>(_pEditView->execute(SCI_LINEFROMPOSITION, posFound));
if (matchedPairLine == curLine) if (matchedPairLine == curLine)
return; return;
@ -2821,7 +2821,7 @@ void Notepad_plus::setTitle()
void Notepad_plus::activateNextDoc(bool direction) void Notepad_plus::activateNextDoc(bool direction)
{ {
int nbDoc = _pDocTab->nbItem(); int nbDoc = static_cast<int32_t>(_pDocTab->nbItem());
int curIndex = _pDocTab->getCurrentTabIndex(); int curIndex = _pDocTab->getCurrentTabIndex();
curIndex += (direction == dirUp)?-1:1; curIndex += (direction == dirUp)?-1:1;
@ -2837,7 +2837,7 @@ void Notepad_plus::activateNextDoc(bool direction)
if (viewVisible(otherView())) if (viewVisible(otherView()))
{ {
switchEditViewTo(otherView()); switchEditViewTo(otherView());
nbDoc = _pDocTab->nbItem(); nbDoc = static_cast<int32_t>(_pDocTab->nbItem());
} }
curIndex = nbDoc - 1; curIndex = nbDoc - 1;
} }
@ -2846,10 +2846,10 @@ void Notepad_plus::activateNextDoc(bool direction)
activateBuffer(id, currentView()); activateBuffer(id, currentView());
} }
void Notepad_plus::activateDoc(int pos) void Notepad_plus::activateDoc(size_t pos)
{ {
int nbDoc = _pDocTab->nbItem(); size_t nbDoc = _pDocTab->nbItem();
if (pos == _pDocTab->getCurrentTabIndex()) if (pos == static_cast<size_t>(_pDocTab->getCurrentTabIndex()))
{ {
Buffer * buf = _pEditView->getCurrentBuffer(); Buffer * buf = _pEditView->getCurrentBuffer();
buf->increaseRecentTag(); buf->increaseRecentTag();
@ -2869,7 +2869,7 @@ static const char utflen[] = {1,1,2,3};
size_t Notepad_plus::getSelectedCharNumber(UniMode u) size_t Notepad_plus::getSelectedCharNumber(UniMode u)
{ {
size_t result = 0; size_t result = 0;
int numSel = _pEditView->execute(SCI_GETSELECTIONS); int numSel = static_cast<int32_t>(_pEditView->execute(SCI_GETSELECTIONS));
if (u == uniUTF8 || u == uniCookie) if (u == uniUTF8 || u == uniCookie)
{ {
for (int i=0; i < numSel; ++i) for (int i=0; i < numSel; ++i)
@ -2915,7 +2915,7 @@ size_t Notepad_plus::getSelectedCharNumber(UniMode u)
#ifdef _OPENMP #ifdef _OPENMP
#include <omp.h> #include <omp.h>
#endif #endif
static inline size_t countUtf8Characters(unsigned char *buf, int pos, int endpos) static inline size_t countUtf8Characters(unsigned char *buf, size_t pos, size_t endpos)
{ {
size_t result = 0; size_t result = 0;
while(pos < endpos) while(pos < endpos)
@ -2923,7 +2923,8 @@ static inline size_t countUtf8Characters(unsigned char *buf, int pos, int endpos
unsigned char c = buf[pos++]; unsigned char c = buf[pos++];
if ((c&0xc0) == 0x80 // do not count unexpected continuation bytes (this handles the case where an UTF-8 character is split in the middle) if ((c&0xc0) == 0x80 // do not count unexpected continuation bytes (this handles the case where an UTF-8 character is split in the middle)
|| c == '\n' || c == '\r') continue; // do not count end of lines || c == '\n' || c == '\r') continue; // do not count end of lines
if (c >= 0xc0) pos += utflen[(c & 0x30) >> 4]; if (c >= 0xc0)
pos += utflen[(c & 0x30) >> 4];
++result; ++result;
} }
return result; return result;
@ -2935,11 +2936,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);
int result = _pEditView->execute(SCI_GETLENGTH); size_t 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 ((int)result < 0) ? 0 : result;
} }
else else
{ {
@ -2994,9 +2995,9 @@ int Notepad_plus::getBOMSize(UniMode u)
} }
} }
int Notepad_plus::getSelectedAreas() size_t Notepad_plus::getSelectedAreas()
{ {
int numSel = _pEditView->execute(SCI_GETSELECTIONS); size_t numSel = _pEditView->execute(SCI_GETSELECTIONS);
if (numSel == 1) // either 0 or 1 selection if (numSel == 1) // either 0 or 1 selection
return (_pEditView->execute(SCI_GETSELECTIONNSTART, 0) == _pEditView->execute(SCI_GETSELECTIONNEND, 0)) ? 0 : 1; return (_pEditView->execute(SCI_GETSELECTIONNSTART, 0) == _pEditView->execute(SCI_GETSELECTIONNEND, 0)) ? 0 : 1;
return (_pEditView->execute(SCI_SELECTIONISRECTANGLE)) ? 1 : numSel; return (_pEditView->execute(SCI_SELECTIONISRECTANGLE)) ? 1 : numSel;
@ -3004,9 +3005,9 @@ int Notepad_plus::getSelectedAreas()
size_t Notepad_plus::getSelectedBytes() size_t Notepad_plus::getSelectedBytes()
{ {
int numSel = _pEditView->execute(SCI_GETSELECTIONS); size_t numSel = _pEditView->execute(SCI_GETSELECTIONS);
size_t result = 0; size_t result = 0;
for (int i = 0; i < numSel; ++i) for (size_t i = 0; i < numSel; ++i)
result += (_pEditView->execute(SCI_GETSELECTIONNEND, i) - _pEditView->execute(SCI_GETSELECTIONNSTART, i)); result += (_pEditView->execute(SCI_GETSELECTIONNEND, i) - _pEditView->execute(SCI_GETSELECTIONNSTART, i));
return result; return result;
} }
@ -3328,7 +3329,7 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne)
{ {
int toActivate = 0; int toActivate = 0;
//activate next doc, otherwise prev if not possible //activate next doc, otherwise prev if not possible
if (active == tabToClose->nbItem() - 1) //prev if (size_t(active) == tabToClose->nbItem() - 1) //prev
{ {
toActivate = active - 1; toActivate = active - 1;
} }
@ -3604,9 +3605,9 @@ void Notepad_plus::performPostReload(int whichOne) {
void Notepad_plus::bookmarkNext(bool forwardScan) void Notepad_plus::bookmarkNext(bool forwardScan)
{ {
int lineno = _pEditView->getCurrentLineNumber(); size_t lineno = _pEditView->getCurrentLineNumber();
int sci_marker = SCI_MARKERNEXT; int sci_marker = SCI_MARKERNEXT;
int lineStart = lineno + 1; //Scan starting from next line size_t lineStart = lineno + 1; //Scan starting from next line
int lineRetry = 0; //If not found, try from the beginning int lineRetry = 0; //If not found, try from the beginning
if (!forwardScan) if (!forwardScan)
{ {
@ -3864,8 +3865,8 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
size_t caretPosition = _pEditView->execute(SCI_GETCURRENTPOS); size_t caretPosition = _pEditView->execute(SCI_GETCURRENTPOS);
// checking if caret is located in _beginning_ of selected block // checking if caret is located in _beginning_ of selected block
bool move_caret = caretPosition < selectionEnd; bool move_caret = caretPosition < selectionEnd;
int selStartLine = _pEditView->execute(SCI_LINEFROMPOSITION, selectionStart); int selStartLine = static_cast<int32_t>(_pEditView->execute(SCI_LINEFROMPOSITION, selectionStart));
int selEndLine = _pEditView->execute(SCI_LINEFROMPOSITION, selectionEnd); int selEndLine = static_cast<int32_t>(_pEditView->execute(SCI_LINEFROMPOSITION, selectionEnd));
int lines = selEndLine - selStartLine; int lines = selEndLine - selStartLine;
size_t firstSelLineStart = _pEditView->execute(SCI_POSITIONFROMLINE, selStartLine); size_t firstSelLineStart = _pEditView->execute(SCI_POSITIONFROMLINE, selStartLine);
// "caret return" is part of the last selected line // "caret return" is part of the last selected line
@ -3877,9 +3878,9 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
for (int i = selStartLine; i <= selEndLine; ++i) for (int i = selStartLine; i <= selEndLine; ++i)
{ {
int lineStart = _pEditView->execute(SCI_POSITIONFROMLINE, i); auto lineStart = _pEditView->execute(SCI_POSITIONFROMLINE, i);
int lineIndent = lineStart; auto lineIndent = lineStart;
int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, i); auto lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, i);
size_t linebufferSize = lineEnd - lineStart + 2; size_t linebufferSize = lineEnd - lineStart + 2;
TCHAR* linebuf = new TCHAR[linebufferSize]; TCHAR* linebuf = new TCHAR[linebufferSize];
@ -3904,7 +3905,8 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
//if (linebufStr.substr(0, comment_length - 1) == comment.substr(0, comment_length - 1)) //if (linebufStr.substr(0, comment_length - 1) == comment.substr(0, comment_length - 1))
if (generic_strnicmp(linebufStr.c_str(), comment.c_str(), comment_length -1) == 0) if (generic_strnicmp(linebufStr.c_str(), comment.c_str(), comment_length -1) == 0)
{ {
int len = (generic_strnicmp(linebufStr.substr(0, comment_length).c_str(),comment.c_str(), comment_length) == 0)?comment_length:comment_length - 1; generic_string commentStr = linebufStr.substr(0, comment_length);
size_t len = (generic_strnicmp(commentStr.c_str(), comment.c_str(), comment_length) == 0) ? comment_length : comment_length - 1;
_pEditView->execute(SCI_SETSEL, lineIndent, lineIndent + len); _pEditView->execute(SCI_SETSEL, lineIndent, lineIndent + len);
_pEditView->replaceSelWith(""); _pEditView->replaceSelWith("");
@ -4022,7 +4024,7 @@ bool Notepad_plus::doStreamComment()
// if there is no selection? // if there is no selection?
if (selectionEnd - selectionStart <= 0) if (selectionEnd - selectionStart <= 0)
{ {
int selLine = _pEditView->execute(SCI_LINEFROMPOSITION, selectionStart); auto selLine = _pEditView->execute(SCI_LINEFROMPOSITION, selectionStart);
selectionStart = _pEditView->execute(SCI_GETLINEINDENTPOSITION, selLine); selectionStart = _pEditView->execute(SCI_GETLINEINDENTPOSITION, selLine);
selectionEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, selLine); selectionEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, selLine);
} }
@ -4059,7 +4061,7 @@ bool Notepad_plus::addCurrentMacro()
NppParameters* nppParams = NppParameters::getInstance(); NppParameters* nppParams = NppParameters::getInstance();
vector<MacroShortcut> & theMacros = nppParams->getMacroList(); vector<MacroShortcut> & theMacros = nppParams->getMacroList();
int nbMacro = theMacros.size(); int nbMacro = static_cast<int32_t>(theMacros.size());
int cmdID = ID_MACRO + nbMacro; int cmdID = ID_MACRO + nbMacro;
MacroShortcut ms(Shortcut(), _macro, cmdID); MacroShortcut ms(Shortcut(), _macro, cmdID);
@ -4124,22 +4126,22 @@ bool Notepad_plus::switchToFile(BufferID id)
void Notepad_plus::getTaskListInfo(TaskListInfo *tli) void Notepad_plus::getTaskListInfo(TaskListInfo *tli)
{ {
size_t currentNbDoc = _pDocTab->nbItem(); int currentNbDoc = static_cast<int32_t>(_pDocTab->nbItem());
size_t nonCurrentNbDoc = _pNonDocTab->nbItem(); int nonCurrentNbDoc = static_cast<int32_t>(_pNonDocTab->nbItem());
tli->_currentIndex = 0; tli->_currentIndex = 0;
if (!viewVisible(otherView())) if (!viewVisible(otherView()))
nonCurrentNbDoc = 0; nonCurrentNbDoc = 0;
for (size_t i = 0 ; i < currentNbDoc ; ++i) for (int i = 0 ; i < currentNbDoc ; ++i)
{ {
BufferID bufID = _pDocTab->getBufferByIndex(i); BufferID bufID = _pDocTab->getBufferByIndex(i);
Buffer * b = MainFileManager->getBufferByID(bufID); Buffer * b = MainFileManager->getBufferByID(bufID);
int status = b->isReadOnly()?tb_ro:(b->isDirty()?tb_unsaved:tb_saved); int status = b->isReadOnly()?tb_ro:(b->isDirty()?tb_unsaved:tb_saved);
tli->_tlfsLst.push_back(TaskLstFnStatus(currentView(), i, b->getFullPathName(), status, (void *)bufID)); tli->_tlfsLst.push_back(TaskLstFnStatus(currentView(), i, b->getFullPathName(), status, (void *)bufID));
} }
for (size_t i = 0 ; i < nonCurrentNbDoc ; ++i) for (int i = 0 ; i < nonCurrentNbDoc ; ++i)
{ {
BufferID bufID = _pNonDocTab->getBufferByIndex(i); BufferID bufID = _pNonDocTab->getBufferByIndex(i);
Buffer * b = MainFileManager->getBufferByID(bufID); Buffer * b = MainFileManager->getBufferByID(bufID);
@ -4151,12 +4153,12 @@ void Notepad_plus::getTaskListInfo(TaskListInfo *tli)
bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const
{ {
int position = _pEditView->execute(SCI_GETCURRENTPOS); auto position = _pEditView->execute(SCI_GETCURRENTPOS);
int docLen = _pEditView->getCurrentDocLen(); auto docLen = _pEditView->getCurrentDocLen();
BOOL isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, position); bool isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, position) != 0;
int posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, position); auto posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, position);
int posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, position); auto posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, position);
// pre-condition // pre-condition
if ((posStart == 0) && (posEnd == docLen - 1)) if ((posStart == 0) && (posEnd == docLen - 1))
@ -4167,7 +4169,7 @@ bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const
if (!isWrap) if (!isWrap)
return false; return false;
isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, docLen - 1); isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, docLen - 1) != 0;
posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, docLen - 1); posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, docLen - 1);
} }
@ -4182,7 +4184,7 @@ bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const
} }
} }
int newPos = posStart - 1; auto newPos = posStart - 1;
posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, newPos); posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, newPos);
posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, newPos); posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, newPos);
@ -4192,7 +4194,7 @@ bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
nppGUI._disableSmartHiliteTmp = true; nppGUI._disableSmartHiliteTmp = true;
int currentline = _pEditView->execute(SCI_LINEFROMPOSITION, posEnd); auto currentline = _pEditView->execute(SCI_LINEFROMPOSITION, posEnd);
_pEditView->execute(SCI_ENSUREVISIBLE, currentline); // make sure target line is unfolded _pEditView->execute(SCI_ENSUREVISIBLE, currentline); // make sure target line is unfolded
_pEditView->execute(SCI_SETSEL, posEnd, posStart); _pEditView->execute(SCI_SETSEL, posEnd, posStart);
@ -4204,12 +4206,12 @@ bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const
bool Notepad_plus::goToNextIndicator(int indicID2Search, bool isWrap) const bool Notepad_plus::goToNextIndicator(int indicID2Search, bool isWrap) const
{ {
int position = _pEditView->execute(SCI_GETCURRENTPOS); auto position = _pEditView->execute(SCI_GETCURRENTPOS);
int docLen = _pEditView->getCurrentDocLen(); int docLen = _pEditView->getCurrentDocLen();
BOOL isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, position); bool isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, position) != 0;
int posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, position); auto posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, position);
int posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, position); auto posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, position);
// pre-condition // pre-condition
if ((posStart == 0) && (posEnd == docLen - 1)) if ((posStart == 0) && (posEnd == docLen - 1))
@ -4220,7 +4222,7 @@ bool Notepad_plus::goToNextIndicator(int indicID2Search, bool isWrap) const
if (!isWrap) if (!isWrap)
return false; return false;
isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, 0); isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, 0) != 0;
posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, 0); posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, 0);
} }
@ -4235,7 +4237,7 @@ bool Notepad_plus::goToNextIndicator(int indicID2Search, bool isWrap) const
posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, 0); posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, 0);
} }
} }
int newPos = posEnd; auto newPos = posEnd;
posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, newPos); posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, newPos);
posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, newPos); posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, newPos);
@ -4245,7 +4247,7 @@ bool Notepad_plus::goToNextIndicator(int indicID2Search, bool isWrap) const
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
nppGUI._disableSmartHiliteTmp = true; nppGUI._disableSmartHiliteTmp = true;
int currentline = _pEditView->execute(SCI_LINEFROMPOSITION, posEnd); auto currentline = _pEditView->execute(SCI_LINEFROMPOSITION, posEnd);
_pEditView->execute(SCI_ENSUREVISIBLE, currentline); // make sure target line is unfolded _pEditView->execute(SCI_ENSUREVISIBLE, currentline); // make sure target line is unfolded
_pEditView->execute(SCI_SETSEL, posStart, posEnd); _pEditView->execute(SCI_SETSEL, posStart, posEnd);
@ -4529,19 +4531,19 @@ void Notepad_plus::doSynScorll(HWND whichView)
if (_syncInfo._isSynScollV) if (_syncInfo._isSynScollV)
{ {
// Compute for Line // Compute for Line
mainCurrentLine = _mainEditView.execute(SCI_GETFIRSTVISIBLELINE); mainCurrentLine = static_cast<int32_t>(_mainEditView.execute(SCI_GETFIRSTVISIBLELINE));
subCurrentLine = _subEditView.execute(SCI_GETFIRSTVISIBLELINE); subCurrentLine = static_cast<int32_t>(_subEditView.execute(SCI_GETFIRSTVISIBLELINE));
line = mainCurrentLine - _syncInfo._line - subCurrentLine; line = mainCurrentLine - _syncInfo._line - subCurrentLine;
} }
if (_syncInfo._isSynScollH) if (_syncInfo._isSynScollH)
{ {
// Compute for Column // Compute for Column
mxoffset = _mainEditView.execute(SCI_GETXOFFSET); mxoffset = static_cast<int32_t>(_mainEditView.execute(SCI_GETXOFFSET));
pixel = int(_mainEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P")); pixel = static_cast<int32_t>(_mainEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P"));
mainColumn = mxoffset/pixel; mainColumn = mxoffset/pixel;
sxoffset = _subEditView.execute(SCI_GETXOFFSET); sxoffset = static_cast<int32_t>(_subEditView.execute(SCI_GETXOFFSET));
pixel = int(_subEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P")); pixel = static_cast<int32_t>(_subEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P"));
subColumn = sxoffset/pixel; subColumn = sxoffset/pixel;
column = mainColumn - _syncInfo._column - subColumn; column = mainColumn - _syncInfo._column - subColumn;
} }
@ -4552,19 +4554,19 @@ void Notepad_plus::doSynScorll(HWND whichView)
if (_syncInfo._isSynScollV) if (_syncInfo._isSynScollV)
{ {
// Compute for Line // Compute for Line
mainCurrentLine = _mainEditView.execute(SCI_GETFIRSTVISIBLELINE); mainCurrentLine = static_cast<int32_t>(_mainEditView.execute(SCI_GETFIRSTVISIBLELINE));
subCurrentLine = _subEditView.execute(SCI_GETFIRSTVISIBLELINE); subCurrentLine = static_cast<int32_t>(_subEditView.execute(SCI_GETFIRSTVISIBLELINE));
line = subCurrentLine + _syncInfo._line - mainCurrentLine; line = subCurrentLine + _syncInfo._line - mainCurrentLine;
} }
if (_syncInfo._isSynScollH) if (_syncInfo._isSynScollH)
{ {
// Compute for Column // Compute for Column
mxoffset = _mainEditView.execute(SCI_GETXOFFSET); mxoffset = static_cast<int32_t>(_mainEditView.execute(SCI_GETXOFFSET));
pixel = int(_mainEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P")); pixel = static_cast<int32_t>(_mainEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P"));
mainColumn = mxoffset/pixel; mainColumn = mxoffset/pixel;
sxoffset = _subEditView.execute(SCI_GETXOFFSET); sxoffset = static_cast<int32_t>(_subEditView.execute(SCI_GETXOFFSET));
pixel = int(_subEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P")); pixel = static_cast<int32_t>(_subEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P"));
subColumn = sxoffset/pixel; subColumn = sxoffset/pixel;
column = subColumn + _syncInfo._column - mainColumn; column = subColumn + _syncInfo._column - mainColumn;
} }
@ -4620,11 +4622,11 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool includUntitledD
docTab[1] = &_subDocTab; docTab[1] = &_subDocTab;
for (size_t k = 0; k < nbElem; ++k) for (size_t k = 0; k < nbElem; ++k)
{ {
for (int i = 0, len = docTab[k]->nbItem(); i < len ; ++i) for (size_t i = 0, len = docTab[k]->nbItem(); i < len ; ++i)
{ {
BufferID bufID = docTab[k]->getBufferByIndex(i); BufferID bufID = docTab[k]->getBufferByIndex(i);
ScintillaEditView *editView = k == 0?&_mainEditView:&_subEditView; ScintillaEditView *editView = k == 0?&_mainEditView:&_subEditView;
int activeIndex = int(k == 0?session._activeMainIndex:session._activeSubIndex); size_t activeIndex = k == 0 ? session._activeMainIndex : session._activeSubIndex;
vector<sessionFileInfo> *viewFiles = (vector<sessionFileInfo> *)(k == 0?&(session._mainViewFiles):&(session._subViewFiles)); vector<sessionFileInfo> *viewFiles = (vector<sessionFileInfo> *)(k == 0?&(session._mainViewFiles):&(session._subViewFiles));
Buffer * buf = MainFileManager->getBufferByID(bufID); Buffer * buf = MainFileManager->getBufferByID(bufID);
@ -4642,11 +4644,11 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool includUntitledD
sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(editView), buf->getBackupFileName().c_str(), int(buf->getLastModifiedTimestamp())); sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(editView), buf->getBackupFileName().c_str(), int(buf->getLastModifiedTimestamp()));
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument()); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
int maxLine = _invisibleEditView.execute(SCI_GETLINECOUNT); size_t maxLine = static_cast<size_t>(_invisibleEditView.execute(SCI_GETLINECOUNT));
for (int j = 0 ; j < maxLine ; ++j) for (size_t j = 0 ; j < maxLine ; ++j)
{ {
if ((_invisibleEditView.execute(SCI_MARKERGET, j)&(1 << MARK_BOOKMARK)) != 0) if ((_invisibleEditView.execute(SCI_MARKERGET, j) & (1 << MARK_BOOKMARK)) != 0)
{ {
sfi._marks.push_back(j); sfi._marks.push_back(j);
} }
@ -4686,7 +4688,8 @@ bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) {
TCHAR savePath[MAX_PATH] = {0}; TCHAR savePath[MAX_PATH] = {0};
//rescue primary //rescue primary
for (int i = 0; i < MainFileManager->getNrBuffers(); ++i) { for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i)
{
Buffer * docbuf = MainFileManager->getBufferByIndex(i); Buffer * docbuf = MainFileManager->getBufferByIndex(i);
if (!docbuf->isDirty()) //skip saved documents if (!docbuf->isDirty()) //skip saved documents
continue; continue;
@ -4830,7 +4833,7 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
if (didDialog) if (didDialog)
{ {
int curPos = _pEditView->execute(SCI_GETCURRENTPOS); auto curPos = _pEditView->execute(SCI_GETCURRENTPOS);
::PostMessage(_pEditView->getHSelf(), WM_LBUTTONUP, 0, 0); ::PostMessage(_pEditView->getHSelf(), WM_LBUTTONUP, 0, 0);
::PostMessage(_pEditView->getHSelf(), SCI_SETSEL, curPos, curPos); ::PostMessage(_pEditView->getHSelf(), SCI_SETSEL, curPos, curPos);
if (::IsIconic(_pPublicInterface->getHSelf())) if (::IsIconic(_pPublicInterface->getHSelf()))
@ -5036,7 +5039,7 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam
} }
else else
{ {
int pos = _pEditView->execute(SCI_FINDCOLUMN, ln-1, cn-1); auto pos = _pEditView->execute(SCI_FINDCOLUMN, ln-1, cn-1);
_pEditView->execute(SCI_GOTOPOS, pos); _pEditView->execute(SCI_GOTOPOS, pos);
} }
@ -6135,7 +6138,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params)
} }
else else
{ {
int currentPos = ::SendMessage(pCurrentView->getHSelf(), SCI_GETSELECTIONSTART, 0, 0); auto currentPos = ::SendMessage(pCurrentView->getHSelf(), SCI_GETSELECTIONSTART, 0, 0);
::SendMessage(pCurrentView->getHSelf(), SCI_SETSELECTION, currentPos, currentPos - strlen(text2display)); ::SendMessage(pCurrentView->getHSelf(), SCI_SETSELECTION, currentPos, currentPos - strlen(text2display));
BufferID currentBufID = pCurrentView->getCurrentBufferID(); BufferID currentBufID = pCurrentView->getCurrentBufferID();
if (currentBufID != targetBufID) if (currentBufID != targetBufID)
@ -6179,8 +6182,8 @@ bool Notepad_plus::selectBack(ScintillaEditView *pCurrentView, BufferID targetBu
{ {
int ranNum = getRandomNumber(maxRange - 100); int ranNum = getRandomNumber(maxRange - 100);
BufferID currentBufID = pCurrentView->getCurrentBufferID(); BufferID currentBufID = pCurrentView->getCurrentBufferID();
int currentPos = ::SendMessage(pCurrentView->getHSelf(), SCI_GETSELECTIONSTART, 0, 0); auto currentPos = ::SendMessage(pCurrentView->getHSelf(), SCI_GETSELECTIONSTART, 0, 0);
int currentAnchor = ::SendMessage(pCurrentView->getHSelf(), SCI_GETSELECTIONEND, 0, 0); auto currentAnchor = ::SendMessage(pCurrentView->getHSelf(), SCI_GETSELECTIONEND, 0, 0);
Sleep(ranNum + intervalTimeArray[ranNum%nbIntervalTime]); Sleep(ranNum + intervalTimeArray[ranNum%nbIntervalTime]);
if (currentBufID != targetBufID) if (currentBufID != targetBufID)
return false; return false;
@ -6259,7 +6262,7 @@ DWORD WINAPI Notepad_plus::backupDocument(void * /*param*/)
if (timer < 1000) if (timer < 1000)
timer = 1000; timer = 1000;
::Sleep(timer); ::Sleep(DWORD(timer));
nppParam = NppParameters::getInstance(); nppParam = NppParameters::getInstance();
if (!nppParam) if (!nppParam)
@ -6319,16 +6322,16 @@ bool Notepad_plus::undoStreamComment()
generic_string start_comment(commentStart); generic_string start_comment(commentStart);
generic_string end_comment(commentEnd); generic_string end_comment(commentEnd);
generic_string white_space(TEXT(" ")); generic_string white_space(TEXT(" "));
int start_comment_length = start_comment.length(); size_t start_comment_length = start_comment.length();
int end_comment_length = end_comment.length(); size_t end_comment_length = end_comment.length();
// do as long as stream-comments are within selection // do as long as stream-comments are within selection
do do
{ {
int selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART); auto selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART);
int selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND); auto selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND);
int caretPosition = _pEditView->execute(SCI_GETCURRENTPOS); auto caretPosition = _pEditView->execute(SCI_GETCURRENTPOS);
int docLength = (_pEditView->execute(SCI_GETLENGTH)); auto docLength = _pEditView->execute(SCI_GETLENGTH);
// checking if caret is located in _beginning_ of selected block // checking if caret is located in _beginning_ of selected block
bool move_caret = caretPosition < selectionEnd; bool move_caret = caretPosition < selectionEnd;
@ -6414,8 +6417,8 @@ bool Notepad_plus::undoStreamComment()
//-- Ok, there are valid start-comment and valid end-comment around the caret-position. //-- Ok, there are valid start-comment and valid end-comment around the caret-position.
// Now, un-comment stream-comment: // Now, un-comment stream-comment:
retVal = true; retVal = true;
int startCommentLength = start_comment_length; int startCommentLength = static_cast<int32_t>(start_comment_length);
int endCommentLength = end_comment_length; int endCommentLength = static_cast<int32_t>(end_comment_length);
//-- First delete end-comment, so that posStartCommentBefore does not change! //-- First delete end-comment, so that posStartCommentBefore does not change!
//-- Get character before end-comment to decide, if there is a white character before the end-comment, which will be removed too! //-- Get character before end-comment to decide, if there is a white character before the end-comment, which will be removed too!

View File

@ -522,7 +522,7 @@ private:
void bookmarkAdd(int lineno) const void bookmarkAdd(int lineno) const
{ {
if (lineno == -1) if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber(); lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
if (!bookmarkPresent(lineno)) if (!bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK); _pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
} }
@ -530,7 +530,7 @@ private:
void bookmarkDelete(int lineno) const void bookmarkDelete(int lineno) const
{ {
if (lineno == -1) if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber(); lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
if ( bookmarkPresent(lineno)) if ( bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK); _pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
} }
@ -538,7 +538,7 @@ private:
bool bookmarkPresent(int lineno) const bool bookmarkPresent(int lineno) const
{ {
if (lineno == -1) if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber(); lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno); LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
return ((state & (1 << MARK_BOOKMARK)) != 0); return ((state & (1 << MARK_BOOKMARK)) != 0);
} }
@ -546,7 +546,7 @@ private:
void bookmarkToggle(int lineno) const void bookmarkToggle(int lineno) const
{ {
if (lineno == -1) if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber(); lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
if (bookmarkPresent(lineno)) if (bookmarkPresent(lineno))
bookmarkDelete(lineno); bookmarkDelete(lineno);
@ -572,12 +572,12 @@ private:
bool braceMatch(); bool braceMatch();
void activateNextDoc(bool direction); void activateNextDoc(bool direction);
void activateDoc(int pos); void activateDoc(size_t pos);
void updateStatusBar(); void updateStatusBar();
size_t getSelectedCharNumber(UniMode); size_t getSelectedCharNumber(UniMode);
size_t getCurrentDocCharCount(UniMode u); size_t getCurrentDocCharCount(UniMode u);
int getSelectedAreas(); size_t getSelectedAreas();
size_t getSelectedBytes(); size_t getSelectedBytes();
bool isFormatUnicode(UniMode); bool isFormatUnicode(UniMode);
int getBOMSize(UniMode); int getBOMSize(UniMode);

View File

@ -167,7 +167,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
generic_string name{userLangName}; generic_string name{userLangName};
//loop through buffers and reset the language (L_USER, TEXT("")) if (L_USER, name) //loop through buffers and reset the language (L_USER, TEXT("")) if (L_USER, name)
for (int i = 0; i < MainFileManager->getNrBuffers(); ++i) for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i)
{ {
Buffer* buf = MainFileManager->getBufferByIndex(i); Buffer* buf = MainFileManager->getBufferByIndex(i);
if (buf->getLangType() == L_USER && name == buf->getUserDefineLangName()) if (buf->getLangType() == L_USER && name == buf->getUserDefineLangName())
@ -185,7 +185,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
generic_string newName{(TCHAR *)wParam}; generic_string newName{(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 (int i = 0; i < MainFileManager->getNrBuffers(); ++i) for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i)
{ {
Buffer* buf = MainFileManager->getBufferByIndex(i); Buffer* buf = MainFileManager->getBufferByIndex(i);
if (buf->getLangType() == L_USER && oldName == buf->getUserDefineLangName()) if (buf->getLangType() == L_USER && oldName == buf->getUserDefineLangName())
@ -388,7 +388,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
else else
return (LRESULT)BUFFER_INVALID; return (LRESULT)BUFFER_INVALID;
if ((int)wParam < pView->nbItem()) if ((size_t)wParam < pView->nbItem())
return (LRESULT)(pView->getBufferByIndex((int)wParam)); return (LRESULT)(pView->getBufferByIndex((int)wParam));
return (LRESULT)BUFFER_INVALID; return (LRESULT)BUFFER_INVALID;
@ -618,7 +618,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETSHORTCUTBYCMDID: case NPPM_GETSHORTCUTBYCMDID:
{ {
int cmdID = wParam; // cmdID int cmdID = static_cast<int32_t>(wParam); // cmdID
ShortcutKey *sk = (ShortcutKey *)lParam; // ShortcutKey structure ShortcutKey *sk = (ShortcutKey *)lParam; // ShortcutKey structure
return _pluginsManager.getShortcutByCmdID(cmdID, sk); return _pluginsManager.getShortcutByCmdID(cmdID, sk);
@ -626,7 +626,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_MENUCOMMAND: case NPPM_MENUCOMMAND:
{ {
command(lParam); command(static_cast<int32_t>(lParam));
return TRUE; return TRUE;
} }
@ -684,7 +684,7 @@ 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, wParam); lstrcpyn((TCHAR *)lParam, str, static_cast<int32_t>(wParam));
return TRUE; return TRUE;
} }
} }
@ -751,8 +751,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETNBOPENFILES: case NPPM_GETNBOPENFILES:
{ {
int nbDocPrimary = _mainDocTab.nbItem(); size_t nbDocPrimary = _mainDocTab.nbItem();
int nbDocSecond = _subDocTab.nbItem(); size_t nbDocSecond = _subDocTab.nbItem();
if (lParam == ALL_OPEN_FILES) if (lParam == ALL_OPEN_FILES)
return nbDocPrimary + nbDocSecond; return nbDocPrimary + nbDocSecond;
else if (lParam == PRIMARY_VIEW) else if (lParam == PRIMARY_VIEW)
@ -769,12 +769,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return 0; return 0;
TCHAR** fileNames = (TCHAR**) wParam; TCHAR** fileNames = (TCHAR**) wParam;
int nbFileNames = lParam; size_t nbFileNames = static_cast<size_t>(lParam);
int j = 0; size_t j = 0;
if (Message != NPPM_GETOPENFILENAMESSECOND) if (Message != NPPM_GETOPENFILENAMESSECOND)
{ {
for (int i = 0 ; i < _mainDocTab.nbItem() && j < nbFileNames ; ++i) for (size_t i = 0; i < _mainDocTab.nbItem() && j < nbFileNames; ++i)
{ {
BufferID id = _mainDocTab.getBufferByIndex(i); BufferID id = _mainDocTab.getBufferByIndex(i);
Buffer * buf = MainFileManager->getBufferByID(id); Buffer * buf = MainFileManager->getBufferByID(id);
@ -784,7 +784,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (Message != NPPM_GETOPENFILENAMESPRIMARY) if (Message != NPPM_GETOPENFILENAMESPRIMARY)
{ {
for (int i = 0 ; i < _subDocTab.nbItem() && j < nbFileNames ; ++i) for (size_t i = 0; i < _subDocTab.nbItem() && j < nbFileNames; ++i)
{ {
BufferID id = _subDocTab.getBufferByIndex(i); BufferID id = _subDocTab.getBufferByIndex(i);
Buffer * buf = MainFileManager->getBufferByID(id); Buffer * buf = MainFileManager->getBufferByID(id);
@ -856,7 +856,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case APPCOMMAND_BROWSER_BACKWARD: case APPCOMMAND_BROWSER_BACKWARD:
case APPCOMMAND_BROWSER_FORWARD: case APPCOMMAND_BROWSER_FORWARD:
{ {
int nbDoc = viewVisible(MAIN_VIEW)?_mainDocTab.nbItem():0; size_t nbDoc = viewVisible(MAIN_VIEW) ? _mainDocTab.nbItem() : 0;
nbDoc += viewVisible(SUB_VIEW)?_subDocTab.nbItem():0; nbDoc += viewVisible(SUB_VIEW)?_subDocTab.nbItem():0;
if (nbDoc > 1) if (nbDoc > 1)
activateNextDoc((GET_APPCOMMAND_LPARAM(lParam) == APPCOMMAND_BROWSER_FORWARD)?dirDown:dirUp); activateNextDoc((GET_APPCOMMAND_LPARAM(lParam) == APPCOMMAND_BROWSER_FORWARD)?dirDown:dirUp);
@ -918,7 +918,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return -1; return -1;
// get text of current scintilla // get text of current scintilla
UINT length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1; auto length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1;
char* buffer = new char[length]; char* buffer = new char[length];
pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer); pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer);
@ -956,7 +956,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return -1; return -1;
// get text of current scintilla // get text of current scintilla
UINT length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1; auto length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1;
char* buffer = new char[length]; char* buffer = new char[length];
pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer); pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer);
@ -986,8 +986,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_TRIGGERTABBARCONTEXTMENU: case NPPM_TRIGGERTABBARCONTEXTMENU:
{ {
// similar to NPPM_ACTIVEDOC // similar to NPPM_ACTIVEDOC
int whichView = ((wParam != MAIN_VIEW) && (wParam != SUB_VIEW))?currentView():wParam; int whichView = ((wParam != MAIN_VIEW) && (wParam != SUB_VIEW)) ? currentView() : static_cast<int32_t>(wParam);
int index = lParam; int index = static_cast<int32_t>(lParam);
switchEditViewTo(whichView); switchEditViewTo(whichView);
activateDoc(index); activateDoc(index);
@ -1051,13 +1051,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_FRSAVE_INT: case WM_FRSAVE_INT:
{ {
_macro.push_back(recordedMacroStep(wParam, 0, lParam, NULL, recordedMacroStep::mtSavedSnR)); _macro.push_back(recordedMacroStep(static_cast<int32_t>(wParam), 0, static_cast<long>(lParam), NULL, recordedMacroStep::mtSavedSnR));
break; break;
} }
case WM_FRSAVE_STR: case WM_FRSAVE_STR:
{ {
_macro.push_back(recordedMacroStep(wParam, 0, 0, (const TCHAR *)lParam, recordedMacroStep::mtSavedSnR)); _macro.push_back(recordedMacroStep(static_cast<int32_t>(wParam), 0, 0, (const TCHAR *)lParam, recordedMacroStep::mtSavedSnR));
break; break;
} }
@ -1074,8 +1074,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
break; break;
int counter = 0; int counter = 0;
int lastLine = int(_pEditView->execute(SCI_GETLINECOUNT)) - 1; int lastLine = static_cast<int32_t>(_pEditView->execute(SCI_GETLINECOUNT)) - 1;
int currLine = _pEditView->getCurrentLineNumber(); int currLine = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
int indexMacro = _runMacroDlg.getMacro2Exec(); int indexMacro = _runMacroDlg.getMacro2Exec();
int deltaLastLine = 0; int deltaLastLine = 0;
int deltaCurrLine = 0; int deltaCurrLine = 0;
@ -1101,8 +1101,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
else // run until eof else // run until eof
{ {
bool cursorMovedUp = deltaCurrLine < 0; bool cursorMovedUp = deltaCurrLine < 0;
deltaLastLine = int(_pEditView->execute(SCI_GETLINECOUNT)) - 1 - lastLine; deltaLastLine = static_cast<int32_t>(_pEditView->execute(SCI_GETLINECOUNT)) - 1 - lastLine;
deltaCurrLine = _pEditView->getCurrentLineNumber() - currLine; deltaCurrLine = static_cast<int32_t>(_pEditView->getCurrentLineNumber()) - currLine;
if (( deltaCurrLine == 0 ) // line no. not changed? if (( deltaCurrLine == 0 ) // line no. not changed?
&& (deltaLastLine >= 0)) // and no lines removed? && (deltaLastLine >= 0)) // and no lines removed?
@ -1187,7 +1187,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case STATUSBAR_EOF_FORMAT: case STATUSBAR_EOF_FORMAT:
case STATUSBAR_UNICODE_TYPE: case STATUSBAR_UNICODE_TYPE:
case STATUSBAR_TYPING_MODE: case STATUSBAR_TYPING_MODE:
_statusBar.setText(str2set, wParam); _statusBar.setText(str2set, static_cast<int32_t>(wParam));
return TRUE; return TRUE;
default : default :
return FALSE; return FALSE;
@ -1905,12 +1905,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_ALLOCATECMDID: case NPPM_ALLOCATECMDID:
{ {
return _pluginsManager.allocateCmdID(wParam, reinterpret_cast<int *>(lParam)); return _pluginsManager.allocateCmdID(static_cast<int32_t>(wParam), reinterpret_cast<int *>(lParam));
} }
case NPPM_ALLOCATEMARKER: case NPPM_ALLOCATEMARKER:
{ {
return _pluginsManager.allocateMarker(wParam, reinterpret_cast<int *>(lParam)); return _pluginsManager.allocateMarker(static_cast<int32_t>(wParam), reinterpret_cast<int *>(lParam));
} }
case NPPM_HIDETABBAR: case NPPM_HIDETABBAR:
@ -2076,7 +2076,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_DOCSWITCHERDISABLECOLUMN: case NPPM_DOCSWITCHERDISABLECOLUMN:
{ {
BOOL isOff = lParam; BOOL isOff = static_cast<BOOL>(lParam);
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
nppGUI._fileSwitcherWithoutExtColumn = isOff == TRUE; nppGUI._fileSwitcherWithoutExtColumn = isOff == TRUE;
@ -2098,7 +2098,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_SHOWDOCSWITCHER: case NPPM_SHOWDOCSWITCHER:
{ {
BOOL toShow = lParam; BOOL toShow = static_cast<BOOL>(lParam);
if (toShow) if (toShow)
{ {
if (!_pFileSwitcherPanel || !_pFileSwitcherPanel->isVisible()) if (!_pFileSwitcherPanel || !_pFileSwitcherPanel->isVisible())
@ -2248,7 +2248,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WDT_SORT: case WDT_SORT:
{ {
if (nmdlg->nItems != (unsigned int)_pDocTab->nbItem()) //sanity check, if mismatch just abort if (nmdlg->nItems != _pDocTab->nbItem()) //sanity check, if mismatch just abort
break; break;
//Collect all buffers //Collect all buffers

View File

@ -52,7 +52,7 @@ void Notepad_plus::macroPlayback(Macro macro)
if (step->isPlayable()) if (step->isPlayable())
step->PlayBack(this->_pPublicInterface, _pEditView); step->PlayBack(this->_pPublicInterface, _pEditView);
else else
_findReplaceDlg.execSavedCommand(step->message, step->lParameter, step->sParameter); _findReplaceDlg.execSavedCommand(step->_message, step->_lParameter, step->_sParameter);
} }
_pEditView->execute(SCI_ENDUNDOACTION); _pEditView->execute(SCI_ENDUNDOACTION);
@ -244,7 +244,7 @@ void Notepad_plus::command(int id)
case IDM_EDIT_COPY_BINARY: case IDM_EDIT_COPY_BINARY:
case IDM_EDIT_CUT_BINARY: case IDM_EDIT_CUT_BINARY:
{ {
int textLen = _pEditView->execute(SCI_GETSELTEXT, 0, 0) - 1; int textLen = static_cast<int32_t>(_pEditView->execute(SCI_GETSELTEXT, 0, 0)) - 1;
if (!textLen) if (!textLen)
return; return;
@ -426,8 +426,8 @@ void Notepad_plus::command(int id)
} }
else else
{ {
int selStart = _pEditView->execute(SCI_GETSELECTIONSTART); auto selStart = _pEditView->execute(SCI_GETSELECTIONSTART);
int selEnd = _pEditView->execute(SCI_GETSELECTIONEND); auto selEnd = _pEditView->execute(SCI_GETSELECTIONEND);
hasLineSelection = selStart != selEnd; hasLineSelection = selStart != selEnd;
if (hasLineSelection) if (hasLineSelection)
{ {
@ -490,8 +490,8 @@ void Notepad_plus::command(int id)
if (hasLineSelection) // there was 1 selection, so we restore it if (hasLineSelection) // there was 1 selection, so we restore it
{ {
int posStart = _pEditView->execute(SCI_POSITIONFROMLINE, fromLine); auto posStart = _pEditView->execute(SCI_POSITIONFROMLINE, fromLine);
int posEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, toLine); auto posEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, toLine);
_pEditView->execute(SCI_SETSELECTIONSTART, posStart); _pEditView->execute(SCI_SETSELECTIONSTART, posStart);
_pEditView->execute(SCI_SETSELECTIONEND, posEnd); _pEditView->execute(SCI_SETSELECTIONEND, posEnd);
} }
@ -1632,8 +1632,8 @@ void Notepad_plus::command(int id)
_syncInfo._isSynScollV = isSynScollV; _syncInfo._isSynScollV = isSynScollV;
if (_syncInfo._isSynScollV) if (_syncInfo._isSynScollV)
{ {
int mainCurrentLine = _mainEditView.execute(SCI_GETFIRSTVISIBLELINE); int mainCurrentLine = static_cast<int32_t>(_mainEditView.execute(SCI_GETFIRSTVISIBLELINE));
int subCurrentLine = _subEditView.execute(SCI_GETFIRSTVISIBLELINE); int subCurrentLine = static_cast<int32_t>(_subEditView.execute(SCI_GETFIRSTVISIBLELINE));
_syncInfo._line = mainCurrentLine - subCurrentLine; _syncInfo._line = mainCurrentLine - subCurrentLine;
} }
@ -1649,11 +1649,11 @@ void Notepad_plus::command(int id)
_syncInfo._isSynScollH = isSynScollH; _syncInfo._isSynScollH = isSynScollH;
if (_syncInfo._isSynScollH) if (_syncInfo._isSynScollH)
{ {
int mxoffset = _mainEditView.execute(SCI_GETXOFFSET); int mxoffset = static_cast<int32_t>(_mainEditView.execute(SCI_GETXOFFSET));
int pixel = int(_mainEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P")); int pixel = static_cast<int32_t>(_mainEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P"));
int mainColumn = mxoffset/pixel; int mainColumn = mxoffset/pixel;
int sxoffset = _subEditView.execute(SCI_GETXOFFSET); int sxoffset = static_cast<int32_t>(_subEditView.execute(SCI_GETXOFFSET));
pixel = int(_subEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P")); pixel = int(_subEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P"));
int subColumn = sxoffset/pixel; int subColumn = sxoffset/pixel;
_syncInfo._column = mainColumn - subColumn; _syncInfo._column = mainColumn - subColumn;
@ -1703,13 +1703,13 @@ void Notepad_plus::command(int id)
TCHAR *nbRangeLabel = TEXT(" ranges"); TCHAR *nbRangeLabel = TEXT(" ranges");
UniMode um = _pEditView->getCurrentBuffer()->getUnicodeMode(); UniMode um = _pEditView->getCurrentBuffer()->getUnicodeMode();
int nbChar = getCurrentDocCharCount(um); auto nbChar = getCurrentDocCharCount(um);
int nbWord = wordCount(); int nbWord = wordCount();
size_t nbLine = _pEditView->execute(SCI_GETLINECOUNT); auto nbLine = _pEditView->execute(SCI_GETLINECOUNT);
int nbByte = _pEditView->execute(SCI_GETLENGTH); auto nbByte = _pEditView->execute(SCI_GETLENGTH);
int nbSel = getSelectedCharNumber(um); auto nbSel = getSelectedCharNumber(um);
int nbSelByte = getSelectedBytes(); auto nbSelByte = getSelectedBytes();
int nbRange = getSelectedAreas(); auto nbRange = getSelectedAreas();
TCHAR nbCharStr[32]; TCHAR nbCharStr[32];
TCHAR nbWordStr[16]; TCHAR nbWordStr[16];
@ -2144,7 +2144,7 @@ void Notepad_plus::command(int id)
// Save the current clipboard content // Save the current clipboard content
::OpenClipboard(_pPublicInterface->getHSelf()); ::OpenClipboard(_pPublicInterface->getHSelf());
HANDLE clipboardData = ::GetClipboardData(CF_TEXT); HANDLE clipboardData = ::GetClipboardData(CF_TEXT);
int len = ::GlobalSize(clipboardData); int len = static_cast<int32_t>(::GlobalSize(clipboardData));
LPVOID clipboardDataPtr = ::GlobalLock(clipboardData); LPVOID clipboardDataPtr = ::GlobalLock(clipboardData);
HANDLE allocClipboardData = ::GlobalAlloc(GMEM_MOVEABLE, len); HANDLE allocClipboardData = ::GlobalAlloc(GMEM_MOVEABLE, len);
@ -2318,7 +2318,7 @@ void Notepad_plus::command(int id)
{ {
bool doAboutDlg = false; bool doAboutDlg = false;
const int maxSelLen = 32; const int maxSelLen = 32;
int textLen = _pEditView->execute(SCI_GETSELTEXT, 0, 0) - 1; auto textLen = _pEditView->execute(SCI_GETSELTEXT, 0, 0) - 1;
if (!textLen) if (!textLen)
doAboutDlg = true; doAboutDlg = true;
if (textLen > maxSelLen) if (textLen > maxSelLen)
@ -2564,7 +2564,7 @@ void Notepad_plus::command(int id)
case IDC_PREV_DOC : case IDC_PREV_DOC :
case IDC_NEXT_DOC : case IDC_NEXT_DOC :
{ {
int nbDoc = viewVisible(MAIN_VIEW)?_mainDocTab.nbItem():0; size_t nbDoc = viewVisible(MAIN_VIEW) ? _mainDocTab.nbItem() : 0;
nbDoc += viewVisible(SUB_VIEW)?_subDocTab.nbItem():0; nbDoc += viewVisible(SUB_VIEW)?_subDocTab.nbItem():0;
bool doTaskList = ((NppParameters::getInstance())->getNppGUI())._doTaskList; bool doTaskList = ((NppParameters::getInstance())->getNppGUI())._doTaskList;

View File

@ -377,7 +377,7 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
TEXT("$INT_REPLACE$ files are about to be opened.\rAre you sure to open them?"), TEXT("$INT_REPLACE$ files are about to be opened.\rAre you sure to open them?"),
TEXT("Amount of files to open is too large"), TEXT("Amount of files to open is too large"),
MB_YESNO|MB_APPLMODAL, MB_YESNO|MB_APPLMODAL,
nbFiles2Open); static_cast<int32_t>(nbFiles2Open));
} }
if (ok2Open) if (ok2Open)
@ -624,7 +624,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
} }
} }
int nrDocs = whichOne==MAIN_VIEW?(_mainDocTab.nbItem()):(_subDocTab.nbItem()); size_t nrDocs = whichOne==MAIN_VIEW?(_mainDocTab.nbItem()):(_subDocTab.nbItem());
if (buf->isMonitoringOn()) if (buf->isMonitoringOn())
{ {
@ -829,8 +829,7 @@ bool Notepad_plus::fileClose(BufferID id, int curView)
int viewToClose = currentView(); int viewToClose = currentView();
if (curView != -1) if (curView != -1)
viewToClose = curView; viewToClose = curView;
//first check amount of documents, we dont want the view to hide if we closed a secondary doc with primary being empty
//int nrDocs = _pDocTab->nbItem();
bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode();
doClose(bufferID, viewToClose, isSnapshotMode); doClose(bufferID, viewToClose, isSnapshotMode);
return true; return true;
@ -841,7 +840,7 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
//closes all documents, makes the current view the only one visible //closes all documents, makes the current view the only one visible
//first check if we need to save any file //first check if we need to save any file
for(int i = 0; i < _mainDocTab.nbItem(); ++i) for (size_t i = 0; i < _mainDocTab.nbItem(); ++i)
{ {
BufferID id = _mainDocTab.getBufferByIndex(i); BufferID id = _mainDocTab.getBufferByIndex(i);
Buffer * buf = MainFileManager->getBufferByID(id); Buffer * buf = MainFileManager->getBufferByID(id);
@ -895,7 +894,7 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
} }
} }
} }
for(int i = 0; i < _subDocTab.nbItem(); ++i) for (size_t i = 0; i < _subDocTab.nbItem(); ++i)
{ {
BufferID id = _subDocTab.getBufferByIndex(i); BufferID id = _subDocTab.getBufferByIndex(i);
Buffer * buf = MainFileManager->getBufferByID(id); Buffer * buf = MainFileManager->getBufferByID(id);
@ -951,17 +950,19 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
//Then start closing, inactive view first so the active is left open //Then start closing, inactive view first so the active is left open
if (bothActive()) if (bothActive())
{ //first close all docs in non-current view, which gets closed automatically {
//first close all docs in non-current view, which gets closed automatically
//Set active tab to the last one closed. //Set active tab to the last one closed.
activateBuffer(_pNonDocTab->getBufferByIndex(0), otherView()); activateBuffer(_pNonDocTab->getBufferByIndex(0), otherView());
for(int i = _pNonDocTab->nbItem() - 1; i >= 0; i--) { //close all from right to left for (size_t i = _pNonDocTab->nbItem() - 1; i >= 0; i--) //close all from right to left
{
doClose(_pNonDocTab->getBufferByIndex(i), otherView(), doDeleteBackup); doClose(_pNonDocTab->getBufferByIndex(i), otherView(), doDeleteBackup);
} }
//hideView(otherView());
} }
activateBuffer(_pDocTab->getBufferByIndex(0), currentView()); activateBuffer(_pDocTab->getBufferByIndex(0), currentView());
for(int i = _pDocTab->nbItem() - 1; i >= 0; i--) { //close all from right to left for (int i = static_cast<int32_t>(_pDocTab->nbItem()) - 1; i >= 0; i--)
{ //close all from right to left
doClose(_pDocTab->getBufferByIndex(i), currentView(), doDeleteBackup); doClose(_pDocTab->getBufferByIndex(i), currentView(), doDeleteBackup);
} }
return true; return true;
@ -1033,7 +1034,7 @@ bool Notepad_plus::fileCloseAllToRight()
// indexes (smaller than the one just closed) will point to the wrong tab. // indexes (smaller than the one just closed) will point to the wrong tab.
const int kiActive = _pDocTab->getCurrentTabIndex(); const int kiActive = _pDocTab->getCurrentTabIndex();
std::vector<int> vecIndexesToClose; std::vector<int> vecIndexesToClose;
for(int i = _pDocTab->nbItem() - 1; i > kiActive; i--) { for(int i = int(_pDocTab->nbItem()) - 1; i > kiActive; i--) {
vecIndexesToClose.push_back(i); vecIndexesToClose.push_back(i);
} }
return fileCloseAllGiven(vecIndexesToClose); return fileCloseAllGiven(vecIndexesToClose);
@ -1046,7 +1047,8 @@ bool Notepad_plus::fileCloseAllButCurrent()
//closes all documents, makes the current view the only one visible //closes all documents, makes the current view the only one visible
//first check if we need to save any file //first check if we need to save any file
for(int i = 0; i < _mainDocTab.nbItem(); ++i) { for (size_t i = 0; i < _mainDocTab.nbItem(); ++i)
{
BufferID id = _mainDocTab.getBufferByIndex(i); BufferID id = _mainDocTab.getBufferByIndex(i);
if (id == current) if (id == current)
continue; continue;
@ -1073,7 +1075,7 @@ bool Notepad_plus::fileCloseAllButCurrent()
} }
} }
} }
for(int i = 0; i < _subDocTab.nbItem(); ++i) for (size_t i = 0; i < _subDocTab.nbItem(); ++i)
{ {
BufferID id = _subDocTab.getBufferByIndex(i); BufferID id = _subDocTab.getBufferByIndex(i);
Buffer * buf = MainFileManager->getBufferByID(id); Buffer * buf = MainFileManager->getBufferByID(id);
@ -1104,19 +1106,22 @@ bool Notepad_plus::fileCloseAllButCurrent()
bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode();
//Then start closing, inactive view first so the active is left open //Then start closing, inactive view first so the active is left open
if (bothActive()) if (bothActive())
{ //first close all docs in non-current view, which gets closed automatically {
//first close all docs in non-current view, which gets closed automatically
//Set active tab to the last one closed. //Set active tab to the last one closed.
activateBuffer(_pNonDocTab->getBufferByIndex(0), otherView()); activateBuffer(_pNonDocTab->getBufferByIndex(0), otherView());
for(int i = _pNonDocTab->nbItem() - 1; i >= 0; i--) { //close all from right to left for (int i = int(_pNonDocTab->nbItem()) - 1; i >= 0; i--) //close all from right to left
{
doClose(_pNonDocTab->getBufferByIndex(i), otherView(), isSnapshotMode); doClose(_pNonDocTab->getBufferByIndex(i), otherView(), isSnapshotMode);
} }
//hideView(otherView());
} }
activateBuffer(_pDocTab->getBufferByIndex(0), currentView()); activateBuffer(_pDocTab->getBufferByIndex(0), currentView());
for(int i = _pDocTab->nbItem() - 1; i >= 0; i--) { //close all from right to left for (int i = int(_pDocTab->nbItem()) - 1; i >= 0; i--) //close all from right to left
if (i == active) { //dont close active index {
if (i == active) //dont close active index
{
continue; continue;
} }
doClose(_pDocTab->getBufferByIndex(i), currentView(), isSnapshotMode); doClose(_pDocTab->getBufferByIndex(i), currentView(), isSnapshotMode);
@ -1233,16 +1238,21 @@ bool Notepad_plus::fileSaveSpecific(const generic_string& fileNameToSave)
} }
} }
bool Notepad_plus::fileSaveAll() { bool Notepad_plus::fileSaveAll()
if (viewVisible(MAIN_VIEW)) { {
for(int i = 0; i < _mainDocTab.nbItem(); ++i) { if (viewVisible(MAIN_VIEW))
{
for(size_t i = 0; i < _mainDocTab.nbItem(); ++i)
{
BufferID idToSave = _mainDocTab.getBufferByIndex(i); BufferID idToSave = _mainDocTab.getBufferByIndex(i);
fileSave(idToSave); fileSave(idToSave);
} }
} }
if (viewVisible(SUB_VIEW)) { if (viewVisible(SUB_VIEW))
for(int i = 0; i < _subDocTab.nbItem(); ++i) { {
for(size_t i = 0; i < _subDocTab.nbItem(); ++i)
{
BufferID idToSave = _subDocTab.getBufferByIndex(i); BufferID idToSave = _subDocTab.getBufferByIndex(i);
fileSave(idToSave); fileSave(idToSave);
} }
@ -1548,7 +1558,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
{ {
if (buf == _mainEditView.getCurrentBuffer()) // current document if (buf == _mainEditView.getCurrentBuffer()) // current document
// Set floding state in the current doccument // Set floding state in the current doccument
mainIndex2Update = i; mainIndex2Update = static_cast<int32_t>(i);
else else
// Set fold states in the buffer // Set fold states in the buffer
buf->setHeaderLineState(session._mainViewFiles[i]._foldStates, &_mainEditView); buf->setHeaderLineState(session._mainViewFiles[i]._foldStates, &_mainEditView);
@ -1651,7 +1661,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
{ {
if (buf == _subEditView.getCurrentBuffer()) // current document if (buf == _subEditView.getCurrentBuffer()) // current document
// Set floding state in the current doccument // Set floding state in the current doccument
subIndex2Update = k; subIndex2Update = static_cast<int32_t>(k);
else else
// Set fold states in the buffer // Set fold states in the buffer
buf->setHeaderLineState(session._subViewFiles[k]._foldStates, &_subEditView); buf->setHeaderLineState(session._subViewFiles[k]._foldStates, &_subEditView);
@ -1694,14 +1704,14 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
_mainEditView.restoreCurrentPos(); _mainEditView.restoreCurrentPos();
_subEditView.restoreCurrentPos(); _subEditView.restoreCurrentPos();
if (session._activeMainIndex < (size_t)_mainDocTab.nbItem())//session.nbMainFiles()) if (session._activeMainIndex < _mainDocTab.nbItem())//session.nbMainFiles())
activateBuffer(_mainDocTab.getBufferByIndex(session._activeMainIndex), MAIN_VIEW); activateBuffer(_mainDocTab.getBufferByIndex(session._activeMainIndex), MAIN_VIEW);
if (session._activeSubIndex < (size_t)_subDocTab.nbItem())//session.nbSubFiles()) if (session._activeSubIndex < _subDocTab.nbItem())//session.nbSubFiles())
activateBuffer(_subDocTab.getBufferByIndex(session._activeSubIndex), SUB_VIEW); activateBuffer(_subDocTab.getBufferByIndex(session._activeSubIndex), SUB_VIEW);
if ((session.nbSubFiles() > 0) && (session._activeView == MAIN_VIEW || session._activeView == SUB_VIEW)) if ((session.nbSubFiles() > 0) && (session._activeView == MAIN_VIEW || session._activeView == SUB_VIEW))
switchEditViewTo(session._activeView); switchEditViewTo(static_cast<int32_t>(session._activeView));
else else
switchEditViewTo(MAIN_VIEW); switchEditViewTo(MAIN_VIEW);

View File

@ -540,35 +540,34 @@ BOOL Notepad_plus::notify(SCNotification *notification)
std::string bufstring; std::string bufstring;
unsigned int position_of_click; size_t position_of_click;
// For some reason Ctrl+DoubleClick on an empty line means that notification->position == 1. // For some reason Ctrl+DoubleClick on an empty line means that notification->position == 1.
// In that case we use SCI_GETCURRENTPOS to get the position. // In that case we use SCI_GETCURRENTPOS to get the position.
if (notification->position != -1) if (notification->position != -1)
position_of_click = notification->position; position_of_click = notification->position;
else else
position_of_click = int(_pEditView->execute(SCI_GETCURRENTPOS)); position_of_click = _pEditView->execute(SCI_GETCURRENTPOS);
// Anonymous scope to limit use of the buf pointer (much easier to deal with std::string). // Anonymous scope to limit use of the buf pointer (much easier to deal with std::string).
{ {
char *buf; char *buf;
int length;
if (nppGUI._delimiterSelectionOnEntireDocument) if (nppGUI._delimiterSelectionOnEntireDocument)
{ {
// Get entire document. // Get entire document.
length = notifyView->execute(SCI_GETLENGTH); auto length = notifyView->execute(SCI_GETLENGTH);
buf = new char[length + 1]; buf = new char[length + 1];
notifyView->execute(SCI_GETTEXT, (LPARAM)(length + 1), (WPARAM)buf); notifyView->execute(SCI_GETTEXT, (LPARAM)(length + 1), (WPARAM)buf);
} }
else else
{ {
// Get single line. // Get single line.
length = notifyView->execute(SCI_GETCURLINE); auto length = notifyView->execute(SCI_GETCURLINE);
buf = new char[length + 1]; buf = new char[length + 1];
notifyView->execute(SCI_GETCURLINE, (WPARAM)length, (LPARAM)buf); notifyView->execute(SCI_GETCURLINE, (WPARAM)length, (LPARAM)buf);
// Compute the position of the click (relative to the beginning of the line). // Compute the position of the click (relative to the beginning of the line).
const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber()); const auto line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber());
position_of_click = position_of_click - line_position; position_of_click = position_of_click - line_position;
} }
@ -583,7 +582,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{ {
// If the delimiters are the same (e.g. they are both a quotation mark), choose the ones // If the delimiters are the same (e.g. they are both a quotation mark), choose the ones
// which are closest to the clicked position. // which are closest to the clicked position.
for (int i = position_of_click; i >= 0; --i) for (int i = static_cast<int32_t>(position_of_click); i >= 0; --i)
{ {
if (bufstring.at(i) == nppGUI._leftmostDelimiter) if (bufstring.at(i) == nppGUI._leftmostDelimiter)
{ {
@ -608,7 +607,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
break; break;
// Scan for right delimiter. // Scan for right delimiter.
for (unsigned int i = position_of_click; i < bufstring.length(); ++i) for (size_t i = position_of_click; i < bufstring.length(); ++i)
{ {
if (bufstring.at(i) == nppGUI._rightmostDelimiter) if (bufstring.at(i) == nppGUI._rightmostDelimiter)
{ {
@ -617,13 +616,13 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{ {
if (! (i > 0 && bufstring.at(i - 1) == '\\')) if (! (i > 0 && bufstring.at(i - 1) == '\\'))
{ {
rightmost_position = i; rightmost_position = static_cast<int32_t>(i);
break; break;
} }
} }
else else
{ {
rightmost_position = i; rightmost_position = static_cast<int32_t>(i);
break; break;
} }
} }
@ -673,7 +672,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
} }
else else
{ {
const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber()); const auto line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber());
notifyView->execute(SCI_SETCURRENTPOS, line_position + rightmost_position); notifyView->execute(SCI_SETCURRENTPOS, line_position + rightmost_position);
notifyView->execute(SCI_SETANCHOR, line_position + leftmost_position + 1); notifyView->execute(SCI_SETANCHOR, line_position + leftmost_position + 1);
} }
@ -681,7 +680,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
} }
else if (_isHotspotDblClicked) else if (_isHotspotDblClicked)
{ {
int pos = notifyView->execute(SCI_GETCURRENTPOS); auto pos = notifyView->execute(SCI_GETCURRENTPOS);
notifyView->execute(SCI_SETCURRENTPOS, pos); notifyView->execute(SCI_SETCURRENTPOS, pos);
notifyView->execute(SCI_SETANCHOR, pos); notifyView->execute(SCI_SETANCHOR, pos);
_isHotspotDblClicked = false; _isHotspotDblClicked = false;
@ -806,7 +805,11 @@ BOOL Notepad_plus::notify(SCNotification *notification)
case SCN_MACRORECORD: case SCN_MACRORECORD:
{ {
_macro.push_back(recordedMacroStep(notification->message, notification->wParam, notification->lParam, _pEditView->execute(SCI_GETCODEPAGE))); _macro.push_back(recordedMacroStep(
notification->message,
static_cast<long>(notification->wParam),
static_cast<long>(notification->lParam),
static_cast<int32_t>(_pEditView->execute(SCI_GETCODEPAGE))));
break; break;
} }
@ -851,13 +854,13 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{ {
notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.,:?&@=/%#()"); notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.,:?&@=/%#()");
int pos = notifyView->execute(SCI_GETCURRENTPOS); auto pos = notifyView->execute(SCI_GETCURRENTPOS);
int startPos = static_cast<int>(notifyView->execute(SCI_WORDSTARTPOSITION, pos, false)); int startPos = static_cast<int>(notifyView->execute(SCI_WORDSTARTPOSITION, pos, false));
int endPos = static_cast<int>(notifyView->execute(SCI_WORDENDPOSITION, pos, false)); int endPos = static_cast<int>(notifyView->execute(SCI_WORDENDPOSITION, pos, false));
notifyView->execute(SCI_SETTARGETRANGE, startPos, endPos); notifyView->execute(SCI_SETTARGETRANGE, startPos, endPos);
int posFound = notifyView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR); int posFound = static_cast<int32_t>(notifyView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR));
if (posFound != -2) if (posFound != -2)
{ {
if (posFound != -1) if (posFound != -1)
@ -875,7 +878,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
notifyView->getGenericText(currentWord, MAX_PATH*2, startPos, endPos); notifyView->getGenericText(currentWord, MAX_PATH*2, startPos, endPos);
// This treatment would fail on some valid URLs where there's actually supposed to be a comma or parenthesis at the end. // This treatment would fail on some valid URLs where there's actually supposed to be a comma or parenthesis at the end.
int lastCharIndex = _tcsnlen(currentWord, MAX_PATH*2) - 1; size_t lastCharIndex = _tcsnlen(currentWord, MAX_PATH*2) - 1;
if(lastCharIndex >= 0 && (currentWord[lastCharIndex] == ',' || currentWord[lastCharIndex] == ')' || currentWord[lastCharIndex] == '(')) if(lastCharIndex >= 0 && (currentWord[lastCharIndex] == ',' || currentWord[lastCharIndex] == ')' || currentWord[lastCharIndex] == '('))
currentWord[lastCharIndex] = '\0'; currentWord[lastCharIndex] = '\0';

View File

@ -1482,7 +1482,7 @@ void NppParameters::setCurLineHilitingColour(COLORREF colour2Set)
static int CALLBACK EnumFontFamExProc(const LOGFONT* lpelfe, const TEXTMETRIC*, DWORD, LPARAM lParam) static int CALLBACK EnumFontFamExProc(const LOGFONT* lpelfe, const TEXTMETRIC*, DWORD, LPARAM lParam)
{ {
std::vector<generic_string>& strVect = *(std::vector<generic_string> *)lParam; std::vector<generic_string>& strVect = *(std::vector<generic_string> *)lParam;
const size_t vectSize = strVect.size(); const int32_t vectSize = static_cast<int32_t>(strVect.size());
const TCHAR* lfFaceName = ((ENUMLOGFONTEX*)lpelfe)->elfLogFont.lfFaceName; const TCHAR* lfFaceName = ((ENUMLOGFONTEX*)lpelfe)->elfLogFont.lfFaceName;
//Search through all the fonts, EnumFontFamiliesEx never states anything about order //Search through all the fonts, EnumFontFamiliesEx never states anything about order
@ -2272,9 +2272,8 @@ void NppParameters::feedMacros(TiXmlNode *node)
{ {
Macro macro; Macro macro;
getActions(childNode, macro); getActions(childNode, macro);
int cmdID = ID_MACRO + _macros.size(); int cmdID = ID_MACRO + static_cast<int32_t>(_macros.size());
MacroShortcut ms(sc, macro, cmdID); MacroShortcut ms(sc, macro, cmdID);
//if (ms.isValid())
_macros.push_back(ms); _macros.push_back(ms);
} }
} }
@ -2329,7 +2328,7 @@ void NppParameters::feedUserCmds(TiXmlNode *node)
const TCHAR *cmdStr = aNode->Value(); const TCHAR *cmdStr = aNode->Value();
if (cmdStr) if (cmdStr)
{ {
int cmdID = ID_USER_CMD + _userCommands.size(); int cmdID = ID_USER_CMD + int32_t(_userCommands.size());
UserCommand uc(sc, cmdStr, cmdID); UserCommand uc(sc, cmdStr, cmdID);
//if (uc.isValid()) //if (uc.isValid())
_userCommands.push_back(uc); _userCommands.push_back(uc);
@ -2395,7 +2394,7 @@ void NppParameters::feedScintKeys(TiXmlNode *node)
//Find the corresponding scintillacommand and alter it, put the index in the list //Find the corresponding scintillacommand and alter it, put the index in the list
size_t len = _scintillaKeyCommands.size(); size_t len = _scintillaKeyCommands.size();
for(size_t i = 0; i < len; ++i) for (int32_t i = 0; i < static_cast<int32_t>(len); ++i)
{ {
ScintillaKeyMap & skmOrig = _scintillaKeyCommands[i]; ScintillaKeyMap & skmOrig = _scintillaKeyCommands[i];
if (skmOrig.getScintillaKeyID() == (unsigned long)scintKey && skmOrig.getMenuCmdID() == menuID) if (skmOrig.getScintillaKeyID() == (unsigned long)scintKey && skmOrig.getMenuCmdID() == menuID)
@ -2563,12 +2562,12 @@ bool NppParameters::importUDLFromFile(generic_string sourceFile)
return loadOkay; return loadOkay;
} }
bool NppParameters::exportUDLToFile(int langIndex2export, generic_string fileName2save) bool NppParameters::exportUDLToFile(size_t langIndex2export, generic_string fileName2save)
{ {
if (langIndex2export >= NB_MAX_USER_LANG) if (langIndex2export >= NB_MAX_USER_LANG)
return false; return false;
if (langIndex2export < 0 && langIndex2export >= _nbUserLang) if (static_cast<int32_t>(langIndex2export) >= _nbUserLang)
return false; return false;
TiXmlDocument *pNewXmlUserLangDoc = new TiXmlDocument(fileName2save); TiXmlDocument *pNewXmlUserLangDoc = new TiXmlDocument(fileName2save);
@ -2821,11 +2820,11 @@ void NppParameters::insertMacro(TiXmlNode *macrosRoot, const MacroShortcut & mac
{ {
TiXmlNode *actionNode = macroRoot->InsertEndChild(TiXmlElement(TEXT("Action"))); TiXmlNode *actionNode = macroRoot->InsertEndChild(TiXmlElement(TEXT("Action")));
const recordedMacroStep & action = macro._macro[i]; const recordedMacroStep & action = macro._macro[i];
actionNode->ToElement()->SetAttribute(TEXT("type"), action.MacroType); actionNode->ToElement()->SetAttribute(TEXT("type"), action._macroType);
actionNode->ToElement()->SetAttribute(TEXT("message"), action.message); actionNode->ToElement()->SetAttribute(TEXT("message"), action._message);
actionNode->ToElement()->SetAttribute(TEXT("wParam"), action.wParameter); actionNode->ToElement()->SetAttribute(TEXT("wParam"), action._wParameter);
actionNode->ToElement()->SetAttribute(TEXT("lParam"), action.lParameter); actionNode->ToElement()->SetAttribute(TEXT("lParam"), action._lParameter);
actionNode->ToElement()->SetAttribute(TEXT("sParam"), action.sParameter.c_str()); actionNode->ToElement()->SetAttribute(TEXT("sParam"), action._sParameter.c_str());
} }
} }
@ -2938,14 +2937,14 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName)
{ {
size_t markLine = viewSessionFiles[i]._marks[j]; size_t markLine = viewSessionFiles[i]._marks[j];
TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Mark"))); TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Mark")));
markNode->ToElement()->SetAttribute(TEXT("line"), markLine); markNode->ToElement()->SetAttribute(TEXT("line"), int(markLine));
} }
for (size_t j = 0, len = viewSessionFiles[i]._foldStates.size() ; j < len ; ++j) for (size_t j = 0, len = viewSessionFiles[i]._foldStates.size() ; j < len ; ++j)
{ {
size_t foldLine = viewSessionFiles[i]._foldStates[j]; size_t foldLine = viewSessionFiles[i]._foldStates[j];
TiXmlNode *foldNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Fold"))); TiXmlNode *foldNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Fold")));
foldNode->ToElement()->SetAttribute(TEXT("line"), foldLine); foldNode->ToElement()->SetAttribute(TEXT("line"), int(foldLine));
} }
} }
} }
@ -3040,12 +3039,13 @@ int NppParameters::addUserLangToEnd(const UserLangContainer & userLang, const TC
} }
void NppParameters::removeUserLang(int index) void NppParameters::removeUserLang(size_t index)
{ {
if (index >= _nbUserLang ) if (static_cast<int32_t>(index) >= _nbUserLang)
return; return;
delete _userLangArray[index]; delete _userLangArray[index];
for (int i = index ; i < (_nbUserLang - 1) ; ++i)
for (int32_t i = static_cast<int32_t>(index); i < (_nbUserLang - 1); ++i)
_userLangArray[i] = _userLangArray[i+1]; _userLangArray[i] = _userLangArray[i+1];
_nbUserLang--; _nbUserLang--;
} }
@ -3415,7 +3415,7 @@ bool NppParameters::writeProjectPanelsSettings() const
TiXmlElement projPanelRootNode{TEXT("ProjectPanels")}; TiXmlElement projPanelRootNode{TEXT("ProjectPanels")};
// Add 3 Project Panel parameters // Add 3 Project Panel parameters
for (size_t i = 0 ; i < 3 ; ++i) for (int32_t i = 0 ; i < 3 ; ++i)
{ {
TiXmlElement projPanelNode{TEXT("ProjectPanel")}; TiXmlElement projPanelNode{TEXT("ProjectPanel")};
(projPanelNode.ToElement())->SetAttribute(TEXT("id"), i); (projPanelNode.ToElement())->SetAttribute(TEXT("id"), i);
@ -5301,7 +5301,7 @@ bool NppParameters::writeGUIParams()
element->SetAttribute(TEXT("dir"), _nppGUI._backupDir.c_str()); element->SetAttribute(TEXT("dir"), _nppGUI._backupDir.c_str());
element->SetAttribute(TEXT("isSnapshotMode"), _nppGUI._isSnapshotMode && _nppGUI._rememberLastSession?TEXT("yes"):TEXT("no")); element->SetAttribute(TEXT("isSnapshotMode"), _nppGUI._isSnapshotMode && _nppGUI._rememberLastSession?TEXT("yes"):TEXT("no"));
element->SetAttribute(TEXT("snapshotBackupTiming"), _nppGUI._snapshotBackupTiming); element->SetAttribute(TEXT("snapshotBackupTiming"), int32_t(_nppGUI._snapshotBackupTiming));
backExist = true; backExist = true;
} }
else if (!lstrcmp(nm, TEXT("MRU"))) else if (!lstrcmp(nm, TEXT("MRU")))
@ -5362,7 +5362,7 @@ bool NppParameters::writeGUIParams()
{ {
autocExist = true; autocExist = true;
element->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus); element->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus);
element->SetAttribute(TEXT("triggerFromNbChar"), _nppGUI._autocFromLen); element->SetAttribute(TEXT("triggerFromNbChar"), int32_t(_nppGUI._autocFromLen));
const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no"); const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no");
element->SetAttribute(TEXT("funcParams"), pStr); element->SetAttribute(TEXT("funcParams"), pStr);
} }
@ -5594,7 +5594,7 @@ bool NppParameters::writeGUIParams()
GUIConfigElement->SetAttribute(TEXT("dir"), _nppGUI._backupDir.c_str()); GUIConfigElement->SetAttribute(TEXT("dir"), _nppGUI._backupDir.c_str());
GUIConfigElement->SetAttribute(TEXT("isSnapshotMode"), _nppGUI.isSnapshotMode()?TEXT("yes"):TEXT("no")); GUIConfigElement->SetAttribute(TEXT("isSnapshotMode"), _nppGUI.isSnapshotMode()?TEXT("yes"):TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("snapshotBackupTiming"), _nppGUI._snapshotBackupTiming); GUIConfigElement->SetAttribute(TEXT("snapshotBackupTiming"), int32_t(_nppGUI._snapshotBackupTiming));
} }
if (!doTaskListExist) if (!doTaskListExist)
@ -5638,7 +5638,7 @@ bool NppParameters::writeGUIParams()
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("auto-completion")); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("auto-completion"));
GUIConfigElement->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus); GUIConfigElement->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus);
GUIConfigElement->SetAttribute(TEXT("triggerFromNbChar"), _nppGUI._autocFromLen); GUIConfigElement->SetAttribute(TEXT("triggerFromNbChar"), int32_t(_nppGUI._autocFromLen));
const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no"); const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no");
GUIConfigElement->SetAttribute(TEXT("funcParams"), pStr); GUIConfigElement->SetAttribute(TEXT("funcParams"), pStr);
autocExist = true; autocExist = true;

View File

@ -436,9 +436,9 @@ public:
int getNbStyler() const {return _nbStyler;}; int getNbStyler() const {return _nbStyler;};
void setNbStyler(int nb) {_nbStyler = nb;}; void setNbStyler(int nb) {_nbStyler = nb;};
Style& getStyler(int index) Style& getStyler(size_t index)
{ {
assert((size_t) index < SCE_STYLE_ARRAY_SIZE); assert(index < SCE_STYLE_ARRAY_SIZE);
return _styleArray[index]; return _styleArray[index];
} }
@ -1281,9 +1281,8 @@ public:
return nullptr; return nullptr;
} }
Lang * getLangFromIndex(int i) const Lang * getLangFromIndex(size_t i) const {
{ return (i < size_t(_nbLang)) ? _langList[i] : nullptr;
return (i >= 0 and i < _nbLang) ? _langList[i] : nullptr;
} }
int getNbLang() const {return _nbLang;}; int getNbLang() const {return _nbLang;};
@ -1368,7 +1367,7 @@ public:
const std::vector<generic_string>& getFontList() const { return _fontlist; } const std::vector<generic_string>& getFontList() const { return _fontlist; }
int getNbUserLang() const {return _nbUserLang;} int getNbUserLang() const {return _nbUserLang;}
UserLangContainer & getULCFromIndex(int i) {return *_userLangArray[i];}; UserLangContainer & getULCFromIndex(size_t i) {return *_userLangArray[i];};
UserLangContainer * getULCFromName(const TCHAR *userLangName); UserLangContainer * getULCFromName(const TCHAR *userLangName);
int getNbExternalLang() const {return _nbExternalLang;}; int getNbExternalLang() const {return _nbExternalLang;};
@ -1402,7 +1401,7 @@ public:
const TCHAR * getUserDefinedLangNameFromExt(TCHAR *ext, TCHAR *fullName) const; const TCHAR * getUserDefinedLangNameFromExt(TCHAR *ext, TCHAR *fullName) const;
int addUserLangToEnd(const UserLangContainer & userLang, const TCHAR *newName); int addUserLangToEnd(const UserLangContainer & userLang, const TCHAR *newName);
void removeUserLang(int index); void removeUserLang(size_t index);
bool isExistingExternalLangName(const TCHAR *newName) const; bool isExistingExternalLangName(const TCHAR *newName) const;
@ -1523,7 +1522,7 @@ public:
PluginList & getPluginList() {return _pluginList;}; PluginList & getPluginList() {return _pluginList;};
bool importUDLFromFile(generic_string sourceFile); bool importUDLFromFile(generic_string sourceFile);
bool exportUDLToFile(int langIndex2export, generic_string fileName2save); bool exportUDLToFile(size_t langIndex2export, generic_string fileName2save);
NativeLangSpeaker* getNativeLangSpeaker() { NativeLangSpeaker* getNativeLangSpeaker() {
return _pNativeLangSpeaker; return _pNativeLangSpeaker;
} }

View File

@ -133,7 +133,7 @@ void AutoCompletion::getWordArray(vector<generic_string> & wordArray, TCHAR *beg
int flags = SCFIND_WORDSTART | SCFIND_MATCHCASE | SCFIND_REGEXP | SCFIND_POSIX; int flags = SCFIND_WORDSTART | SCFIND_MATCHCASE | SCFIND_REGEXP | SCFIND_POSIX;
_pEditView->execute(SCI_SETSEARCHFLAGS, flags); _pEditView->execute(SCI_SETSEARCHFLAGS, flags);
int posFind = _pEditView->searchInTarget(expr.c_str(), expr.length(), 0, docLength); int posFind = _pEditView->searchInTarget(expr.c_str(), int(expr.length()), 0, docLength);
while (posFind != -1 && posFind != -2) while (posFind != -1 && posFind != -2)
{ {
@ -149,7 +149,7 @@ void AutoCompletion::getWordArray(vector<generic_string> & wordArray, TCHAR *beg
if (!isInList(w, wordArray)) if (!isInList(w, wordArray))
wordArray.push_back(w); wordArray.push_back(w);
} }
posFind = _pEditView->searchInTarget(expr.c_str(), expr.length(), wordEnd, docLength); posFind = _pEditView->searchInTarget(expr.c_str(), static_cast<int32_t>(expr.length()), wordEnd, docLength);
} }
} }
@ -244,10 +244,10 @@ void AutoCompletion::showPathCompletion()
// Get current line (at most MAX_PATH characters "backwards" from current caret). // Get current line (at most MAX_PATH characters "backwards" from current caret).
generic_string currentLine; generic_string currentLine;
{ {
const long bufSize = MAX_PATH; const size_t bufSize = MAX_PATH;
TCHAR buf[bufSize + 1]; TCHAR buf[bufSize + 1];
const int currentPos = _pEditView->execute(SCI_GETCURRENTPOS); const size_t currentPos = static_cast<size_t>(_pEditView->execute(SCI_GETCURRENTPOS));
const int startPos = max(0, currentPos - bufSize); const auto startPos = max(0, currentPos - bufSize);
_pEditView->getGenericText(buf, bufSize + 1, startPos, currentPos); _pEditView->getGenericText(buf, bufSize + 1, startPos, currentPos);
currentLine = buf; currentLine = buf;
} }
@ -428,12 +428,12 @@ void InsertedMatchedChars::removeInvalidElements(MatchedCharInserted mci)
} }
else else
{ {
for (int i = _insertedMatchedChars.size() - 1; i >= 0; --i) for (int i = int(_insertedMatchedChars.size()) - 1; i >= 0; --i)
{ {
if (_insertedMatchedChars[i]._pos < mci._pos) if (_insertedMatchedChars[i]._pos < mci._pos)
{ {
int posToDetectLine = _pEditView->execute(SCI_LINEFROMPOSITION, mci._pos); auto posToDetectLine = _pEditView->execute(SCI_LINEFROMPOSITION, mci._pos);
int startPosLine = _pEditView->execute(SCI_LINEFROMPOSITION, _insertedMatchedChars[i]._pos); auto startPosLine = _pEditView->execute(SCI_LINEFROMPOSITION, _insertedMatchedChars[i]._pos);
if (posToDetectLine != startPosLine) //not in the same line if (posToDetectLine != startPosLine) //not in the same line
{ {
@ -461,18 +461,18 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
{ {
if (isEmpty()) if (isEmpty())
return -1; return -1;
int posToDetectLine = _pEditView->execute(SCI_LINEFROMPOSITION, posToDetect); auto posToDetectLine = _pEditView->execute(SCI_LINEFROMPOSITION, posToDetect);
for (int i = _insertedMatchedChars.size() - 1; i >= 0; --i) for (int i = int32_t(_insertedMatchedChars.size()) - 1; i >= 0; --i)
{ {
if (_insertedMatchedChars[i]._c == startChar) if (_insertedMatchedChars[i]._c == startChar)
{ {
if (_insertedMatchedChars[i]._pos < posToDetect) if (_insertedMatchedChars[i]._pos < posToDetect)
{ {
int startPosLine = _pEditView->execute(SCI_LINEFROMPOSITION, _insertedMatchedChars[i]._pos); auto startPosLine = _pEditView->execute(SCI_LINEFROMPOSITION, _insertedMatchedChars[i]._pos);
if (posToDetectLine == startPosLine) if (posToDetectLine == startPosLine)
{ {
int endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, startPosLine); auto endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, startPosLine);
for (int j = posToDetect; j <= endPos; ++j) for (int j = posToDetect; j <= endPos; ++j)
{ {
@ -511,7 +511,7 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & matchedPairConf) void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & matchedPairConf)
{ {
const vector< pair<char, char> > & matchedPairs = matchedPairConf._matchedPairs; const vector< pair<char, char> > & matchedPairs = matchedPairConf._matchedPairs;
int caretPos = _pEditView->execute(SCI_GETCURRENTPOS); int caretPos = static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS));
char *matchedChars = NULL; char *matchedChars = NULL;
char charPrev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 2); char charPrev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 2);

View File

@ -518,14 +518,14 @@ void FileManager::init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratch
void FileManager::checkFilesystemChanges() void FileManager::checkFilesystemChanges()
{ {
for(int i = int(_nrBufs -1) ; i >= 0 ; i--) for (int i = int(_nrBufs) - 1; i >= 0 ; i--)
{ {
if (i >= int(_nrBufs)) if (i >= int(_nrBufs))
{ {
if (_nrBufs == 0) if (_nrBufs == 0)
return; return;
i = _nrBufs - 1; i = int(_nrBufs) - 1;
} }
_buffers[i]->checkFileState(); //something has changed. Triggers update automatically _buffers[i]->checkFileState(); //something has changed. Triggers update automatically
} }
@ -542,8 +542,10 @@ int FileManager::getBufferIndexByID(BufferID id)
return -1; return -1;
} }
Buffer* FileManager::getBufferByIndex(int index) Buffer* FileManager::getBufferByIndex(size_t index)
{ {
if (index >= _buffers.size())
return nullptr;
return _buffers.at(index); return _buffers.at(index);
} }
@ -1259,7 +1261,7 @@ int FileManager::detectCodepage(char* buf, size_t len)
return codepage; return codepage;
} }
LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data, unsigned int dataLen) LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen)
{ {
struct FirstLineLanguages struct FirstLineLanguages
{ {
@ -1458,7 +1460,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data,
{ {
WcharMbcsConvertor* wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor* wmc = WcharMbcsConvertor::getInstance();
int newDataLen = 0; int newDataLen = 0;
const char *newData = wmc->encode(encoding, SC_CP_UTF8, data, lenFile, &newDataLen, &incompleteMultibyteChar); const char *newData = wmc->encode(encoding, SC_CP_UTF8, data, static_cast<int32_t>(lenFile), &newDataLen, &incompleteMultibyteChar);
_pscratchTilla->execute(SCI_APPENDTEXT, newDataLen, (LPARAM)newData); _pscratchTilla->execute(SCI_APPENDTEXT, newDataLen, (LPARAM)newData);
} }

View File

@ -74,9 +74,9 @@ public:
//void activateBuffer(int index); //void activateBuffer(int index);
void checkFilesystemChanges(); void checkFilesystemChanges();
int getNrBuffers() { return _nrBufs; }; size_t getNrBuffers() { return _nrBufs; };
int getBufferIndexByID(BufferID id); int getBufferIndexByID(BufferID id);
Buffer * getBufferByIndex(int index); //generates exception if index is invalid Buffer * getBufferByIndex(size_t index);
Buffer * getBufferByID(BufferID id) {return (Buffer*)id;} Buffer * getBufferByID(BufferID id) {return (Buffer*)id;}
void beNotifiedOfBufferChange(Buffer * theBuf, int mask); void beNotifiedOfBufferChange(Buffer * theBuf, int mask);
@ -114,7 +114,7 @@ private:
~FileManager(); ~FileManager();
int detectCodepage(char* buf, size_t len); int detectCodepage(char* buf, size_t len);
bool loadFileData(Document doc, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LangType & language, int & encoding, EolType & eolFormat); bool loadFileData(Document doc, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LangType & language, int & encoding, EolType & eolFormat);
LangType detectLanguageFromTextBegining(const unsigned char *data, unsigned int dataLen); LangType detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen);
private: private:

View File

@ -120,7 +120,7 @@ int DocTabView::getIndexByBuffer(BufferID id)
} }
BufferID DocTabView::getBufferByIndex(int index) BufferID DocTabView::getBufferByIndex(size_t index)
{ {
TCITEM tie; TCITEM tie;
tie.lParam = -1; tie.lParam = -1;

View File

@ -71,7 +71,7 @@ public :
BufferID findBufferByName(const TCHAR * fullfilename); //-1 if not found, something else otherwise BufferID findBufferByName(const TCHAR * fullfilename); //-1 if not found, something else otherwise
int getIndexByBuffer(BufferID id); int getIndexByBuffer(BufferID id);
BufferID getBufferByIndex(int index); BufferID getBufferByIndex(size_t index);
void setBuffer(int index, BufferID id); void setBuffer(int index, BufferID id);

View File

@ -45,9 +45,7 @@ void addText2Combo(const TCHAR * txt2add, HWND hCombo)
if (!hCombo) return; if (!hCombo) return;
if (!lstrcmp(txt2add, TEXT(""))) return; if (!lstrcmp(txt2add, TEXT(""))) return;
int i = 0; auto i = ::SendMessage(hCombo, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2add);
i = ::SendMessage(hCombo, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2add);
if (i != CB_ERR) // found if (i != CB_ERR) // found
{ {
::SendMessage(hCombo, CB_DELETESTRING, i, 0); ::SendMessage(hCombo, CB_DELETESTRING, i, 0);
@ -230,7 +228,7 @@ FindReplaceDlg::~FindReplaceDlg()
_tab.destroy(); _tab.destroy();
if (_pFinder) if (_pFinder)
delete _pFinder; delete _pFinder;
for (int n = _findersOfFinder.size() - 1; n >= 0; n--) for (int n = static_cast<int32_t>(_findersOfFinder.size()) - 1; n >= 0; n--)
{ {
delete _findersOfFinder[n]; delete _findersOfFinder[n];
_findersOfFinder.erase(_findersOfFinder.begin() + n); _findersOfFinder.erase(_findersOfFinder.begin() + n);
@ -378,7 +376,7 @@ int FindReplaceDlg::saveComboHistory(int id, int maxcount, vector<generic_string
{ {
TCHAR text[FINDREPLACE_MAXLENGTH]; TCHAR text[FINDREPLACE_MAXLENGTH];
HWND hCombo = ::GetDlgItem(_hSelf, id); HWND hCombo = ::GetDlgItem(_hSelf, id);
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0); int count = static_cast<int32_t>(::SendMessage(hCombo, CB_GETCOUNT, 0, 0));
count = min(count, maxcount); count = min(count, maxcount);
if (count == CB_ERR) return 0; if (count == CB_ERR) return 0;
@ -428,10 +426,10 @@ bool Finder::notify(SCNotification *notification)
isDoubleClicked = true; isDoubleClicked = true;
int pos = notification->position; int pos = notification->position;
if (pos == INVALID_POSITION) if (pos == INVALID_POSITION)
pos = _scintView.execute(SCI_GETLINEENDPOSITION, notification->line); pos = static_cast<int32_t>(_scintView.execute(SCI_GETLINEENDPOSITION, notification->line));
_scintView.execute(SCI_SETSEL, pos, pos); _scintView.execute(SCI_SETSEL, pos, pos);
GotoFoundLine(); gotoFoundLine();
} }
break; break;
@ -447,12 +445,13 @@ bool Finder::notify(SCNotification *notification)
} }
void Finder::GotoFoundLine() void Finder::gotoFoundLine()
{ {
int currentPos = _scintView.execute(SCI_GETCURRENTPOS); auto currentPos = _scintView.execute(SCI_GETCURRENTPOS);
int lno = _scintView.execute(SCI_LINEFROMPOSITION, currentPos); auto lno = _scintView.execute(SCI_LINEFROMPOSITION, currentPos);
int start = _scintView.execute(SCI_POSITIONFROMLINE, lno); auto start = _scintView.execute(SCI_POSITIONFROMLINE, lno);
int end = _scintView.execute(SCI_GETLINEENDPOSITION, lno); auto end = _scintView.execute(SCI_GETLINEENDPOSITION, lno);
if (start + 2 >= end) return; // avoid empty lines if (start + 2 >= end) return; // avoid empty lines
if (_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG) if (_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG)
@ -471,34 +470,34 @@ void Finder::GotoFoundLine()
setFinderStyle(); setFinderStyle();
//_scintView.execute(SCI_SETLEXER, SCLEX_NULL); // yniq - this line causes a bug!!! (last line suddenly belongs to file header level (?) instead of having level=0x400) //_scintView.execute(SCI_SETLEXER, SCLEX_NULL); // yniq - this line causes a bug!!! (last line suddenly belongs to file header level (?) instead of having level=0x400)
// later it affects DeleteResult and gotoNextFoundResult (assertions) // later it affects DeleteResult and gotoNextFoundResult (assertions)
// fixed by calling setFinderStyle() in DeleteResult() // fixed by calling setFinderStyle() in deleteResult()
_scintView.execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_HIGHLIGHT_LINE, true); _scintView.execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_HIGHLIGHT_LINE, true);
_scintView.execute(SCI_STARTSTYLING, start, STYLING_MASK); _scintView.execute(SCI_STARTSTYLING, start, STYLING_MASK);
_scintView.execute(SCI_SETSTYLING, end - start + 2, SCE_SEARCHRESULT_HIGHLIGHT_LINE); _scintView.execute(SCI_SETSTYLING, end - start + 2, SCE_SEARCHRESULT_HIGHLIGHT_LINE);
_scintView.execute(SCI_COLOURISE, start, end + 1); _scintView.execute(SCI_COLOURISE, start, end + 1);
} }
void Finder::DeleteResult() void Finder::deleteResult()
{ {
int currentPos = _scintView.execute(SCI_GETCURRENTPOS); // yniq - add handling deletion of multiple lines? auto currentPos = _scintView.execute(SCI_GETCURRENTPOS); // yniq - add handling deletion of multiple lines?
int lno = _scintView.execute(SCI_LINEFROMPOSITION, currentPos); auto lno = _scintView.execute(SCI_LINEFROMPOSITION, currentPos);
int start = _scintView.execute(SCI_POSITIONFROMLINE, lno); auto start = _scintView.execute(SCI_POSITIONFROMLINE, lno);
int end = _scintView.execute(SCI_GETLINEENDPOSITION, lno); auto end = _scintView.execute(SCI_GETLINEENDPOSITION, lno);
if (start + 2 >= end) return; // avoid empty lines if (start + 2 >= end) return; // avoid empty lines
_scintView.setLexer(SCLEX_SEARCHRESULT, L_SEARCHRESULT, 0); // Restore searchResult lexer in case the lexer was changed to SCLEX_NULL in GotoFoundLine() _scintView.setLexer(SCLEX_SEARCHRESULT, L_SEARCHRESULT, 0); // Restore searchResult lexer in case the lexer was changed to SCLEX_NULL in GotoFoundLine()
if (_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG) // delete a folder if (_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG) // delete a folder
{ {
int endline = _scintView.execute(SCI_GETLASTCHILD, lno, -1) + 1; auto endline = _scintView.execute(SCI_GETLASTCHILD, lno, -1) + 1;
assert((size_t) endline <= _pMainFoundInfos->size()); assert((size_t) endline <= _pMainFoundInfos->size());
_pMainFoundInfos->erase(_pMainFoundInfos->begin() + lno, _pMainFoundInfos->begin() + endline); // remove found info _pMainFoundInfos->erase(_pMainFoundInfos->begin() + lno, _pMainFoundInfos->begin() + endline); // remove found info
_pMainMarkings->erase(_pMainMarkings->begin() + lno, _pMainMarkings->begin() + endline); _pMainMarkings->erase(_pMainMarkings->begin() + lno, _pMainMarkings->begin() + endline);
int end = _scintView.execute(SCI_POSITIONFROMLINE, endline); auto end2 = _scintView.execute(SCI_POSITIONFROMLINE, endline);
_scintView.execute(SCI_SETSEL, start, end); _scintView.execute(SCI_SETSEL, start, end2);
setFinderReadOnly(false); setFinderReadOnly(false);
_scintView.execute(SCI_CLEAR); _scintView.execute(SCI_CLEAR);
setFinderReadOnly(true); setFinderReadOnly(true);
@ -514,7 +513,7 @@ void Finder::DeleteResult()
_scintView.execute(SCI_LINEDELETE); _scintView.execute(SCI_LINEDELETE);
setFinderReadOnly(true); setFinderReadOnly(true);
} }
_MarkingsStruct._length = _pMainMarkings->size(); _markingsStruct._length = static_cast<long>(_pMainMarkings->size());
assert(_pMainFoundInfos->size() == _pMainMarkings->size()); assert(_pMainFoundInfos->size() == _pMainMarkings->size());
assert(size_t(_scintView.execute(SCI_GETLINECOUNT)) == _pMainFoundInfos->size() + 1); assert(size_t(_scintView.execute(SCI_GETLINECOUNT)) == _pMainFoundInfos->size() + 1);
@ -558,21 +557,21 @@ bool Finder::canFind(const TCHAR *fileName, size_t lineNumber) const
void Finder::gotoNextFoundResult(int direction) void Finder::gotoNextFoundResult(int direction)
{ {
int increment = direction < 0 ? -1 : 1; int increment = direction < 0 ? -1 : 1;
int currentPos = _scintView.execute(SCI_GETCURRENTPOS); auto currentPos = _scintView.execute(SCI_GETCURRENTPOS);
int lno = _scintView.execute(SCI_LINEFROMPOSITION, currentPos); auto lno = _scintView.execute(SCI_LINEFROMPOSITION, currentPos);
int total_lines = _scintView.execute(SCI_GETLINECOUNT); auto total_lines = _scintView.execute(SCI_GETLINECOUNT);
if (total_lines <= 1) return; if (total_lines <= 1) return;
if (lno == total_lines - 1) lno--; // last line doesn't belong to any search, use last search if (lno == total_lines - 1) lno--; // last line doesn't belong to any search, use last search
int init_lno = lno; auto init_lno = lno;
int max_lno = _scintView.execute(SCI_GETLASTCHILD, lno, searchHeaderLevel); auto max_lno = _scintView.execute(SCI_GETLASTCHILD, lno, searchHeaderLevel);
assert(max_lno <= total_lines - 2); assert(max_lno <= total_lines - 2);
// get the line number of the current search (searchHeaderLevel) // get the line number of the current search (searchHeaderLevel)
int level = _scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELNUMBERMASK; int level = _scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELNUMBERMASK;
int min_lno = lno; auto min_lno = lno;
while (level-- >= fileHeaderLevel) while (level-- >= fileHeaderLevel)
{ {
min_lno = _scintView.execute(SCI_GETFOLDPARENT, min_lno); min_lno = _scintView.execute(SCI_GETFOLDPARENT, min_lno);
@ -598,12 +597,12 @@ void Finder::gotoNextFoundResult(int direction)
if ((_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG) == 0) if ((_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG) == 0)
{ {
int start = _scintView.execute(SCI_POSITIONFROMLINE, lno); auto start = _scintView.execute(SCI_POSITIONFROMLINE, lno);
_scintView.execute(SCI_SETSEL, start, start); _scintView.execute(SCI_SETSEL, start, start);
_scintView.execute(SCI_ENSUREVISIBLE, lno); _scintView.execute(SCI_ENSUREVISIBLE, lno);
_scintView.execute(SCI_SCROLLCARET); _scintView.execute(SCI_SCROLLCARET);
GotoFoundLine(); gotoFoundLine();
} }
} }
@ -708,7 +707,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{ {
if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER)) if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER))
{ {
int percent = ::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0); int percent = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0));
FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory(); FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory();
findHistory._transparency = percent; findHistory._transparency = percent;
if (isCheckedOrNot(IDC_TRANSPARENT_ALWAYS_RADIO)) if (isCheckedOrNot(IDC_TRANSPARENT_ALWAYS_RADIO))
@ -779,7 +778,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{ {
if (LOWORD(wParam) == WA_INACTIVE && isVisible()) if (LOWORD(wParam) == WA_INACTIVE && isVisible())
{ {
int percent = ::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0); int percent = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0));
(NppParameters::getInstance())->SetTransparent(_hSelf, percent); (NppParameters::getInstance())->SetTransparent(_hSelf, percent);
} }
else else
@ -1203,7 +1202,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
case IDC_TRANSPARENT_ALWAYS_RADIO : case IDC_TRANSPARENT_ALWAYS_RADIO :
{ {
int percent = ::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0); int percent = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0));
(NppParameters::getInstance())->SetTransparent(_hSelf, percent); (NppParameters::getInstance())->SetTransparent(_hSelf, percent);
findHistory._transparencyMode = FindHistory::persistant; findHistory._transparencyMode = FindHistory::persistant;
} }
@ -1631,8 +1630,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
const FindOption *pOptions = opt?opt:_env; const FindOption *pOptions = opt?opt:_env;
int stringSizeFind = 0; LRESULT stringSizeFind = 0;
int stringSizeReplace = 0; LRESULT stringSizeReplace = 0;
TCHAR *pTextFind = NULL; TCHAR *pTextFind = NULL;
if (not findReplaceInfo._txt2find) if (not findReplaceInfo._txt2find)
@ -1677,9 +1676,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
if (pOptions->_searchType == FindExtended) if (pOptions->_searchType == FindExtended)
{ {
stringSizeFind = Searching::convertExtendedToString(pTextFind, pTextFind, stringSizeFind); stringSizeFind = Searching::convertExtendedToString(pTextFind, pTextFind, static_cast<int32_t>(stringSizeFind));
if (op == ProcessReplaceAll) if (op == ProcessReplaceAll)
stringSizeReplace = Searching::convertExtendedToString(pTextReplace, pTextReplace, stringSizeReplace); stringSizeReplace = Searching::convertExtendedToString(pTextReplace, pTextReplace, static_cast<int32_t>(stringSizeReplace));
} }
bool isRegExp = pOptions->_searchType == FindRegex; bool isRegExp = pOptions->_searchType == FindRegex;
@ -1742,9 +1741,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
findAllFileNameAdded = true; findAllFileNameAdded = true;
} }
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart); auto lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart);
int lend = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber); int lend = static_cast<int32_t>((*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber));
int lstart = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber); int lstart = static_cast<int32_t>((*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber));
int nbChar = lend - lstart; int nbChar = lend - lstart;
// use the static buffer // use the static buffer
@ -1781,9 +1780,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
findAllFileNameAdded = true; findAllFileNameAdded = true;
} }
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart); auto lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart);
int lend = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber); int lend = static_cast<int32_t>((*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber));
int lstart = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber); int lstart = static_cast<int32_t>((*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber));
int nbChar = lend - lstart; int nbChar = lend - lstart;
// use the static buffer // use the static buffer
@ -1841,8 +1840,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
if (_env->_doMarkLine) if (_env->_doMarkLine)
{ {
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart); auto lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart);
int state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber); auto state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber);
if (!(state & (1 << MARK_BOOKMARK))) if (!(state & (1 << MARK_BOOKMARK)))
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK); (*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
@ -1994,7 +1993,7 @@ void FindReplaceDlg::findAllIn(InWhat op)
{ {
// Send the address of _MarkingsStruct to the lexer // Send the address of _MarkingsStruct to the lexer
char ptrword[sizeof(void*)*2+1]; char ptrword[sizeof(void*)*2+1];
sprintf(ptrword, "%p", &_pFinder->_MarkingsStruct); sprintf(ptrword, "%p", &_pFinder->_markingsStruct);
_pFinder->_scintView.execute(SCI_SETPROPERTY, (WPARAM)"@MarkingsStruct", (LPARAM)ptrword); _pFinder->_scintView.execute(SCI_SETPROPERTY, (WPARAM)"@MarkingsStruct", (LPARAM)ptrword);
} }
@ -2083,7 +2082,7 @@ Finder * FindReplaceDlg::createFinder()
// Send the address of _MarkingsStruct to the lexer // Send the address of _MarkingsStruct to the lexer
char ptrword[sizeof(void*) * 2 + 1]; char ptrword[sizeof(void*) * 2 + 1];
sprintf(ptrword, "%p", &pFinder->_MarkingsStruct); sprintf(ptrword, "%p", &pFinder->_markingsStruct);
pFinder->_scintView.execute(SCI_SETPROPERTY, (WPARAM)"@MarkingsStruct", (LPARAM)ptrword); pFinder->_scintView.execute(SCI_SETPROPERTY, (WPARAM)"@MarkingsStruct", (LPARAM)ptrword);
_findersOfFinder.push_back(pFinder); _findersOfFinder.push_back(pFinder);
@ -2238,7 +2237,7 @@ void FindReplaceDlg::getPatterns(vector<generic_string> & patternVect)
cutString(_env->_filters.c_str(), patternVect); cutString(_env->_filters.c_str(), patternVect);
} }
void FindReplaceDlg::saveInMacro(int cmd, int cmdType) void FindReplaceDlg::saveInMacro(size_t cmd, int cmdType)
{ {
int booleans = 0; int booleans = 0;
::SendMessage(_hParent, WM_FRSAVE_INT, IDC_FRCOMMAND_INIT, 0); ::SendMessage(_hParent, WM_FRSAVE_INT, IDC_FRCOMMAND_INIT, 0);
@ -2545,9 +2544,9 @@ LRESULT FAR PASCAL FindReplaceDlg::finderProc(HWND hwnd, UINT message, WPARAM wP
ScintillaEditView *pScint = (ScintillaEditView *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); ScintillaEditView *pScint = (ScintillaEditView *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
Finder *pFinder = (Finder *)(::GetWindowLongPtr(pScint->getHParent(), GWLP_USERDATA)); Finder *pFinder = (Finder *)(::GetWindowLongPtr(pScint->getHParent(), GWLP_USERDATA));
if (wParam == VK_RETURN) if (wParam == VK_RETURN)
pFinder->GotoFoundLine(); pFinder->gotoFoundLine();
else // VK_DELETE else // VK_DELETE
pFinder->DeleteResult(); pFinder->deleteResult();
return 0; return 0;
} }
else else
@ -2684,7 +2683,7 @@ void Finder::addSearchLine(const TCHAR *searchName)
setFinderReadOnly(false); setFinderReadOnly(false);
_scintView.addGenericText(str.c_str()); _scintView.addGenericText(str.c_str());
setFinderReadOnly(true); setFinderReadOnly(true);
_lastSearchHeaderPos = _scintView.execute(SCI_GETCURRENTPOS) - 2; _lastSearchHeaderPos = static_cast<int32_t>(_scintView.execute(SCI_GETCURRENTPOS) - 2);
_pMainFoundInfos->push_back(EmptyFoundInfo); _pMainFoundInfos->push_back(EmptyFoundInfo);
_pMainMarkings->push_back(EmptySearchResultMarking); _pMainMarkings->push_back(EmptySearchResultMarking);
@ -2699,7 +2698,7 @@ void Finder::addFileNameTitle(const TCHAR * fileName)
setFinderReadOnly(false); setFinderReadOnly(false);
_scintView.addGenericText(str.c_str()); _scintView.addGenericText(str.c_str());
setFinderReadOnly(true); setFinderReadOnly(true);
_lastFileHeaderPos = _scintView.execute(SCI_GETCURRENTPOS) - 2; _lastFileHeaderPos = static_cast<int32_t>(_scintView.execute(SCI_GETCURRENTPOS) - 2);
_pMainFoundInfos->push_back(EmptyFoundInfo); _pMainFoundInfos->push_back(EmptyFoundInfo);
_pMainMarkings->push_back(EmptySearchResultMarking); _pMainMarkings->push_back(EmptySearchResultMarking);
@ -2745,8 +2744,8 @@ void Finder::add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline)
wsprintf(lnb, TEXT("%d"), fi._lineNumber); wsprintf(lnb, TEXT("%d"), fi._lineNumber);
str += lnb; str += lnb;
str += TEXT(": "); str += TEXT(": ");
mi._start += str.length(); mi._start += static_cast<int32_t>(str.length());
mi._end += str.length(); mi._end += static_cast<int32_t>(str.length());
str += foundline; str += foundline;
if (str.length() >= SC_SEARCHRESULT_LINEBUFFERMAXLENGTH) if (str.length() >= SC_SEARCHRESULT_LINEBUFFERMAXLENGTH)
@ -2782,7 +2781,7 @@ void Finder::openAll()
bool Finder::isLineActualSearchResult(const generic_string & s) const bool Finder::isLineActualSearchResult(const generic_string & s) const
{ {
const long firstColon = s.find(TEXT("\tLine ")); const auto firstColon = s.find(TEXT("\tLine "));
return (firstColon == 0); return (firstColon == 0);
} }
@ -2792,7 +2791,7 @@ generic_string & Finder::prepareStringForClipboard(generic_string & s) const
// Output: "search result" // Output: "search result"
s = stringReplace(s, TEXT("\r"), TEXT("")); s = stringReplace(s, TEXT("\r"), TEXT(""));
s = stringReplace(s, TEXT("\n"), TEXT("")); s = stringReplace(s, TEXT("\n"), TEXT(""));
const unsigned int firstColon = s.find(TEXT(':')); const auto firstColon = s.find(TEXT(':'));
if (firstColon == std::string::npos) if (firstColon == std::string::npos)
{ {
// Should never happen. // Should never happen.
@ -2811,8 +2810,8 @@ void Finder::copy()
{ {
size_t fromLine, toLine; size_t fromLine, toLine;
{ {
const int selStart = _scintView.execute(SCI_GETSELECTIONSTART); const auto selStart = _scintView.execute(SCI_GETSELECTIONSTART);
const int selEnd = _scintView.execute(SCI_GETSELECTIONEND); const auto selEnd = _scintView.execute(SCI_GETSELECTIONEND);
const bool hasSelection = selStart != selEnd; const bool hasSelection = selStart != selEnd;
const pair<int, int> lineRange = _scintView.getSelectionLinesRange(); const pair<int, int> lineRange = _scintView.getSelectionLinesRange();
if (hasSelection && lineRange.first != lineRange.second) if (hasSelection && lineRange.first != lineRange.second)
@ -2878,9 +2877,9 @@ void Finder::finishFilesSearch(int count, bool isMatchLines)
_pMainFoundInfos = _pOldFoundInfos; _pMainFoundInfos = _pOldFoundInfos;
_pMainMarkings = _pOldMarkings; _pMainMarkings = _pOldMarkings;
_MarkingsStruct._length = _pMainMarkings->size(); _markingsStruct._length = static_cast<long>(_pMainMarkings->size());
if (_pMainMarkings->size() > 0) if (_pMainMarkings->size() > 0)
_MarkingsStruct._markings = &((*_pMainMarkings)[0]); _markingsStruct._markings = &((*_pMainMarkings)[0]);
addSearchHitCount(count, isMatchLines); addSearchHitCount(count, isMatchLines);
_scintView.execute(SCI_SETSEL, 0, 0); _scintView.execute(SCI_SETSEL, 0, 0);
@ -3514,8 +3513,8 @@ RECT Progress::adjustSizeAndPos(int width, int height)
win.right = win.left + width; win.right = win.left + width;
win.bottom = win.top + height; win.bottom = win.top + height;
::AdjustWindowRectEx(&win, ::GetWindowLongPtr(_hwnd, GWL_STYLE), DWORD style = static_cast<DWORD>(::GetWindowLongPtr(_hwnd, GWL_EXSTYLE));
FALSE, ::GetWindowLongPtr(_hwnd, GWL_EXSTYLE)); ::AdjustWindowRectEx(&win, static_cast<DWORD>(::GetWindowLongPtr(_hwnd, GWL_STYLE)), FALSE, style);
width = win.right - win.left; width = win.right - win.left;
height = win.bottom - win.top; height = win.bottom - win.top;

View File

@ -120,8 +120,8 @@ class Finder : public DockingDlgInterface {
friend class FindReplaceDlg; friend class FindReplaceDlg;
public: public:
Finder() : DockingDlgInterface(IDD_FINDRESULT), _pMainFoundInfos(&_foundInfos1), _pMainMarkings(&_markings1) { Finder() : DockingDlgInterface(IDD_FINDRESULT), _pMainFoundInfos(&_foundInfos1), _pMainMarkings(&_markings1) {
_MarkingsStruct._length = 0; _markingsStruct._length = 0;
_MarkingsStruct._markings = NULL; _markingsStruct._markings = NULL;
}; };
~Finder() { ~Finder() {
@ -144,8 +144,8 @@ public:
void beginNewFilesSearch(); void beginNewFilesSearch();
void finishFilesSearch(int count, bool isMatchLines = false); void finishFilesSearch(int count, bool isMatchLines = false);
void gotoNextFoundResult(int direction); void gotoNextFoundResult(int direction);
void GotoFoundLine(); void gotoFoundLine();
void DeleteResult(); void deleteResult();
std::vector<generic_string> getResultFilePaths() const; std::vector<generic_string> getResultFilePaths() const;
bool canFind(const TCHAR *fileName, size_t lineNumber) const; bool canFind(const TCHAR *fileName, size_t lineNumber) const;
void setVolatiled(bool val) { _canBeVolatiled = val; }; void setVolatiled(bool val) { _canBeVolatiled = val; };
@ -165,7 +165,7 @@ private:
std::vector<SearchResultMarking> _markings1; std::vector<SearchResultMarking> _markings1;
std::vector<SearchResultMarking> _markings2; std::vector<SearchResultMarking> _markings2;
std::vector<SearchResultMarking>* _pMainMarkings; std::vector<SearchResultMarking>* _pMainMarkings;
SearchResultMarkings _MarkingsStruct; SearchResultMarkings _markingsStruct;
ScintillaEditView _scintView; ScintillaEditView _scintView;
unsigned int _nbFoundFiles = 0; unsigned int _nbFoundFiles = 0;
@ -390,7 +390,7 @@ private :
}; };
void gotoCorrectTab() { void gotoCorrectTab() {
int currentIndex = _tab.getCurrentTabIndex(); auto currentIndex = _tab.getCurrentTabIndex();
if (currentIndex != _currentStatus) if (currentIndex != _currentStatus)
_tab.activateAt(_currentStatus); _tab.activateAt(_currentStatus);
}; };
@ -408,7 +408,7 @@ private :
static const int FR_OP_REPLACE = 2; static const int FR_OP_REPLACE = 2;
static const int FR_OP_FIF = 4; static const int FR_OP_FIF = 4;
static const int FR_OP_GLOBAL = 8; static const int FR_OP_GLOBAL = 8;
void saveInMacro(int cmd, int cmdType); void saveInMacro(size_t cmd, int cmdType);
void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
}; };

View File

@ -91,14 +91,16 @@ void FunctionCallTip::setLanguageXML(TiXmlElement * pXmlKeyword) {
_funcName = 0; _funcName = 0;
} }
bool FunctionCallTip::updateCalltip(int ch, bool needShown) { bool FunctionCallTip::updateCalltip(int ch, bool needShown)
if (!needShown && ch != _start && !isVisible()) //must be already visible {
if (not needShown && ch != _start && not isVisible()) //must be already visible
return false; return false;
_curPos = _pEditView->execute(SCI_GETCURRENTPOS); _curPos = static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS));
//recalculate everything //recalculate everything
if (!getCursorFunction()) { //cannot display calltip (anymore) if (not getCursorFunction())
{ //cannot display calltip (anymore)
close(); close();
return false; return false;
} }
@ -132,9 +134,9 @@ void FunctionCallTip::close()
bool FunctionCallTip::getCursorFunction() bool FunctionCallTip::getCursorFunction()
{ {
int line = _pEditView->execute(SCI_LINEFROMPOSITION, _curPos); auto line = _pEditView->execute(SCI_LINEFROMPOSITION, _curPos);
int startpos = _pEditView->execute(SCI_POSITIONFROMLINE, line); int startpos = static_cast<int32_t>(_pEditView->execute(SCI_POSITIONFROMLINE, line));
int endpos = _pEditView->execute(SCI_GETLINEENDPOSITION, line); int endpos = static_cast<int32_t>(_pEditView->execute(SCI_GETLINEENDPOSITION, line));
int len = endpos - startpos + 3; //also take CRLF in account, even if not there int len = endpos - startpos + 3; //also take CRLF in account, even if not there
int offset = _curPos - startpos; //offset is cursor location, only stuff before cursor has influence int offset = _curPos - startpos; //offset is cursor location, only stuff before cursor has influence
const int maxLen = 256; const int maxLen = 256;
@ -163,7 +165,8 @@ bool FunctionCallTip::getCursorFunction()
{ {
tokenLen = 0; tokenLen = 0;
TCHAR * begin = lineData+i; TCHAR * begin = lineData+i;
while ((isBasicWordChar(ch) || isAdditionalWordChar(ch)) && i < offset) { while ((isBasicWordChar(ch) || isAdditionalWordChar(ch)) && i < offset)
{
++tokenLen; ++tokenLen;
++i; ++i;
ch = lineData[i]; ch = lineData[i];
@ -195,9 +198,12 @@ bool FunctionCallTip::getCursorFunction()
for (size_t i = 0; i < vsize; ++i) for (size_t i = 0; i < vsize; ++i)
{ {
Token & curToken = tokenVector.at(i); Token & curToken = tokenVector.at(i);
if (curToken.isIdentifier) { if (curToken.isIdentifier)
curValue.lastIdentifier = i; {
} else { curValue.lastIdentifier = static_cast<int32_t>(i);
}
else
{
if (curToken.token[0] == _start) if (curToken.token[0] == _start)
{ {
++scopeLevel; ++scopeLevel;
@ -205,25 +211,37 @@ bool FunctionCallTip::getCursorFunction()
valueVec.push_back(newValue); //store the current settings, so when this new function doesnt happen to be the 'real' one, we can restore everything valueVec.push_back(newValue); //store the current settings, so when this new function doesnt happen to be the 'real' one, we can restore everything
curValue.scopeLevel = scopeLevel; curValue.scopeLevel = scopeLevel;
if (i > 0 && curValue.lastIdentifier == int(i)-1) { //identifier must be right before (, else we have some expression like "( x + y() )" if (i > 0 && curValue.lastIdentifier == static_cast<int32_t>(i) - 1)
{ //identifier must be right before (, else we have some expression like "( x + y() )"
curValue.lastFunctionIdentifier = curValue.lastIdentifier; curValue.lastFunctionIdentifier = curValue.lastIdentifier;
curValue.param = 0; curValue.param = 0;
} else { //some expression }
else
{ //some expression
curValue.lastFunctionIdentifier = -1; curValue.lastFunctionIdentifier = -1;
} }
} else if (curToken.token[0] == _param && curValue.lastFunctionIdentifier > -1) { }
else if (curToken.token[0] == _param && curValue.lastFunctionIdentifier > -1)
{
++curValue.param; ++curValue.param;
} else if (curToken.token[0] == _stop) { }
else if (curToken.token[0] == _stop)
{
if (scopeLevel) //scope cannot go below -1 if (scopeLevel) //scope cannot go below -1
scopeLevel--; scopeLevel--;
if (valueVec.size() > 0) { //only pop level if scope was of actual function if (valueVec.size() > 0)
{ //only pop level if scope was of actual function
curValue = valueVec.back(); curValue = valueVec.back();
valueVec.pop_back(); valueVec.pop_back();
} else { }
else
{
//invalidate curValue //invalidate curValue
curValue = FunctionValues(); curValue = FunctionValues();
} }
} else if (curToken.token[0] == _terminal) { }
else if (curToken.token[0] == _terminal)
{
//invalidate everything //invalidate everything
valueVec.clear(); valueVec.clear();
curValue = FunctionValues(); curValue = FunctionValues();
@ -233,32 +251,40 @@ bool FunctionCallTip::getCursorFunction()
bool res = false; bool res = false;
if (curValue.lastFunctionIdentifier == -1) { //not in direct function. Start popping the stack untill we empty it, or a func IS found if (curValue.lastFunctionIdentifier == -1)
while(curValue.lastFunctionIdentifier == -1 && valueVec.size() > 0) { { //not in direct function. Start popping the stack untill we empty it, or a func IS found
while(curValue.lastFunctionIdentifier == -1 && valueVec.size() > 0)
{
curValue = valueVec.back(); curValue = valueVec.back();
valueVec.pop_back(); valueVec.pop_back();
} }
} }
if (curValue.lastFunctionIdentifier > -1) { if (curValue.lastFunctionIdentifier > -1)
{
Token funcToken = tokenVector.at(curValue.lastFunctionIdentifier); Token funcToken = tokenVector.at(curValue.lastFunctionIdentifier);
funcToken.token[funcToken.length] = 0; funcToken.token[funcToken.length] = 0;
_currentParam = curValue.param; _currentParam = curValue.param;
bool same = false; bool same = false;
if (_funcName) { if (_funcName)
{
if(_ignoreCase) if(_ignoreCase)
same = testNameNoCase(_funcName, funcToken.token, lstrlen(_funcName)) == 0; same = testNameNoCase(_funcName, funcToken.token, lstrlen(_funcName)) == 0;
else else
same = generic_strncmp(_funcName, funcToken.token, lstrlen(_funcName)) == 0; same = generic_strncmp(_funcName, funcToken.token, lstrlen(_funcName)) == 0;
} }
if (!same) { //check if we need to reload data if (!same)
if (_funcName) { { //check if we need to reload data
if (_funcName)
{
delete [] _funcName; delete [] _funcName;
} }
_funcName = new TCHAR[funcToken.length+1]; _funcName = new TCHAR[funcToken.length+1];
lstrcpy(_funcName, funcToken.token); lstrcpy(_funcName, funcToken.token);
res = loadFunction(); res = loadFunction();
} else { }
else
{
res = true; res = true;
} }
} }
@ -276,7 +302,7 @@ bool FunctionCallTip::loadFunction()
//Iterate through all keywords and find the correct function keyword //Iterate through all keywords and find the correct function keyword
TiXmlElement *funcNode = _pXmlKeyword; TiXmlElement *funcNode = _pXmlKeyword;
for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")))
{ {
const TCHAR * name = NULL; const TCHAR * name = NULL;
name = funcNode->Attribute(TEXT("name")); name = funcNode->Attribute(TEXT("name"));
@ -359,12 +385,15 @@ void FunctionCallTip::showCalltip()
//Check if the current overload still holds. If the current param exceeds amounti n overload, see if another one fits better (enough params) //Check if the current overload still holds. If the current param exceeds amounti n overload, see if another one fits better (enough params)
stringVec & params = _overloads.at(_currentOverload); stringVec & params = _overloads.at(_currentOverload);
size_t psize = params.size()+1; size_t psize = params.size()+1;
if ((size_t)_currentParam >= psize) { if ((size_t)_currentParam >= psize)
{
size_t osize = _overloads.size(); size_t osize = _overloads.size();
for(size_t i = 0; i < osize; ++i) { for(size_t i = 0; i < osize; ++i)
{
psize = _overloads.at(i).size()+1; psize = _overloads.at(i).size()+1;
if ((size_t)_currentParam < psize) { if ((size_t)_currentParam < psize)
_currentOverload = i; {
_currentOverload = static_cast<int32_t>(i);
break; break;
} }
} }

View File

@ -55,11 +55,14 @@ INT_PTR CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{ {
display(false); display(false);
cleanLineEdit(); cleanLineEdit();
if (_mode == go2line) { if (_mode == go2line)
{
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, line-1); (*_ppEditView)->execute(SCI_ENSUREVISIBLE, line-1);
(*_ppEditView)->execute(SCI_GOTOLINE, line-1); (*_ppEditView)->execute(SCI_GOTOLINE, line-1);
} else { }
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, line); else
{
auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, line);
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line); (*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
(*_ppEditView)->execute(SCI_GOTOPOS, line); (*_ppEditView)->execute(SCI_GOTOPOS, line);
} }

View File

@ -213,13 +213,13 @@ size_t Printer::doPrint(bool justDoIt)
{ {
if (_startPos > _endPos) if (_startPos > _endPos)
{ {
lengthPrinted = _endPos; lengthPrinted = static_cast<long>(_endPos);
lengthDoc = _startPos; lengthDoc = static_cast<long>(_startPos);
} }
else else
{ {
lengthPrinted = _startPos; lengthPrinted = static_cast<long>(_startPos);
lengthDoc = _endPos; lengthDoc = static_cast<long>(_endPos);
} }
if (lengthPrinted < 0) if (lengthPrinted < 0)

View File

@ -44,7 +44,7 @@ int ScintillaCtrls::getIndexFrom(HWND handle2Find)
{ {
if (_scintVector[i]->getHSelf() == handle2Find) if (_scintVector[i]->getHSelf() == handle2Find)
{ {
return i; return static_cast<int32_t>(i);
} }
} }
return -1; return -1;

View File

@ -39,7 +39,7 @@ using namespace std;
// get full ScinLexer.dll path to avoid hijack // get full ScinLexer.dll path to avoid hijack
TCHAR * getSciLexerFullPathName(TCHAR * moduleFileName, size_t len){ TCHAR * getSciLexerFullPathName(TCHAR * moduleFileName, size_t len){
::GetModuleFileName(NULL, moduleFileName, len); ::GetModuleFileName(NULL, moduleFileName, static_cast<int32_t>(len));
::PathRemoveFileSpec(moduleFileName); ::PathRemoveFileSpec(moduleFileName);
::PathAppend(moduleFileName, TEXT("SciLexer.dll")); ::PathAppend(moduleFileName, TEXT("SciLexer.dll"));
return moduleFileName; return moduleFileName;
@ -340,7 +340,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
// get the codepage of the text // get the codepage of the text
unsigned int codepage = execute(SCI_GETCODEPAGE); UINT codepage = static_cast<UINT>(execute(SCI_GETCODEPAGE));
// get the current text selection // get the current text selection
@ -1560,8 +1560,8 @@ BufferID ScintillaEditView::attachDefaultDoc()
void ScintillaEditView::saveCurrentPos() void ScintillaEditView::saveCurrentPos()
{ {
//Save data so, that the current topline becomes visible again after restoring. //Save data so, that the current topline becomes visible again after restoring.
int displayedLine = static_cast<int>(execute(SCI_GETFIRSTVISIBLELINE)); int32_t displayedLine = static_cast<int32_t>(execute(SCI_GETFIRSTVISIBLELINE));
int docLine = execute(SCI_DOCLINEFROMVISIBLE, displayedLine); //linenumber of the line displayed in the top int32_t docLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, displayedLine)); //linenumber of the line displayed in the top
//int offset = displayedLine - execute(SCI_VISIBLEFROMDOCLINE, docLine); //use this to calc offset of wrap. If no wrap this should be zero //int offset = displayedLine - execute(SCI_VISIBLEFROMDOCLINE, docLine); //use this to calc offset of wrap. If no wrap this should be zero
Buffer * buf = MainFileManager->getBufferByID(_currentBufferID); Buffer * buf = MainFileManager->getBufferByID(_currentBufferID);
@ -1572,8 +1572,8 @@ void ScintillaEditView::saveCurrentPos()
pos._startPos = static_cast<int>(execute(SCI_GETANCHOR)); pos._startPos = static_cast<int>(execute(SCI_GETANCHOR));
pos._endPos = static_cast<int>(execute(SCI_GETCURRENTPOS)); pos._endPos = static_cast<int>(execute(SCI_GETCURRENTPOS));
pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET)); pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET));
pos._selMode = execute(SCI_GETSELECTIONMODE); pos._selMode = static_cast<int32_t>(execute(SCI_GETSELECTIONMODE));
pos._scrollWidth = execute(SCI_GETSCROLLWIDTH); pos._scrollWidth = static_cast<int32_t>(execute(SCI_GETSCROLLWIDTH));
buf->setPosition(pos, this); buf->setPosition(pos, this);
} }
@ -1595,7 +1595,7 @@ void ScintillaEditView::restoreCurrentPos()
} }
execute(SCI_CHOOSECARETX); // choose current x position execute(SCI_CHOOSECARETX); // choose current x position
int lineToShow = execute(SCI_VISIBLEFROMDOCLINE, pos._firstVisibleLine); int lineToShow = static_cast<int32_t>(execute(SCI_VISIBLEFROMDOCLINE, pos._firstVisibleLine));
scroll(0, lineToShow); scroll(0, lineToShow);
} }
@ -1654,7 +1654,7 @@ void ScintillaEditView::activateBuffer(BufferID buffer)
bufferUpdated(_currentBuffer, (BufferChangeMask & ~BufferChangeLanguage)); //everything should be updated, but the language (which undoes some operations done here like folding) bufferUpdated(_currentBuffer, (BufferChangeMask & ~BufferChangeLanguage)); //everything should be updated, but the language (which undoes some operations done here like folding)
//setup line number margin //setup line number margin
int numLines = execute(SCI_GETLINECOUNT); int numLines = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
char numLineStr[32]; char numLineStr[32];
itoa(numLines, numLineStr, 10); itoa(numLines, numLineStr, 10);
@ -1667,10 +1667,10 @@ void ScintillaEditView::getCurrentFoldStates(std::vector<size_t> & lineStateVect
{ {
//-- FLS: xCodeOptimization1304: For active document get folding state from Scintilla. //-- FLS: xCodeOptimization1304: For active document get folding state from Scintilla.
//-- The code using SCI_CONTRACTEDFOLDNEXT is usually 10%-50% faster than checking each line of the document!! //-- The code using SCI_CONTRACTEDFOLDNEXT is usually 10%-50% faster than checking each line of the document!!
int contractedFoldHeaderLine = 0; size_t contractedFoldHeaderLine = 0;
do { do {
contractedFoldHeaderLine = execute(SCI_CONTRACTEDFOLDNEXT, contractedFoldHeaderLine); contractedFoldHeaderLine = static_cast<size_t>(execute(SCI_CONTRACTEDFOLDNEXT, contractedFoldHeaderLine));
if (contractedFoldHeaderLine != -1) if (contractedFoldHeaderLine != -1)
{ {
//-- Store contracted line //-- Store contracted line
@ -1683,10 +1683,10 @@ void ScintillaEditView::getCurrentFoldStates(std::vector<size_t> & lineStateVect
void ScintillaEditView::syncFoldStateWith(const std::vector<size_t> & lineStateVectorNew) void ScintillaEditView::syncFoldStateWith(const std::vector<size_t> & lineStateVectorNew)
{ {
int nbLineState = lineStateVectorNew.size(); size_t nbLineState = lineStateVectorNew.size();
for (int i = 0 ; i < nbLineState ; ++i) for (size_t i = 0 ; i < nbLineState ; ++i)
{ {
int line = lineStateVectorNew.at(i); auto line = lineStateVectorNew.at(i);
fold(line, false); fold(line, false);
} }
} }
@ -1745,11 +1745,11 @@ void ScintillaEditView::collapse(int level2Collapse, bool mode)
{ {
execute(SCI_COLOURISE, 0, -1); execute(SCI_COLOURISE, 0, -1);
int maxLine = execute(SCI_GETLINECOUNT); int maxLine = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
for (int line = 0; line < maxLine; ++line) for (int line = 0; line < maxLine; ++line)
{ {
int level = execute(SCI_GETFOLDLEVEL, line); int level = static_cast<int32_t>(execute(SCI_GETFOLDLEVEL, line));
if (level & SC_FOLDLEVELHEADERFLAG) if (level & SC_FOLDLEVELHEADERFLAG)
{ {
level -= SC_FOLDLEVELBASE; level -= SC_FOLDLEVELBASE;
@ -1766,26 +1766,26 @@ void ScintillaEditView::collapse(int level2Collapse, bool mode)
void ScintillaEditView::foldCurrentPos(bool mode) void ScintillaEditView::foldCurrentPos(bool mode)
{ {
int currentLine = this->getCurrentLineNumber(); auto currentLine = this->getCurrentLineNumber();
fold(currentLine, mode); fold(currentLine, mode);
} }
void ScintillaEditView::fold(int line, bool mode) void ScintillaEditView::fold(size_t line, bool mode)
{ {
int endStyled = execute(SCI_GETENDSTYLED); auto endStyled = execute(SCI_GETENDSTYLED);
int len = execute(SCI_GETTEXTLENGTH); auto len = execute(SCI_GETTEXTLENGTH);
if (endStyled < len) if (endStyled < len)
execute(SCI_COLOURISE, 0, -1); execute(SCI_COLOURISE, 0, -1);
int headerLine; int headerLine;
int level = execute(SCI_GETFOLDLEVEL, line); auto level = execute(SCI_GETFOLDLEVEL, line);
if (level & SC_FOLDLEVELHEADERFLAG) if (level & SC_FOLDLEVELHEADERFLAG)
headerLine = line; headerLine = static_cast<int32_t>(line);
else else
{ {
headerLine = execute(SCI_GETFOLDPARENT, line); headerLine = static_cast<int32_t>(execute(SCI_GETFOLDPARENT, line));
if (headerLine == -1) if (headerLine == -1)
return; return;
} }
@ -1807,30 +1807,30 @@ void ScintillaEditView::fold(int line, bool mode)
void ScintillaEditView::foldAll(bool mode) void ScintillaEditView::foldAll(bool mode)
{ {
int maxLine = execute(SCI_GETLINECOUNT); auto maxLine = execute(SCI_GETLINECOUNT);
for (int line = 0; line < maxLine; ++line) for (int line = 0; line < maxLine; ++line)
{ {
int level = execute(SCI_GETFOLDLEVEL, line); auto level = execute(SCI_GETFOLDLEVEL, line);
if (level & SC_FOLDLEVELHEADERFLAG) if (level & SC_FOLDLEVELHEADERFLAG)
if (isFolded(line) != mode) if (isFolded(line) != mode)
fold(line, mode); fold(line, mode);
} }
} }
void ScintillaEditView::getText(char *dest, int start, int end) const void ScintillaEditView::getText(char *dest, size_t start, size_t end) const
{ {
TextRange tr; TextRange tr;
tr.chrg.cpMin = start; tr.chrg.cpMin = static_cast<long>(start);
tr.chrg.cpMax = end; tr.chrg.cpMax = static_cast<long>(end);
tr.lpstrText = dest; tr.lpstrText = dest;
execute(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&tr)); execute(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&tr));
} }
generic_string ScintillaEditView::getGenericTextAsString(int start, int end) const generic_string ScintillaEditView::getGenericTextAsString(size_t start, size_t end) const
{ {
assert(end > start); assert(end > start);
const int bufSize = end - start + 1; const size_t bufSize = end - start + 1;
TCHAR *buf = new TCHAR[bufSize]; TCHAR *buf = new TCHAR[bufSize];
getGenericText(buf, bufSize, start, end); getGenericText(buf, bufSize, start, end);
generic_string text = buf; generic_string text = buf;
@ -1838,12 +1838,12 @@ generic_string ScintillaEditView::getGenericTextAsString(int start, int end) con
return text; return text;
} }
void ScintillaEditView::getGenericText(TCHAR *dest, size_t destlen, int start, int end) const void ScintillaEditView::getGenericText(TCHAR *dest, size_t destlen, size_t start, size_t end) const
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
char *destA = new char[end - start + 1]; char *destA = new char[end - start + 1];
getText(destA, start, end); getText(destA, start, end);
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const TCHAR *destW = wmc->char2wchar(destA, cp); const TCHAR *destW = wmc->char2wchar(destA, cp);
_tcsncpy_s(dest, destlen, destW, _TRUNCATE); _tcsncpy_s(dest, destlen, destW, _TRUNCATE);
delete [] destA; delete [] destA;
@ -1857,16 +1857,16 @@ void ScintillaEditView::getGenericText(TCHAR *dest, size_t destlen, int start, i
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
char *destA = new char[end - start + 1]; char *destA = new char[end - start + 1];
getText(destA, start, end); getText(destA, start, end);
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE)) ;
const TCHAR *destW = wmc->char2wchar(destA, cp, mstart, mend); const TCHAR *destW = wmc->char2wchar(destA, cp, mstart, mend);
_tcsncpy_s(dest, destlen, destW, _TRUNCATE); _tcsncpy_s(dest, destlen, destW, _TRUNCATE);
delete [] destA; delete [] destA;
} }
void ScintillaEditView::insertGenericTextFrom(int position, const TCHAR *text2insert) const void ScintillaEditView::insertGenericTextFrom(size_t position, const TCHAR *text2insert) const
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *text2insertA = wmc->wchar2char(text2insert, cp); const char *text2insertA = wmc->wchar2char(text2insert, cp);
execute(SCI_INSERTTEXT, position, (WPARAM)text2insertA); execute(SCI_INSERTTEXT, position, (WPARAM)text2insertA);
} }
@ -1880,12 +1880,14 @@ void ScintillaEditView::getVisibleStartAndEndPosition(int * startPos, int * endP
{ {
assert(startPos != NULL && endPos != NULL); assert(startPos != NULL && endPos != NULL);
int firstVisibleLine = execute(SCI_GETFIRSTVISIBLELINE); auto firstVisibleLine = execute(SCI_GETFIRSTVISIBLELINE);
*startPos = execute(SCI_POSITIONFROMLINE, execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLine)); *startPos = static_cast<int32_t>(execute(SCI_POSITIONFROMLINE, execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLine)));
int linesOnScreen = execute(SCI_LINESONSCREEN); auto linesOnScreen = execute(SCI_LINESONSCREEN);
int lineCount = execute(SCI_GETLINECOUNT); auto lineCount = execute(SCI_GETLINECOUNT);
*endPos = execute(SCI_POSITIONFROMLINE, execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLine + min(linesOnScreen, lineCount))); auto visibleLine = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLine + min(linesOnScreen, lineCount));
if (*endPos == -1) *endPos = execute(SCI_GETLENGTH); *endPos = static_cast<int32_t>(execute(SCI_POSITIONFROMLINE, visibleLine));
if (*endPos == -1)
*endPos = static_cast<int32_t>(execute(SCI_GETLENGTH));
} }
char * ScintillaEditView::getWordFromRange(char * txt, int size, int pos1, int pos2) char * ScintillaEditView::getWordFromRange(char * txt, int size, int pos1, int pos2)
@ -1918,7 +1920,7 @@ char * ScintillaEditView::getWordOnCaretPos(char * txt, int size)
TCHAR * ScintillaEditView::getGenericWordOnCaretPos(TCHAR * txt, int size) TCHAR * ScintillaEditView::getGenericWordOnCaretPos(TCHAR * txt, int size)
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
char *txtA = new char[size + 1]; char *txtA = new char[size + 1];
getWordOnCaretPos(txtA, size); getWordOnCaretPos(txtA, size);
@ -1949,7 +1951,7 @@ char * ScintillaEditView::getSelectedText(char * txt, int size, bool expand)
TCHAR * ScintillaEditView::getGenericSelectedText(TCHAR * txt, int size, bool expand) TCHAR * ScintillaEditView::getGenericSelectedText(TCHAR * txt, int size, bool expand)
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
char *txtA = new char[size + 1]; char *txtA = new char[size + 1];
getSelectedText(txtA, size, expand); getSelectedText(txtA, size, expand);
@ -1959,23 +1961,22 @@ TCHAR * ScintillaEditView::getGenericSelectedText(TCHAR * txt, int size, bool ex
return txt; return txt;
} }
int ScintillaEditView::searchInTarget(const TCHAR * text2Find, int lenOfText2Find, int fromPos, int toPos) const int ScintillaEditView::searchInTarget(const TCHAR * text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const
{ {
execute(SCI_SETTARGETRANGE, fromPos, toPos); execute(SCI_SETTARGETRANGE, fromPos, toPos);
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *text2FindA = wmc->wchar2char(text2Find, cp); const char *text2FindA = wmc->wchar2char(text2Find, cp);
size_t text2FindALen = strlen(text2FindA); size_t text2FindALen = strlen(text2FindA);
int len = (lenOfText2Find > (int)text2FindALen)?lenOfText2Find:text2FindALen; size_t len = (lenOfText2Find > text2FindALen) ? lenOfText2Find : text2FindALen;
int targetFound = execute(SCI_SEARCHINTARGET, (WPARAM)len, (LPARAM)text2FindA); return static_cast<int32_t>(execute(SCI_SEARCHINTARGET, (WPARAM)len, (LPARAM)text2FindA));
return targetFound;
} }
void ScintillaEditView::appandGenericText(const TCHAR * text2Append) const void ScintillaEditView::appandGenericText(const TCHAR * text2Append) const
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *text2AppendA =wmc->wchar2char(text2Append, cp); const char *text2AppendA =wmc->wchar2char(text2Append, cp);
execute(SCI_APPENDTEXT, strlen(text2AppendA), (LPARAM)text2AppendA); execute(SCI_APPENDTEXT, strlen(text2AppendA), (LPARAM)text2AppendA);
} }
@ -1983,7 +1984,7 @@ void ScintillaEditView::appandGenericText(const TCHAR * text2Append) const
void ScintillaEditView::addGenericText(const TCHAR * text2Append) const void ScintillaEditView::addGenericText(const TCHAR * text2Append) const
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *text2AppendA =wmc->wchar2char(text2Append, cp); const char *text2AppendA =wmc->wchar2char(text2Append, cp);
execute(SCI_ADDTEXT, strlen(text2AppendA), (LPARAM)text2AppendA); execute(SCI_ADDTEXT, strlen(text2AppendA), (LPARAM)text2AppendA);
} }
@ -1991,21 +1992,21 @@ void ScintillaEditView::addGenericText(const TCHAR * text2Append) const
void ScintillaEditView::addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const void ScintillaEditView::addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *text2AppendA =wmc->wchar2char(text2Append, cp, mstart, mend); const char *text2AppendA =wmc->wchar2char(text2Append, cp, mstart, mend);
execute(SCI_ADDTEXT, strlen(text2AppendA), (LPARAM)text2AppendA); execute(SCI_ADDTEXT, strlen(text2AppendA), (LPARAM)text2AppendA);
} }
int ScintillaEditView::replaceTarget(const TCHAR * str2replace, int fromTargetPos, int toTargetPos) const int32_t ScintillaEditView::replaceTarget(const TCHAR * str2replace, int fromTargetPos, int toTargetPos) const
{ {
if (fromTargetPos != -1 || toTargetPos != -1) if (fromTargetPos != -1 || toTargetPos != -1)
{ {
execute(SCI_SETTARGETRANGE, fromTargetPos, toTargetPos); execute(SCI_SETTARGETRANGE, fromTargetPos, toTargetPos);
} }
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *str2replaceA = wmc->wchar2char(str2replace, cp); const char *str2replaceA = wmc->wchar2char(str2replace, cp);
return execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)str2replaceA); return static_cast<int32_t>(execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)str2replaceA));
} }
int ScintillaEditView::replaceTargetRegExMode(const TCHAR * re, int fromTargetPos, int toTargetPos) const int ScintillaEditView::replaceTargetRegExMode(const TCHAR * re, int fromTargetPos, int toTargetPos) const
@ -2015,15 +2016,15 @@ int ScintillaEditView::replaceTargetRegExMode(const TCHAR * re, int fromTargetPo
execute(SCI_SETTARGETRANGE, fromTargetPos, toTargetPos); execute(SCI_SETTARGETRANGE, fromTargetPos, toTargetPos);
} }
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *reA = wmc->wchar2char(re, cp); const char *reA = wmc->wchar2char(re, cp);
return execute(SCI_REPLACETARGETRE, (WPARAM)-1, (LPARAM)reA); return static_cast<int32_t>(execute(SCI_REPLACETARGETRE, (WPARAM)-1, (LPARAM)reA));
} }
void ScintillaEditView::showAutoComletion(int lenEntered, const TCHAR* list) void ScintillaEditView::showAutoComletion(size_t lenEntered, const TCHAR* list)
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *listA = wmc->wchar2char(list, cp); const char *listA = wmc->wchar2char(list, cp);
execute(SCI_AUTOCSHOW, lenEntered, WPARAM(listA)); execute(SCI_AUTOCSHOW, lenEntered, WPARAM(listA));
} }
@ -2031,24 +2032,24 @@ void ScintillaEditView::showAutoComletion(int lenEntered, const TCHAR* list)
void ScintillaEditView::showCallTip(int startPos, const TCHAR * def) void ScintillaEditView::showCallTip(int startPos, const TCHAR * def)
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *defA = wmc->wchar2char(def, cp); const char *defA = wmc->wchar2char(def, cp);
execute(SCI_CALLTIPSHOW, startPos, LPARAM(defA)); execute(SCI_CALLTIPSHOW, startPos, LPARAM(defA));
} }
generic_string ScintillaEditView::getLine(int lineNumber) generic_string ScintillaEditView::getLine(size_t lineNumber)
{ {
int lineLen = execute(SCI_LINELENGTH, lineNumber); int32_t lineLen = static_cast<int32_t>(execute(SCI_LINELENGTH, lineNumber));
const int bufSize = lineLen + 1; const int bufSize = lineLen + 1;
std::unique_ptr<TCHAR[]> buf = std::make_unique<TCHAR[]>(bufSize); std::unique_ptr<TCHAR[]> buf = std::make_unique<TCHAR[]>(bufSize);
getLine(lineNumber, buf.get(), bufSize); getLine(lineNumber, buf.get(), bufSize);
return buf.get(); return buf.get();
} }
void ScintillaEditView::getLine(int lineNumber, TCHAR * line, int lineBufferLen) void ScintillaEditView::getLine(size_t lineNumber, TCHAR * line, int lineBufferLen)
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
char *lineA = new char[lineBufferLen]; char *lineA = new char[lineBufferLen];
// From Scintilla documentation for SCI_GETLINE: "The buffer is not terminated by a 0 character." // From Scintilla documentation for SCI_GETLINE: "The buffer is not terminated by a 0 character."
memset(lineA, 0x0, sizeof(char) * lineBufferLen); memset(lineA, 0x0, sizeof(char) * lineBufferLen);
@ -2058,16 +2059,16 @@ void ScintillaEditView::getLine(int lineNumber, TCHAR * line, int lineBufferLen)
delete [] lineA; delete [] lineA;
} }
void ScintillaEditView::addText(int length, const char *buf) void ScintillaEditView::addText(size_t length, const char *buf)
{ {
execute(SCI_ADDTEXT, length, (LPARAM)buf); execute(SCI_ADDTEXT, length, (LPARAM)buf);
} }
void ScintillaEditView::beginOrEndSelect() void ScintillaEditView::beginOrEndSelect()
{ {
if(_beginSelectPosition == -1) if (_beginSelectPosition == -1)
{ {
_beginSelectPosition = execute(SCI_GETCURRENTPOS); _beginSelectPosition = static_cast<int32_t>(execute(SCI_GETCURRENTPOS));
} }
else else
{ {
@ -2266,9 +2267,9 @@ void ScintillaEditView::setLineIndent(int line, int indent) const {
if (indent < 0) if (indent < 0)
return; return;
CharacterRange crange = getSelection(); CharacterRange crange = getSelection();
int posBefore = execute(SCI_GETLINEINDENTPOSITION, line); int posBefore = static_cast<int32_t>(execute(SCI_GETLINEINDENTPOSITION, line));
execute(SCI_SETLINEINDENTATION, line, indent); execute(SCI_SETLINEINDENTATION, line, indent);
int posAfter = execute(SCI_GETLINEINDENTPOSITION, line); int32_t posAfter = static_cast<int32_t>(execute(SCI_GETLINEINDENTPOSITION, line));
int posDifference = posAfter - posBefore; int posDifference = posAfter - posBefore;
if (posAfter > posBefore) { if (posAfter > posBefore) {
// Move selection on // Move selection on
@ -2377,11 +2378,11 @@ pair<int, int> ScintillaEditView::getSelectionLinesRange() const
pair<int, int> range(-1, -1); pair<int, int> range(-1, -1);
if (execute(SCI_GETSELECTIONS) > 1) // multi-selection if (execute(SCI_GETSELECTIONS) > 1) // multi-selection
return range; return range;
int start = execute(SCI_GETSELECTIONSTART); int32_t start = static_cast<int32_t>(execute(SCI_GETSELECTIONSTART));
int end = execute(SCI_GETSELECTIONEND); int32_t end = static_cast<int32_t>(execute(SCI_GETSELECTIONEND));
range.first = execute(SCI_LINEFROMPOSITION, start); range.first = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, start));
range.second = execute(SCI_LINEFROMPOSITION, end); range.second = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, end));
return range; return range;
} }
@ -2452,10 +2453,11 @@ void ScintillaEditView::convertSelectedTextTo(bool Case)
size_t selectionStart = execute(SCI_GETSELECTIONSTART); size_t selectionStart = execute(SCI_GETSELECTIONSTART);
size_t selectionEnd = execute(SCI_GETSELECTIONEND); size_t selectionEnd = execute(SCI_GETSELECTIONEND);
int strSize = (selectionEnd - selectionStart) + 1; int32_t strLen = static_cast<int32_t>(selectionEnd - selectionStart);
if (strSize) if (strLen)
{ {
char *selectedStr = new char[strSize+1]; int strSize = strLen + 1;
char *selectedStr = new char[strSize];
int strWSize = strSize * 2; int strWSize = strSize * 2;
wchar_t *selectedStrW = new wchar_t[strWSize+3]; wchar_t *selectedStrW = new wchar_t[strWSize+3];
@ -2473,7 +2475,7 @@ void ScintillaEditView::convertSelectedTextTo(bool Case)
::WideCharToMultiByte(codepage, 0, selectedStrW, strWSize, selectedStr, strSize, NULL, NULL); ::WideCharToMultiByte(codepage, 0, selectedStrW, strWSize, selectedStr, strSize, NULL, NULL);
execute(SCI_SETTARGETRANGE, selectionStart, selectionEnd); execute(SCI_SETTARGETRANGE, selectionStart, selectionEnd);
execute(SCI_REPLACETARGET, strSize - 1, (LPARAM)selectedStr); execute(SCI_REPLACETARGET, strLen, (LPARAM)selectedStr);
execute(SCI_SETSEL, selectionStart, selectionEnd); execute(SCI_SETSEL, selectionStart, selectionEnd);
delete [] selectedStr; delete [] selectedStr;
delete [] selectedStrW; delete [] selectedStrW;
@ -2484,7 +2486,7 @@ void ScintillaEditView::convertSelectedTextTo(bool Case)
pair<int, int> ScintillaEditView::getWordRange() pair<int, int> ScintillaEditView::getWordRange()
{ {
int caretPos = execute(SCI_GETCURRENTPOS, 0, 0); auto caretPos = execute(SCI_GETCURRENTPOS, 0, 0);
int startPos = static_cast<int>(execute(SCI_WORDSTARTPOSITION, caretPos, true)); int startPos = static_cast<int>(execute(SCI_WORDSTARTPOSITION, caretPos, true));
int endPos = static_cast<int>(execute(SCI_WORDENDPOSITION, caretPos, true)); int endPos = static_cast<int>(execute(SCI_WORDENDPOSITION, caretPos, true));
return pair<int, int>(startPos, endPos); return pair<int, int>(startPos, endPos);
@ -2566,14 +2568,14 @@ ColumnModeInfos ScintillaEditView::getColumnModeSelectInfo()
ColumnModeInfos columnModeInfos; ColumnModeInfos columnModeInfos;
if (execute(SCI_GETSELECTIONS) > 1) // Multi-Selection || Column mode if (execute(SCI_GETSELECTIONS) > 1) // Multi-Selection || Column mode
{ {
int nbSel = execute(SCI_GETSELECTIONS); int nbSel = static_cast<int32_t>(execute(SCI_GETSELECTIONS));
for (int i = 0 ; i < nbSel ; ++i) for (int i = 0 ; i < nbSel ; ++i)
{ {
int absPosSelStartPerLine = execute(SCI_GETSELECTIONNANCHOR, i); int absPosSelStartPerLine = static_cast<int32_t>(execute(SCI_GETSELECTIONNANCHOR, i));
int absPosSelEndPerLine = execute(SCI_GETSELECTIONNCARET, i); int absPosSelEndPerLine = static_cast<int32_t>(execute(SCI_GETSELECTIONNCARET, i));
int nbVirtualAnchorSpc = execute(SCI_GETSELECTIONNANCHORVIRTUALSPACE, i); int nbVirtualAnchorSpc = static_cast<int32_t>(execute(SCI_GETSELECTIONNANCHORVIRTUALSPACE, i));
int nbVirtualCaretSpc = execute(SCI_GETSELECTIONNCARETVIRTUALSPACE, i); int nbVirtualCaretSpc = static_cast<int32_t>(execute(SCI_GETSELECTIONNCARETVIRTUALSPACE, i));
if (absPosSelStartPerLine == absPosSelEndPerLine && execute(SCI_SELECTIONISRECTANGLE)) if (absPosSelStartPerLine == absPosSelEndPerLine && execute(SCI_SELECTIONISRECTANGLE))
{ {
@ -2616,7 +2618,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, const TCHAR *str)
execute(SCI_SETTARGETRANGE, cmi[i]._selLpos, cmi[i]._selRpos); execute(SCI_SETTARGETRANGE, cmi[i]._selLpos, cmi[i]._selRpos);
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *strA = wmc->wchar2char(str, cp); const char *strA = wmc->wchar2char(str, cp);
execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)strA); execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)strA);
@ -2670,7 +2672,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, int initial, int in
std::vector<int> numbers; std::vector<int> numbers;
{ {
int curNumber = initial; int curNumber = initial;
const unsigned int kiMaxSize = cmi.size(); const size_t kiMaxSize = cmi.size();
while(numbers.size() < kiMaxSize) while(numbers.size() < kiMaxSize)
{ {
for(int i = 0; i < repeat; i++) for(int i = 0; i < repeat; i++)
@ -2718,7 +2720,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, int initial, int in
execute(SCI_SETTARGETRANGE, cmi[i]._selLpos, cmi[i]._selRpos); execute(SCI_SETTARGETRANGE, cmi[i]._selLpos, cmi[i]._selRpos);
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
const char *strA = wmc->wchar2char(str, cp); const char *strA = wmc->wchar2char(str, cp);
execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)strA); execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)strA);
@ -2764,22 +2766,22 @@ void ScintillaEditView::foldChanged(int line, int levelNow, int levelPrev)
((levelPrev & SC_FOLDLEVELNUMBERMASK) > (levelNow & SC_FOLDLEVELNUMBERMASK))) ((levelPrev & SC_FOLDLEVELNUMBERMASK) > (levelNow & SC_FOLDLEVELNUMBERMASK)))
{ {
// See if should still be hidden // See if should still be hidden
int parentLine = execute(SCI_GETFOLDPARENT, line); int parentLine = static_cast<int32_t>(execute(SCI_GETFOLDPARENT, line));
if ((parentLine < 0) || !isFolded(parentLine && execute(SCI_GETLINEVISIBLE, parentLine))) if ((parentLine < 0) || !isFolded(parentLine && execute(SCI_GETLINEVISIBLE, parentLine)))
execute(SCI_SHOWLINES, line, line); execute(SCI_SHOWLINES, line, line);
} }
} }
void ScintillaEditView::scrollPosToCenter(int pos) void ScintillaEditView::scrollPosToCenter(size_t pos)
{ {
execute(SCI_GOTOPOS, pos); execute(SCI_GOTOPOS, pos);
int line = execute(SCI_LINEFROMPOSITION, pos); int line = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, pos));
int firstVisibleDisplayLine = execute(SCI_GETFIRSTVISIBLELINE); int firstVisibleDisplayLine = static_cast<int32_t>(execute(SCI_GETFIRSTVISIBLELINE));
int firstVisibleDocLine = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine); int firstVisibleDocLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine));
int nbLine = execute(SCI_LINESONSCREEN, firstVisibleDisplayLine); int nbLine = static_cast<int32_t>(execute(SCI_LINESONSCREEN, firstVisibleDisplayLine));
int lastVisibleDocLine = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine); int lastVisibleDocLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine));
int middleLine; int middleLine;
if (line - firstVisibleDocLine < lastVisibleDocLine - line) if (line - firstVisibleDocLine < lastVisibleDocLine - line)
@ -2790,16 +2792,17 @@ void ScintillaEditView::scrollPosToCenter(int pos)
scroll(0, nbLines2scroll); scroll(0, nbLines2scroll);
} }
void ScintillaEditView::hideLines() { void ScintillaEditView::hideLines()
{
//Folding can screw up hide lines badly if it unfolds a hidden section. //Folding can screw up hide lines badly if it unfolds a hidden section.
//Adding runMarkers(hide, foldstart) directly (folding on single document) can help //Adding runMarkers(hide, foldstart) directly (folding on single document) can help
//Special func on buffer. If markers are added, create notification with location of start, and hide bool set to true //Special func on buffer. If markers are added, create notification with location of start, and hide bool set to true
int startLine = execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONSTART)); int startLine = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONSTART)));
int endLine = execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONEND)); int endLine = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONEND)));
//perform range check: cannot hide very first and very last lines //perform range check: cannot hide very first and very last lines
//Offset them one off the edges, and then check if they are within the reasonable //Offset them one off the edges, and then check if they are within the reasonable
int nrLines = execute(SCI_GETLINECOUNT); int nrLines = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
if (nrLines < 3) if (nrLines < 3)
return; //cannot possibly hide anything return; //cannot possibly hide anything
if (!startLine) if (!startLine)
@ -2818,11 +2821,13 @@ void ScintillaEditView::hideLines() {
//remove any markers in between //remove any markers in between
int scope = 0; int scope = 0;
for(int i = startLine; i <= endLine; ++i) { for(int i = startLine; i <= endLine; ++i)
int state = execute(SCI_MARKERGET, i); {
auto state = execute(SCI_MARKERGET, i);
bool closePresent = ((state & (1 << MARK_HIDELINESEND)) != 0); //check close first, then open, since close closes scope bool closePresent = ((state & (1 << MARK_HIDELINESEND)) != 0); //check close first, then open, since close closes scope
bool openPresent = ((state & (1 << MARK_HIDELINESBEGIN)) != 0); bool openPresent = ((state & (1 << MARK_HIDELINESBEGIN)) != 0);
if (closePresent) { if (closePresent)
{
execute(SCI_MARKERDELETE, i, MARK_HIDELINESEND); execute(SCI_MARKERDELETE, i, MARK_HIDELINESEND);
if (scope > 0) scope--; if (scope > 0) scope--;
} }
@ -2831,7 +2836,8 @@ void ScintillaEditView::hideLines() {
++scope; ++scope;
} }
} }
if (scope != 0) { //something went wrong if (scope != 0)
{ //something went wrong
//Someone managed to make overlapping hidelines sections. //Someone managed to make overlapping hidelines sections.
//We cant do anything since this isnt supposed to happen //We cant do anything since this isnt supposed to happen
} }
@ -2839,9 +2845,9 @@ void ScintillaEditView::hideLines() {
_currentBuffer->setHideLineChanged(true, startLine-1); _currentBuffer->setHideLineChanged(true, startLine-1);
} }
bool ScintillaEditView::markerMarginClick(int lineNumber) { bool ScintillaEditView::markerMarginClick(int lineNumber)
{
int state = execute(SCI_MARKERGET, lineNumber); auto state = execute(SCI_MARKERGET, lineNumber);
bool openPresent = ((state & (1 << MARK_HIDELINESBEGIN)) != 0); bool openPresent = ((state & (1 << MARK_HIDELINESBEGIN)) != 0);
bool closePresent = ((state & (1 << MARK_HIDELINESEND)) != 0); bool closePresent = ((state & (1 << MARK_HIDELINESEND)) != 0);
@ -2849,16 +2855,22 @@ bool ScintillaEditView::markerMarginClick(int lineNumber) {
return false; return false;
//Special func on buffer. First call show with location of opening marker. Then remove the marker manually //Special func on buffer. First call show with location of opening marker. Then remove the marker manually
if (openPresent) { if (openPresent)
{
_currentBuffer->setHideLineChanged(false, lineNumber); _currentBuffer->setHideLineChanged(false, lineNumber);
} }
if (closePresent) {
if (closePresent)
{
openPresent = false; openPresent = false;
for(lineNumber--; lineNumber >= 0 && !openPresent; lineNumber--) { for(lineNumber--; lineNumber >= 0 && !openPresent; lineNumber--)
{
state = execute(SCI_MARKERGET, lineNumber); state = execute(SCI_MARKERGET, lineNumber);
openPresent = ((state & (1 << MARK_HIDELINESBEGIN)) != 0); openPresent = ((state & (1 << MARK_HIDELINESBEGIN)) != 0);
} }
if (openPresent) {
if (openPresent)
{
_currentBuffer->setHideLineChanged(false, lineNumber); _currentBuffer->setHideLineChanged(false, lineNumber);
} }
} }
@ -2873,7 +2885,8 @@ void ScintillaEditView::notifyMarkers(Buffer * buf, bool isHide, int location, b
} }
//Run through full document. When switching in or opening folding //Run through full document. When switching in or opening folding
//hide is false only when user click on margin //hide is false only when user click on margin
void ScintillaEditView::runMarkers(bool doHide, int searchStart, bool endOfDoc, bool doDelete) { void ScintillaEditView::runMarkers(bool doHide, int searchStart, bool endOfDoc, bool doDelete)
{
//Removes markers if opening //Removes markers if opening
/* /*
AllLines = (start,ENDOFDOCUMENT) AllLines = (start,ENDOFDOCUMENT)
@ -2900,64 +2913,84 @@ void ScintillaEditView::runMarkers(bool doHide, int searchStart, bool endOfDoc,
Skip to LASTCHILD Skip to LASTCHILD
Set last start to lastchild Set last start to lastchild
*/ */
int maxLines = execute(SCI_GETLINECOUNT); int maxLines = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
if (doHide) { if (doHide)
{
int startHiding = searchStart; int startHiding = searchStart;
bool isInSection = false; bool isInSection = false;
for(int i = searchStart; i < maxLines; ++i) { for (int i = searchStart; i < maxLines; ++i)
int state = execute(SCI_MARKERGET, i); {
if ( ((state & (1 << MARK_HIDELINESEND)) != 0) ) { auto state = execute(SCI_MARKERGET, i);
if (isInSection) { if ( ((state & (1 << MARK_HIDELINESEND)) != 0) )
{
if (isInSection)
{
execute(SCI_HIDELINES, startHiding, i-1); execute(SCI_HIDELINES, startHiding, i-1);
if (!endOfDoc) { if (!endOfDoc)
{
return; //done, only single section requested return; //done, only single section requested
} //otherwise keep going } //otherwise keep going
} }
isInSection = false; isInSection = false;
} }
if ( ((state & (1 << MARK_HIDELINESBEGIN)) != 0) ) { if ( ((state & (1 << MARK_HIDELINESBEGIN)) != 0) )
{
isInSection = true; isInSection = true;
startHiding = i+1; startHiding = i+1;
} }
} }
} else { }
else
{
int startShowing = searchStart; int startShowing = searchStart;
bool isInSection = false; bool isInSection = false;
for(int i = searchStart; i < maxLines; ++i) { for (int i = searchStart; i < maxLines; ++i)
int state = execute(SCI_MARKERGET, i); {
if ( ((state & (1 << MARK_HIDELINESEND)) != 0) ) { auto state = execute(SCI_MARKERGET, i);
if ( ((state & (1 << MARK_HIDELINESEND)) != 0) )
{
if (doDelete) if (doDelete)
execute(SCI_MARKERDELETE, i, MARK_HIDELINESEND); execute(SCI_MARKERDELETE, i, MARK_HIDELINESEND);
else if (isInSection) { else if (isInSection)
if (startShowing >= i) { //because of fold skipping, we passed the close tag. In that case we cant do anything {
if (!endOfDoc) { if (startShowing >= i)
{ //because of fold skipping, we passed the close tag. In that case we cant do anything
if (!endOfDoc)
{
return; return;
} else { }
else
{
continue; continue;
} }
} }
execute(SCI_SHOWLINES, startShowing, i-1); execute(SCI_SHOWLINES, startShowing, i-1);
if (!endOfDoc) { if (!endOfDoc)
{
return; //done, only single section requested return; //done, only single section requested
} //otherwise keep going } //otherwise keep going
isInSection = false; isInSection = false;
} }
} }
if ( ((state & (1 << MARK_HIDELINESBEGIN)) != 0) ) { if ( ((state & (1 << MARK_HIDELINESBEGIN)) != 0) )
{
if (doDelete) if (doDelete)
execute(SCI_MARKERDELETE, i, MARK_HIDELINESBEGIN); execute(SCI_MARKERDELETE, i, MARK_HIDELINESBEGIN);
else { else
{
isInSection = true; isInSection = true;
startShowing = i+1; startShowing = i+1;
} }
} }
int levelLine = execute(SCI_GETFOLDLEVEL, i, 0); auto levelLine = execute(SCI_GETFOLDLEVEL, i, 0);
if (levelLine & SC_FOLDLEVELHEADERFLAG) { //fold section. Dont show lines if fold is closed if (levelLine & SC_FOLDLEVELHEADERFLAG)
if (isInSection && !isFolded(i)) { { //fold section. Dont show lines if fold is closed
if (isInSection && !isFolded(i))
{
execute(SCI_SHOWLINES, startShowing, i); execute(SCI_SHOWLINES, startShowing, i);
startShowing = execute(SCI_GETLASTCHILD, i, (levelLine & SC_FOLDLEVELNUMBERMASK)); //startShowing = execute(SCI_GETLASTCHILD, i, (levelLine & SC_FOLDLEVELNUMBERMASK));
} }
} }
} }
@ -2990,7 +3023,7 @@ void ScintillaEditView::setTabSettings(Lang *lang)
void ScintillaEditView::insertNewLineAboveCurrentLine() void ScintillaEditView::insertNewLineAboveCurrentLine()
{ {
generic_string newline = getEOLString(); generic_string newline = getEOLString();
const int current_line = getCurrentLineNumber(); const auto current_line = getCurrentLineNumber();
if(current_line == 0) if(current_line == 0)
{ {
// Special handling if caret is at first line. // Special handling if caret is at first line.
@ -2998,8 +3031,8 @@ void ScintillaEditView::insertNewLineAboveCurrentLine()
} }
else else
{ {
const int eol_length = newline.length(); const auto eol_length = newline.length();
const long position = execute(SCI_POSITIONFROMLINE, current_line) - eol_length; const auto position = static_cast<size_t>(execute(SCI_POSITIONFROMLINE, current_line)) - eol_length;
insertGenericTextFrom(position, newline.c_str()); insertGenericTextFrom(position, newline.c_str());
} }
execute(SCI_SETEMPTYSELECTION, execute(SCI_POSITIONFROMLINE, current_line)); execute(SCI_SETEMPTYSELECTION, execute(SCI_POSITIONFROMLINE, current_line));
@ -3009,8 +3042,8 @@ void ScintillaEditView::insertNewLineAboveCurrentLine()
void ScintillaEditView::insertNewLineBelowCurrentLine() void ScintillaEditView::insertNewLineBelowCurrentLine()
{ {
generic_string newline = getEOLString(); generic_string newline = getEOLString();
const int line_count = execute(SCI_GETLINECOUNT); const auto line_count = static_cast<size_t>(execute(SCI_GETLINECOUNT));
const int current_line = getCurrentLineNumber(); const auto current_line = getCurrentLineNumber();
if(current_line == line_count - 1) if(current_line == line_count - 1)
{ {
// Special handling if caret is at last line. // Special handling if caret is at last line.
@ -3018,8 +3051,8 @@ void ScintillaEditView::insertNewLineBelowCurrentLine()
} }
else else
{ {
const int eol_length = newline.length(); const auto eol_length = newline.length();
const long position = eol_length + execute(SCI_GETLINEENDPOSITION, current_line); const auto position = eol_length + execute(SCI_GETLINEENDPOSITION, current_line);
insertGenericTextFrom(position, newline.c_str()); insertGenericTextFrom(position, newline.c_str());
} }
execute(SCI_SETEMPTYSELECTION, execute(SCI_POSITIONFROMLINE, current_line + 1)); execute(SCI_SETEMPTYSELECTION, execute(SCI_POSITIONFROMLINE, current_line + 1));
@ -3032,8 +3065,8 @@ void ScintillaEditView::sortLines(size_t fromLine, size_t toLine, ISorter *pSort
return; return;
} }
const int startPos = execute(SCI_POSITIONFROMLINE, fromLine); const auto startPos = execute(SCI_POSITIONFROMLINE, fromLine);
const int endPos = execute(SCI_POSITIONFROMLINE, toLine) + execute(SCI_LINELENGTH, toLine); const auto endPos = execute(SCI_POSITIONFROMLINE, toLine) + execute(SCI_LINELENGTH, toLine);
const generic_string text = getGenericTextAsString(startPos, endPos); const generic_string text = getGenericTextAsString(startPos, endPos);
std::vector<generic_string> splitText = stringSplit(text, getEOLString()); std::vector<generic_string> splitText = stringSplit(text, getEOLString());
const size_t lineCount = execute(SCI_GETLINECOUNT); const size_t lineCount = execute(SCI_GETLINECOUNT);
@ -3051,24 +3084,24 @@ void ScintillaEditView::sortLines(size_t fromLine, size_t toLine, ISorter *pSort
if (sortEntireDocument) if (sortEntireDocument)
{ {
assert(joined.length() == text.length()); assert(joined.length() == text.length());
replaceTarget(joined.c_str(), startPos, endPos); replaceTarget(joined.c_str(), int(startPos), int(endPos));
} }
else else
{ {
assert(joined.length() + getEOLString().length() == text.length()); assert(joined.length() + getEOLString().length() == text.length());
replaceTarget((joined + getEOLString()).c_str(), startPos, endPos); replaceTarget((joined + getEOLString()).c_str(), int(startPos), int(endPos));
} }
} }
bool ScintillaEditView::isTextDirectionRTL() const bool ScintillaEditView::isTextDirectionRTL() const
{ {
long exStyle = ::GetWindowLongPtr(_hSelf, GWL_EXSTYLE); long exStyle = static_cast<long>(::GetWindowLongPtr(_hSelf, GWL_EXSTYLE));
return (exStyle & WS_EX_LAYOUTRTL) != 0; return (exStyle & WS_EX_LAYOUTRTL) != 0;
} }
void ScintillaEditView::changeTextDirection(bool isRTL) void ScintillaEditView::changeTextDirection(bool isRTL)
{ {
long exStyle = ::GetWindowLongPtr(_hSelf, GWL_EXSTYLE); long exStyle = static_cast<long>(::GetWindowLongPtr(_hSelf, GWL_EXSTYLE));
exStyle = isRTL ? exStyle | WS_EX_LAYOUTRTL : exStyle&(~WS_EX_LAYOUTRTL); exStyle = isRTL ? exStyle | WS_EX_LAYOUTRTL : exStyle&(~WS_EX_LAYOUTRTL);
::SetWindowLongPtr(_hSelf, GWL_EXSTYLE, exStyle); ::SetWindowLongPtr(_hSelf, GWL_EXSTYLE, exStyle);
} }
@ -3092,7 +3125,7 @@ generic_string ScintillaEditView::getEOLString()
void ScintillaEditView::setBorderEdge(bool doWithBorderEdge) void ScintillaEditView::setBorderEdge(bool doWithBorderEdge)
{ {
long exStyle = ::GetWindowLongPtr(_hSelf, GWL_EXSTYLE); long exStyle = static_cast<long>(::GetWindowLongPtr(_hSelf, GWL_EXSTYLE));
if (doWithBorderEdge) if (doWithBorderEdge)
exStyle |= WS_EX_CLIENTEDGE; exStyle |= WS_EX_CLIENTEDGE;

View File

@ -248,11 +248,11 @@ public:
void getCurrentFoldStates(std::vector<size_t> & lineStateVector); void getCurrentFoldStates(std::vector<size_t> & lineStateVector);
void syncFoldStateWith(const std::vector<size_t> & lineStateVectorNew); void syncFoldStateWith(const std::vector<size_t> & lineStateVectorNew);
void getText(char *dest, int start, int end) const; void getText(char *dest, size_t start, size_t end) const;
void getGenericText(TCHAR *dest, size_t destlen, int start, int end) const; void getGenericText(TCHAR *dest, size_t destlen, size_t start, size_t end) const;
void getGenericText(TCHAR *dest, size_t deslen, int start, int end, int *mstart, int *mend) const; void getGenericText(TCHAR *dest, size_t deslen, int start, int end, int *mstart, int *mend) const;
generic_string getGenericTextAsString(int start, int end) const; generic_string getGenericTextAsString(size_t start, size_t end) const;
void insertGenericTextFrom(int position, const TCHAR *text2insert) const; void insertGenericTextFrom(size_t position, const TCHAR *text2insert) const;
void replaceSelWith(const char * replaceText); void replaceSelWith(const char * replaceText);
int getSelectedTextCount() { int getSelectedTextCount() {
@ -266,17 +266,17 @@ public:
char * getWordOnCaretPos(char * txt, int size); char * getWordOnCaretPos(char * txt, int size);
TCHAR * getGenericWordOnCaretPos(TCHAR * txt, int size); TCHAR * getGenericWordOnCaretPos(TCHAR * txt, int size);
TCHAR * getGenericSelectedText(TCHAR * txt, int size, bool expand = true); TCHAR * getGenericSelectedText(TCHAR * txt, int size, bool expand = true);
int searchInTarget(const TCHAR * Text2Find, int lenOfText2Find, int fromPos, int toPos) const; int searchInTarget(const TCHAR * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
void appandGenericText(const TCHAR * text2Append) const; void appandGenericText(const TCHAR * text2Append) const;
void addGenericText(const TCHAR * text2Append) const; void addGenericText(const TCHAR * text2Append) const;
void addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const; void addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const;
int replaceTarget(const TCHAR * str2replace, int fromTargetPos = -1, int toTargetPos = -1) const; int replaceTarget(const TCHAR * str2replace, int fromTargetPos = -1, int toTargetPos = -1) const;
int replaceTargetRegExMode(const TCHAR * re, int fromTargetPos = -1, int toTargetPos = -1) const; int replaceTargetRegExMode(const TCHAR * re, int fromTargetPos = -1, int toTargetPos = -1) const;
void showAutoComletion(int lenEntered, const TCHAR * list); void showAutoComletion(size_t lenEntered, const TCHAR * list);
void showCallTip(int startPos, const TCHAR * def); void showCallTip(int startPos, const TCHAR * def);
generic_string getLine(int lineNumber); generic_string getLine(size_t lineNumber);
void getLine(int lineNumber, TCHAR * line, int lineBufferLen); void getLine(size_t lineNumber, TCHAR * line, int lineBufferLen);
void addText(int length, const char *buf); void addText(size_t length, const char *buf);
void insertNewLineAboveCurrentLine(); void insertNewLineAboveCurrentLine();
void insertNewLineBelowCurrentLine(); void insertNewLineBelowCurrentLine();
@ -303,8 +303,8 @@ public:
}; };
void getWordToCurrentPos(TCHAR * str, int strLen) const { void getWordToCurrentPos(TCHAR * str, int strLen) const {
int caretPos = execute(SCI_GETCURRENTPOS); auto caretPos = execute(SCI_GETCURRENTPOS);
int startPos = static_cast<int>(execute(SCI_WORDSTARTPOSITION, caretPos, true)); auto startPos = execute(SCI_WORDSTARTPOSITION, caretPos, true);
str[0] = '\0'; str[0] = '\0';
if ((caretPos - startPos) < strLen) if ((caretPos - startPos) < strLen)
@ -420,13 +420,13 @@ public:
execute(SCI_SETWRAPVISUALFLAGS, willBeShown?SC_WRAPVISUALFLAG_END:SC_WRAPVISUALFLAG_NONE); execute(SCI_SETWRAPVISUALFLAGS, willBeShown?SC_WRAPVISUALFLAG_END:SC_WRAPVISUALFLAG_NONE);
}; };
long getCurrentLineNumber()const { size_t getCurrentLineNumber()const {
return long(execute(SCI_LINEFROMPOSITION, execute(SCI_GETCURRENTPOS))); return static_cast<size_t>(execute(SCI_LINEFROMPOSITION, execute(SCI_GETCURRENTPOS)));
}; };
long lastZeroBasedLineNumber() const { int32_t lastZeroBasedLineNumber() const {
int endPos = execute(SCI_GETLENGTH); auto endPos = execute(SCI_GETLENGTH);
return execute(SCI_LINEFROMPOSITION, endPos); return static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, endPos));
}; };
long getCurrentXOffset()const{ long getCurrentXOffset()const{
@ -484,7 +484,7 @@ public:
// return -1 if it's multi-selection or rectangle selection // return -1 if it's multi-selection or rectangle selection
if ((execute(SCI_GETSELECTIONS) > 1) || execute(SCI_SELECTIONISRECTANGLE)) if ((execute(SCI_GETSELECTIONS) > 1) || execute(SCI_SELECTIONISRECTANGLE))
return -1; return -1;
long size_selected = execute(SCI_GETSELTEXT); auto size_selected = execute(SCI_GETSELTEXT);
char *selected = new char[size_selected + 1]; char *selected = new char[size_selected + 1];
execute(SCI_GETSELTEXT, (WPARAM)0, (LPARAM)selected); execute(SCI_GETSELTEXT, (WPARAM)0, (LPARAM)selected);
char *c = selected; char *c = selected;
@ -566,7 +566,7 @@ public:
void collapse(int level2Collapse, bool mode); void collapse(int level2Collapse, bool mode);
void foldAll(bool mode); void foldAll(bool mode);
void fold(int line, bool mode); void fold(size_t line, bool mode);
bool isFolded(int line){ bool isFolded(int line){
return (execute(SCI_GETFOLDEXPANDED, line) != 0); return (execute(SCI_GETFOLDEXPANDED, line) != 0);
}; };
@ -638,7 +638,7 @@ public:
return ((_codepage == CP_CHINESE_TRADITIONAL) || (_codepage == CP_CHINESE_SIMPLIFIED) || return ((_codepage == CP_CHINESE_TRADITIONAL) || (_codepage == CP_CHINESE_SIMPLIFIED) ||
(_codepage == CP_JAPANESE) || (_codepage == CP_KOREAN)); (_codepage == CP_JAPANESE) || (_codepage == CP_KOREAN));
}; };
void scrollPosToCenter(int pos); void scrollPosToCenter(size_t pos);
generic_string getEOLString(); generic_string getEOLString();
void setBorderEdge(bool doWithBorderEdge); void setBorderEdge(bool doWithBorderEdge);
void sortLines(size_t fromLine, size_t toLine, ISorter *pSort); void sortLines(size_t fromLine, size_t toLine, ISorter *pSort);

View File

@ -58,7 +58,7 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView)
//GETWORDCHARS for isQualifiedWord2() and isWordChar2() //GETWORDCHARS for isQualifiedWord2() and isWordChar2()
int listCharSize = pHighlightView->execute(SCI_GETWORDCHARS, 0, 0); auto listCharSize = pHighlightView->execute(SCI_GETWORDCHARS, 0, 0);
char *listChar = new char[listCharSize+1]; char *listChar = new char[listCharSize+1];
pHighlightView->execute(SCI_GETWORDCHARS, 0, (LPARAM)listChar); pHighlightView->execute(SCI_GETWORDCHARS, 0, (LPARAM)listChar);
listChar[listCharSize] = '\0'; listChar[listCharSize] = '\0';
@ -110,7 +110,7 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView)
const TCHAR * searchText = NULL; const TCHAR * searchText = NULL;
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
unsigned int cp = pHighlightView->execute(SCI_GETCODEPAGE); UINT cp = static_cast<UINT>(pHighlightView->execute(SCI_GETCODEPAGE));
const TCHAR * text2FindW = wmc->char2wchar(text2Find, cp); const TCHAR * text2FindW = wmc->char2wchar(text2Find, cp);
searchText = text2FindW; searchText = text2FindW;

View File

@ -50,7 +50,7 @@ GlobalMappers & globalMappper()
bool SharedParametersDialog::setPropertyByCheck(HWND hwnd, WPARAM id, bool & bool2set) bool SharedParametersDialog::setPropertyByCheck(HWND hwnd, WPARAM id, bool & bool2set)
{ {
bool2set = (BST_CHECKED == ::SendMessage(::GetDlgItem(hwnd, id), BM_GETCHECK, 0, 0)); bool2set = (BST_CHECKED == ::SendMessage(::GetDlgItem(hwnd, int(id)), BM_GETCHECK, 0, 0));
if (_pScintilla->getCurrentBuffer()->getLangType() == L_USER) if (_pScintilla->getCurrentBuffer()->getLangType() == L_USER)
_pScintilla->styleChange(); _pScintilla->styleChange();
@ -990,7 +990,7 @@ void UserDefineDialog::changeStyle()
_status = !_status; _status = !_status;
::SetDlgItemText(_hSelf, IDC_DOCK_BUTTON, (_status == DOCK)?TEXT("Undock"):TEXT("Dock")); ::SetDlgItemText(_hSelf, IDC_DOCK_BUTTON, (_status == DOCK)?TEXT("Undock"):TEXT("Dock"));
long style = ::GetWindowLongPtr(_hSelf, GWL_STYLE); auto style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
if (!style) if (!style)
::MessageBox(NULL, TEXT("GetWindowLongPtr failed in UserDefineDialog::changeStyle()"), TEXT(""), MB_OK); ::MessageBox(NULL, TEXT("GetWindowLongPtr failed in UserDefineDialog::changeStyle()"), TEXT(""), MB_OK);
@ -998,7 +998,7 @@ void UserDefineDialog::changeStyle()
((style & ~WS_POPUP) & ~DS_MODALFRAME & ~WS_CAPTION) | WS_CHILD : ((style & ~WS_POPUP) & ~DS_MODALFRAME & ~WS_CAPTION) | WS_CHILD :
(style & ~WS_CHILD) | WS_POPUP | DS_MODALFRAME | WS_CAPTION; (style & ~WS_CHILD) | WS_POPUP | DS_MODALFRAME | WS_CAPTION;
long result = ::SetWindowLongPtr(_hSelf, GWL_STYLE, style); auto result = ::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
if (!result) if (!result)
::MessageBox(NULL, TEXT("SetWindowLongPtr failed in UserDefineDialog::changeStyle()"), TEXT(""), MB_OK); ::MessageBox(NULL, TEXT("SetWindowLongPtr failed in UserDefineDialog::changeStyle()"), TEXT(""), MB_OK);
@ -1010,7 +1010,7 @@ void UserDefineDialog::changeStyle()
::SetParent(_hSelf, (_status == DOCK)?_hParent:NULL); ::SetParent(_hSelf, (_status == DOCK)?_hParent:NULL);
} }
void UserDefineDialog::enableLangAndControlsBy(int index) void UserDefineDialog::enableLangAndControlsBy(size_t index)
{ {
_pUserLang = (index == 0)?_pCurrentUserLang:&((NppParameters::getInstance())->getULCFromIndex(index - 1)); _pUserLang = (index == 0)?_pCurrentUserLang:&((NppParameters::getInstance())->getULCFromIndex(index - 1));
if (index != 0) if (index != 0)
@ -1026,7 +1026,7 @@ void UserDefineDialog::updateDlg()
{ {
if (!_isDirty) if (!_isDirty)
{ {
int i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); int i = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0));
if (i > 0) if (i > 0)
_isDirty = true; _isDirty = true;
} }
@ -1150,8 +1150,8 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
{ {
if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_UD_PERCENTAGE_SLIDER)) if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_UD_PERCENTAGE_SLIDER))
{ {
int percent = ::SendDlgItemMessage(_hSelf, IDC_UD_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0); int percent = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_UD_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0));
pNppParam->SetTransparent(_hSelf, percent/*HIWORD(wParam)*/); pNppParam->SetTransparent(_hSelf, percent);
} }
return TRUE; return TRUE;
} }
@ -1169,7 +1169,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
{ {
if (LOWORD(wParam) == IDC_LANGNAME_COMBO) if (LOWORD(wParam) == IDC_LANGNAME_COMBO)
{ {
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0);
enableLangAndControlsBy(i); enableLangAndControlsBy(i);
updateDlg(); updateDlg();
} }
@ -1203,7 +1203,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_UD_TRANSPARENT_CHECK, BM_GETCHECK, 0, 0)); bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_UD_TRANSPARENT_CHECK, BM_GETCHECK, 0, 0));
if (isChecked) if (isChecked)
{ {
int percent = ::SendDlgItemMessage(_hSelf, IDC_UD_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0); int percent = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_UD_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0));
pNppParam->SetTransparent(_hSelf, percent); pNppParam->SetTransparent(_hSelf, percent);
} }
::ShowWindow(::GetDlgItem(_hSelf, IDC_UD_TRANSPARENT_CHECK), SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_UD_TRANSPARENT_CHECK), SW_SHOW);
@ -1226,7 +1226,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
int result = ::MessageBox(_hSelf, TEXT("Are you sure?"), TEXT("Remove the current language"), MB_YESNO); int result = ::MessageBox(_hSelf, TEXT("Are you sure?"), TEXT("Remove the current language"), MB_YESNO);
if (result == IDYES) if (result == IDYES)
{ {
int i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0);
TCHAR langName[256]; TCHAR langName[256];
::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName); ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName);
@ -1240,7 +1240,9 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
//remove current language from langMenu //remove current language from langMenu
HWND hNpp = ::GetParent(_hSelf); HWND hNpp = ::GetParent(_hSelf);
::RemoveMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER + i, MF_BYCOMMAND); HMENU m = (HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0);
HMENU subMenu = ::GetSubMenu(m, MENUINDEX_LANGUAGE);
::RemoveMenu(subMenu, IDM_LANG_USER + UINT(i), MF_BYCOMMAND);
::DrawMenuBar(hNpp); ::DrawMenuBar(hNpp);
::SendMessage(_hParent, WM_REMOVE_USERLANG, 0, (LPARAM)langName); ::SendMessage(_hParent, WM_REMOVE_USERLANG, 0, (LPARAM)langName);
} }
@ -1249,7 +1251,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
case IDC_RENAME_BUTTON : case IDC_RENAME_BUTTON :
{ {
TCHAR langName[256]; TCHAR langName[256];
int i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0);
::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName); ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName);
StringDlg strDlg; StringDlg strDlg;
@ -1276,7 +1278,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
//rename current language name in langMenu //rename current language name in langMenu
HWND hNpp = ::GetParent(_hSelf); HWND hNpp = ::GetParent(_hSelf);
::ModifyMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER + i, MF_BYCOMMAND, IDM_LANG_USER + i, newName); ::ModifyMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER + UINT(i), MF_BYCOMMAND, IDM_LANG_USER + i, newName);
::DrawMenuBar(hNpp); ::DrawMenuBar(hNpp);
::SendMessage(_hParent, WM_RENAME_USERLANG, (WPARAM)newName, (LPARAM)langName); ::SendMessage(_hParent, WM_RENAME_USERLANG, (WPARAM)newName, (LPARAM)langName);
} }
@ -1288,7 +1290,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
case IDC_SAVEAS_BUTTON : case IDC_SAVEAS_BUTTON :
{ {
//TCHAR langName[256]; //TCHAR langName[256];
int i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0);
//::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName); //::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName);
if (i == 0) if (i == 0)
wParam = IDC_ADDNEW_BUTTON; wParam = IDC_ADDNEW_BUTTON;
@ -1341,7 +1343,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
bool isSuccessful = pNppParam->importUDLFromFile(sourceFile); bool isSuccessful = pNppParam->importUDLFromFile(sourceFile);
if (isSuccessful) if (isSuccessful)
{ {
int i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0);
reloadLangCombo(); reloadLangCombo();
::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_SETCURSEL, i, 0); ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_SETCURSEL, i, 0);
_isDirty = true; _isDirty = true;
@ -1356,7 +1358,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
case IDC_EXPORT_BUTTON : case IDC_EXPORT_BUTTON :
{ {
int i2Export = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); auto i2Export = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0);
if (i2Export == 0) if (i2Export == 0)
{ {
// maybe a better option would be to simply send IDC_SAVEAS_BUTTON message, and display "Save As..." dialog? // maybe a better option would be to simply send IDC_SAVEAS_BUTTON message, and display "Save As..." dialog?
@ -1390,7 +1392,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_UD_TRANSPARENT_CHECK, BM_GETCHECK, 0, 0)); bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_UD_TRANSPARENT_CHECK, BM_GETCHECK, 0, 0));
if (isChecked) if (isChecked)
{ {
int percent = ::SendDlgItemMessage(_hSelf, IDC_UD_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0); int percent = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_UD_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0));
pNppParam->SetTransparent(_hSelf, percent); pNppParam->SetTransparent(_hSelf, percent);
} }
else else
@ -1585,7 +1587,7 @@ INT_PTR CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPAR
else else
wsprintf(size, TEXT("%d"),style._fontSize); wsprintf(size, TEXT("%d"),style._fontSize);
int i = ::SendMessage(hFontSizeCombo, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)size); auto i = ::SendMessage(hFontSizeCombo, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)size);
if (i != CB_ERR) if (i != CB_ERR)
::SendMessage(hFontSizeCombo, CB_SETCURSEL, i, 0); ::SendMessage(hFontSizeCombo, CB_SETCURSEL, i, 0);
@ -1594,7 +1596,7 @@ INT_PTR CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPAR
const std::vector<generic_string> & fontlist = pNppParam->getFontList(); const std::vector<generic_string> & fontlist = pNppParam->getFontList();
for (size_t j = 0, len = fontlist.size() ; j < len ; ++j) for (size_t j = 0, len = fontlist.size() ; j < len ; ++j)
{ {
int k = ::SendMessage(hFontNameCombo, CB_ADDSTRING, 0, (LPARAM)fontlist[j].c_str()); auto k = ::SendMessage(hFontNameCombo, CB_ADDSTRING, 0, (LPARAM)fontlist[j].c_str());
::SendMessage(hFontNameCombo, CB_SETITEMDATA, k, (LPARAM)fontlist[j].c_str()); ::SendMessage(hFontNameCombo, CB_SETITEMDATA, k, (LPARAM)fontlist[j].c_str());
} }
@ -1655,7 +1657,7 @@ INT_PTR CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPAR
Style & style = SharedParametersDialog::_pUserLang->_styleArray.getStyler(dlg->_stylerIndex); Style & style = SharedParametersDialog::_pUserLang->_styleArray.getStyler(dlg->_stylerIndex);
if (HIWORD(wParam) == CBN_SELCHANGE) if (HIWORD(wParam) == CBN_SELCHANGE)
{ {
int i = ::SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETCURSEL, 0, 0);
if (LOWORD(wParam) == IDC_STYLER_COMBO_FONT_SIZE) if (LOWORD(wParam) == IDC_STYLER_COMBO_FONT_SIZE)
{ {
TCHAR intStr[5]; TCHAR intStr[5];

View File

@ -403,7 +403,7 @@ private :
_dlgPos.bottom -= _dlgPos.top; _dlgPos.bottom -= _dlgPos.top;
}; };
void restorePosSize(){reSizeTo(_dlgPos);}; void restorePosSize(){reSizeTo(_dlgPos);};
void enableLangAndControlsBy(int index); void enableLangAndControlsBy(size_t index);
protected : protected :
void setKeywords2List(int){}; void setKeywords2List(int){};
void updateDlg(); void updateDlg();

View File

@ -64,9 +64,6 @@ const COLORREF extremeLitePurple = RGB(0xF8, 0xE8, 0xFF);
const COLORREF veryLitePurple = RGB(0xE7, 0xD8, 0xE9); const COLORREF veryLitePurple = RGB(0xE7, 0xD8, 0xE9);
const COLORREF liteBerge = RGB(0xFE, 0xFC, 0xF5); const COLORREF liteBerge = RGB(0xFE, 0xFC, 0xF5);
const COLORREF berge = RGB(0xFD, 0xF8, 0xE3); const COLORREF berge = RGB(0xFD, 0xF8, 0xE3);
/*
#define RGB2int(color)
(((((long)color) & 0x0000FF) << 16) | ((((long)color) & 0x00FF00)) | ((((long)color) & 0xFF0000) >> 16))
*/
#endif //COLORS_H #endif //COLORS_H

View File

@ -101,22 +101,22 @@ INT_PTR CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
} }
else else
{ {
int cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS); auto cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS);
int cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos); auto cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos);
int cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos); auto cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos);
int endPos = (*_ppEditView)->execute(SCI_GETLENGTH); auto endPos = (*_ppEditView)->execute(SCI_GETLENGTH);
int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos); auto endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);
int lineAllocatedLen = 1024; int lineAllocatedLen = 1024;
TCHAR *line = new TCHAR[lineAllocatedLen]; TCHAR *line = new TCHAR[lineAllocatedLen];
for (int i = cursorLine ; i <= endLine ; ++i) for (size_t i = cursorLine ; i <= static_cast<size_t>(endLine); ++i)
{ {
int lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i); auto lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
int lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i); auto lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
int lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd); auto lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd);
int lineLen = lineEnd - lineBegin + 1; auto lineLen = lineEnd - lineBegin + 1;
if (lineLen > lineAllocatedLen) if (lineLen > lineAllocatedLen)
{ {
@ -134,11 +134,11 @@ INT_PTR CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
} }
else else
{ {
int posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol); auto posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol);
int posRelative2Start = posAbs2Start - lineBegin; auto posRelative2Start = posAbs2Start - lineBegin;
s2r.insert(posRelative2Start, str); s2r.insert(posRelative2Start, str);
} }
(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd); (*_ppEditView)->replaceTarget(s2r.c_str(), int(lineBegin), int(lineEnd));
} }
delete [] line; delete [] line;
} }
@ -165,17 +165,17 @@ INT_PTR CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
} }
else else
{ {
int cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS); auto cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS);
int cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos); auto cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos);
int cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos); auto cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos);
int endPos = (*_ppEditView)->execute(SCI_GETLENGTH); auto endPos = (*_ppEditView)->execute(SCI_GETLENGTH);
int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos); auto endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);
// Compute the numbers to be placed at each column. // Compute the numbers to be placed at each column.
std::vector<int> numbers; std::vector<int> numbers;
{ {
int curNumber = initialNumber; int curNumber = initialNumber;
const unsigned int kiMaxSize = 1 + (unsigned int)endLine - (unsigned int)cursorLine; const size_t kiMaxSize = 1 + (size_t)endLine - (size_t)cursorLine;
while (numbers.size() < kiMaxSize) while (numbers.size() < kiMaxSize)
{ {
for (int i = 0; i < repeat; i++) for (int i = 0; i < repeat; i++)
@ -212,13 +212,13 @@ INT_PTR CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
int nb = max(nbInit, nbEnd); int nb = max(nbInit, nbEnd);
for (int i = cursorLine ; i <= endLine ; ++i) for (size_t i = cursorLine ; i <= size_t(endLine) ; ++i)
{ {
int lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i); auto lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
int lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i); auto lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
int lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd); auto lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd);
int lineLen = lineEnd - lineBegin + 1; auto lineLen = lineEnd - lineBegin + 1;
if (lineLen > lineAllocatedLen) if (lineLen > lineAllocatedLen)
{ {
@ -241,12 +241,12 @@ INT_PTR CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
} }
else else
{ {
int posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol); auto posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol);
int posRelative2Start = posAbs2Start - lineBegin; auto posRelative2Start = posAbs2Start - lineBegin;
s2r.insert(posRelative2Start, str); s2r.insert(posRelative2Start, str);
} }
(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd); (*_ppEditView)->replaceTarget(s2r.c_str(), int(lineBegin), int(lineEnd));
} }
delete [] line; delete [] line;
} }

View File

@ -131,9 +131,9 @@ vector< pair<int, int> > XmlMatchedTagsHighlighter::getAttributesPos(int start,
bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags) bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
{ {
bool tagFound = false; bool tagFound = false;
int caret = _pEditView->execute(SCI_GETCURRENTPOS); int caret = static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS));
int searchStartPoint = caret; int searchStartPoint = caret;
int styleAt; LRESULT styleAt;
FindResult openFound; FindResult openFound;
// Search back for the previous open angle bracket. // Search back for the previous open angle bracket.
@ -160,7 +160,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
if (!closeFound.success) if (!closeFound.success)
{ {
// We're in a tag (either a start tag or an end tag) // We're in a tag (either a start tag or an end tag)
int nextChar = _pEditView->execute(SCI_GETCHARAT, openFound.start + 1); int nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, openFound.start + 1));
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
@ -169,7 +169,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
if ('/' == nextChar) if ('/' == nextChar)
{ {
xmlTags.tagCloseStart = openFound.start; xmlTags.tagCloseStart = openFound.start;
int docLength = _pEditView->execute(SCI_GETLENGTH); int docLength = static_cast<int32_t>(_pEditView->execute(SCI_GETLENGTH));
FindResult endCloseTag = findText(">", caret, docLength, 0); FindResult endCloseTag = findText(">", caret, docLength, 0);
if (endCloseTag.success) if (endCloseTag.success)
{ {
@ -180,13 +180,13 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
// UTF-8 or ASCII tag name // UTF-8 or ASCII tag name
std::string tagName; std::string tagName;
nextChar = _pEditView->execute(SCI_GETCHARAT, position); nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, position));
// Checking for " or ' is actually wrong here, but it means it works better with invalid XML // Checking for " or ' is actually wrong here, but it means it works better with invalid XML
while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'') while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'')
{ {
tagName.push_back((char)nextChar); tagName.push_back((char)nextChar);
++position; ++position;
nextChar = _pEditView->execute(SCI_GETCHARAT, position); nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, position));
} }
// Now we know where the end of the tag is, and we know what the tag is called // Now we know where the end of the tag is, and we know what the tag is called
@ -255,7 +255,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
{ {
xmlTags.tagOpenStart = nextOpenTag.start; xmlTags.tagOpenStart = nextOpenTag.start;
xmlTags.tagOpenEnd = nextOpenTag.end + 1; xmlTags.tagOpenEnd = nextOpenTag.end + 1;
xmlTags.tagNameEnd = nextOpenTag.start + tagName.size() + 1; /* + 1 to account for '<' */ xmlTags.tagNameEnd = nextOpenTag.start + static_cast<int32_t>(tagName.size()) + 1; /* + 1 to account for '<' */
tagFound = true; tagFound = true;
} }
else else
@ -275,18 +275,18 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
// CURSOR IN OPEN TAG // CURSOR IN OPEN TAG
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
int position = openFound.start + 1; int position = openFound.start + 1;
int docLength = _pEditView->execute(SCI_GETLENGTH); int docLength = static_cast<int32_t>(_pEditView->execute(SCI_GETLENGTH));
xmlTags.tagOpenStart = openFound.start; xmlTags.tagOpenStart = openFound.start;
std::string tagName; std::string tagName;
nextChar = _pEditView->execute(SCI_GETCHARAT, position); nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, position));
// Checking for " or ' is actually wrong here, but it means it works better with invalid XML // Checking for " or ' is actually wrong here, but it means it works better with invalid XML
while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'' ) while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'' )
{ {
tagName.push_back((char)nextChar); tagName.push_back((char)nextChar);
++position; ++position;
nextChar = _pEditView->execute(SCI_GETCHARAT, position); nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, position));
} }
// Now we know where the end of the tag is, and we know what the tag is called // Now we know where the end of the tag is, and we know what the tag is called
@ -294,7 +294,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
{ {
// First we need to check if this is a self-closing tag. // First we need to check if this is a self-closing tag.
// If it is, then we can just return this tag to highlight itself. // If it is, then we can just return this tag to highlight itself.
xmlTags.tagNameEnd = openFound.start + tagName.size() + 1; xmlTags.tagNameEnd = openFound.start + static_cast<int32_t>(tagName.size()) + 1;
int closeAnglePosition = findCloseAngle(position, docLength); int closeAnglePosition = findCloseAngle(position, docLength);
if (-1 != closeAnglePosition) if (-1 != closeAnglePosition)
{ {
@ -399,8 +399,8 @@ XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findOpenTag(con
result = findText(search.c_str(), searchStart, searchEnd, 0); result = findText(search.c_str(), searchStart, searchEnd, 0);
if (result.success) if (result.success)
{ {
nextChar = _pEditView->execute(SCI_GETCHARAT, result.end); nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, result.end));
styleAt = _pEditView->execute(SCI_GETSTYLEAT, result.start); styleAt = static_cast<int32_t>(_pEditView->execute(SCI_GETSTYLEAT, result.start));
if (styleAt != SCE_H_CDATA && styleAt != SCE_H_DOUBLESTRING && styleAt != SCE_H_SINGLESTRING && styleAt != SCE_H_COMMENT) if (styleAt != SCE_H_CDATA && styleAt != SCE_H_DOUBLESTRING && styleAt != SCE_H_SINGLESTRING && styleAt != SCE_H_COMMENT)
{ {
// We've got an open tag for this tag name (i.e. nextChar was space or '>') // We've got an open tag for this tag name (i.e. nextChar was space or '>')
@ -469,7 +469,7 @@ int XmlMatchedTagsHighlighter::findCloseAngle(int startPosition, int endPosition
closeAngle = findText(">", startPosition, endPosition); closeAngle = findText(">", startPosition, endPosition);
if (closeAngle.success) if (closeAngle.success)
{ {
int style = _pEditView->execute(SCI_GETSTYLEAT, closeAngle.start); auto style = _pEditView->execute(SCI_GETSTYLEAT, closeAngle.start);
// As long as we're not in an attribute ( <TAGNAME attrib="val>ue"> is VALID XML. ) // As long as we're not in an attribute ( <TAGNAME attrib="val>ue"> is VALID XML. )
if (style != SCE_H_DOUBLESTRING && style != SCE_H_SINGLESTRING && style != SCE_H_COMMENT) if (style != SCE_H_DOUBLESTRING && style != SCE_H_SINGLESTRING && style != SCE_H_COMMENT)
{ {
@ -496,7 +496,6 @@ XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findCloseTag(co
closeTagFound.success = false; closeTagFound.success = false;
FindResult result; FindResult result;
int nextChar; int nextChar;
int styleAt;
int searchStart = start; int searchStart = start;
int searchEnd = end; int searchEnd = end;
bool forwardSearch = (start < end); bool forwardSearch = (start < end);
@ -507,8 +506,8 @@ XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findCloseTag(co
result = findText(search.c_str(), searchStart, searchEnd, 0); result = findText(search.c_str(), searchStart, searchEnd, 0);
if (result.success) if (result.success)
{ {
nextChar = _pEditView->execute(SCI_GETCHARAT, result.end); nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, result.end));
styleAt = _pEditView->execute(SCI_GETSTYLEAT, result.start); auto styleAt = _pEditView->execute(SCI_GETSTYLEAT, result.start);
// Setup the parameters for the next search, if there is one. // Setup the parameters for the next search, if there is one.
if (forwardSearch) if (forwardSearch)
@ -536,7 +535,7 @@ XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findCloseTag(co
do do
{ {
++whitespacePoint; ++whitespacePoint;
nextChar = _pEditView->execute(SCI_GETCHARAT, whitespacePoint); nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, whitespacePoint));
} while(isWhitespace(nextChar)); } while(isWhitespace(nextChar));
@ -565,7 +564,7 @@ XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findText(const
search.lpstrText = const_cast<char *>(text); // Grrrrrr search.lpstrText = const_cast<char *>(text); // Grrrrrr
search.chrg.cpMin = start; search.chrg.cpMin = start;
search.chrg.cpMax = end; search.chrg.cpMax = end;
int result = _pEditView->execute(SCI_FINDTEXT, flags, reinterpret_cast<LPARAM>(&search)); int result = static_cast<int32_t>(_pEditView->execute(SCI_FINDTEXT, flags, reinterpret_cast<LPARAM>(&search)));
if (-1 == result) if (-1 == result)
{ {
returnValue.success = false; returnValue.success = false;
@ -597,7 +596,7 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr)
std::string codeBeginTag = lang == L_PHP ? "<?" : "<%"; std::string codeBeginTag = lang == L_PHP ? "<?" : "<%";
std::string codeEndTag = lang == L_PHP ? "?>" : "%>"; std::string codeEndTag = lang == L_PHP ? "?>" : "%>";
const int caret = 1 + _pEditView->execute(SCI_GETCURRENTPOS); // +1 to deal with the case when the caret is between the angle and the question mark in "<?" (or between '<' and '%'). const int caret = 1 + static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS)); // +1 to deal with the case when the caret is between the angle and the question mark in "<?" (or between '<' and '%').
const FindResult startFound = findText(codeBeginTag.c_str(), caret, 0, 0); // This searches backwards from "caret". const FindResult startFound = findText(codeBeginTag.c_str(), caret, 0, 0); // This searches backwards from "caret".
const FindResult endFound= findText(codeEndTag.c_str(), caret, 0, 0); // This searches backwards from "caret". const FindResult endFound= findText(codeEndTag.c_str(), caret, 0, 0); // This searches backwards from "caret".
@ -611,9 +610,9 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr)
} }
// Get the original targets and search options to restore after tag matching operation // Get the original targets and search options to restore after tag matching operation
int originalStartPos = _pEditView->execute(SCI_GETTARGETSTART); auto originalStartPos = _pEditView->execute(SCI_GETTARGETSTART);
int originalEndPos = _pEditView->execute(SCI_GETTARGETEND); auto originalEndPos = _pEditView->execute(SCI_GETTARGETEND);
int originalSearchFlags = _pEditView->execute(SCI_GETSEARCHFLAGS); auto originalSearchFlags = _pEditView->execute(SCI_GETSEARCHFLAGS);
XmlMatchedTagsPos xmlTags; XmlMatchedTagsPos xmlTags;

View File

@ -399,7 +399,7 @@ void TiXmlDocumentA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag )
while ( in->good() ) while ( in->good() )
{ {
int tagIndex = tag->length(); size_t tagIndex = tag->length();
while ( in->good() && in->peek() != '>' ) while ( in->good() && in->peek() != '>' )
{ {
int c = in->get(); int c = in->get();
@ -640,7 +640,7 @@ void TiXmlElementA::StreamIn (TIXMLA_ISTREAM * in, TIXMLA_STRING * tag)
// We should be at a "<", regardless. // We should be at a "<", regardless.
if ( !in->good() ) return; if ( !in->good() ) return;
assert( in->peek() == '<' ); assert( in->peek() == '<' );
int tagIndex = tag->length(); size_t tagIndex = tag->length();
bool closingTag = false; bool closingTag = false;
bool firstCharFound = false; bool firstCharFound = false;
@ -1154,7 +1154,7 @@ const char* TiXmlDeclarationA::Parse( const char* p, TiXmlParsingDataA* data )
bool TiXmlTextA::Blank() const bool TiXmlTextA::Blank() const
{ {
for ( unsigned int i=0, len=value.length(); i<len; i++ ) for ( size_t i = 0, len = value.length(); i < len; i++ )
if ( !isspace( value[i] ) ) if ( !isspace( value[i] ) )
return false; return false;
return true; return true;

View File

@ -379,7 +379,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
while ( in->good() ) while ( in->good() )
{ {
int tagIndex = tag->length(); size_t tagIndex = tag->length();
while ( in->good() && in->peek() != '>' ) while ( in->good() && in->peek() != '>' )
{ {
int c = in->get(); int c = in->get();
@ -620,7 +620,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
// We should be at a "<", regardless. // We should be at a "<", regardless.
if ( !in->good() ) return; if ( !in->good() ) return;
assert( in->peek() == '<' ); assert( in->peek() == '<' );
int tagIndex = tag->length(); size_t tagIndex = tag->length();
bool closingTag = false; bool closingTag = false;
bool firstCharFound = false; bool firstCharFound = false;
@ -1134,7 +1134,7 @@ const TCHAR* TiXmlDeclaration::Parse( const TCHAR* p, TiXmlParsingData* data )
bool TiXmlText::Blank() const bool TiXmlText::Blank() const
{ {
for ( unsigned int i=0, len=value.length(); i<len; i++ ) for (size_t i = 0, len = value.length(); i < len; i++)
if ( !isspace( value[i] ) ) if ( !isspace( value[i] ) )
return false; return false;
return true; return true;

View File

@ -205,7 +205,7 @@ void Utf8_16_Read::determineEncoding()
m_nSkip = 3; m_nSkip = 3;
} }
// try to detect UTF-16 little-endian without BOM // try to detect UTF-16 little-endian without BOM
else if (m_nLen > 1 && m_nLen % 2 == 0 && m_pBuf[0] != NULL && m_pBuf[1] == NULL && IsTextUnicode(m_pBuf, m_nLen, &uniTest)) else if (m_nLen > 1 && m_nLen % 2 == 0 && m_pBuf[0] != NULL && m_pBuf[1] == NULL && IsTextUnicode(m_pBuf, static_cast<int32_t>(m_nLen), &uniTest))
{ {
m_eEncoding = uni16LE_NoBOM; m_eEncoding = uni16LE_NoBOM;
m_nSkip = 0; m_nSkip = 0;
@ -231,7 +231,7 @@ void Utf8_16_Read::determineEncoding()
} }
} }
UniMode Utf8_16_Read::determineEncoding(const unsigned char *buf, int bufLen) UniMode Utf8_16_Read::determineEncoding(const unsigned char *buf, size_t bufLen)
{ {
// detect UTF-16 big-endian with BOM // detect UTF-16 big-endian with BOM
if (bufLen > 1 && buf[0] == k_Boms[uni16BE][0] && buf[1] == k_Boms[uni16BE][1]) if (bufLen > 1 && buf[0] == k_Boms[uni16BE][0] && buf[1] == k_Boms[uni16BE][1])

View File

@ -117,7 +117,7 @@ public:
UniMode getEncoding() const { return m_eEncoding; } UniMode getEncoding() const { return m_eEncoding; }
size_t calcCurPos(size_t pos); size_t calcCurPos(size_t pos);
static UniMode determineEncoding(const unsigned char *buf, int bufLen); static UniMode determineEncoding(const unsigned char *buf, size_t bufLen);
protected: protected:
void determineEncoding(); void determineEncoding();

View File

@ -197,7 +197,7 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
// colours, and with an underline text style // colours, and with an underline text style
case WM_PAINT: case WM_PAINT:
{ {
DWORD dwStyle = ::GetWindowLongPtr(hwnd, GWL_STYLE); DWORD dwStyle = static_cast<DWORD>(::GetWindowLongPtr(hwnd, GWL_STYLE));
DWORD dwDTStyle = DT_SINGLELINE; DWORD dwDTStyle = DT_SINGLELINE;
//Test if centered horizontally or vertically //Test if centered horizontally or vertically

View File

@ -133,7 +133,7 @@ void AnsiCharPanel::insertChar(unsigned char char2insert) const
WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL);
} }
(*_ppEditView)->execute(SCI_REPLACESEL, 0, (LPARAM)""); (*_ppEditView)->execute(SCI_REPLACESEL, 0, (LPARAM)"");
int len = (char2insert < 128)?1:strlen(multiByteStr); size_t len = (char2insert < 128)?1:strlen(multiByteStr);
(*_ppEditView)->execute(SCI_ADDTEXT, len, (LPARAM)multiByteStr); (*_ppEditView)->execute(SCI_ADDTEXT, len, (LPARAM)multiByteStr);
(*_ppEditView)->getFocus(); (*_ppEditView)->getFocus();
} }

View File

@ -152,7 +152,7 @@ int ClipboardHistoryPanel::getClipboardDataIndex(ClipboardData cbd)
if (found) if (found)
{ {
iFound = i; iFound = static_cast<int32_t>(i);
break; break;
} }
} }
@ -235,24 +235,24 @@ INT_PTR CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam,
{ {
if (HIWORD(wParam) == LBN_DBLCLK) if (HIWORD(wParam) == LBN_DBLCLK)
{ {
int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_CLIPBOARD, LB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_LIST_CLIPBOARD, LB_GETCURSEL, 0, 0);
if (i != LB_ERR) if (i != LB_ERR)
{ {
int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding(); int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding();
if (codepage == -1) if (codepage == -1)
{ {
int cp = (*_ppEditView)->execute(SCI_GETCODEPAGE); auto cp = (*_ppEditView)->execute(SCI_GETCODEPAGE);
codepage = cp==SC_CP_UTF8?SC_CP_UTF8:0; codepage = cp == SC_CP_UTF8 ? SC_CP_UTF8 : 0;
} }
else else
codepage = SC_CP_UTF8; codepage = SC_CP_UTF8;
ByteArray ba(_clipboardDataVector[i]); ByteArray ba(_clipboardDataVector[i]);
int nbChar = WideCharToMultiByte(codepage, 0, (wchar_t *)ba.getPointer(), ba.getLength(), NULL, 0, NULL, NULL); int nbChar = WideCharToMultiByte(codepage, 0, (wchar_t *)ba.getPointer(), static_cast<int32_t>(ba.getLength()), NULL, 0, NULL, NULL);
char *c = new char[nbChar+1]; char *c = new char[nbChar+1];
WideCharToMultiByte(codepage, 0, (wchar_t *)ba.getPointer(), ba.getLength(), c, nbChar+1, NULL, NULL); WideCharToMultiByte(codepage, 0, (wchar_t *)ba.getPointer(), static_cast<int32_t>(ba.getLength()), c, nbChar + 1, NULL, NULL);
(*_ppEditView)->execute(SCI_REPLACESEL, 0, (LPARAM)""); (*_ppEditView)->execute(SCI_REPLACESEL, 0, (LPARAM)"");
(*_ppEditView)->execute(SCI_ADDTEXT, strlen(c), (LPARAM)c); (*_ppEditView)->execute(SCI_ADDTEXT, strlen(c), (LPARAM)c);
@ -273,18 +273,7 @@ INT_PTR CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam,
::MoveWindow(::GetDlgItem(_hSelf, IDC_LIST_CLIPBOARD), 0, 0, width, height, TRUE); ::MoveWindow(::GetDlgItem(_hSelf, IDC_LIST_CLIPBOARD), 0, 0, width, height, TRUE);
break; break;
} }
/*
case WM_VKEYTOITEM:
{
if (LOWORD(wParam) == VK_RETURN)
{
int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_CLIPBOARD, LB_GETCURSEL, 0, 0);
printInt(i);
return TRUE;
}//return TRUE;
break;
}
*/
case WM_CTLCOLORLISTBOX: case WM_CTLCOLORLISTBOX:
{ {
if (_lbBgColor != -1) if (_lbBgColor != -1)

View File

@ -218,8 +218,8 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{ {
if (HIWORD(wParam) == LBN_SELCHANGE) if (HIWORD(wParam) == LBN_SELCHANGE)
{ {
int i = ::SendMessage((HWND)lParam, LB_GETCURSEL, 0L, 0L); auto i = ::SendMessage((HWND)lParam, LB_GETCURSEL, 0L, 0L);
_colour = ::SendMessage((HWND)lParam, LB_GETITEMDATA, i, 0L); _colour = static_cast<COLORREF>(::SendMessage((HWND)lParam, LB_GETITEMDATA, i, 0L));
::SendMessage(_hParent, WM_PICKUP_COLOR, _colour, 0); ::SendMessage(_hParent, WM_PICKUP_COLOR, _colour, 0);
return TRUE; return TRUE;

View File

@ -109,7 +109,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
for(size_t i = 0 ; i < themeSwitcher.size() ; ++i) for(size_t i = 0 ; i < themeSwitcher.size() ; ++i)
{ {
pair<generic_string, generic_string> & themeInfo = themeSwitcher.getElementFromIndex(i); pair<generic_string, generic_string> & themeInfo = themeSwitcher.getElementFromIndex(i);
int j = ::SendMessage(_hSwitch2ThemeCombo, CB_ADDSTRING, 0, (LPARAM)themeInfo.first.c_str()); int j = static_cast<int32_t>(::SendMessage(_hSwitch2ThemeCombo, CB_ADDSTRING, 0, (LPARAM)themeInfo.first.c_str()));
if (! themeInfo.second.compare( nppParamInst->getNppGUI()._themeName ) ) if (! themeInfo.second.compare( nppParamInst->getNppGUI()._themeName ) )
{ {
_currentThemeIndex = j; _currentThemeIndex = j;
@ -132,7 +132,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
const std::vector<generic_string> & fontlist = (NppParameters::getInstance())->getFontList(); const std::vector<generic_string> & fontlist = (NppParameters::getInstance())->getFontList();
for (size_t i = 0, len = fontlist.size() ; i < len ; ++i) for (size_t i = 0, len = fontlist.size() ; i < len ; ++i)
{ {
int j = ::SendMessage(_hFontNameCombo, CB_ADDSTRING, 0, (LPARAM)fontlist[i].c_str()); auto j = ::SendMessage(_hFontNameCombo, CB_ADDSTRING, 0, (LPARAM)fontlist[i].c_str());
::SendMessage(_hFontNameCombo, CB_SETITEMDATA, j, (LPARAM)fontlist[i].c_str()); ::SendMessage(_hFontNameCombo, CB_SETITEMDATA, j, (LPARAM)fontlist[i].c_str());
} }
@ -185,7 +185,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
{ {
if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_SC_PERCENTAGE_SLIDER)) if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_SC_PERCENTAGE_SLIDER))
{ {
int percent = ::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0); int percent = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0));
(NppParameters::getInstance())->SetTransparent(_hSelf, percent); (NppParameters::getInstance())->SetTransparent(_hSelf, percent);
} }
return TRUE; return TRUE;
@ -283,7 +283,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
updateThemeName(_themeName); updateThemeName(_themeName);
_restoreInvalid = false; _restoreInvalid = false;
_currentThemeIndex = ::SendMessage(_hSwitch2ThemeCombo, CB_GETCURSEL, 0, 0); _currentThemeIndex = static_cast<int32_t>(::SendMessage(_hSwitch2ThemeCombo, CB_GETCURSEL, 0, 0));
::EnableWindow(::GetDlgItem(_hSelf, IDOK), FALSE); ::EnableWindow(::GetDlgItem(_hSelf, IDOK), FALSE);
_isDirty = false; _isDirty = false;
} }
@ -301,7 +301,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_SC_TRANSPARENT_CHECK, BM_GETCHECK, 0, 0)); bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_SC_TRANSPARENT_CHECK, BM_GETCHECK, 0, 0));
if (isChecked) if (isChecked)
{ {
int percent = ::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0); int percent = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0));
(NppParameters::getInstance())->SetTransparent(_hSelf, percent); (NppParameters::getInstance())->SetTransparent(_hSelf, percent);
} }
else else
@ -314,7 +314,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
case IDC_GLOBAL_FG_CHECK : case IDC_GLOBAL_FG_CHECK :
{ {
GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle(); GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle();
glo.enableFg = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0)); glo.enableFg = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0));
notifyDataModified(); notifyDataModified();
apply(); apply();
return TRUE; return TRUE;
@ -323,7 +323,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
case IDC_GLOBAL_BG_CHECK: case IDC_GLOBAL_BG_CHECK:
{ {
GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle(); GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle();
glo.enableBg = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0)); glo.enableBg = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0));
notifyDataModified(); notifyDataModified();
apply(); apply();
return TRUE; return TRUE;
@ -332,7 +332,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
case IDC_GLOBAL_FONT_CHECK : case IDC_GLOBAL_FONT_CHECK :
{ {
GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle(); GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle();
glo.enableFont = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0)); glo.enableFont = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0));
notifyDataModified(); notifyDataModified();
apply(); apply();
return TRUE; return TRUE;
@ -340,7 +340,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
case IDC_GLOBAL_FONTSIZE_CHECK : case IDC_GLOBAL_FONTSIZE_CHECK :
{ {
GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle(); GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle();
glo.enableFontSize = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0)); glo.enableFontSize = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0));
notifyDataModified(); notifyDataModified();
apply(); apply();
return TRUE; return TRUE;
@ -348,7 +348,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
case IDC_GLOBAL_BOLD_CHECK : case IDC_GLOBAL_BOLD_CHECK :
{ {
GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle(); GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle();
glo.enableBold = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0)); glo.enableBold = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0));
notifyDataModified(); notifyDataModified();
apply(); apply();
return TRUE; return TRUE;
@ -357,7 +357,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
case IDC_GLOBAL_ITALIC_CHECK : case IDC_GLOBAL_ITALIC_CHECK :
{ {
GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle(); GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle();
glo.enableItalic = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0)); glo.enableItalic = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0));
notifyDataModified(); notifyDataModified();
apply(); apply();
return TRUE; return TRUE;
@ -365,7 +365,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
case IDC_GLOBAL_UNDERLINE_CHECK : case IDC_GLOBAL_UNDERLINE_CHECK :
{ {
GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle(); GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle();
glo.enableUnderLine = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0)); glo.enableUnderLine = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0));
notifyDataModified(); notifyDataModified();
apply(); apply();
return TRUE; return TRUE;
@ -390,7 +390,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
break; break;
case IDC_LANGUAGES_LIST : case IDC_LANGUAGES_LIST :
{ {
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0); int i = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0));
if (i != LB_ERR) if (i != LB_ERR)
{ {
bool prevThemeState = _isThemeDirty; bool prevThemeState = _isThemeDirty;
@ -491,7 +491,7 @@ void WordStyleDlg::updateThemeName(generic_string themeName)
int WordStyleDlg::whichTabColourIndex() int WordStyleDlg::whichTabColourIndex()
{ {
int i = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0);
if (i == LB_ERR) if (i == LB_ERR)
return -1; return -1;
TCHAR styleName[128]; TCHAR styleName[128];
@ -536,7 +536,7 @@ void WordStyleDlg::updateColour(bool which)
void WordStyleDlg::updateFontSize() void WordStyleDlg::updateFontSize()
{ {
Style & style = getCurrentStyler(); Style & style = getCurrentStyler();
int iFontSizeSel = ::SendMessage(_hFontSizeCombo, CB_GETCURSEL, 0, 0); auto iFontSizeSel = ::SendMessage(_hFontSizeCombo, CB_GETCURSEL, 0, 0);
TCHAR intStr[5]; TCHAR intStr[5];
if (iFontSizeSel != 0) if (iFontSizeSel != 0)
@ -569,8 +569,8 @@ void WordStyleDlg::updateUserKeywords()
Style & style = getCurrentStyler(); Style & style = getCurrentStyler();
//const int NB_MAX = 2048; //const int NB_MAX = 2048;
//TCHAR kw[NB_MAX]; //TCHAR kw[NB_MAX];
int len = ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXTLENGTH, 0, 0); auto len = ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXTLENGTH, 0, 0);
len +=1; len += 1;
TCHAR *kw = new TCHAR[len]; TCHAR *kw = new TCHAR[len];
::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXT, len, (LPARAM)kw); ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXT, len, (LPARAM)kw);
style.setKeywords(kw); style.setKeywords(kw);
@ -581,7 +581,7 @@ void WordStyleDlg::updateUserKeywords()
void WordStyleDlg::updateFontName() void WordStyleDlg::updateFontName()
{ {
Style & style = getCurrentStyler(); Style & style = getCurrentStyler();
int iFontSel = ::SendMessage(_hFontNameCombo, CB_GETCURSEL, 0, 0); auto iFontSel = ::SendMessage(_hFontNameCombo, CB_GETCURSEL, 0, 0);
TCHAR *fnStr = (TCHAR *)::SendMessage(_hFontNameCombo, CB_GETITEMDATA, iFontSel, 0); TCHAR *fnStr = (TCHAR *)::SendMessage(_hFontNameCombo, CB_GETITEMDATA, iFontSel, 0);
style._fontName = fnStr; style._fontName = fnStr;
} }
@ -606,7 +606,7 @@ void WordStyleDlg::updateFontStyleStatus(fontStyleType whitchStyle)
hWnd = _hCheckItalic; hWnd = _hCheckItalic;
} }
int isChecked = ::SendMessage(hWnd, BM_GETCHECK, 0, 0); auto isChecked = ::SendMessage(hWnd, BM_GETCHECK, 0, 0);
if (isChecked != BST_INDETERMINATE) if (isChecked != BST_INDETERMINATE)
{ {
if (isChecked == BST_CHECKED) if (isChecked == BST_CHECKED)
@ -618,7 +618,7 @@ void WordStyleDlg::updateFontStyleStatus(fontStyleType whitchStyle)
void WordStyleDlg::switchToTheme() void WordStyleDlg::switchToTheme()
{ {
int iSel = ::SendMessage(_hSwitch2ThemeCombo, CB_GETCURSEL, 0, 0); auto iSel = ::SendMessage(_hSwitch2ThemeCombo, CB_GETCURSEL, 0, 0);
generic_string prevThemeName(_themeName); generic_string prevThemeName(_themeName);
_themeName.clear(); _themeName.clear();
@ -713,7 +713,7 @@ void WordStyleDlg::setVisualFromStyleList()
str[0] = '\0'; str[0] = '\0';
int i = ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETCURSEL, 0, 0);
if (i == LB_ERR) if (i == LB_ERR)
return; return;
::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETTEXT, i, (LPARAM)str); ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETTEXT, i, (LPARAM)str);
@ -752,7 +752,7 @@ void WordStyleDlg::setVisualFromStyleList()
//-- font name //-- font name
isEnable = false; isEnable = false;
int iFontName; LRESULT iFontName;
if (style._fontName != NULL) if (style._fontName != NULL)
{ {
iFontName = ::SendMessage(_hFontNameCombo, CB_FINDSTRING, 1, (LPARAM)style._fontName); iFontName = ::SendMessage(_hFontNameCombo, CB_FINDSTRING, 1, (LPARAM)style._fontName);
@ -770,7 +770,7 @@ void WordStyleDlg::setVisualFromStyleList()
//-- font size //-- font size
isEnable = false; isEnable = false;
TCHAR intStr[5] = TEXT(""); TCHAR intStr[5] = TEXT("");
int iFontSize = 0; LRESULT iFontSize = 0;
if (style._fontSize != STYLE_NOT_USED) if (style._fontSize != STYLE_NOT_USED)
{ {
wsprintf(intStr, TEXT("%d"), style._fontSize); wsprintf(intStr, TEXT("%d"), style._fontSize);

View File

@ -161,7 +161,7 @@ private :
Style & getCurrentStyler() { Style & getCurrentStyler() {
int styleIndex = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0); auto styleIndex = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0);
if (styleIndex == LB_ERR) styleIndex = 0; if (styleIndex == LB_ERR) styleIndex = 0;
if (_currentLexerIndex == 0) if (_currentLexerIndex == 0)

View File

@ -80,7 +80,7 @@ void ContextMenu::create(HWND hParent, const std::vector<MenuItemUnit> & menuIte
j = 0; j = 0;
_subMenus.push_back(hParentFolder); _subMenus.push_back(hParentFolder);
::InsertMenu(_hMenu, i, MF_BYPOSITION | MF_POPUP, (UINT_PTR)hParentFolder, currentParentFolderStr.c_str()); ::InsertMenu(_hMenu, static_cast<UINT>(i), MF_BYPOSITION | MF_POPUP, (UINT_PTR)hParentFolder, currentParentFolderStr.c_str());
} }
} }
@ -96,12 +96,12 @@ void ContextMenu::create(HWND hParent, const std::vector<MenuItemUnit> & menuIte
} }
else if (item._cmdID != 0) else if (item._cmdID != 0)
{ {
::InsertMenu(_hMenu, i, flag, item._cmdID, item._itemName.c_str()); ::InsertMenu(_hMenu, static_cast<UINT>(i), flag, item._cmdID, item._itemName.c_str());
lastIsSep = false; lastIsSep = false;
} }
else if (item._cmdID == 0 && !lastIsSep) else if (item._cmdID == 0 && !lastIsSep)
{ {
::InsertMenu(_hMenu, i, flag, item._cmdID, item._itemName.c_str()); ::InsertMenu(_hMenu, static_cast<int32_t>(i), flag, item._cmdID, item._itemName.c_str());
lastIsSep = true; lastIsSep = true;
} }
else // last item is separator and current item is separator else // last item is separator and current item is separator

View File

@ -53,11 +53,11 @@ static LRESULT CALLBACK hookProcMouse(UINT nCode, WPARAM wParam, LPARAM lParam)
{ {
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
case WM_NCMOUSEMOVE: case WM_NCMOUSEMOVE:
::PostMessage(hWndServer, wParam, 0, 0); ::PostMessage(hWndServer, UINT(wParam), 0, 0);
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_NCLBUTTONUP: case WM_NCLBUTTONUP:
::PostMessage(hWndServer, wParam, 0, 0); ::PostMessage(hWndServer, UINT(wParam), 0, 0);
break; break;
default: default:
break; break;
@ -227,7 +227,7 @@ void DockingCont::setActiveTb(int iItem)
int DockingCont::getActiveTb() int DockingCont::getActiveTb()
{ {
return ::SendMessage(_hContTab, TCM_GETCURSEL, 0, 0); return static_cast<int32_t>(::SendMessage(_hContTab, TCM_GETCURSEL, 0, 0));
} }
tTbData* DockingCont::getDataOfActiveTb() tTbData* DockingCont::getDataOfActiveTb()
@ -251,7 +251,7 @@ vector<tTbData*> DockingCont::getDataOfVisTb()
{ {
vector<tTbData*> vTbData; vector<tTbData*> vTbData;
TCITEM tcItem = {0}; TCITEM tcItem = {0};
int iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); int iItemCnt = static_cast<int32_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
tcItem.mask = TCIF_PARAM; tcItem.mask = TCIF_PARAM;
@ -266,7 +266,7 @@ vector<tTbData*> DockingCont::getDataOfVisTb()
bool DockingCont::isTbVis(tTbData* data) bool DockingCont::isTbVis(tTbData* data)
{ {
TCITEM tcItem = {0}; TCITEM tcItem = {0};
int iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); int iItemCnt = static_cast<int32_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
tcItem.mask = TCIF_PARAM; tcItem.mask = TCIF_PARAM;
@ -458,7 +458,7 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct)
HBITMAP hBmpCur = NULL; HBITMAP hBmpCur = NULL;
HBITMAP hBmpOld = NULL; HBITMAP hBmpOld = NULL;
HBITMAP hBmpNew = NULL; HBITMAP hBmpNew = NULL;
UINT length = _pszCaption.length(); int length = static_cast<int32_t>(_pszCaption.length());
int nSavedDC = ::SaveDC(hDc); int nSavedDC = ::SaveDC(hDc);
@ -656,7 +656,7 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
// get selected sub item // get selected sub item
info.pt.x = LOWORD(lParam); info.pt.x = LOWORD(lParam);
info.pt.y = HIWORD(lParam); info.pt.y = HIWORD(lParam);
iItem = ::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info); iItem = static_cast<int32_t>(::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info));
SelectTab(iItem); SelectTab(iItem);
_beginDrag = FALSE; _beginDrag = FALSE;
@ -676,7 +676,7 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
// get selected sub item // get selected sub item
info.pt.x = LOWORD(lParam); info.pt.x = LOWORD(lParam);
info.pt.y = HIWORD(lParam); info.pt.y = HIWORD(lParam);
iItem = ::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info); iItem = static_cast<int32_t>(::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info));
SelectTab(iItem); SelectTab(iItem);
@ -703,7 +703,7 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
// get selected sub item // get selected sub item
info.pt.x = LOWORD(lParam); info.pt.x = LOWORD(lParam);
info.pt.y = HIWORD(lParam); info.pt.y = HIWORD(lParam);
iItem = ::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info); iItem = static_cast<int32_t>(::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info));
if ((_beginDrag == TRUE) && (wParam == MK_LBUTTON)) if ((_beginDrag == TRUE) && (wParam == MK_LBUTTON))
{ {
@ -716,7 +716,7 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
} }
else else
{ {
int iItemSel = ::SendMessage(hwnd, TCM_GETCURSEL, 0, 0); int iItemSel = static_cast<int32_t>(::SendMessage(hwnd, TCM_GETCURSEL, 0, 0));
if ((_bTabTTHover == FALSE) && (iItem != iItemSel)) if ((_bTabTTHover == FALSE) && (iItem != iItemSel))
{ {
@ -774,7 +774,7 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
// get selected sub item // get selected sub item
info.pt.x = LOWORD(lParam); info.pt.x = LOWORD(lParam);
info.pt.y = HIWORD(lParam); info.pt.y = HIWORD(lParam);
iItem = ::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info); iItem = static_cast<int32_t>(::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info));
// recalc mouse position // recalc mouse position
::ClientToScreen(hwnd, &info.pt); ::ClientToScreen(hwnd, &info.pt);
@ -809,7 +809,7 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
// get selected sub item // get selected sub item
info.pt.x = LOWORD(lParam); info.pt.x = LOWORD(lParam);
info.pt.y = HIWORD(lParam); info.pt.y = HIWORD(lParam);
iItem = ::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info); iItem = static_cast<int32_t>(::SendMessage(hwnd, TCM_HITTEST, 0, (LPARAM)&info));
SelectTab(iItem); SelectTab(iItem);
} }
@ -870,7 +870,7 @@ void DockingCont::drawTabItem(DRAWITEMSTRUCT *pDrawItemStruct)
if (((tTbData*)tcItem.lParam)->uMask & DWS_ICONTAB) if (((tTbData*)tcItem.lParam)->uMask & DWS_ICONTAB)
{ {
HIMAGELIST hImageList = (HIMAGELIST)::SendMessage(_hParent, DMM_GETIMAGELIST, 0, 0); HIMAGELIST hImageList = (HIMAGELIST)::SendMessage(_hParent, DMM_GETIMAGELIST, 0, 0);
int iPosImage = ::SendMessage(_hParent, DMM_GETICONPOS, 0, (LPARAM)((tTbData*)tcItem.lParam)->hClient); int iPosImage = static_cast<int32_t>(::SendMessage(_hParent, DMM_GETICONPOS, 0, (LPARAM)((tTbData*)tcItem.lParam)->hClient));
if ((hImageList != NULL) && (iPosImage >= 0)) if ((hImageList != NULL) && (iPosImage >= 0))
{ {
@ -1017,7 +1017,7 @@ void DockingCont::onSize()
TCITEM tcItem = {0}; TCITEM tcItem = {0};
RECT rc = {0}; RECT rc = {0};
RECT rcTemp = {0}; RECT rcTemp = {0};
UINT iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); UINT iItemCnt = static_cast<int32_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
UINT iTabOff = 0; UINT iTabOff = 0;
getClientRect(rc); getClientRect(rc);
@ -1111,10 +1111,10 @@ void DockingCont::onSize()
// get active item data // get active item data
UINT iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); size_t iItemCnt = static_cast<size_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
// resize visible plugin windows // resize visible plugin windows
for (UINT iItem = 0; iItem < iItemCnt; ++iItem) for (size_t iItem = 0; iItem < iItemCnt; ++iItem)
{ {
tcItem.mask = TCIF_PARAM; tcItem.mask = TCIF_PARAM;
::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem);
@ -1139,7 +1139,7 @@ void DockingCont::onSize()
void DockingCont::doClose() void DockingCont::doClose()
{ {
int iItemOff = 0; int iItemOff = 0;
int iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); int iItemCnt = static_cast<int32_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
for (int iItem = 0; iItem < iItemCnt; ++iItem) for (int iItem = 0; iItem < iItemCnt; ++iItem)
{ {
@ -1191,7 +1191,7 @@ int DockingCont::hideToolbar(tTbData *pTbData, BOOL hideClient)
// delete item // delete item
if (TRUE == ::SendMessage(_hContTab, TCM_DELETEITEM, iItem, 0)) if (TRUE == ::SendMessage(_hContTab, TCM_DELETEITEM, iItem, 0))
{ {
UINT iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); auto iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0);
if (iItemCnt != 0) if (iItemCnt != 0)
{ {
@ -1199,7 +1199,7 @@ int DockingCont::hideToolbar(tTbData *pTbData, BOOL hideClient)
tcItem.mask = TCIF_PARAM; tcItem.mask = TCIF_PARAM;
if ((unsigned int)iItem == iItemCnt) if (iItem == iItemCnt)
{ {
iItem--; iItem--;
} }
@ -1240,7 +1240,7 @@ int DockingCont::hideToolbar(tTbData *pTbData, BOOL hideClient)
void DockingCont::viewToolbar(tTbData *pTbData) void DockingCont::viewToolbar(tTbData *pTbData)
{ {
TCITEM tcItem = {0}; TCITEM tcItem = {0};
int iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); int iItemCnt = static_cast<int32_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
if (iItemCnt > 0) if (iItemCnt > 0)
{ {
@ -1287,7 +1287,7 @@ void DockingCont::viewToolbar(tTbData *pTbData)
int DockingCont::SearchPosInTab(tTbData* pTbData) int DockingCont::SearchPosInTab(tTbData* pTbData)
{ {
TCITEM tcItem = {0}; TCITEM tcItem = {0};
int iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); int iItemCnt = static_cast<int32_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
tcItem.mask = TCIF_PARAM; tcItem.mask = TCIF_PARAM;
@ -1311,7 +1311,7 @@ void DockingCont::SelectTab(int iTab)
TCITEM tcItem = {0}; TCITEM tcItem = {0};
SIZE size = {0}; SIZE size = {0};
int maxWidth = 0; int maxWidth = 0;
int iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); int iItemCnt = static_cast<int32_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
// get data of new active dialog // get data of new active dialog
tcItem.mask = TCIF_PARAM; tcItem.mask = TCIF_PARAM;

View File

@ -113,7 +113,7 @@ public:
return _isFloating; return _isFloating;
} }
INT getElementCnt() { size_t getElementCnt() {
return _vTbData.size(); return _vTbData.size();
} }
@ -142,7 +142,7 @@ public:
}; };
virtual void destroy() { virtual void destroy() {
for (INT iTb = _vTbData.size(); iTb > 0; iTb--) for (int iTb = (int)_vTbData.size(); iTb > 0; iTb--)
{ {
delete _vTbData[iTb-1]; delete _vTbData[iTb-1];
} }

View File

@ -213,12 +213,12 @@ void DockingManager::updateContainerInfo(HWND hClient)
} }
} }
void DockingManager::showContainer(HWND hCont, BOOL view) void DockingManager::showContainer(HWND hCont, bool display)
{ {
for (size_t iCont = 0, len = _vContainer.size(); iCont < len; ++iCont) for (size_t iCont = 0, len = _vContainer.size(); iCont < len; ++iCont)
{ {
if (_vContainer[iCont]->getHSelf() == hCont) if (_vContainer[iCont]->getHSelf() == hCont)
showContainer(iCont, view); showContainer(iCont, display);
} }
} }
@ -262,7 +262,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
} }
// destroy containers // destroy containers
for (int i = _vContainer.size(); i > 0; i--) for (size_t i = _vContainer.size(); i > 0; i--)
{ {
_vContainer[i-1]->destroy(); _vContainer[i-1]->destroy();
delete _vContainer[i-1]; delete _vContainer[i-1];
@ -293,7 +293,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
case DMM_MOVE_SPLITTER: case DMM_MOVE_SPLITTER:
{ {
int offset = wParam; int offset = static_cast<int32_t>(wParam);
for (int iCont = 0; iCont < DOCKCONT_MAX; ++iCont) for (int iCont = 0; iCont < DOCKCONT_MAX; ++iCont)
{ {
@ -382,7 +382,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
} }
case DMM_GETICONPOS: case DMM_GETICONPOS:
{ {
for (UINT uImageCnt = 0, len = _vImageList.size(); uImageCnt < len; ++uImageCnt) for (size_t uImageCnt = 0, len = _vImageList.size(); uImageCnt < len; ++uImageCnt)
{ {
if ((HWND)lParam == _vImageList[uImageCnt]) if ((HWND)lParam == _vImageList[uImageCnt])
{ {
@ -611,7 +611,7 @@ void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible)
// get previous position and set container id // get previous position and set container id
data.iPrevCont = (data.uMask & 0x30000000) >> 28; data.iPrevCont = (data.uMask & 0x30000000) >> 28;
iCont = _vContainer.size()-1; iCont = static_cast<int32_t>(_vContainer.size()) - 1;
} }
else else
{ {
@ -639,7 +639,7 @@ void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible)
// initialize and map container id // initialize and map container id
pCont->init(_hInst, _hSelf); pCont->init(_hInst, _hSelf);
pCont->doDialog(isVisible, true); pCont->doDialog(isVisible, true);
_iContMap[iCont] = _vContainer.size()-1; _iContMap[iCont] = static_cast<int32_t>(_vContainer.size()) - 1;
} }
// get current container from map // get current container from map
@ -659,7 +659,7 @@ void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible)
pCont->init(_hInst, _hSelf); pCont->init(_hInst, _hSelf);
pCont->doDialog(false, true); pCont->doDialog(false, true);
pCont->reSizeToWH(data.rcFloat); pCont->reSizeToWH(data.rcFloat);
_iContMap[data.iPrevCont] = _vContainer.size()-1; _iContMap[data.iPrevCont] = static_cast<int32_t>(_vContainer.size()) - 1;
} }
data.iPrevCont = _iContMap[data.iPrevCont]; data.iPrevCont = _iContMap[data.iPrevCont];
} }
@ -935,7 +935,7 @@ int DockingManager::GetContainer(DockingCont* pCont)
{ {
if (_vContainer[iCont] == pCont) if (_vContainer[iCont] == pCont)
{ {
iRet = iCont; iRet = static_cast<int32_t>(iCont);
break; break;
} }
} }
@ -974,7 +974,7 @@ int DockingManager::FindEmptyContainer()
// and test if container is hidden // and test if container is hidden
if (!_vContainer[iCont]->isVisible()) if (!_vContainer[iCont]->isVisible())
{ {
iRetCont = iCont; iRetCont = static_cast<int32_t>(iCont);
break; break;
} }
} }

View File

@ -63,10 +63,10 @@ public :
_ppMainWindow = ppWin; _ppMainWindow = ppWin;
}; };
void showContainer(HWND hCont, BOOL view = TRUE); void showContainer(HWND hCont, bool display = true);
void showContainer(UINT uCont, BOOL view = TRUE) { void showContainer(size_t uCont, bool display = true) {
_vContainer[uCont]->doDialog((view == TRUE)); _vContainer[uCont]->doDialog(display);
onSize(); onSize();
} }

View File

@ -50,11 +50,11 @@ static LRESULT CALLBACK hookProcMouse(UINT nCode, WPARAM wParam, LPARAM lParam)
{ {
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
case WM_NCMOUSEMOVE: case WM_NCMOUSEMOVE:
::PostMessage(hWndMouse, wParam, 0, 0); ::PostMessage(hWndMouse, static_cast<UINT>(wParam), 0, 0);
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_NCLBUTTONUP: case WM_NCLBUTTONUP:
::PostMessage(hWndMouse, wParam, 0, 0); ::PostMessage(hWndMouse, static_cast<UINT>(wParam), 0, 0);
return TRUE; return TRUE;
default: default:
break; break;

View File

@ -59,13 +59,11 @@ static LRESULT CALLBACK hookProcMouse(INT nCode, WPARAM wParam, LPARAM lParam)
{ {
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
case WM_NCMOUSEMOVE: case WM_NCMOUSEMOVE:
//::PostMessage(hWndServer, wParam, 0, 0); ::SendMessage(hWndServer, static_cast<UINT>(wParam), 0, 0);
::SendMessage(hWndServer, wParam, 0, 0);
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_NCLBUTTONUP: case WM_NCLBUTTONUP:
//::PostMessage(hWndServer, wParam, 0, 0); ::SendMessage(hWndServer, static_cast<UINT>(wParam), 0, 0);
::SendMessage(hWndServer, wParam, 0, 0);
return TRUE; return TRUE;
default: default:
break; break;
@ -414,7 +412,6 @@ void Gripper::doTabReordering(POINT pt)
BOOL inTab = FALSE; BOOL inTab = FALSE;
HWND hTab = NULL; HWND hTab = NULL;
HWND hTabOld = _hTab; HWND hTabOld = _hTab;
int iItem = -1;
int iItemOld = _iItem; int iItemOld = _iItem;
/* search for every tab entry */ /* search for every tab entry */
@ -441,14 +438,14 @@ void Gripper::doTabReordering(POINT pt)
iItemOld = _iItem; iItemOld = _iItem;
} }
/* get pointed tab item */ // get pointed tab item
info.pt = pt; info.pt = pt;
::ScreenToClient(hTab, &info.pt); ::ScreenToClient(hTab, &info.pt);
iItem = ::SendMessage(hTab, TCM_HITTEST, 0, (LPARAM)&info); auto iItem = ::SendMessage(hTab, TCM_HITTEST, 0, (LPARAM)&info);
if (iItem != -1) if (iItem != -1)
{ {
/* prevent flickering of tabs with different sizes */ // prevent flickering of tabs with different sizes
::SendMessage(hTab, TCM_GETITEMRECT, iItem, (LPARAM)&rc); ::SendMessage(hTab, TCM_GETITEMRECT, iItem, (LPARAM)&rc);
ClientRectToScreenRect(hTab, &rc); ClientRectToScreenRect(hTab, &rc);
@ -457,17 +454,17 @@ void Gripper::doTabReordering(POINT pt)
return; return;
} }
_iItem = iItem; _iItem = static_cast<int32_t>(iItem);
} }
else if (_hTab && ((hTab != _hTab) || (_iItem == -1))) else if (_hTab && ((hTab != _hTab) || (_iItem == -1)))
{ {
/* test if cusor points after last tab */ // test if cusor points after last tab
int iLastItem = ::SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0) - 1; auto iLastItem = ::SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0) - 1;
::SendMessage(hTab, TCM_GETITEMRECT, iLastItem, (LPARAM)&rc); ::SendMessage(hTab, TCM_GETITEMRECT, iLastItem, (LPARAM)&rc);
if ((rc.left + rc.right) < pt.x) if ((rc.left + rc.right) < pt.x)
{ {
_iItem = iLastItem + 1; _iItem = static_cast<int32_t>(iLastItem) + 1;
} }
} }
@ -478,18 +475,18 @@ void Gripper::doTabReordering(POINT pt)
} }
} }
/* set and remove tabs correct */ // set and remove tabs correct
if ((inTab == TRUE) && (iItemOld != _iItem)) if ((inTab == TRUE) && (iItemOld != _iItem))
{ {
if (_hTab == _hTabSource) if (_hTab == _hTabSource)
{ {
/* delete item if switching back to source tab */ // delete item if switching back to source tab
int iSel = ::SendMessage(_hTab, TCM_GETCURSEL, 0, 0); auto iSel = ::SendMessage(_hTab, TCM_GETCURSEL, 0, 0);
::SendMessage(_hTab, TCM_DELETEITEM, iSel, 0); ::SendMessage(_hTab, TCM_DELETEITEM, iSel, 0);
} }
else if (_hTab == hTabOld) else if (_hTab == hTabOld)
{ {
/* delete item on switch between tabs */ // delete item on switch between tabs
::SendMessage(_hTab, TCM_DELETEITEM, iItemOld, 0); ::SendMessage(_hTab, TCM_DELETEITEM, iItemOld, 0);
} }
} }
@ -502,14 +499,14 @@ void Gripper::doTabReordering(POINT pt)
_iItem = -1; _iItem = -1;
} }
/* insert new entry when mouse doesn't point to current hovered tab */ // insert new entry when mouse doesn't point to current hovered tab
if (_hTab && ((_hTab != hTabOld) || (_iItem != iItemOld))) if (_hTab && ((_hTab != hTabOld) || (_iItem != iItemOld)))
{ {
_tcItem.mask = TCIF_PARAM | (_hTab == _hTabSource ? TCIF_TEXT : 0); _tcItem.mask = TCIF_PARAM | (_hTab == _hTabSource ? TCIF_TEXT : 0);
::SendMessage(_hTab, TCM_INSERTITEM, _iItem, (LPARAM)&_tcItem); ::SendMessage(_hTab, TCM_INSERTITEM, _iItem, (LPARAM)&_tcItem);
} }
/* select the tab only in source tab window */ // select the tab only in source tab window
if ((_hTab == _hTabSource) && (_iItem != -1)) if ((_hTab == _hTabSource) && (_iItem != -1))
{ {
::SendMessage(_hTab, TCM_SETCURSEL, _iItem, 0); ::SendMessage(_hTab, TCM_SETCURSEL, _iItem, 0);
@ -731,7 +728,7 @@ DockingCont* Gripper::contHitTest(POINT pt)
vector<DockingCont*> vCont = _pDockMgr->getContainerInfo(); vector<DockingCont*> vCont = _pDockMgr->getContainerInfo();
HWND hWnd = ::WindowFromPoint(pt); HWND hWnd = ::WindowFromPoint(pt);
for (UINT iCont = 0, len = vCont.size(); iCont < len; ++iCont) for (size_t iCont = 0, len = vCont.size(); iCont < len; ++iCont)
{ {
/* test if within caption */ /* test if within caption */
if (hWnd == vCont[iCont]->getCaptionWnd()) if (hWnd == vCont[iCont]->getCaptionWnd())
@ -869,8 +866,8 @@ void Gripper::initTabInformation()
} }
else else
{ {
/* get active tab item */ // get active tab item
_iItem = ::SendMessage(_hTabSource, TCM_GETCURSEL, 0, 0); _iItem = static_cast<int32_t>(::SendMessage(_hTabSource, TCM_GETCURSEL, 0, 0));
} }
/* get size of item */ /* get size of item */

View File

@ -68,7 +68,7 @@ void DocumentMap::setSyntaxHiliting()
bool DocumentMap::needToRecomputeWith() bool DocumentMap::needToRecomputeWith()
{ {
int currentZoom = (*_ppEditView)->execute(SCI_GETZOOM); auto currentZoom = (*_ppEditView)->execute(SCI_GETZOOM);
if (_displayZoom != currentZoom) if (_displayZoom != currentZoom)
return true; return true;
@ -152,7 +152,7 @@ void DocumentMap::wrapMap()
// update the wrap needed data // update the wrap needed data
_displayWidth = editZoneWidth; _displayWidth = editZoneWidth;
_displayZoom = (*_ppEditView)->execute(SCI_GETZOOM); _displayZoom = static_cast<int32_t>((*_ppEditView)->execute(SCI_GETZOOM));
double zr = zoomRatio[_displayZoom + 10]; double zr = zoomRatio[_displayZoom + 10];
// compute doc map width: dzw/ezw = 1/zoomRatio // compute doc map width: dzw/ezw = 1/zoomRatio
@ -175,7 +175,7 @@ int DocumentMap::getEditorTextZoneWidth()
int marginWidths = 0; int marginWidths = 0;
for (int m = 0; m < 4; ++m) for (int m = 0; m < 4; ++m)
{ {
marginWidths += (*_ppEditView)->execute(SCI_GETMARGINWIDTHN, m); marginWidths += static_cast<int32_t>((*_ppEditView)->execute(SCI_GETMARGINWIDTHN, m));
} }
return editorRect.right - editorRect.left - marginWidths; return editorRect.right - editorRect.left - marginWidths;
} }
@ -185,16 +185,16 @@ void DocumentMap::scrollMap()
if (_pScintillaEditView && _ppEditView) if (_pScintillaEditView && _ppEditView)
{ {
// Visible document line for the code view (but not displayed line) // Visible document line for the code view (but not displayed line)
int firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE); auto firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
int firstVisibleDocLine = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine); auto firstVisibleDocLine = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine);
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine); auto nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine);
int lastVisibleDocLine = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine); auto lastVisibleDocLine = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine);
// Visible document line for the map view // Visible document line for the map view
int firstVisibleDisplayLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE); auto firstVisibleDisplayLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE);
int firstVisibleDocLineMap = _pScintillaEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap); auto firstVisibleDocLineMap = _pScintillaEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap);
int nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap); auto nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap);
int lastVisibleDocLineMap = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap + nbLineMap); auto lastVisibleDocLineMap = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap + nbLineMap);
// If part of editor view is out of map, then scroll map // If part of editor view is out of map, then scroll map
if (lastVisibleDocLineMap < lastVisibleDocLine) if (lastVisibleDocLineMap < lastVisibleDocLine)
@ -203,30 +203,30 @@ void DocumentMap::scrollMap()
_pScintillaEditView->execute(SCI_GOTOLINE, firstVisibleDocLine); _pScintillaEditView->execute(SCI_GOTOLINE, firstVisibleDocLine);
// Get the editor's higher/lower Y, then compute the map's higher/lower Y // Get the editor's higher/lower Y, then compute the map's higher/lower Y
int higherY = 0; LRESULT higherY = 0;
int lowerY = 0; LRESULT lowerY = 0;
if (!(*_ppEditView)->isWrap()) if (!(*_ppEditView)->isWrap())
{ {
int higherPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, firstVisibleDocLine); auto higherPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, firstVisibleDocLine);
int lowerPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, lastVisibleDocLine); auto lowerPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, lastVisibleDocLine);
higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos); higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos);
lowerY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos); lowerY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos);
if (lowerY == 0) if (lowerY == 0)
{ {
int lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine); auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine);
lowerY = nbLine * lineHeight + firstVisibleDocLine; lowerY = nbLine * lineHeight + firstVisibleDocLine;
} }
} }
else else
{ {
int higherPos = (*_ppEditView)->execute(SCI_POSITIONFROMPOINT, 0, 0); auto higherPos = (*_ppEditView)->execute(SCI_POSITIONFROMPOINT, 0, 0);
higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos); higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos);
int lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine); auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine);
lowerY = nbLine * lineHeight + higherY; lowerY = nbLine * lineHeight + higherY;
} }
// Update view zone in map // Update view zone in map
_vzDlg.drawZone(higherY, lowerY); _vzDlg.drawZone(static_cast<long>(higherY), static_cast<long>(lowerY));
} }
} }
@ -252,10 +252,10 @@ void DocumentMap::foldAll(bool mode)
void DocumentMap::scrollMap(bool direction, moveMode whichMode) void DocumentMap::scrollMap(bool direction, moveMode whichMode)
{ {
// Visible line for the code view // Visible line for the code view
int firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE); auto firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine); auto nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine);
int nbLine2go = (whichMode == perLine?1:nbLine); auto nbLine2go = (whichMode == perLine ? 1 : nbLine);
(*_ppEditView)->execute(SCI_LINESCROLL, 0, (direction == moveDown)?nbLine2go:-nbLine2go); (*_ppEditView)->execute(SCI_LINESCROLL, 0, (direction == moveDown) ? nbLine2go : -nbLine2go);
scrollMap(); scrollMap();
} }
@ -384,7 +384,7 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{ {
int newPosY = HIWORD(lParam); int newPosY = HIWORD(lParam);
int currentCenterPosY = _vzDlg.getCurrentCenterPosY(); int currentCenterPosY = _vzDlg.getCurrentCenterPosY();
int pixelPerLine = _pScintillaEditView->execute(SCI_TEXTHEIGHT, 0); int pixelPerLine = static_cast<int32_t>(_pScintillaEditView->execute(SCI_TEXTHEIGHT, 0));
int jumpDistance = newPosY - currentCenterPosY; int jumpDistance = newPosY - currentCenterPosY;
int nbLine2jump = jumpDistance/pixelPerLine; int nbLine2jump = jumpDistance/pixelPerLine;
(*_ppEditView)->execute(SCI_LINESCROLL, 0, nbLine2jump); (*_ppEditView)->execute(SCI_LINESCROLL, 0, nbLine2jump);

View File

@ -376,7 +376,7 @@ generic_string FileBrowser::getNodePath(HTREEITEM node) const
} }
for (long i = fullPathArray.size() - 1; i >= 0; --i) for (int i = int(fullPathArray.size()) - 1; i >= 0; --i)
{ {
fullPath += fullPathArray[i]; fullPath += fullPathArray[i];
if (i != 0) if (i != 0)
@ -485,7 +485,7 @@ void FileBrowser::notified(LPNMHDR notification)
else else
return; return;
lpGetInfoTip->pszText = (LPTSTR)tipStr.c_str(); lpGetInfoTip->pszText = (LPTSTR)tipStr.c_str();
lpGetInfoTip->cchTextMax = tipStr.size(); lpGetInfoTip->cchTextMax = static_cast<int>(tipStr.size());
} }
break; break;
@ -724,7 +724,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
case IDM_FILEBROWSER_REMOVEALLROOTS: case IDM_FILEBROWSER_REMOVEALLROOTS:
{ {
for (int i = _folderUpdaters.size() - 1; i >= 0; --i) for (int i = (int)_folderUpdaters.size() - 1; i >= 0; --i)
{ {
_folderUpdaters[i]->stopWatcher(); _folderUpdaters[i]->stopWatcher();

View File

@ -52,7 +52,7 @@ INT_PTR CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, L
case ID_FINDCHAR_NEXT: case ID_FINDCHAR_NEXT:
{ {
int currentPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS); int currentPos = static_cast<int32_t>((*_ppEditView)->execute(SCI_GETCURRENTPOS));
unsigned char startRange = 0; unsigned char startRange = 0;
unsigned char endRange = 255; unsigned char endRange = 255;
bool direction = dirDown; bool direction = dirDown;
@ -122,7 +122,7 @@ bool FindCharsInRangeDlg::findCharInRange(unsigned char beginRange, unsigned cha
if (found != -1) if (found != -1)
{ {
//printInt(found); //printInt(found);
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, found); auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, found);
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line); (*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
(*_ppEditView)->execute(SCI_GOTOPOS, found); (*_ppEditView)->execute(SCI_GOTOPOS, found);
(*_ppEditView)->execute(SCI_SETSEL, (direction == dirDown)?found:found+1, (direction == dirDown)?found+1:found); (*_ppEditView)->execute(SCI_SETSEL, (direction == dirDown)?found:found+1, (direction == dirDown)?found+1:found);

View File

@ -43,7 +43,7 @@ void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText
{ {
HTREEITEM itemParent = NULL; HTREEITEM itemParent = NULL;
TCHAR posStr[32]; TCHAR posStr[32];
generic_itoa(pos, posStr, 10); generic_itoa(static_cast<int32_t>(pos), posStr, 10);
HTREEITEM root = _treeView.getRoot(); HTREEITEM root = _treeView.getRoot();
if (nodeName != NULL && *nodeName != '\0') if (nodeName != NULL && *nodeName != '\0')
@ -108,7 +108,7 @@ size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSym
else // nothing found else // nothing found
{ {
cntOpen = 0; // get me out of here cntOpen = 0; // get me out of here
targetEnd = begin; targetEnd = static_cast<int32_t>(begin);
} }
targetStart = (*_ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), targetEnd, docLen); targetStart = (*_ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), targetEnd, docLen);
@ -370,7 +370,7 @@ bool FunctionListPanel::openSelection(const TreeView & treeView)
if (pos == -1) if (pos == -1)
return false; return false;
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos); auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos);
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line); (*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
(*_ppEditView)->scrollPosToCenter(pos); (*_ppEditView)->scrollPosToCenter(pos);

View File

@ -248,7 +248,7 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
{ {
if (_parsers[i]->_id == id) if (_parsers[i]->_id == id)
{ {
_associationMap.push_back(AssociationInfo(i, langIDStr?langID:-1, exts?exts:TEXT(""), userDefinedLangName?userDefinedLangName:TEXT(""))); _associationMap.push_back(AssociationInfo(static_cast<int32_t>(i), langIDStr ? langID : -1, exts ? exts : TEXT(""), userDefinedLangName ? userDefinedLangName : TEXT("")));
break; break;
} }
} }
@ -464,13 +464,13 @@ size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSy
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags); (*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
int targetStart = (*ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), begin, docLen); int targetStart = (*ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), begin, docLen);
int targetEnd = 0; LRESULT targetEnd = 0;
do do
{ {
if (targetStart != -1 && targetStart != -2) // found open or close symbol if (targetStart != -1 && targetStart != -2) // found open or close symbol
{ {
targetEnd = int((*ppEditView)->execute(SCI_GETTARGETEND)); targetEnd = (*ppEditView)->execute(SCI_GETTARGETEND);
// Treat it only if it's NOT in the comment zone // Treat it only if it's NOT in the comment zone
if (!isInZones(targetStart, commentZones)) if (!isInZones(targetStart, commentZones))
@ -523,7 +523,7 @@ void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair
if (not _openSymbole.empty() && not _closeSymbole.empty()) if (not _openSymbole.empty() && not _closeSymbole.empty())
{ {
targetEnd = getBodyClosePos(targetEnd, _openSymbole.c_str(), _closeSymbole.c_str(), commentZones, ppEditView); targetEnd = static_cast<int32_t>(getBodyClosePos(targetEnd, _openSymbole.c_str(), _closeSymbole.c_str(), commentZones, ppEditView));
} }
if (targetEnd > int(end)) //we found a result but outside our range, therefore do not process it if (targetEnd > int(end)) //we found a result but outside our range, therefore do not process it

View File

@ -476,7 +476,7 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe
{ {
HBRUSH hbrush,holdbrush; HBRUSH hbrush,holdbrush;
HPEN hpen,holdpen; HPEN hpen,holdpen;
iProtection=SendMessage(hWnd,BGM_GETPROTECTION,(WPARAM)&BGcell,0); iProtection = static_cast<int32_t>(SendMessage(hWnd, BGM_GETPROTECTION, (WPARAM)&BGcell, 0));
if(BGHS[SI].DRAWHIGHLIGHT)//highlight on if(BGHS[SI].DRAWHIGHLIGHT)//highlight on
{ {
if(r==BGHS[SI].cursorrow) if(r==BGHS[SI].cursorrow)
@ -527,7 +527,7 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe
rect.right -= 2; rect.right -= 2;
rect.left += 2; rect.left += 2;
iDataType=SendMessage(hWnd,BGM_GETTYPE,(WPARAM)&BGcell,0); iDataType = static_cast<int32_t>(SendMessage(hWnd, BGM_GETTYPE, (WPARAM)&BGcell, 0));
if((iDataType < 1)||(iDataType > 5)) if((iDataType < 1)||(iDataType > 5))
{ {
iDataType = 1;//default to alphanumeric data type.. can't happen iDataType = 1;//default to alphanumeric data type.. can't happen
@ -691,7 +691,7 @@ TCHAR GetASCII(WPARAM wParam, LPARAM lParam)
BYTE keys[256]; BYTE keys[256];
WORD dwReturnedValue; WORD dwReturnedValue;
GetKeyboardState(keys); GetKeyboardState(keys);
result=ToAscii(wParam,(lParam >> 16) && 0xff,keys,&dwReturnedValue,0); result = ToAscii(static_cast<UINT>(wParam), (lParam >> 16) && 0xff, keys, &dwReturnedValue, 0);
returnvalue = (TCHAR) dwReturnedValue; returnvalue = (TCHAR) dwReturnedValue;
if(returnvalue < 0){returnvalue = 0;} if(returnvalue < 0){returnvalue = 0;}
wsprintf(mbuffer, TEXT("return value = %d"), returnvalue); wsprintf(mbuffer, TEXT("return value = %d"), returnvalue);
@ -1464,15 +1464,15 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case BGM_DRAWCURSOR: case BGM_DRAWCURSOR:
DrawCursor(hWnd,wParam); DrawCursor(hWnd, static_cast<int32_t>(wParam));
break; break;
case BGM_SETCURSORPOS: case BGM_SETCURSORPOS:
DrawCursor(hWnd,SelfIndex); DrawCursor(hWnd,SelfIndex);
if((((int)wParam <= BGHS[SelfIndex].rows)&&((int)wParam > 0))&& if((((int)wParam <= BGHS[SelfIndex].rows)&&((int)wParam > 0))&&
(((int)lParam <= BGHS[SelfIndex].cols)&&((int)lParam > 0))) (((int)lParam <= BGHS[SelfIndex].cols)&&((int)lParam > 0)))
{ {
BGHS[SelfIndex].cursorrow=wParam; BGHS[SelfIndex].cursorrow = static_cast<int32_t>(wParam);
BGHS[SelfIndex].cursorcol=lParam; BGHS[SelfIndex].cursorcol = static_cast<int32_t>(lParam);
} }
else else
{ {
@ -1625,7 +1625,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
lstrcat(buffer, TEXT("|")); lstrcat(buffer, TEXT("|"));
lstrcat(buffer, (TCHAR*)lParam); lstrcat(buffer, (TCHAR*)lParam);
FindResult=SendMessage(BGHS[SelfIndex].hlist1,LB_ADDSTRING,0,(LPARAM)buffer); FindResult = static_cast<int32_t>(SendMessage(BGHS[SelfIndex].hlist1, LB_ADDSTRING, 0, (LPARAM)buffer));
if(FindResult==LB_ERR) if(FindResult==LB_ERR)
{ {
@ -1639,8 +1639,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
//get the last line and adjust grid dimmensions //get the last line and adjust grid dimmensions
if(BGHS[SelfIndex].AUTOROW) if(BGHS[SelfIndex].AUTOROW)
{ {
int j; int j = static_cast<int32_t>(SendMessage(BGHS[SelfIndex].hlist1, LB_GETCOUNT, 0, 0));
j=SendMessage(BGHS[SelfIndex].hlist1,LB_GETCOUNT,0,0);
if(j>0) if(j>0)
{ {
SendMessage(BGHS[SelfIndex].hlist1,LB_GETTEXT,j-1,(LPARAM)buffer); SendMessage(BGHS[SelfIndex].hlist1,LB_GETTEXT,j-1,(LPARAM)buffer);
@ -1799,7 +1798,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case BGM_SETGRIDDIM: case BGM_SETGRIDDIM:
if((wParam>=0)&&(wParam<=MAX_ROWS)) if((wParam>=0)&&(wParam<=MAX_ROWS))
{ {
BGHS[SelfIndex].rows = wParam; BGHS[SelfIndex].rows = static_cast<int32_t>(wParam);
} }
else else
{ {
@ -1815,7 +1814,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if((lParam>0)&&(lParam<=MAX_COLS)) if((lParam>0)&&(lParam<=MAX_COLS))
{ {
BGHS[SelfIndex].cols = lParam; BGHS[SelfIndex].cols = static_cast<int32_t>(lParam);
} }
else else
{ {
@ -1840,7 +1839,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if((wParam <= MAX_COLS)&&(wParam >= 0) && (lParam >= 0)) if((wParam <= MAX_COLS)&&(wParam >= 0) && (lParam >= 0))
{ {
RECT rect; RECT rect;
BGHS[SelfIndex].columnwidths[wParam] = lParam; BGHS[SelfIndex].columnwidths[wParam] = static_cast<int32_t>(lParam);
GetClientRect(hWnd,&rect); GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE); InvalidateRect(hWnd,&rect,FALSE);
GetVisibleColumns(hWnd,SelfIndex); GetVisibleColumns(hWnd,SelfIndex);
@ -1850,7 +1849,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if(wParam >= 0) if(wParam >= 0)
{ {
RECT rect; RECT rect;
BGHS[SelfIndex].headerrowheight = wParam; BGHS[SelfIndex].headerrowheight = static_cast<int32_t>(wParam);
SizeGrid(hWnd,SelfIndex); SizeGrid(hWnd,SelfIndex);
GetClientRect(hWnd,&rect); GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE); InvalidateRect(hWnd,&rect,FALSE);
@ -1921,7 +1920,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case BGM_SETROWHEIGHT: case BGM_SETROWHEIGHT:
if(wParam <1){wParam=1;} if(wParam <1){wParam=1;}
BGHS[SelfIndex].rowheight = wParam; BGHS[SelfIndex].rowheight = static_cast<int32_t>(wParam);
SetHomeRow(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol); SetHomeRow(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol);
SetHomeCol(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol); SetHomeCol(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol);
SizeGrid(hWnd,SelfIndex); SizeGrid(hWnd,SelfIndex);
@ -1935,7 +1934,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case BGM_SETTITLEHEIGHT: case BGM_SETTITLEHEIGHT:
if(wParam<0){wParam =0;} if(wParam<0){wParam =0;}
BGHS[SelfIndex].titleheight = wParam; BGHS[SelfIndex].titleheight = static_cast<int32_t>(wParam);
SetHomeRow(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol); SetHomeRow(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol);
SetHomeCol(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol); SetHomeCol(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol);
{ {
@ -2138,7 +2137,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
//resizing hidden column to the left of cursor //resizing hidden column to the left of cursor
if(c==-1) if(c==-1)
{ {
c=SendMessage(hWnd,BGM_GETCOLS,0,0); c = static_cast<int32_t>(SendMessage(hWnd, BGM_GETCOLS, 0, 0));
} }
else else
{ {
@ -3103,7 +3102,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext)
FOUND=FALSE; FOUND=FALSE;
//get count of items in listbox //get count of items in listbox
lbcount = SendMessage(lbhWnd,LB_GETCOUNT,0,0); lbcount = static_cast<int32_t>(SendMessage(lbhWnd, LB_GETCOUNT, 0, 0));
if(lbcount == 0) if(lbcount == 0)
{ {
ReturnValue = LB_ERR; ReturnValue = LB_ERR;
@ -3112,7 +3111,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 = SendMessage(lbhWnd,LB_FINDSTRING,(unsigned int)-1,(LPARAM) searchtext); FindResult = static_cast<int32_t>(SendMessage(lbhWnd, LB_FINDSTRING, (unsigned int)-1, (LPARAM)searchtext));
ReturnValue = FindResult; ReturnValue = FindResult;
return ReturnValue; return ReturnValue;
} }

View File

@ -62,8 +62,8 @@ public :
void setText(size_t row, size_t col, const TCHAR *text) { void setText(size_t row, size_t col, const TCHAR *text) {
_BGCELL cell; _BGCELL cell;
cell.row = row; cell.row = int(row);
cell.col = col; cell.col = int(col);
::SendMessage(_hSelf, BGM_SETCELLDATA, (WPARAM)&cell, (LPARAM)text); ::SendMessage(_hSelf, BGM_SETCELLDATA, (WPARAM)&cell, (LPARAM)text);
}; };
@ -72,7 +72,7 @@ public :
}; };
int getSelectedRow() { int getSelectedRow() {
return ::SendMessage(_hSelf, BGM_GETROW, 0, 0); return (int)::SendMessage(_hSelf, BGM_GETROW, 0, 0);
}; };
void deleteCell(int row, int col) { void deleteCell(int row, int col) {

View File

@ -354,7 +354,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
DWORD cmdID = 0; DWORD cmdID = 0;
// Menu data // Menu data
size_t posBase = 0; int32_t posBase = 0;
size_t nbElem = 0; size_t nbElem = 0;
HMENU hMenu = NULL; HMENU hMenu = NULL;
int modifCmd = IDM_SETTING_SHORTCUT_MAPPER_RUN; int modifCmd = IDM_SETTING_SHORTCUT_MAPPER_RUN;
@ -417,7 +417,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
nppParam->setShortcutDirty(); nppParam->setShortcutDirty();
// All menu items are shifted up. So we delete the last item // All menu items are shifted up. So we delete the last item
::RemoveMenu(hMenu, posBase + nbElem, MF_BYPOSITION); ::RemoveMenu(hMenu, posBase + static_cast<int32_t>(nbElem), MF_BYPOSITION);
if (nbElem == 0) if (nbElem == 0)
{ {

View File

@ -125,7 +125,7 @@ int FileDialog::setExtsFilter(const TCHAR *extText, const TCHAR *exts)
extFilter += TEXT(")"); extFilter += TEXT(")");
// Resize filter buffer // Resize filter buffer
int nbCharAdditional = extFilter.length() + lstrlen(exts) + 3; // 3 additional for nulls int nbCharAdditional = static_cast<int32_t>(extFilter.length() + lstrlen(exts) + 3); // 3 additional for nulls
if (_fileExt) if (_fileExt)
{ {
oldFilter = new TCHAR[_nbCharFileExt]; oldFilter = new TCHAR[_nbCharFileExt];
@ -150,7 +150,7 @@ int FileDialog::setExtsFilter(const TCHAR *extText, const TCHAR *exts)
// Append new filter // Append new filter
TCHAR *pFileExt = _fileExt + _nbCharFileExt; TCHAR *pFileExt = _fileExt + _nbCharFileExt;
lstrcpy(pFileExt, extFilter.c_str()); lstrcpy(pFileExt, extFilter.c_str());
_nbCharFileExt += extFilter.length() + 1; _nbCharFileExt += static_cast<int32_t>(extFilter.length()) + 1;
pFileExt = _fileExt + _nbCharFileExt; pFileExt = _fileExt + _nbCharFileExt;
lstrcpy(pFileExt, exts); lstrcpy(pFileExt, exts);
@ -337,9 +337,9 @@ static generic_string addExt(HWND textCtrl, HWND typeCtrl) {
TCHAR fn[MAX_PATH]; TCHAR fn[MAX_PATH];
::GetWindowText(textCtrl, fn, MAX_PATH); ::GetWindowText(textCtrl, fn, MAX_PATH);
int i = ::SendMessage(typeCtrl, CB_GETCURSEL, 0, 0); auto i = ::SendMessage(typeCtrl, CB_GETCURSEL, 0, 0);
int cbTextLen = ::SendMessage(typeCtrl, CB_GETLBTEXTLEN, i, 0); auto cbTextLen = ::SendMessage(typeCtrl, CB_GETLBTEXTLEN, i, 0);
TCHAR * ext = new TCHAR[cbTextLen + 1]; TCHAR * ext = new TCHAR[cbTextLen + 1];
::SendMessage(typeCtrl, CB_GETLBTEXT, i, (LPARAM)ext); ::SendMessage(typeCtrl, CB_GETLBTEXT, i, (LPARAM)ext);
@ -428,7 +428,7 @@ BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM, LPARAM lParam)
case CDN_FILEOK : case CDN_FILEOK :
{ {
HWND typeControl = ::GetDlgItem(::GetParent(hWnd), cmb1); HWND typeControl = ::GetDlgItem(::GetParent(hWnd), cmb1);
int index = ::SendMessage(typeControl, CB_GETCURSEL, 0, 0); int index = static_cast<int32_t>(::SendMessage(typeControl, CB_GETCURSEL, 0, 0));
NppParameters *pNppParam = NppParameters::getInstance(); NppParameters *pNppParam = NppParameters::getInstance();
pNppParam->setFileSaveDlgFilterIndex(index); pNppParam->setFileSaveDlgFilterIndex(index);
return TRUE; return TRUE;
@ -478,16 +478,16 @@ generic_string changeExt(generic_string fn, generic_string ext, bool forceReplac
generic_string fnExt = fn; generic_string fnExt = fn;
int index = fnExt.find_last_of(TEXT(".")); auto index = fnExt.find_last_of(TEXT("."));
generic_string extension = TEXT("."); generic_string extension = TEXT(".");
extension += ext; extension += ext;
if (size_t(index) == generic_string::npos) if (index == generic_string::npos)
{ {
fnExt += extension; fnExt += extension;
} }
else if (forceReplaced) else if (forceReplaced)
{ {
int len = (extension.length() > fnExt.length() - index + 1)?extension.length():fnExt.length() - index + 1; auto len = (extension.length() > fnExt.length() - index + 1)?extension.length():fnExt.length() - index + 1;
fnExt.replace(index, len, extension); fnExt.replace(index, len, extension);
} }
return fnExt; return fnExt;

View File

@ -203,7 +203,7 @@ INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
{ {
if (HIWORD(wParam) == CBN_SELCHANGE) if (HIWORD(wParam) == CBN_SELCHANGE)
{ {
int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETCURSEL, 0, 0);
if (i != LB_ERR) if (i != LB_ERR)
{ {
showDialogByIndex(i); showDialogByIndex(i);
@ -279,7 +279,7 @@ bool PreferenceDlg::renameDialogTitle(const TCHAR *internalName, const TCHAR *ne
return true; return true;
} }
void PreferenceDlg::showDialogByIndex(int index) void PreferenceDlg::showDialogByIndex(size_t index)
{ {
size_t len = _wVector.size(); size_t len = _wVector.size();
for (size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
@ -371,7 +371,7 @@ INT_PTR CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
fnW.assign(fn.begin(), fn.end()); fnW.assign(fn.begin(), fn.end());
lang = localizationSwitcher.getLangFromXmlFileName(fnW.c_str()); lang = localizationSwitcher.getLangFromXmlFileName(fnW.c_str());
} }
int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)lang.c_str()); auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)lang.c_str());
if (index != CB_ERR) if (index != CB_ERR)
::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_SETCURSEL, index, 0); ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_SETCURSEL, index, 0);
@ -493,7 +493,7 @@ INT_PTR CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
case IDC_COMBO_LOCALIZATION : case IDC_COMBO_LOCALIZATION :
{ {
LocalizationSwitcher & localizationSwitcher = pNppParam->getLocalizationSwitcher(); LocalizationSwitcher & localizationSwitcher = pNppParam->getLocalizationSwitcher();
int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETCURSEL, 0, 0);
wchar_t langName[MAX_PATH]; wchar_t langName[MAX_PATH];
::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETLBTEXT, index, (LPARAM)langName); ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETLBTEXT, index, (LPARAM)langName);
if (langName[0]) if (langName[0])
@ -799,7 +799,7 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
{ {
case IDC_WIDTH_COMBO: case IDC_WIDTH_COMBO:
{ {
nppGUI._caretWidth = ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_GETCURSEL, 0, 0); nppGUI._caretWidth = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_GETCURSEL, 0, 0));
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETWIDTH, 0, 0); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETWIDTH, 0, 0);
return TRUE; return TRUE;
} }
@ -992,15 +992,15 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
return TRUE; return TRUE;
case IDC_CHECK_AUTOUPDATE: case IDC_CHECK_AUTOUPDATE:
nppGUI._autoUpdateOpt._doAutoUpdate = isCheckedOrNot(wParam); nppGUI._autoUpdateOpt._doAutoUpdate = isCheckedOrNot(static_cast<int32_t>(wParam));
return TRUE; return TRUE;
case IDC_CHECK_MIN2SYSTRAY: case IDC_CHECK_MIN2SYSTRAY:
nppGUI._isMinimizedToTray = isCheckedOrNot(wParam); nppGUI._isMinimizedToTray = isCheckedOrNot(static_cast<int32_t>(wParam));
return TRUE; return TRUE;
case IDC_CHECK_DETECTENCODING: case IDC_CHECK_DETECTENCODING:
nppGUI._detectEncoding = isCheckedOrNot(wParam); nppGUI._detectEncoding = isCheckedOrNot(static_cast<int32_t>(wParam));
return TRUE; return TRUE;
case IDC_CHECK_ENABLEDOCSWITCHER : case IDC_CHECK_ENABLEDOCSWITCHER :
{ {
@ -1167,7 +1167,7 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
{ {
cmdID += IDM_FORMAT_ENCODE; cmdID += IDM_FORMAT_ENCODE;
getNameStrFromCmd(cmdID, str); getNameStrFromCmd(cmdID, str);
int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_ADDSTRING, 0, (LPARAM)str.c_str()); int index = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_ADDSTRING, 0, (LPARAM)str.c_str()));
if (ndds._codepage == encodings[i]) if (ndds._codepage == encodings[i])
selIndex = index; selIndex = index;
::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_SETITEMDATA, index, (LPARAM)encodings[i]); ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_SETITEMDATA, index, (LPARAM)encodings[i]);
@ -1188,7 +1188,7 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, (ID2Check == IDC_RADIO_UTF8SANSBOM && ndds._openAnsiAsUtf8)?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, (ID2Check == IDC_RADIO_UTF8SANSBOM && ndds._openAnsiAsUtf8)?BST_CHECKED:BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), ID2Check == IDC_RADIO_UTF8SANSBOM); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), ID2Check == IDC_RADIO_UTF8SANSBOM);
int index = 0; size_t index = 0;
for (int i = L_TEXT ; i < pNppParam->L_END ; ++i) for (int i = L_TEXT ; i < pNppParam->L_END ; ++i)
{ {
str.clear(); str.clear();
@ -1263,9 +1263,8 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
case IDC_RADIO_OTHERCP : case IDC_RADIO_OTHERCP :
{ {
::EnableWindow(::GetDlgItem(_hSelf, IDC_COMBO_OTHERCP), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COMBO_OTHERCP), true);
int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_GETCURSEL, 0, 0);
int cp = ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_GETITEMDATA, index, 0); ndds._codepage = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_GETITEMDATA, index, 0));
ndds._codepage = cp;
return TRUE; return TRUE;
} }
@ -1291,15 +1290,14 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
{ {
if (LOWORD(wParam) == IDC_COMBO_DEFAULTLANG) if (LOWORD(wParam) == IDC_COMBO_DEFAULTLANG)
{ {
int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_GETCURSEL, 0, 0);
ndds._lang = _langList[index]._id; ndds._lang = _langList[index]._id;
return TRUE; return TRUE;
} }
else if (LOWORD(wParam) == IDC_COMBO_OTHERCP) else if (LOWORD(wParam) == IDC_COMBO_OTHERCP)
{ {
int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_GETCURSEL, 0, 0);
int cp = ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_GETITEMDATA, index, 0); ndds._codepage = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_GETITEMDATA, index, 0));
ndds._codepage = cp;
return TRUE; return TRUE;
} }
} }
@ -1616,7 +1614,7 @@ INT_PTR CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP
idButton2Disable = IDC_BUTTON_REMOVE; idButton2Disable = IDC_BUTTON_REMOVE;
} }
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (i != LB_ERR) if (i != LB_ERR)
{ {
::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE);
@ -1675,7 +1673,7 @@ INT_PTR CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP
vector<LangMenuItem>::iterator lang2Remove = pSrcLst->begin() + iRemove; vector<LangMenuItem>::iterator lang2Remove = pSrcLst->begin() + iRemove;
pSrcLst->erase(lang2Remove); pSrcLst->erase(lang2Remove);
int iAdd = ::SendDlgItemMessage(_hSelf, list2Add, LB_ADDSTRING, 0, (LPARAM)s); auto iAdd = ::SendDlgItemMessage(_hSelf, list2Add, LB_ADDSTRING, 0, (LPARAM)s);
::SendDlgItemMessage(_hSelf, list2Remove, LB_DELETESTRING, iRemove, 0); ::SendDlgItemMessage(_hSelf, list2Remove, LB_DELETESTRING, iRemove, 0);
pDestLst->push_back(lmi); pDestLst->push_back(lmi);
@ -1715,7 +1713,9 @@ INT_PTR CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP
} }
else else
{ {
::InsertMenu(::GetSubMenu((HMENU)::SendMessage(grandParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), iAdd-1, MF_BYPOSITION, lmi._cmdID, lmi._langName.c_str()); HMENU menu = HMENU(::SendMessage(grandParent, NPPM_INTERNAL_GETMENU, 0, 0));
HMENU subMenu = ::GetSubMenu(menu, MENUINDEX_LANGUAGE);
::InsertMenu(subMenu, static_cast<int32_t>(iAdd - 1), MF_BYPOSITION, lmi._cmdID, lmi._langName.c_str());
} }
::DrawMenuBar(grandParent); ::DrawMenuBar(grandParent);
return TRUE; return TRUE;
@ -1766,7 +1766,7 @@ INT_PTR CALLBACK TabSettings::run_dlgProc(UINT Message, WPARAM wParam, LPARAM/*
{ {
if (LOWORD(wParam) == IDC_LIST_TABSETTNG) if (LOWORD(wParam) == IDC_LIST_TABSETTNG)
{ {
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR) if (index == LB_ERR)
return FALSE; return FALSE;
::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), index?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), index?SW_SHOW:SW_HIDE);
@ -1826,7 +1826,7 @@ INT_PTR CALLBACK TabSettings::run_dlgProc(UINT Message, WPARAM wParam, LPARAM/*
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE);
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE);
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR) return FALSE; if (index == LB_ERR) return FALSE;
if (index != 0) if (index != 0)
@ -1861,7 +1861,7 @@ INT_PTR CALLBACK TabSettings::run_dlgProc(UINT Message, WPARAM wParam, LPARAM/*
case IDC_CHECK_REPLACEBYSPACE: case IDC_CHECK_REPLACEBYSPACE:
{ {
bool isTabReplacedBySpace = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_GETCHECK, 0, 0); bool isTabReplacedBySpace = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_GETCHECK, 0, 0);
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR) return FALSE; if (index == LB_ERR) return FALSE;
if (index != 0) if (index != 0)
{ {
@ -1897,7 +1897,7 @@ INT_PTR CALLBACK TabSettings::run_dlgProc(UINT Message, WPARAM wParam, LPARAM/*
case IDC_CHECK_DEFAULTTABVALUE: case IDC_CHECK_DEFAULTTABVALUE:
{ {
bool useDefaultTab = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_GETCHECK, 0, 0); bool useDefaultTab = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_GETCHECK, 0, 0);
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR || index == 0) // index == 0 shouldn't happen if (index == LB_ERR || index == 0) // index == 0 shouldn't happen
return FALSE; return FALSE;
@ -1994,14 +1994,14 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
const std::vector<generic_string> & fontlist = pNppParam->getFontList(); const std::vector<generic_string> & fontlist = pNppParam->getFontList();
for (size_t i = 0, len = fontlist.size() ; i < len ; ++i) for (size_t i = 0, len = fontlist.size() ; i < len ; ++i)
{ {
int j = ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_ADDSTRING, 0, (LPARAM)fontlist[i].c_str()); auto j = ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_ADDSTRING, 0, (LPARAM)fontlist[i].c_str());
::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTNAME, CB_ADDSTRING, 0, (LPARAM)fontlist[i].c_str()); ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTNAME, CB_ADDSTRING, 0, (LPARAM)fontlist[i].c_str());
::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_SETITEMDATA, j, (LPARAM)fontlist[i].c_str()); ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_SETITEMDATA, j, (LPARAM)fontlist[i].c_str());
::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTNAME, CB_SETITEMDATA, j, (LPARAM)fontlist[i].c_str()); ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTNAME, CB_SETITEMDATA, j, (LPARAM)fontlist[i].c_str());
} }
int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)nppGUI._printSettings._headerFontName.c_str()); auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)nppGUI._printSettings._headerFontName.c_str());
if (index == CB_ERR) if (index == CB_ERR)
index = 0; index = 0;
::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_SETCURSEL, index, 0); ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_SETCURSEL, index, 0);
@ -2030,7 +2030,7 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
for (size_t i = 0, len = varList.size() ; i < len ; ++i) for (size_t i = 0, len = varList.size() ; i < len ; ++i)
{ {
int j = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_ADDSTRING, 0, (LPARAM)varList[i]._varDesc.c_str()); auto j = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_ADDSTRING, 0, (LPARAM)varList[i]._varDesc.c_str());
::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_SETITEMDATA, j, (LPARAM)varList[i]._var.c_str()); ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_SETITEMDATA, j, (LPARAM)varList[i]._var.c_str());
} }
::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_SETCURSEL, 0, 0); ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_SETCURSEL, 0, 0);
@ -2141,7 +2141,7 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
} }
else if (HIWORD(wParam) == CBN_SELCHANGE) else if (HIWORD(wParam) == CBN_SELCHANGE)
{ {
int iSel = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0); auto iSel = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0);
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
@ -2223,7 +2223,7 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
if (!_focusedEditCtrl) if (!_focusedEditCtrl)
return TRUE; return TRUE;
int iSel = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETCURSEL, 0, 0); auto iSel = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETCURSEL, 0, 0);
TCHAR *varStr = (TCHAR *)::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETITEMDATA, iSel, 0); TCHAR *varStr = (TCHAR *)::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETITEMDATA, iSel, 0);
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, EM_GETSEL, (WPARAM)&_selStart, (LPARAM)&_selEnd); ::SendDlgItemMessage(_hSelf, _focusedEditCtrl, EM_GETSEL, (WPARAM)&_selStart, (LPARAM)&_selEnd);
@ -2257,8 +2257,8 @@ INT_PTR CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
::SendDlgItemMessage(_hSelf, IDC_CHECK_REMEMBERSESSION, BM_SETCHECK, nppGUI._rememberLastSession, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_REMEMBERSESSION, BM_SETCHECK, nppGUI._rememberLastSession, 0);
bool snapshotCheck = nppGUI._rememberLastSession && nppGUI.isSnapshotMode(); bool snapshotCheck = nppGUI._rememberLastSession && nppGUI.isSnapshotMode();
::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK, BM_SETCHECK, snapshotCheck?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK, BM_SETCHECK, snapshotCheck?BST_CHECKED:BST_UNCHECKED, 0);
int periodicBackupInSec = nppGUI._snapshotBackupTiming/1000; auto periodicBackupInSec = static_cast<UINT>(nppGUI._snapshotBackupTiming / 1000);
::SetDlgItemInt(_hSelf, IDC_BACKUPDIR_RESTORESESSION_EDIT, periodicBackupInSec, FALSE); ::SetDlgItemInt(_hSelf, IDC_BACKUPDIR_RESTORESESSION_EDIT,periodicBackupInSec, FALSE);
generic_string backupFilePath = NppParameters::getInstance()->getUserPath(); generic_string backupFilePath = NppParameters::getInstance()->getUserPath();
backupFilePath += TEXT("\\backup\\"); backupFilePath += TEXT("\\backup\\");
::SetDlgItemText(_hSelf, IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT, backupFilePath.c_str()); ::SetDlgItemText(_hSelf, IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT, backupFilePath.c_str());
@ -2336,7 +2336,7 @@ INT_PTR CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
if (lstrcmp(str, TEXT("")) == 0) if (lstrcmp(str, TEXT("")) == 0)
{ {
::SetDlgItemInt(_hSelf, IDC_BACKUPDIR_RESTORESESSION_EDIT, nppGUI._snapshotBackupTiming/1000, FALSE); ::SetDlgItemInt(_hSelf, IDC_BACKUPDIR_RESTORESESSION_EDIT, static_cast<int32_t>(nppGUI._snapshotBackupTiming / 1000), FALSE);
} }
} }
} }
@ -2448,7 +2448,7 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPA
{ {
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
::SetDlgItemInt(_hSelf, IDD_AUTOC_STATIC_N, nppGUI._autocFromLen, FALSE); ::SetDlgItemInt(_hSelf, IDD_AUTOC_STATIC_N, static_cast<UINT>(nppGUI._autocFromLen), FALSE);
_nbCharVal.init(_hInst, _hSelf); _nbCharVal.init(_hInst, _hSelf);
_nbCharVal.create(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), IDD_AUTOC_STATIC_N); _nbCharVal.create(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), IDD_AUTOC_STATIC_N);
@ -2636,7 +2636,7 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPA
ValueDlg valDlg; ValueDlg valDlg;
//NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); //NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
valDlg.init(NULL, _hSelf, nppGUI._autocFromLen, TEXT("Nb char : ")); valDlg.init(NULL, _hSelf, static_cast<int32_t>(nppGUI._autocFromLen), TEXT("Nb char : "));
valDlg.setNBNumber(1); valDlg.setNBNumber(1);
POINT p; POINT p;
@ -2651,7 +2651,7 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPA
size = NB_MIN_CHAR; size = NB_MIN_CHAR;
nppGUI._autocFromLen = size; nppGUI._autocFromLen = size;
::SetDlgItemInt(_hSelf, IDD_AUTOC_STATIC_N, nppGUI._autocFromLen, FALSE); ::SetDlgItemInt(_hSelf, IDD_AUTOC_STATIC_N, static_cast<int32_t>(nppGUI._autocFromLen), FALSE);
} }
return TRUE; return TRUE;
} }
@ -2662,7 +2662,7 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPA
case IDD_AUTOC_DOUBLEQUOTESCHECK : case IDD_AUTOC_DOUBLEQUOTESCHECK :
case IDD_AUTOC_QUOTESCHECK : case IDD_AUTOC_QUOTESCHECK :
{ {
bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0)); bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0));
TCHAR *label; TCHAR *label;
if (wParam == IDD_AUTOCPARENTHESES_CHECK) if (wParam == IDD_AUTOCPARENTHESES_CHECK)
{ {
@ -2689,7 +2689,7 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPA
nppGUI._matchedPairConf._doQuotes = isChecked; nppGUI._matchedPairConf._doQuotes = isChecked;
label = isChecked?TEXT(" ' '"):TEXT(" '"); label = isChecked?TEXT(" ' '"):TEXT(" '");
} }
::SendDlgItemMessage(_hSelf, wParam, WM_SETTEXT, 0, (LPARAM)label); ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), WM_SETTEXT, 0, (LPARAM)label);
return TRUE; return TRUE;
} }

View File

@ -244,7 +244,7 @@ public :
bool renameDialogTitle(const TCHAR *internalName, const TCHAR *newName); bool renameDialogTitle(const TCHAR *internalName, const TCHAR *newName);
int getListSelectedIndex() const { int getListSelectedIndex() const {
return ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETCURSEL, 0, 0); return static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETCURSEL, 0, 0));
}; };
void setListSelection(size_t currentSel) const; void setListSelection(size_t currentSel) const;
@ -253,7 +253,7 @@ public :
private : private :
INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
void makeCategoryList(); void makeCategoryList();
void showDialogByIndex(int index); void showDialogByIndex(size_t index);
//ControlsTab _ctrlTab; //ControlsTab _ctrlTab;
WindowVector _wVector; WindowVector _wVector;
BarsDlg _barsDlg; BarsDlg _barsDlg;

View File

@ -607,7 +607,7 @@ void ProjectPanel::notified(LPNMHDR notification)
return; return;
} }
lpGetInfoTip->pszText = (LPTSTR)str->c_str(); lpGetInfoTip->pszText = (LPTSTR)str->c_str();
lpGetInfoTip->cchTextMax = str->size(); lpGetInfoTip->cchTextMax = static_cast<int32_t>(str->size());
} }
break; break;
@ -1202,10 +1202,10 @@ int FileRelocalizerDlg::doDialog(const TCHAR *fn, bool isRTL)
{ {
DLGTEMPLATE *pMyDlgTemplate = NULL; DLGTEMPLATE *pMyDlgTemplate = NULL;
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_FILERELOCALIZER_DIALOG, &pMyDlgTemplate); HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_FILERELOCALIZER_DIALOG, &pMyDlgTemplate);
int result = ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); int result = static_cast<int32_t>(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this));
::GlobalFree(hMyDlgTemplate); ::GlobalFree(hMyDlgTemplate);
return result; return result;
} }
return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FILERELOCALIZER_DIALOG), _hParent, dlgProc, (LPARAM)this); return static_cast<int32_t>(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FILERELOCALIZER_DIALOG), _hParent, dlgProc, (LPARAM)this));
} }

View File

@ -98,7 +98,7 @@ void CReadChangesRequest::BeginRead()
::ReadDirectoryChangesW( ::ReadDirectoryChangesW(
m_hDirectory, // handle to directory m_hDirectory, // handle to directory
&m_Buffer[0], // read results buffer &m_Buffer[0], // read results buffer
m_Buffer.size(), // length of buffer static_cast<DWORD>(m_Buffer.size()), // length of buffer
m_bIncludeChildren, // monitoring option m_bIncludeChildren, // monitoring option
m_dwFilterFlags, // filter conditions m_dwFilterFlags, // filter conditions
&dwBytes, // bytes returned &dwBytes, // bytes returned

View File

@ -91,14 +91,14 @@ int whichVar(TCHAR *str)
void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t strDestLen, HWND hWnd) void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t strDestLen, HWND hWnd)
{ {
size_t j = 0; size_t j = 0;
for (size_t i = 0, len = size_t(lstrlen(strSrc)); i < len; ++i) for (int i = 0, len = lstrlen(strSrc); i < len; ++i)
{ {
int iBegin = -1; int iBegin = -1;
int iEnd = -1; int iEnd = -1;
if ((strSrc[i] == '$') && (strSrc[i+1] == '(')) if ((strSrc[i] == '$') && (strSrc[i+1] == '('))
{ {
iBegin = i += 2; iBegin = i += 2;
for (size_t len2 = size_t(lstrlen(strSrc)); i < len2 ; ++i) for (size_t len2 = size_t(lstrlen(strSrc)); size_t(i) < len2 ; ++i)
{ {
if (strSrc[i] == ')') if (strSrc[i] == ')')
{ {
@ -131,7 +131,7 @@ void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t str
TCHAR expandedStr[CURRENTWORD_MAXLENGTH]; TCHAR expandedStr[CURRENTWORD_MAXLENGTH];
if (internalVar == CURRENT_LINE || internalVar == CURRENT_COLUMN) if (internalVar == CURRENT_LINE || internalVar == CURRENT_COLUMN)
{ {
int lineNumber = ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, 0, 0); auto lineNumber = ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, 0, 0);
wsprintf(expandedStr, TEXT("%d"), lineNumber); wsprintf(expandedStr, TEXT("%d"), lineNumber);
} }
else else
@ -231,7 +231,7 @@ INT_PTR CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{ {
std::vector<UserCommand> & theUserCmds = (NppParameters::getInstance())->getUserCommandList(); std::vector<UserCommand> & theUserCmds = (NppParameters::getInstance())->getUserCommandList();
int nbCmd = theUserCmds.size(); int nbCmd = static_cast<int32_t>(theUserCmds.size());
int cmdID = ID_USER_CMD + nbCmd; int cmdID = ID_USER_CMD + nbCmd;
TCHAR cmd[MAX_PATH]; TCHAR cmd[MAX_PATH];
@ -301,7 +301,7 @@ INT_PTR CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
void RunDlg::addTextToCombo(const TCHAR *txt2Add) const void RunDlg::addTextToCombo(const TCHAR *txt2Add) const
{ {
HWND handle = ::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH); HWND handle = ::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH);
int i = ::SendMessage(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Add); auto i = ::SendMessage(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Add);
if (i == CB_ERR) if (i == CB_ERR)
i = ::SendMessage(handle, CB_ADDSTRING, 0, (LPARAM)txt2Add); i = ::SendMessage(handle, CB_ADDSTRING, 0, (LPARAM)txt2Add);
::SendMessage(handle, CB_SETCURSEL, i, 0); ::SendMessage(handle, CB_SETCURSEL, i, 0);
@ -309,7 +309,7 @@ void RunDlg::addTextToCombo(const TCHAR *txt2Add) const
void RunDlg::removeTextFromCombo(const TCHAR *txt2Remove) const void RunDlg::removeTextFromCombo(const TCHAR *txt2Remove) const
{ {
HWND handle = ::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH); HWND handle = ::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH);
int i = ::SendMessage(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Remove); auto i = ::SendMessage(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Remove);
if (i == CB_ERR) if (i == CB_ERR)
return; return;
::SendMessage(handle, CB_DELETESTRING, i, 0); ::SendMessage(handle, CB_DELETESTRING, i, 0);

View File

@ -92,7 +92,7 @@ bool ControlsTab::renameTab(const TCHAR *internalName, const TCHAR *newName)
return true; return true;
} }
void ControlsTab::renameTab(int index, const TCHAR *newName) void ControlsTab::renameTab(size_t index, const TCHAR *newName)
{ {
TCITEM tie; TCITEM tie;
tie.mask = TCIF_TEXT; tie.mask = TCIF_TEXT;

View File

@ -76,7 +76,7 @@ public :
int indexClicked = int(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); int indexClicked = int(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0));
activateWindowAt(indexClicked); activateWindowAt(indexClicked);
}; };
void renameTab(int index, const TCHAR *newName); void renameTab(size_t index, const TCHAR *newName);
bool renameTab(const TCHAR *internalName, const TCHAR *newName); bool renameTab(const TCHAR *internalName, const TCHAR *newName);
private: private:

View File

@ -132,7 +132,7 @@ void TabBar::getCurrentTitle(TCHAR *title, int titleLen)
} }
void TabBar::setFont(TCHAR *fontName, size_t fontSize) void TabBar::setFont(TCHAR *fontName, int fontSize)
{ {
if (_hFont) if (_hFont)
::DeleteObject(_hFont); ::DeleteObject(_hFont);
@ -457,7 +457,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
} }
::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam); ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam);
int currentTabOn = ::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0); int currentTabOn = static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0));
if (wParam == 2) if (wParam == 2)
return TRUE; return TRUE;

View File

@ -41,6 +41,7 @@
#include "resource.h" #include "resource.h"
#endif //RESOURCE_H #endif //RESOURCE_H
#include <stdint.h>
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include "Window.h" #include "Window.h"
@ -80,12 +81,12 @@ public:
void activateAt(int index) const; void activateAt(int index) const;
void getCurrentTitle(TCHAR *title, int titleLen); void getCurrentTitle(TCHAR *title, int titleLen);
int getCurrentTabIndex() const { int32_t getCurrentTabIndex() const {
return ::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0); return static_cast<int32_t>(SendMessage(_hSelf, TCM_GETCURSEL, 0, 0));
}; };
int getItemCount() const { int32_t getItemCount() const {
return ::SendMessage(_hSelf, TCM_GETITEMCOUNT, 0, 0); return static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETITEMCOUNT, 0, 0));
} }
void deletItemAt(size_t index); void deletItemAt(size_t index);
@ -97,11 +98,11 @@ public:
void setImageList(HIMAGELIST himl); void setImageList(HIMAGELIST himl);
int nbItem() const { size_t nbItem() const {
return _nbItem; return _nbItem;
} }
void setFont(TCHAR *fontName, size_t fontSize); void setFont(TCHAR *fontName, int fontSize);
void setVertical(bool b) { void setVertical(bool b) {
_isVertical = b; _isVertical = b;
@ -277,12 +278,12 @@ protected:
return getTabIndexAt(p.x, p.y); return getTabIndexAt(p.x, p.y);
} }
int getTabIndexAt(int x, int y) int32_t getTabIndexAt(int x, int y)
{ {
TCHITTESTINFO hitInfo; TCHITTESTINFO hitInfo;
hitInfo.pt.x = x; hitInfo.pt.x = x;
hitInfo.pt.y = y; hitInfo.pt.y = y;
return ::SendMessage(_hSelf, TCM_HITTEST, 0, (LPARAM)&hitInfo); return static_cast<int32_t>(::SendMessage(_hSelf, TCM_HITTEST, 0, (LPARAM)&hitInfo));
} }
bool isPointInParentZone(POINT screenPoint) const bool isPointInParentZone(POINT screenPoint) const

View File

@ -137,7 +137,7 @@ RECT TaskList::adjustSize()
return _rc; return _rc;
} }
void TaskList::setFont(TCHAR *fontName, size_t fontSize) void TaskList::setFont(TCHAR *fontName, int fontSize)
{ {
if (_hFont) if (_hFont)
::DeleteObject(_hFont); ::DeleteObject(_hFont);
@ -192,7 +192,7 @@ LRESULT TaskList::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
short zDelta = (short) HIWORD(wParam); short zDelta = (short) HIWORD(wParam);
if (zDelta > 0) if (zDelta > 0)
{ {
size_t selected = (_currentIndex - 1) < 0 ? (_nbItem - 1) : (_currentIndex - 1); int32_t selected = (_currentIndex - 1) < 0 ? (_nbItem - 1) : (_currentIndex - 1);
ListView_SetItemState(_hSelf, _currentIndex, 0, LVIS_SELECTED|LVIS_FOCUSED); ListView_SetItemState(_hSelf, _currentIndex, 0, LVIS_SELECTED|LVIS_FOCUSED);
// tells what item(s) to be repainted // tells what item(s) to be repainted
ListView_RedrawItems(_hSelf, _currentIndex, _currentIndex); ListView_RedrawItems(_hSelf, _currentIndex, _currentIndex);
@ -207,7 +207,7 @@ LRESULT TaskList::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
} }
else else
{ {
size_t selected = (_currentIndex + 1) > (_nbItem - 1) ? 0 : (_currentIndex + 1); int32_t selected = (_currentIndex + 1) > (_nbItem - 1) ? 0 : (_currentIndex + 1);
ListView_SetItemState(_hSelf, _currentIndex, 0, LVIS_SELECTED|LVIS_FOCUSED); ListView_SetItemState(_hSelf, _currentIndex, 0, LVIS_SELECTED|LVIS_FOCUSED);
// tells what item(s) to be repainted // tells what item(s) to be repainted
ListView_RedrawItems(_hSelf, _currentIndex, _currentIndex); ListView_RedrawItems(_hSelf, _currentIndex, _currentIndex);
@ -241,7 +241,7 @@ LRESULT TaskList::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
if (((msg->wParam == VK_TAB) && (0x80 & GetKeyState(VK_SHIFT))) || if (((msg->wParam == VK_TAB) && (0x80 & GetKeyState(VK_SHIFT))) ||
(msg->wParam == VK_UP)) (msg->wParam == VK_UP))
{ {
size_t selected = (_currentIndex - 1) < 0 ? (_nbItem - 1) : (_currentIndex - 1); int32_t selected = (_currentIndex - 1) < 0 ? (_nbItem - 1) : (_currentIndex - 1);
ListView_SetItemState(_hSelf, _currentIndex, 0, LVIS_SELECTED|LVIS_FOCUSED); ListView_SetItemState(_hSelf, _currentIndex, 0, LVIS_SELECTED|LVIS_FOCUSED);
// tells what item(s) to be repainted // tells what item(s) to be repainted
ListView_RedrawItems(_hSelf, _currentIndex, _currentIndex); ListView_RedrawItems(_hSelf, _currentIndex, _currentIndex);
@ -257,7 +257,7 @@ LRESULT TaskList::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
// VK_DOWN and VK_RIGHT do the same as VK_TAB does // VK_DOWN and VK_RIGHT do the same as VK_TAB does
else if ((msg->wParam == VK_TAB) || (msg->wParam == VK_DOWN)) else if ((msg->wParam == VK_TAB) || (msg->wParam == VK_DOWN))
{ {
size_t selected = (_currentIndex + 1) > (_nbItem - 1) ? 0 : (_currentIndex + 1); int32_t selected = (_currentIndex + 1) > (_nbItem - 1) ? 0 : (_currentIndex + 1);
ListView_SetItemState(_hSelf, _currentIndex, 0, LVIS_SELECTED|LVIS_FOCUSED); ListView_SetItemState(_hSelf, _currentIndex, 0, LVIS_SELECTED|LVIS_FOCUSED);
// tells what item(s) to be repainted // tells what item(s) to be repainted
ListView_RedrawItems(_hSelf, _currentIndex, _currentIndex); ListView_RedrawItems(_hSelf, _currentIndex, _currentIndex);

View File

@ -50,7 +50,7 @@ public:
virtual ~TaskList() {}; virtual ~TaskList() {};
void init(HINSTANCE hInst, HWND hwnd, HIMAGELIST hImaLst, int nbItem, int index2set); void init(HINSTANCE hInst, HWND hwnd, HIMAGELIST hImaLst, int nbItem, int index2set);
virtual void destroy(); virtual void destroy();
void setFont(TCHAR *fontName, size_t fontSize); void setFont(TCHAR *fontName, int fontSize);
RECT adjustSize(); RECT adjustSize();
int getCurrentIndex() const {return _currentIndex;} int getCurrentIndex() const {return _currentIndex;}
int updateCurrentIndex(); int updateCurrentIndex();

View File

@ -47,11 +47,11 @@ LRESULT CALLBACK hookProc(UINT nCode, WPARAM wParam, LPARAM lParam)
{ {
DLGTEMPLATE *pMyDlgTemplate = NULL; DLGTEMPLATE *pMyDlgTemplate = NULL;
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_VALUE_DLG, &pMyDlgTemplate); HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_VALUE_DLG, &pMyDlgTemplate);
int result = ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); int result = static_cast<int32_t>(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this));
::GlobalFree(hMyDlgTemplate); ::GlobalFree(hMyDlgTemplate);
return result; return result;
} }
return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_TASKLIST_DLG), _hParent, dlgProc, (LPARAM)this); return static_cast<int32_t>(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_TASKLIST_DLG), _hParent, dlgProc, (LPARAM)this));
} }
INT_PTR CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
@ -61,7 +61,7 @@ INT_PTR CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
::SendMessage(_hParent, WM_GETTASKLISTINFO, (WPARAM)&_taskListInfo, 0); ::SendMessage(_hParent, WM_GETTASKLISTINFO, (WPARAM)&_taskListInfo, 0);
int nbTotal = _taskListInfo._tlfsLst.size(); int nbTotal = static_cast<int32_t>(_taskListInfo._tlfsLst.size());
int i2set = _taskListInfo._currentIndex + (_initDir == dirDown?1:-1); int i2set = _taskListInfo._currentIndex + (_initDir == dirDown?1:-1);
@ -145,7 +145,7 @@ INT_PTR CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP
{ {
case ID_PICKEDUP : case ID_PICKEDUP :
{ {
int listIndex = lParam; auto listIndex = lParam;
int view2set = _taskListInfo._tlfsLst[listIndex]._iView; int view2set = _taskListInfo._tlfsLst[listIndex]._iView;
int index2Switch = _taskListInfo._tlfsLst[listIndex]._docIndex; int index2Switch = _taskListInfo._tlfsLst[listIndex]._docIndex;
::SendMessage(_hParent, NPPM_ACTIVATEDOC, view2set, index2Switch); ::SendMessage(_hParent, NPPM_ACTIVATEDOC, view2set, index2Switch);

View File

@ -298,7 +298,8 @@ void ToolBar::reset(bool create)
TBADDBITMAP addbmpdyn = {0, 0}; TBADDBITMAP addbmpdyn = {0, 0};
for (size_t i = 0 ; i < _nrButtons ; ++i) for (size_t i = 0 ; i < _nrButtons ; ++i)
{ {
HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, MAKEINTRESOURCE(_toolBarIcons.getStdIconAt(i)), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT); int icoID = _toolBarIcons.getStdIconAt(static_cast<int32_t>(i));
HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
addbmp.nID = (UINT_PTR)hBmp; addbmp.nID = (UINT_PTR)hBmp;
//addbmp.nID = _toolBarIcons.getStdIconAt(i); //addbmp.nID = _toolBarIcons.getStdIconAt(i);

View File

@ -207,13 +207,13 @@ void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const
int view = tlfs->_iView; int view = tlfs->_iView;
BufferID bufferID = static_cast<BufferID>(tlfs->_bufID); BufferID bufferID = static_cast<BufferID>(tlfs->_bufID);
int currentView = ::SendMessage(_hParent, NPPM_GETCURRENTVIEW, 0, 0); auto currentView = ::SendMessage(_hParent, NPPM_GETCURRENTVIEW, 0, 0);
BufferID currentBufID = reinterpret_cast<BufferID>(::SendMessage(_hParent, NPPM_GETCURRENTBUFFERID, 0, 0)); BufferID currentBufID = reinterpret_cast<BufferID>(::SendMessage(_hParent, NPPM_GETCURRENTBUFFERID, 0, 0));
if (bufferID == currentBufID && view == currentView) if (bufferID == currentBufID && view == currentView)
return; return;
int docPosInfo = ::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, (WPARAM)bufferID, view); int docPosInfo = static_cast<int32_t>(::SendMessage(_hParent, NPPM_GETPOSFROMBUFFERID, (WPARAM)bufferID, view));
int view2set = docPosInfo >> 30; int view2set = docPosInfo >> 30;
int index2Switch = (docPosInfo << 2) >> 2 ; int index2Switch = (docPosInfo << 2) >> 2 ;
@ -222,9 +222,9 @@ void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const
int VerticalFileSwitcher::setHeaderOrder(LPNMLISTVIEW pnm_list_view) int VerticalFileSwitcher::setHeaderOrder(LPNMLISTVIEW pnm_list_view)
{ {
HWND hListView,colHeader; HWND hListView, colHeader;
LVCOLUMN lvc; LVCOLUMN lvc;
int q,cols; int q, cols;
int index = pnm_list_view->iSubItem; int index = pnm_list_view->iSubItem;
lvc.mask = LVCF_FMT; lvc.mask = LVCF_FMT;
@ -250,8 +250,8 @@ int VerticalFileSwitcher::setHeaderOrder(LPNMLISTVIEW pnm_list_view)
// this is the case our clicked column wasn't the one being sorted up until now // this is the case our clicked column wasn't the one being sorted up until now
// so first we need to iterate through all columns and send LVM_SETCOLUMN to them with fmt set to NOT include these HDFs // so first we need to iterate through all columns and send LVM_SETCOLUMN to them with fmt set to NOT include these HDFs
colHeader = (HWND)SendMessage(hListView,LVM_GETHEADER,0,0); colHeader = (HWND)SendMessage(hListView,LVM_GETHEADER,0,0);
cols = SendMessage(colHeader,HDM_GETITEMCOUNT,0,0); cols = static_cast<int32_t>(SendMessage(colHeader, HDM_GETITEMCOUNT, 0, 0));
for(q=0; q<cols; ++q) for (q = 0; q < cols; ++q)
{ {
//Get current fmt //Get current fmt
SendMessage(hListView,LVM_GETCOLUMN,(WPARAM) q, (LPARAM) &lvc); SendMessage(hListView,LVM_GETCOLUMN,(WPARAM) q, (LPARAM) &lvc);

View File

@ -139,7 +139,7 @@ void VerticalFileSwitcherListView::initList()
item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
item.pszText = fn; item.pszText = fn;
item.iItem = i; item.iItem = static_cast<int32_t>(i);
item.iSubItem = 0; item.iSubItem = 0;
item.iImage = fileNameStatus._status; item.iImage = fileNameStatus._status;
item.lParam = (LPARAM)tl; item.lParam = (LPARAM)tl;
@ -225,12 +225,12 @@ void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID)
generic_string VerticalFileSwitcherListView::getFullFilePath(size_t i) const generic_string VerticalFileSwitcherListView::getFullFilePath(size_t i) const
{ {
size_t nbItem = ListView_GetItemCount(_hSelf); size_t nbItem = ListView_GetItemCount(_hSelf);
if (i < 0 || i > nbItem) if (i > nbItem)
return TEXT(""); return TEXT("");
LVITEM item; LVITEM item;
item.mask = LVIF_PARAM; item.mask = LVIF_PARAM;
item.iItem = i; item.iItem = static_cast<int32_t>(i);
ListView_GetItem(_hSelf, &item); ListView_GetItem(_hSelf, &item);
TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;

View File

@ -69,7 +69,7 @@ public:
ListView_DeleteColumn(_hSelf, i); ListView_DeleteColumn(_hSelf, i);
}; };
int nbSelectedFiles() const { int nbSelectedFiles() const {
return SendMessage(_hSelf, LVM_GETSELECTEDCOUNT, 0, 0); return static_cast<int32_t>(SendMessage(_hSelf, LVM_GETSELECTEDCOUNT, 0, 0));
}; };
std::vector<SwitcherFileInfo> getSelectedFiles(bool reverse = false) const; std::vector<SwitcherFileInfo> getSelectedFiles(bool reverse = false) const;

View File

@ -74,7 +74,7 @@ INT_PTR CALLBACK SizeableDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
} }
case WM_SIZE: case WM_SIZE:
{ {
onSize(wParam, LOWORD(lParam), HIWORD(lParam)); onSize(static_cast<UINT>(wParam), LOWORD(lParam), HIWORD(lParam));
return TRUE; return TRUE;
} }

View File

@ -54,7 +54,7 @@ inline static DWORD GetExStyle(HWND hWnd) {
} }
inline static BOOL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd) { inline static BOOL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd) {
DWORD dwStyle = ::GetWindowLongPtr(hWnd, GWL_STYLE); DWORD dwStyle = (DWORD)::GetWindowLongPtr(hWnd, GWL_STYLE);
DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
if(dwStyle == dwNewStyle) if(dwStyle == dwNewStyle)
return FALSE; return FALSE;
@ -63,7 +63,7 @@ inline static BOOL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd) {
} }
inline static BOOL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd) { inline static BOOL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd) {
DWORD dwStyle = ::GetWindowLongPtr(hWnd, GWL_EXSTYLE); DWORD dwStyle = (DWORD)::GetWindowLongPtr(hWnd, GWL_EXSTYLE);
DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
if(dwStyle == dwNewStyle) if(dwStyle == dwNewStyle)
return FALSE; return FALSE;
@ -100,7 +100,7 @@ struct NumericStringEquivalence
{ {
lcmp = generic_strtol(str1, &p1, 10) - generic_strtol(str2, &p2, 10); lcmp = generic_strtol(str1, &p1, 10) - generic_strtol(str2, &p2, 10);
if ( lcmp == 0 ) if ( lcmp == 0 )
lcmp = (p2 - str2) - (p1 - str1); lcmp = static_cast<int32_t>((p2 - str2) - (p1 - str1));
if ( lcmp != 0 ) if ( lcmp != 0 )
break; break;
str1 = p1, str2 = p2; str1 = p1, str2 = p2;
@ -283,8 +283,8 @@ INT_PTR CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
if(pLvdi->item.mask & LVIF_TEXT) if(pLvdi->item.mask & LVIF_TEXT)
{ {
pLvdi->item.pszText[0] = 0; pLvdi->item.pszText[0] = 0;
int index = pLvdi->item.iItem; size_t index = pLvdi->item.iItem;
if (index >= _pTab->nbItem() || index >= (int)_idxMap.size()) if (index >= _pTab->nbItem() || index >= _idxMap.size())
return FALSE; return FALSE;
index = _idxMap[index]; index = _idxMap[index];
@ -356,13 +356,16 @@ INT_PTR CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
{ {
_lastSort = iColumn; _lastSort = iColumn;
} }
int i; size_t i;
int n = _idxMap.size(); size_t n = _idxMap.size();
vector<int> sortMap; vector<int> sortMap;
sortMap.resize(n); sortMap.resize(n);
for (i=0; i<n; ++i) sortMap[_idxMap[i]] = ListView_GetItemState(_hList, i, LVIS_SELECTED); for (i = 0; i < n; ++i)
sortMap[_idxMap[i]] = ListView_GetItemState(_hList, i, LVIS_SELECTED);
stable_sort(_idxMap.begin(), _idxMap.end(), BufferEquivalent(_pTab, iColumn, reverse)); stable_sort(_idxMap.begin(), _idxMap.end(), BufferEquivalent(_pTab, iColumn, reverse));
for (i=0; i<n; ++i) ListView_SetItemState(_hList, i, sortMap[_idxMap[i]] ? LVIS_SELECTED : 0, LVIS_SELECTED); for (i = 0; i < n; ++i)
ListView_SetItemState(_hList, i, sortMap[_idxMap[i]] ? LVIS_SELECTED : 0, LVIS_SELECTED);
::InvalidateRect(_hList, &_rc, FALSE); ::InvalidateRect(_hList, &_rc, FALSE);
_isSorted = true; _isSorted = true;
@ -426,7 +429,7 @@ void WindowsDlg::updateButtonState()
int WindowsDlg::doDialog(TiXmlNodeA *dlgNode) int WindowsDlg::doDialog(TiXmlNodeA *dlgNode)
{ {
_dlgNode = dlgNode; _dlgNode = dlgNode;
return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, (LPARAM)this); return (int)::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, (LPARAM)this);
}; };
bool WindowsDlg::changeDlgLang() bool WindowsDlg::changeDlgLang()
@ -579,11 +582,10 @@ void WindowsDlg::doRefresh(bool invalidate /*= false*/)
_idxMap.resize(count); _idxMap.resize(count);
if (oldSize < count) if (oldSize < count)
lo = oldSize; lo = oldSize;
for (size_t i=lo; i<count; ++i) for (size_t i = lo; i < count; ++i)
_idxMap[i] = i; _idxMap[i] = int(i);
} }
LPARAM lp = invalidate ? LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL : LVSICF_NOSCROLL; LPARAM lp = invalidate ? LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL : LVSICF_NOSCROLL;
//ListView_SetItemCountEx(_hList, count, lp);
::SendMessage(_hList, LVM_SETITEMCOUNT, (WPARAM)count, lp); ::SendMessage(_hList, LVM_SETITEMCOUNT, (WPARAM)count, lp);
::InvalidateRect(_hList, &_rc, FALSE); ::InvalidateRect(_hList, &_rc, FALSE);
@ -610,7 +612,7 @@ void WindowsDlg::fitColumnsToSize()
void WindowsDlg::resetSelection() void WindowsDlg::resetSelection()
{ {
int curSel = _pTab->getCurrentTabIndex(); auto curSel = _pTab->getCurrentTabIndex();
int pos = 0; int pos = 0;
for (vector<int>::iterator itr = _idxMap.begin(), end = _idxMap.end(); itr != end; ++itr, ++pos) for (vector<int>::iterator itr = _idxMap.begin(), end = _idxMap.end(); itr != end; ++itr, ++pos)
{ {
@ -712,7 +714,7 @@ void WindowsDlg::doClose()
} }
delete[] nmdlg.Items; delete[] nmdlg.Items;
if (_pTab->nbItem() != (int)_idxMap.size()) if (_pTab->nbItem() != _idxMap.size())
doRefresh(true); doRefresh(true);
else else
{ {
@ -806,12 +808,13 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab)
{ {
if (hMenu == _hMenu) if (hMenu == _hMenu)
{ {
int curDoc = pTab->getCurrentTabIndex(); auto curDoc = pTab->getCurrentTabIndex();
int nMaxDoc = IDM_WINDOW_MRU_LIMIT - IDM_WINDOW_MRU_FIRST + 1; size_t nMaxDoc = IDM_WINDOW_MRU_LIMIT - IDM_WINDOW_MRU_FIRST + 1;
int nDoc = pTab->nbItem(); size_t nDoc = pTab->nbItem();
nDoc = min(nDoc, nMaxDoc); nDoc = min(nDoc, nMaxDoc);
int id, pos; int id;
for (id=IDM_WINDOW_MRU_FIRST, pos=0; id<IDM_WINDOW_MRU_FIRST + nDoc; ++id, ++pos) size_t pos;
for (id = IDM_WINDOW_MRU_FIRST, pos = 0; id < IDM_WINDOW_MRU_FIRST + static_cast<int32_t>(nDoc); ++id, ++pos)
{ {
BufferID bufID = pTab->getBufferByIndex(pos); BufferID bufID = pTab->getBufferByIndex(pos);
Buffer * buf = MainFileManager->getBufferByID(bufID); Buffer * buf = MainFileManager->getBufferByID(bufID);
@ -820,14 +823,14 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab)
memset(&mii, 0, sizeof(mii)); memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii); mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING|MIIM_STATE|MIIM_ID; mii.fMask = MIIM_STRING|MIIM_STATE|MIIM_ID;
generic_string strBuffer(BuildMenuFileName(60, pos, buf->getFileName())); generic_string strBuffer(BuildMenuFileName(60, static_cast<int32_t>(pos), buf->getFileName()));
// Can't make mii.dwTypeData = strBuffer.c_str() because of const cast. // Can't make mii.dwTypeData = strBuffer.c_str() because of const cast.
// So, making temporary buffer for this. // So, making temporary buffer for this.
std::vector<TCHAR> vBuffer(strBuffer.begin(), strBuffer.end()); std::vector<TCHAR> vBuffer(strBuffer.begin(), strBuffer.end());
vBuffer.push_back('\0'); vBuffer.push_back('\0');
mii.dwTypeData = (&vBuffer[0]); mii.dwTypeData = (&vBuffer[0]);
mii.fState &= ~(MF_GRAYED|MF_DISABLED|MF_CHECKED); mii.fState &= ~(MF_GRAYED|MF_DISABLED|MF_CHECKED);
if (pos == curDoc) if (int(pos) == curDoc)
mii.fState |= MF_CHECKED; mii.fState |= MF_CHECKED;
mii.wID = id; mii.wID = id;

View File

@ -48,7 +48,7 @@ void RunMacroDlg::initMacroList()
::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_ADDSTRING, 0, (LPARAM)macroList[i].getName()); ::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_ADDSTRING, 0, (LPARAM)macroList[i].getName());
::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_SETCURSEL, 0, 0); ::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_SETCURSEL, 0, 0);
m_macroIndex = 0; _macroIndex = 0;
} }
INT_PTR CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) INT_PTR CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
@ -58,8 +58,8 @@ INT_PTR CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
initMacroList(); initMacroList();
::SetDlgItemInt(_hSelf, IDC_M_RUN_TIMES, m_Times, FALSE); ::SetDlgItemInt(_hSelf, IDC_M_RUN_TIMES, _times, FALSE);
switch ( m_Mode ) switch (_mode)
{ {
case RM_RUN_MULTI: case RM_RUN_MULTI:
check(IDC_M_RUN_MULTI); check(IDC_M_RUN_MULTI);
@ -98,12 +98,12 @@ INT_PTR CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
case IDOK : case IDOK :
if ( isCheckedOrNot(IDC_M_RUN_MULTI) ) if ( isCheckedOrNot(IDC_M_RUN_MULTI) )
{ {
m_Mode = RM_RUN_MULTI; _mode = RM_RUN_MULTI;
m_Times = ::GetDlgItemInt(_hSelf, IDC_M_RUN_TIMES, NULL, FALSE); _times = ::GetDlgItemInt(_hSelf, IDC_M_RUN_TIMES, NULL, FALSE);
} }
else if ( isCheckedOrNot(IDC_M_RUN_EOF) ) else if ( isCheckedOrNot(IDC_M_RUN_EOF) )
{ {
m_Mode = RM_RUN_EOF; _mode = RM_RUN_EOF;
} }
if (::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_GETCOUNT, 0, 0)) if (::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_GETCOUNT, 0, 0))
@ -114,7 +114,7 @@ INT_PTR CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
default: default:
if ((HIWORD(wParam) == CBN_SELCHANGE) && (LOWORD(wParam) == IDC_MACRO_COMBO)) if ((HIWORD(wParam) == CBN_SELCHANGE) && (LOWORD(wParam) == IDC_MACRO_COMBO))
{ {
m_macroIndex = ::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_GETCURSEL, 0, 0); _macroIndex = static_cast<int32_t>(::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_GETCURSEL, 0, 0));
return TRUE; return TRUE;
} }
} }
@ -141,5 +141,5 @@ void RunMacroDlg::check(int id)
int RunMacroDlg::getMacro2Exec() const int RunMacroDlg::getMacro2Exec() const
{ {
bool isCurMacroPresent = ::SendMessage(_hParent, WM_GETCURRENTMACROSTATUS, 0, 0) == MACRO_RECORDING_HAS_STOPPED; bool isCurMacroPresent = ::SendMessage(_hParent, WM_GETCURRENTMACROSTATUS, 0, 0) == MACRO_RECORDING_HAS_STOPPED;
return isCurMacroPresent?(m_macroIndex - 1):m_macroIndex; return isCurMacroPresent?(_macroIndex - 1):_macroIndex;
} }

View File

@ -43,7 +43,7 @@
class RunMacroDlg : public StaticDialog class RunMacroDlg : public StaticDialog
{ {
public : public :
RunMacroDlg() : StaticDialog(), m_Mode(RM_RUN_MULTI), m_Times(1) {}; RunMacroDlg() : StaticDialog(), _mode(RM_RUN_MULTI), _times(1) {};
~RunMacroDlg() { ~RunMacroDlg() {
}; };
@ -60,17 +60,17 @@ public :
void initMacroList(); void initMacroList();
int getMode() const {return m_Mode;}; int getMode() const {return _mode;};
int getTimes() const {return m_Times;}; int getTimes() const {return _times;};
int getMacro2Exec() const; int getMacro2Exec() const;
private : private :
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
void check(int); void check(int);
int m_Mode; int _mode;
int m_Times; int _times;
int m_macroIndex; int _macroIndex;
}; };
#endif //RUN_MACRO_DLG_H #endif //RUN_MACRO_DLG_H

View File

@ -213,7 +213,7 @@ generic_string ScintillaKeyMap::toString() const {
return toString(0); return toString(0);
} }
generic_string ScintillaKeyMap::toString(int index) const { generic_string ScintillaKeyMap::toString(size_t index) const {
generic_string sc = TEXT(""); generic_string sc = TEXT("");
if (!isEnabled()) if (!isEnabled())
return sc; return sc;
@ -232,39 +232,46 @@ generic_string ScintillaKeyMap::toString(int index) const {
return sc; return sc;
} }
KeyCombo ScintillaKeyMap::getKeyComboByIndex(int index) const { KeyCombo ScintillaKeyMap::getKeyComboByIndex(size_t index) const {
return _keyCombos[index]; return _keyCombos[index];
} }
void ScintillaKeyMap::setKeyComboByIndex(int index, KeyCombo combo) { void ScintillaKeyMap::setKeyComboByIndex(int index, KeyCombo combo)
if(combo._key == 0 && (size > 1)) { //remove the item if possible {
if(combo._key == 0 && (_size > 1))
{ //remove the item if possible
_keyCombos.erase(_keyCombos.begin() + index); _keyCombos.erase(_keyCombos.begin() + index);
} }
_keyCombos[index] = combo; _keyCombos[index] = combo;
} }
void ScintillaKeyMap::removeKeyComboByIndex(int index) { void ScintillaKeyMap::removeKeyComboByIndex(size_t index)
if (size > 1 && index > -1 && index < int(size)) { {
if (_size > 1 && index < _size)
{
_keyCombos.erase(_keyCombos.begin() + index); _keyCombos.erase(_keyCombos.begin() + index);
size--; _size--;
} }
} }
int ScintillaKeyMap::addKeyCombo(KeyCombo combo) { //returns index where key is added, or -1 when invalid int ScintillaKeyMap::addKeyCombo(KeyCombo combo)
{ //returns index where key is added, or -1 when invalid
if (combo._key == 0) //do not allow to add disabled keycombos if (combo._key == 0) //do not allow to add disabled keycombos
return -1; return -1;
if (!isEnabled()) { //disabled, override current combo with new enabled one if (!isEnabled())
{ //disabled, override current combo with new enabled one
_keyCombos[0] = combo; _keyCombos[0] = combo;
return 0; return 0;
} }
for(size_t i = 0; i < size; ++i) { //if already in the list do not add it for(size_t i = 0; i < _size; ++i)
{ //if already in the list do not add it
KeyCombo & kc = _keyCombos[i]; KeyCombo & kc = _keyCombos[i];
if (combo._key == kc._key && combo._isCtrl == kc._isCtrl && combo._isAlt == kc._isAlt && combo._isShift == kc._isShift) if (combo._key == kc._key && combo._isCtrl == kc._isCtrl && combo._isAlt == kc._isAlt && combo._isShift == kc._isShift)
return i; //already in the list return static_cast<int32_t>(i); //already in the list
} }
_keyCombos.push_back(combo); _keyCombos.push_back(combo);
++size; ++_size;
return (size - 1); return static_cast<int32_t>(_size - 1);
} }
bool ScintillaKeyMap::isEnabled() const { bool ScintillaKeyMap::isEnabled() const {
@ -272,7 +279,7 @@ bool ScintillaKeyMap::isEnabled() const {
} }
size_t ScintillaKeyMap::getSize() const { size_t ScintillaKeyMap::getSize() const {
return size; return _size;
} }
void getKeyStrFromVal(UCHAR keyVal, generic_string & str) void getKeyStrFromVal(UCHAR keyVal, generic_string & str)
@ -309,7 +316,7 @@ void getNameStrFromCmd(DWORD cmd, generic_string & str)
else if ((cmd >= ID_PLUGINS_CMD) && (cmd < ID_PLUGINS_CMD_LIMIT)) else if ((cmd >= ID_PLUGINS_CMD) && (cmd < ID_PLUGINS_CMD_LIMIT))
{ {
vector<PluginCmdShortcut> & pluginCmds = (NppParameters::getInstance())->getPluginCommandList(); vector<PluginCmdShortcut> & pluginCmds = (NppParameters::getInstance())->getPluginCommandList();
int i = 0; size_t i = 0;
for (size_t j = 0, len = pluginCmds.size(); j < len ; ++j) for (size_t j = 0, len = pluginCmds.size(); j < len ; ++j)
{ {
if (pluginCmds[j].getID() == cmd) if (pluginCmds[j].getID() == cmd)
@ -376,7 +383,7 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_ADDSTRING, 0, (LPARAM)namedKeyArray[i].name); ::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_ADDSTRING, 0, (LPARAM)namedKeyArray[i].name);
if (_keyCombo._key == namedKeyArray[i].id) if (_keyCombo._key == namedKeyArray[i].id)
iFound = i; iFound = static_cast<int32_t>(i);
} }
if (iFound != -1) if (iFound != -1)
@ -393,17 +400,17 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
switch (wParam) switch (wParam)
{ {
case IDC_CTRL_CHECK : case IDC_CTRL_CHECK :
_keyCombo._isCtrl = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0); _keyCombo._isCtrl = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDOK), isValid() && (textlen > 0 || !_canModifyName)); ::EnableWindow(::GetDlgItem(_hSelf, IDOK), isValid() && (textlen > 0 || !_canModifyName));
return TRUE; return TRUE;
case IDC_ALT_CHECK : case IDC_ALT_CHECK :
_keyCombo._isAlt = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0); _keyCombo._isAlt = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDOK), isValid() && (textlen > 0 || !_canModifyName)); ::EnableWindow(::GetDlgItem(_hSelf, IDOK), isValid() && (textlen > 0 || !_canModifyName));
return TRUE; return TRUE;
case IDC_SHIFT_CHECK : case IDC_SHIFT_CHECK :
_keyCombo._isShift = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0); _keyCombo._isShift = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
return TRUE; return TRUE;
case IDOK : case IDOK :
@ -435,7 +442,7 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{ {
if (LOWORD(wParam) == IDC_KEY_COMBO) if (LOWORD(wParam) == IDC_KEY_COMBO)
{ {
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0);
_keyCombo._key = namedKeyArray[i].id; _keyCombo._key = namedKeyArray[i].id;
::EnableWindow(::GetDlgItem(_hSelf, IDOK), isValid() && (textlen > 0 || !_canModifyName)); ::EnableWindow(::GetDlgItem(_hSelf, IDOK), isValid() && (textlen > 0 || !_canModifyName));
::ShowWindow(::GetDlgItem(_hSelf, IDC_WARNING_STATIC), isEnabled()?SW_HIDE:SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_WARNING_STATIC), isEnabled()?SW_HIDE:SW_SHOW);
@ -545,7 +552,7 @@ void Accelerator::updateShortcuts()
{ {
tmpAccelArray[i] = IFAcc[i]; tmpAccelArray[i] = IFAcc[i];
} }
_hIncFindAccTab = ::CreateAcceleratorTable(tmpAccelArray, nb); _hIncFindAccTab = ::CreateAcceleratorTable(tmpAccelArray, static_cast<int32_t>(nb));
delete [] tmpAccelArray; delete [] tmpAccelArray;
return; return;
@ -586,10 +593,10 @@ void Accelerator::updateMenuItemByCommand(CommandShortcut csc) {
} }
recordedMacroStep::recordedMacroStep(int iMessage, long wParam, long lParam, int codepage) recordedMacroStep::recordedMacroStep(int iMessage, long wParam, long lParam, int codepage)
: message(iMessage), wParameter(wParam), lParameter(lParam), MacroType(mtUseLParameter) : _message(iMessage), _wParameter(wParam), _lParameter(lParam), _macroType(mtUseLParameter)
{ {
if (lParameter) { if (_lParameter) {
switch (message) { switch (_message) {
case SCI_SETTEXT : case SCI_SETTEXT :
case SCI_REPLACESEL : case SCI_REPLACESEL :
case SCI_REPLACETARGET : case SCI_REPLACETARGET :
@ -611,17 +618,17 @@ recordedMacroStep::recordedMacroStep(int iMessage, long wParam, long lParam, int
case IDD_FINDINFILES_DIR_COMBO: case IDD_FINDINFILES_DIR_COMBO:
case IDD_FINDINFILES_FILTERS_COMBO: case IDD_FINDINFILES_FILTERS_COMBO:
{ {
char *ch = reinterpret_cast<char *>(lParameter); char *ch = reinterpret_cast<char *>(_lParameter);
TCHAR tch[2]; TCHAR tch[2];
::MultiByteToWideChar(codepage, 0, ch, -1, tch, 2); ::MultiByteToWideChar(codepage, 0, ch, -1, tch, 2);
sParameter = *tch; _sParameter = *tch;
MacroType = mtUseSParameter; _macroType = mtUseSParameter;
lParameter = 0; _lParameter = 0;
} }
break; break;
default : // for all other messages, use lParameter "as is" default : // for all other messages, use _lParameter "as is"
break; break;
} }
} }
@ -629,34 +636,38 @@ recordedMacroStep::recordedMacroStep(int iMessage, long wParam, long lParam, int
void recordedMacroStep::PlayBack(Window* pNotepad, ScintillaEditView *pEditView) void recordedMacroStep::PlayBack(Window* pNotepad, ScintillaEditView *pEditView)
{ {
if (MacroType == mtMenuCommand) if (_macroType == mtMenuCommand)
::SendMessage(pNotepad->getHSelf(), WM_COMMAND, wParameter, 0); ::SendMessage(pNotepad->getHSelf(), WM_COMMAND, _wParameter, 0);
else else
{ {
long lParam = lParameter;
char ansiBuffer[3]; char ansiBuffer[3];
if (MacroType == mtUseSParameter) if (_macroType == mtUseSParameter)
{ {
::WideCharToMultiByte(pEditView->execute(SCI_GETCODEPAGE), 0, sParameter.c_str(), -1, ansiBuffer, 3, NULL, NULL); ::WideCharToMultiByte(static_cast<UINT>(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, ansiBuffer, 3, NULL, NULL);
lParam = reinterpret_cast<LPARAM>(ansiBuffer); auto lParam = reinterpret_cast<LPARAM>(ansiBuffer);
pEditView->execute(_message, _wParameter, lParam);
}
else
{
pEditView->execute(_message, _wParameter, _lParameter);
} }
pEditView->execute(message, wParameter, lParam); if ( (_message == SCI_SETTEXT)
if ( (message == SCI_SETTEXT) || (_message == SCI_REPLACESEL)
|| (message == SCI_REPLACESEL) || (_message == SCI_ADDTEXT)
|| (message == SCI_ADDTEXT) || (_message == SCI_ADDSTYLEDTEXT)
|| (message == SCI_ADDSTYLEDTEXT) || (_message == SCI_INSERTTEXT)
|| (message == SCI_INSERTTEXT) || (_message == SCI_APPENDTEXT) )
|| (message == SCI_APPENDTEXT) ) { {
SCNotification scnN; SCNotification scnN;
scnN.nmhdr.code = SCN_CHARADDED; scnN.nmhdr.code = SCN_CHARADDED;
scnN.nmhdr.hwndFrom = pEditView->getHSelf(); scnN.nmhdr.hwndFrom = pEditView->getHSelf();
scnN.nmhdr.idFrom = 0; scnN.nmhdr.idFrom = 0;
if(sParameter.empty()) if(_sParameter.empty())
scnN.ch = 0; scnN.ch = 0;
else else
scnN.ch = sParameter.at(0); scnN.ch = _sParameter.at(0);
::SendMessage(pNotepad->getHSelf(), WM_NOTIFY, 0, reinterpret_cast<LPARAM>(&scnN)); ::SendMessage(pNotepad->getHSelf(), WM_NOTIFY, 0, reinterpret_cast<LPARAM>(&scnN));
} }
} }
@ -744,13 +755,13 @@ void ScintillaKeyMap::validateDialog() {
bool isDisabled = !isEnabled(); //true if this shortcut already is bool isDisabled = !isEnabled(); //true if this shortcut already is
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_ADD), valid && !isDisabling); ::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_ADD), valid && !isDisabling);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_APPLY), valid && (!isDisabling || size == 1)); ::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_APPLY), valid && (!isDisabling || _size == 1));
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_RMVE), (size > 1)?TRUE:FALSE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_RMVE), (_size > 1)?TRUE:FALSE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_WARNING_STATIC), isDisabled?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_WARNING_STATIC), isDisabled?SW_SHOW:SW_HIDE);
} }
void ScintillaKeyMap::showCurrentSettings() { void ScintillaKeyMap::showCurrentSettings() {
int keyIndex = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0); auto keyIndex = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0);
_keyCombo = _keyCombos[keyIndex]; _keyCombo = _keyCombos[keyIndex];
::SendDlgItemMessage(_hSelf, IDC_CTRL_CHECK, BM_SETCHECK, _keyCombo._isCtrl?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CTRL_CHECK, BM_SETCHECK, _keyCombo._isCtrl?BST_CHECKED:BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_ALT_CHECK, BM_SETCHECK, _keyCombo._isAlt?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_ALT_CHECK, BM_SETCHECK, _keyCombo._isAlt?BST_CHECKED:BST_UNCHECKED, 0);
@ -785,7 +796,8 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_ADDSTRING, 0, (LPARAM)namedKeyArray[i].name); ::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_ADDSTRING, 0, (LPARAM)namedKeyArray[i].name);
} }
for(size_t i = 0; i < size; ++i) { for(size_t i = 0; i < _size; ++i)
{
::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_ADDSTRING, 0, (LPARAM)toString(i).c_str()); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_ADDSTRING, 0, (LPARAM)toString(i).c_str());
} }
::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, 0, 0); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, 0, 0);
@ -802,19 +814,19 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
switch (wParam) switch (wParam)
{ {
case IDC_CTRL_CHECK : case IDC_CTRL_CHECK :
_keyCombo._isCtrl = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0); _keyCombo._isCtrl = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
//applyToCurrentIndex(); //applyToCurrentIndex();
validateDialog(); validateDialog();
return TRUE; return TRUE;
case IDC_ALT_CHECK : case IDC_ALT_CHECK :
_keyCombo._isAlt = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0); _keyCombo._isAlt = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
//applyToCurrentIndex(); //applyToCurrentIndex();
validateDialog(); validateDialog();
return TRUE; return TRUE;
case IDC_SHIFT_CHECK : case IDC_SHIFT_CHECK :
_keyCombo._isShift = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0); _keyCombo._isShift = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
//applyToCurrentIndex(); //applyToCurrentIndex();
return TRUE; return TRUE;
@ -829,29 +841,35 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
::EndDialog(_hSelf, -1); ::EndDialog(_hSelf, -1);
return TRUE; return TRUE;
case IDC_BUTTON_ADD: { case IDC_BUTTON_ADD:
int oldsize = size; {
size_t oldsize = _size;
int res = addKeyCombo(_keyCombo); int res = addKeyCombo(_keyCombo);
if (res > -1) { if (res > -1)
if (res == oldsize) { {
if (res == static_cast<int32_t>(oldsize))
{
::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)toString(res).c_str()); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)toString(res).c_str());
}else { //update current generic_string, can happen if it was disabled }
else
{ //update current generic_string, can happen if it was disabled
updateListItem(res); updateListItem(res);
} }
::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, res, 0); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, res, 0);
} }
showCurrentSettings(); showCurrentSettings();
validateDialog(); validateDialog();
return TRUE; } return TRUE;
}
case IDC_BUTTON_RMVE: { case IDC_BUTTON_RMVE: {
if (size == 1) //cannot delete last shortcut if (_size == 1) //cannot delete last shortcut
return TRUE; return TRUE;
int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0);
removeKeyComboByIndex(i); removeKeyComboByIndex(i);
::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, i, 0); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, i, 0);
if (i == (int)size) if (i == (int)_size)
i = size - 1; i = _size - 1;
::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, i, 0); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, i, 0);
showCurrentSettings(); showCurrentSettings();
validateDialog(); validateDialog();
@ -868,7 +886,7 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
switch(LOWORD(wParam)) { switch(LOWORD(wParam)) {
case IDC_KEY_COMBO: case IDC_KEY_COMBO:
{ {
int i = ::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_GETCURSEL, 0, 0); auto i = ::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_GETCURSEL, 0, 0);
_keyCombo._key = namedKeyArray[i].id; _keyCombo._key = namedKeyArray[i].id;
//applyToCurrentIndex(); //applyToCurrentIndex();
validateDialog(); validateDialog();

View File

@ -206,30 +206,30 @@ public:
_keyCombos.clear(); _keyCombos.clear();
_keyCombos.push_back(_keyCombo); _keyCombos.push_back(_keyCombo);
_keyCombo._key = 0; _keyCombo._key = 0;
size = 1; _size = 1;
}; };
unsigned long getScintillaKeyID() const {return _scintillaKeyID;}; unsigned long getScintillaKeyID() const {return _scintillaKeyID;};
int getMenuCmdID() const {return _menuCmdID;}; int getMenuCmdID() const {return _menuCmdID;};
int toKeyDef(int index) const { int toKeyDef(size_t index) const {
KeyCombo kc = _keyCombos[index]; KeyCombo kc = _keyCombos[index];
int keymod = (kc._isCtrl?SCMOD_CTRL:0) | (kc._isAlt?SCMOD_ALT:0) | (kc._isShift?SCMOD_SHIFT:0); int keymod = (kc._isCtrl?SCMOD_CTRL:0) | (kc._isAlt?SCMOD_ALT:0) | (kc._isShift?SCMOD_SHIFT:0);
return keyTranslate((int)kc._key) + (keymod << 16); return keyTranslate((int)kc._key) + (keymod << 16);
}; };
KeyCombo getKeyComboByIndex(int index) const; KeyCombo getKeyComboByIndex(size_t index) const;
void setKeyComboByIndex(int index, KeyCombo combo); void setKeyComboByIndex(int index, KeyCombo combo);
void removeKeyComboByIndex(int index); void removeKeyComboByIndex(size_t index);
void clearDups() { void clearDups() {
if (size > 1) if (_size > 1)
_keyCombos.erase(_keyCombos.begin()+1, _keyCombos.end()); _keyCombos.erase(_keyCombos.begin()+1, _keyCombos.end());
size = 1; _size = 1;
}; };
int addKeyCombo(KeyCombo combo); int addKeyCombo(KeyCombo combo);
bool isEnabled() const; bool isEnabled() const;
size_t getSize() const; size_t getSize() const;
generic_string toString() const; generic_string toString() const;
generic_string toString(int index) const; generic_string toString(size_t index) const;
INT_PTR doDialog() INT_PTR doDialog()
{ {
@ -238,11 +238,12 @@ public:
//only compares the internal KeyCombos, nothing else //only compares the internal KeyCombos, nothing else
friend inline const bool operator==(const ScintillaKeyMap & a, const ScintillaKeyMap & b) { friend inline const bool operator==(const ScintillaKeyMap & a, const ScintillaKeyMap & b) {
bool equal = a.size == b.size; bool equal = a._size == b._size;
if (!equal) if (!equal)
return false; return false;
size_t i = 0; size_t i = 0;
while(equal && (i < a.size)) { while(equal && (i < a._size))
{
equal = equal =
(a._keyCombos[i]._isCtrl == b._keyCombos[i]._isCtrl) && (a._keyCombos[i]._isCtrl == b._keyCombos[i]._isCtrl) &&
(a._keyCombos[i]._isAlt == b._keyCombos[i]._isAlt) && (a._keyCombos[i]._isAlt == b._keyCombos[i]._isAlt) &&
@ -261,7 +262,7 @@ private:
unsigned long _scintillaKeyID; unsigned long _scintillaKeyID;
int _menuCmdID; int _menuCmdID;
std::vector<KeyCombo> _keyCombos; std::vector<KeyCombo> _keyCombos;
size_t size; size_t _size;
void applyToCurrentIndex(); void applyToCurrentIndex();
void validateDialog(); void validateDialog();
void showCurrentSettings(); void showCurrentSettings();
@ -277,24 +278,24 @@ class ScintillaEditView;
struct recordedMacroStep { struct recordedMacroStep {
enum MacroTypeIndex {mtUseLParameter, mtUseSParameter, mtMenuCommand, mtSavedSnR}; enum MacroTypeIndex {mtUseLParameter, mtUseSParameter, mtMenuCommand, mtSavedSnR};
int message; int _message;
long wParameter; long _wParameter;
long lParameter; long _lParameter;
generic_string sParameter; generic_string _sParameter;
MacroTypeIndex MacroType; MacroTypeIndex _macroType;
recordedMacroStep(int iMessage, long wParam, long lParam, int codepage); recordedMacroStep(int iMessage, long wParam, long lParam, int codepage);
recordedMacroStep(int iCommandID) : message(0), wParameter(iCommandID), lParameter(0), MacroType(mtMenuCommand) {}; recordedMacroStep(int iCommandID) : _message(0), _wParameter(iCommandID), _lParameter(0), _macroType(mtMenuCommand) {};
recordedMacroStep(int iMessage, long wParam, long lParam, const TCHAR *sParam, int type) recordedMacroStep(int iMessage, long wParam, long lParam, const TCHAR *sParam, int type)
: message(iMessage), wParameter(wParam), lParameter(lParam), MacroType(MacroTypeIndex(type)){ : _message(iMessage), _wParameter(wParam), _lParameter(lParam), _macroType(MacroTypeIndex(type)){
sParameter = (sParam)?generic_string(sParam):TEXT(""); _sParameter = (sParam)?generic_string(sParam):TEXT("");
}; };
bool isValid() const { bool isValid() const {
return true; return true;
}; };
bool isPlayable() const {return MacroType <= mtMenuCommand;}; bool isPlayable() const {return _macroType <= mtMenuCommand;};
void PlayBack(Window* pNotepad, ScintillaEditView *pEditView); void PlayBack(Window* pNotepad, ScintillaEditView *pEditView);
}; };

View File

@ -45,11 +45,11 @@ int ValueDlg::doDialog(POINT p, bool isRTL)
{ {
DLGTEMPLATE *pMyDlgTemplate = NULL; DLGTEMPLATE *pMyDlgTemplate = NULL;
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_VALUE_DLG, &pMyDlgTemplate); HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_VALUE_DLG, &pMyDlgTemplate);
int result = ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); int result = static_cast<int32_t>(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this));
::GlobalFree(hMyDlgTemplate); ::GlobalFree(hMyDlgTemplate);
return result; return result;
} }
return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_VALUE_DLG), _hParent, dlgProc, (LPARAM)this); return static_cast<int32_t>(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_VALUE_DLG), _hParent, dlgProc, (LPARAM)this));
} }

View File

@ -723,7 +723,7 @@ void NativeLangSpeaker::changeFindReplaceDlgLang(FindReplaceDlg & findReplaceDlg
void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference) void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference)
{ {
int currentSel = preference.getListSelectedIndex(); auto currentSel = preference.getListSelectedIndex();
changeDlgLang(preference.getHSelf(), "Preference"); changeDlgLang(preference.getHSelf(), "Preference");
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();

View File

@ -74,7 +74,9 @@ PRBool nsCharSetProber::FilterWithoutEnglishLetters(const char* aBuf, PRUint32 a
if (meetMSB && curPtr > prevPtr) if (meetMSB && curPtr > prevPtr)
while (prevPtr < curPtr) *newptr++ = *prevPtr++; while (prevPtr < curPtr) *newptr++ = *prevPtr++;
newLen = newptr - *newBuf; auto np = reinterpret_cast<uintptr_t>(newptr);
auto nb = reinterpret_cast<uintptr_t>(*newBuf);
newLen = static_cast<PRUint32>(np - nb);
return PR_TRUE; return PR_TRUE;
} }
@ -119,7 +121,9 @@ PRBool nsCharSetProber::FilterWithEnglishLetters(const char* aBuf, PRUint32 aLen
while (prevPtr < curPtr) while (prevPtr < curPtr)
*newptr++ = *prevPtr++; *newptr++ = *prevPtr++;
newLen = newptr - *newBuf; auto np = reinterpret_cast<uintptr_t>(newptr);
auto nb = reinterpret_cast<uintptr_t>(*newBuf);
newLen = static_cast<PRUint32>(np - nb);
return PR_TRUE; return PR_TRUE;
} }

View File

@ -117,12 +117,14 @@ void parseCommandLine(TCHAR * commandLine, ParamVector & paramVector) {
//the commandline generic_string is now a list of zero terminated strings concatenated, and the vector contains all the substrings //the commandline generic_string is now a list of zero terminated strings concatenated, and the vector contains all the substrings
} }
bool isInList(const TCHAR *token2Find, ParamVector & params) { bool isInList(const TCHAR *token2Find, ParamVector & params)
int nrItems = params.size(); {
size_t nrItems = params.size();
for (int i = 0; i < nrItems; ++i) for (size_t i = 0; i < nrItems; ++i)
{
if (!lstrcmp(token2Find, params.at(i)))
{ {
if (!lstrcmp(token2Find, params.at(i))) {
params.erase(params.begin() + i); params.erase(params.begin() + i);
return true; return true;
} }
@ -133,9 +135,9 @@ bool isInList(const TCHAR *token2Find, ParamVector & params) {
bool getParamVal(TCHAR c, ParamVector & params, generic_string & value) bool getParamVal(TCHAR c, ParamVector & params, generic_string & value)
{ {
value = TEXT(""); value = TEXT("");
int nrItems = params.size(); size_t nrItems = params.size();
for (int i = 0; i < nrItems; ++i) for (size_t i = 0; i < nrItems; ++i)
{ {
const TCHAR * token = params.at(i); const TCHAR * token = params.at(i);
if (token[0] == '-' && lstrlen(token) >= 2 && token[1] == c) { //dash, and enough chars if (token[0] == '-' && lstrlen(token) >= 2 && token[1] == c) { //dash, and enough chars
@ -150,14 +152,14 @@ bool getParamVal(TCHAR c, ParamVector & params, generic_string & value)
bool getParamValFromString(const TCHAR *str, ParamVector & params, generic_string & value) bool getParamValFromString(const TCHAR *str, ParamVector & params, generic_string & value)
{ {
value = TEXT(""); value = TEXT("");
int nrItems = params.size(); size_t nrItems = params.size();
for (int i = 0; i < nrItems; ++i) for (size_t i = 0; i < nrItems; ++i)
{ {
const TCHAR * token = params.at(i); const TCHAR * token = params.at(i);
generic_string tokenStr = token; generic_string tokenStr = token;
int pos = tokenStr.find(str); size_t pos = tokenStr.find(str);
if (pos != -1 && pos == 0) if (pos != generic_string::npos && pos == 0)
{ {
value = (token + lstrlen(str)); value = (token + lstrlen(str));
params.erase(params.begin() + i); params.erase(params.begin() + i);

View File

@ -135,7 +135,7 @@
<BasicRuntimeChecks>UninitializedLocalUsageCheck</BasicRuntimeChecks> <BasicRuntimeChecks>UninitializedLocalUsageCheck</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<SmallerTypeCheck>true</SmallerTypeCheck> <SmallerTypeCheck>true</SmallerTypeCheck>