Remove ugly coding style

pull/5431/head
Don HO 2019-03-16 05:33:50 +01:00
parent 6dfd22d52f
commit 52a4e21af5
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
26 changed files with 176 additions and 132 deletions

View File

@ -327,7 +327,7 @@ public:
{
int pos ;
for( pos = 0 ; pos < 16 ; pos++ )
for ( pos = 0 ; pos < 16 ; pos++ )
sprintf( digestChars+(pos*2), "%02x", digestRaw[pos] ) ;
}

View File

@ -3101,7 +3101,7 @@ size_t Notepad_plus::getSelectedCharNumber(UniMode u)
static inline size_t countUtf8Characters(unsigned char *buf, size_t pos, size_t endpos)
{
size_t result = 0;
while(pos < endpos)
while (pos < endpos)
{
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)
@ -6935,7 +6935,7 @@ bool Notepad_plus::undoStreamComment(bool tryBlockComment)
_pEditView->execute(SCI_SETSEL, selectionStart+selectionStartMove, selectionEnd+selectionEndMove);
}
}
while(1); //do as long as stream-comments are within selection
while (1); //do as long as stream-comments are within selection
}
void Notepad_plus::monitoringStartOrStopAndUpdateUI(Buffer* pBuf, bool isStarting)

View File

@ -1033,7 +1033,8 @@ bool Notepad_plus::fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes)
std::vector<int>::const_iterator itIndexesEnd = krvecBufferIndexes.end();
for(std::vector<int>::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex) {
for (std::vector<int>::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex)
{
BufferID id = _pDocTab->getBufferByIndex(*itIndex);
Buffer * buf = MainFileManager->getBufferByID(id);
if (buf->isUntitled() && buf->docLength() == 0)
@ -1069,7 +1070,8 @@ bool Notepad_plus::fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes)
// Now we close.
bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode();
for(std::vector<int>::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex) {
for (std::vector<int>::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex)
{
doClose(_pDocTab->getBufferByIndex(*itIndex), currentView(), isSnapshotMode);
}
@ -1081,7 +1083,8 @@ bool Notepad_plus::fileCloseAllToLeft()
// Indexes must go from high to low to deal with the fact that when one index is closed, any remaining
// indexes (smaller than the one just closed) will point to the wrong tab.
std::vector<int> vecIndexesToClose;
for(int i = _pDocTab->getCurrentTabIndex() - 1; i >= 0; i--) {
for (int i = _pDocTab->getCurrentTabIndex() - 1; i >= 0; i--)
{
vecIndexesToClose.push_back(i);
}
return fileCloseAllGiven(vecIndexesToClose);
@ -1093,7 +1096,8 @@ bool Notepad_plus::fileCloseAllToRight()
// indexes (smaller than the one just closed) will point to the wrong tab.
const int kiActive = _pDocTab->getCurrentTabIndex();
std::vector<int> vecIndexesToClose;
for(int i = int(_pDocTab->nbItem()) - 1; i > kiActive; i--) {
for (int i = int(_pDocTab->nbItem()) - 1; i > kiActive; i--)
{
vecIndexesToClose.push_back(i);
}
return fileCloseAllGiven(vecIndexesToClose);
@ -1319,7 +1323,7 @@ bool Notepad_plus::fileSaveAll()
{
if (viewVisible(MAIN_VIEW))
{
for(size_t i = 0; i < _mainDocTab.nbItem(); ++i)
for (size_t i = 0; i < _mainDocTab.nbItem(); ++i)
{
BufferID idToSave = _mainDocTab.getBufferByIndex(i);
fileSave(idToSave);
@ -1328,7 +1332,7 @@ bool Notepad_plus::fileSaveAll()
if (viewVisible(SUB_VIEW))
{
for(size_t i = 0; i < _subDocTab.nbItem(); ++i)
for (size_t i = 0; i < _subDocTab.nbItem(); ++i)
{
BufferID idToSave = _subDocTab.getBufferByIndex(i);
fileSave(idToSave);

View File

@ -915,7 +915,7 @@ bool NppParameters::reloadStylers(TCHAR* stylePath)
getUserStylersFromXmlTree();
// Reload plugin styles.
for( size_t i = 0; i < getExternalLexerDoc()->size(); ++i)
for ( size_t i = 0; i < getExternalLexerDoc()->size(); ++i)
{
getExternalLexerFromXmlTree( getExternalLexerDoc()->at(i) );
}
@ -1783,7 +1783,7 @@ void NppParameters::initMenuKeys()
{
int nbCommands = sizeof(winKeyDefs)/sizeof(WinMenuKeyDefinition);
WinMenuKeyDefinition wkd;
for(int i = 0; i < nbCommands; ++i)
for (int i = 0; i < nbCommands; ++i)
{
wkd = winKeyDefs[i];
Shortcut sc((wkd.specialName ? wkd.specialName : TEXT("")), wkd.isCtrl, wkd.isAlt, wkd.isShift, static_cast<unsigned char>(wkd.vKey));
@ -1799,7 +1799,7 @@ void NppParameters::initScintillaKeys() {
ScintillaKeyDefinition skd;
int prevIndex = -1;
int prevID = -1;
for(int i = 0; i < nbCommands; ++i)
for (int i = 0; i < nbCommands; ++i)
{
skd = scintKeyDefs[i];
if (skd.functionId == prevID)
@ -2370,7 +2370,7 @@ void NppParameters::feedShortcut(TiXmlNode *node)
{
//find the commandid that matches this Shortcut sc and alter it, push back its index in the modified list, if not present
size_t len = _shortcuts.size();
for(size_t i = 0; i < len; ++i)
for (size_t i = 0; i < len; ++i)
{
if (_shortcuts[i].getID() == (unsigned long)id)
{ //found our match
@ -2482,7 +2482,7 @@ void NppParameters::feedPluginCustomizedCmds(TiXmlNode *node)
//Find the corresponding plugincommand and alter it, put the index in the list
size_t len = _pluginCommands.size();
for(size_t i = 0; i < len; ++i)
for (size_t i = 0; i < len; ++i)
{
PluginCmdShortcut & pscOrig = _pluginCommands[i];
if (!generic_strnicmp(pscOrig.getModuleName(), moduleName, lstrlen(moduleName)) && pscOrig.getInternalID() == internalID)
@ -3749,7 +3749,7 @@ TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const TCHA
LangType NppParameters::getLangIDFromStr(const TCHAR *langName)
{
int lang = static_cast<int32_t>(L_TEXT);
for(; lang < L_EXTERNAL; ++lang)
for (; lang < L_EXTERNAL; ++lang)
{
const TCHAR * name = ScintillaEditView::langNames[lang].lexerName;
if (!lstrcmp(name, langName)) //found lang?
@ -6391,7 +6391,7 @@ void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & g
}
}
for(size_t x = 0; x < _pXmlExternalLexerDoc.size(); ++x)
for (size_t x = 0; x < _pXmlExternalLexerDoc.size(); ++x)
{
TiXmlNode *lexersRoot = ( _pXmlExternalLexerDoc[x]->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("LexerStyles"));
for (TiXmlNode *childNode = lexersRoot->FirstChildElement(TEXT("LexerType"));
@ -6668,7 +6668,7 @@ void NppParameters::addUserModifiedIndex(size_t index)
{
size_t len = _customizedShortcuts.size();
bool found = false;
for(size_t i = 0; i < len; ++i)
for (size_t i = 0; i < len; ++i)
{
if (_customizedShortcuts[i] == index)
{
@ -6686,7 +6686,7 @@ void NppParameters::addPluginModifiedIndex(size_t index)
{
size_t len = _pluginCustomizedCmds.size();
bool found = false;
for(size_t i = 0; i < len; ++i)
for (size_t i = 0; i < len; ++i)
{
if (_pluginCustomizedCmds[i] == index)
{
@ -6704,7 +6704,7 @@ void NppParameters::addScintillaModifiedIndex(int index)
{
size_t len = _scintillaModifiedKeyIndices.size();
bool found = false;
for(size_t i = 0; i < len; ++i)
for (size_t i = 0; i < len; ++i)
{
if (_scintillaModifiedKeyIndices[i] == index)
{

View File

@ -303,7 +303,7 @@ void AutoCompletion::showPathCompletion()
if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // If directory, add trailing slash.
autoCompleteEntries += TEXT("\\");
} while(::FindNextFile(hFind, &data));
} while (::FindNextFile(hFind, &data));
::FindClose(hFind);
}
else

View File

@ -399,7 +399,7 @@ void Buffer::setHeaderLineState(const std::vector<size_t> & folds, ScintillaEdit
std::vector<size_t> & local = _foldStates[index];
local.clear();
size_t size = folds.size();
for(size_t i = 0; i < size; ++i)
for (size_t i = 0; i < size; ++i)
local.push_back(folds[i]);
}
@ -471,13 +471,13 @@ int Buffer::removeReference(ScintillaEditView * identifier)
void Buffer::setHideLineChanged(bool isHide, int location)
{
//First run through all docs without removing markers
for(int i = 0; i < _references; ++i)
for (int i = 0; i < _references; ++i)
_referees.at(i)->notifyMarkers(this, isHide, location, false); // (i == _references-1));
if (!isHide) // no deleting if hiding lines
{
//Then all docs to remove markers.
for(int i = 0; i < _references; ++i)
for (int i = 0; i < _references; ++i)
_referees.at(i)->notifyMarkers(this, isHide, location, true);
}
}
@ -528,7 +528,7 @@ void FileManager::checkFilesystemChanges()
int FileManager::getBufferIndexByID(BufferID id)
{
for(size_t i = 0; i < _nbBufs; ++i)
for (size_t i = 0; i < _nbBufs; ++i)
{
if (_buffers[i]->_id == id)
return static_cast<int>(i);
@ -1067,7 +1067,7 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, g
size_t FileManager::nextUntitledNewNumber() const
{
std::vector<size_t> usedNumbers;
for(size_t i = 0; i < _buffers.size(); i++)
for (size_t i = 0; i < _buffers.size(); i++)
{
Buffer *buf = _buffers.at(i);
if (buf->isUntitled())
@ -1087,7 +1087,7 @@ size_t FileManager::nextUntitledNewNumber() const
bool found = false;
do
{
for(size_t j = 0; j < usedNumbers.size(); j++)
for (size_t j = 0; j < usedNumbers.size(); j++)
{
numberAvailable = true;
found = false;
@ -1435,7 +1435,7 @@ BufferID FileManager::getBufferFromName(const TCHAR* name)
::GetLongPathName(fullpath, fullpath, MAX_PATH);
}
for(size_t i = 0; i < _buffers.size(); i++)
for (size_t i = 0; i < _buffers.size(); i++)
{
if (OrdinalIgnoreCaseCompareStrings(name, _buffers.at(i)->getFullPathName()) == 0)
return _buffers.at(i)->getID();

View File

@ -91,7 +91,7 @@ BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) //-1 if not fo
TCITEM tie;
tie.lParam = -1;
tie.mask = TCIF_PARAM;
for(size_t i = 0; i < _nbItem; ++i)
for (size_t i = 0; i < _nbItem; ++i)
{
::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
BufferID id = reinterpret_cast<BufferID>(tie.lParam);
@ -110,7 +110,7 @@ int DocTabView::getIndexByBuffer(BufferID id)
TCITEM tie;
tie.lParam = -1;
tie.mask = TCIF_PARAM;
for(size_t i = 0; i < _nbItem; ++i)
for (size_t i = 0; i < _nbItem; ++i)
{
::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
if (reinterpret_cast<BufferID>(tie.lParam) == id)

View File

@ -155,12 +155,14 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int
return j;
}
bool Searching::readBase(const TCHAR * str, int * value, int base, int size) {
bool Searching::readBase(const TCHAR * str, int * value, int base, int size)
{
int i = 0, temp = 0;
*value = 0;
TCHAR max = '0' + static_cast<TCHAR>(base) - 1;
TCHAR current;
while(i < size) {
while (i < size)
{
current = str[i];
if (current >= 'A')
{
@ -170,10 +172,13 @@ bool Searching::readBase(const TCHAR * str, int * value, int base, int size) {
else if (current > '9')
return false;
if (current >= '0' && current <= max) {
if (current >= '0' && current <= max)
{
temp *= base;
temp += (current - '0');
} else {
}
else
{
return false;
}
++i;

View File

@ -59,13 +59,16 @@ inline bool match(TCHAR c1, TCHAR c2) {
//test string case insensitive ala Scintilla
//0 if equal, <0 of before, >0 if after (name1 that is)
int testNameNoCase(const TCHAR * name1, const TCHAR * name2, int len = -1) {
int testNameNoCase(const TCHAR * name1, const TCHAR * name2, int len = -1)
{
if (len == -1) {
len = 1024; //magic value, but it probably fails way before it reaches this
}
int i = 0;
while(match(name1[i], name2[i])) {
if (name1[i] == 0 || i == len) {
while (match(name1[i], name2[i]))
{
if (name1[i] == 0 || i == len)
{
return 0; //equal
}
++i;
@ -77,7 +80,8 @@ int testNameNoCase(const TCHAR * name1, const TCHAR * name2, int len = -1) {
return ( (name1[i]-subs1) - (name2[i]-subs2) );
}
void FunctionCallTip::setLanguageXML(TiXmlElement * pXmlKeyword) {
void FunctionCallTip::setLanguageXML(TiXmlElement * pXmlKeyword)
{
if (isVisible())
close();
_pXmlKeyword = pXmlKeyword;
@ -108,14 +112,16 @@ bool FunctionCallTip::updateCalltip(int ch, bool needShown)
return true;
}
void FunctionCallTip::showNextOverload() {
void FunctionCallTip::showNextOverload()
{
if (!isVisible())
return;
_currentOverload = (_currentOverload+1) % _currentNbOverloads;
showCalltip();
}
void FunctionCallTip::showPrevOverload() {
void FunctionCallTip::showPrevOverload()
{
if (!isVisible())
return;
_currentOverload = _currentOverload > 0 ? (_currentOverload-1) : (_currentNbOverloads-1);
@ -253,7 +259,7 @@ bool FunctionCallTip::getCursorFunction()
if (curValue.lastFunctionIdentifier == -1)
{ //not in direct function. Start popping the stack untill we empty it, or a func IS found
while(curValue.lastFunctionIdentifier == -1 && valueVec.size() > 0)
while (curValue.lastFunctionIdentifier == -1 && valueVec.size() > 0)
{
curValue = valueVec.back();
valueVec.pop_back();
@ -388,7 +394,7 @@ void FunctionCallTip::showCalltip()
if ((size_t)_currentParam >= psize)
{
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;
if ((size_t)_currentParam < psize)

View File

@ -2976,9 +2976,9 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, int initial, int in
{
int curNumber = initial;
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++)
{
numbers.push_back(curNumber);
if (numbers.size() >= kiMaxSize)
@ -3125,7 +3125,7 @@ void ScintillaEditView::hideLines()
//remove any markers in between
int scope = 0;
for(int i = startLine; i <= endLine; ++i)
for (int i = startLine; i <= endLine; ++i)
{
auto state = execute(SCI_MARKERGET, i);
bool closePresent = ((state & (1 << MARK_HIDELINESEND)) != 0); //check close first, then open, since close closes scope
@ -3168,7 +3168,7 @@ bool ScintillaEditView::markerMarginClick(int lineNumber)
if (closePresent)
{
openPresent = false;
for(lineNumber--; lineNumber >= 0 && !openPresent; lineNumber--)
for (lineNumber--; lineNumber >= 0 && !openPresent; lineNumber--)
{
state = execute(SCI_MARKERGET, lineNumber);
openPresent = ((state & (1 << MARK_HIDELINESBEGIN | 1 << MARK_HIDELINESUNDERLINE)) != 0);

View File

@ -483,7 +483,7 @@ public:
execute(SCI_GETSELTEXT, 0, reinterpret_cast<LPARAM>(selected));
char *c = selected;
long length = 0;
while(*c != '\0')
while (*c != '\0')
{
if ( (*c & 0xC0) != 0x80)
++length;
@ -491,7 +491,7 @@ public:
}
delete [] selected;
return length;
}
};
long getLineLength(int line) const {

View File

@ -1610,7 +1610,7 @@ INT_PTR CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPAR
// for the font size combo
HWND hFontSizeCombo = ::GetDlgItem(hwnd, IDC_STYLER_COMBO_FONT_SIZE);
for(int j = 0 ; j < int(sizeof(fontSizeStrs))/(3*sizeof(TCHAR)) ; ++j)
for (int j = 0 ; j < int(sizeof(fontSizeStrs))/(3*sizeof(TCHAR)) ; ++j)
::SendMessage(hFontSizeCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(fontSizeStrs[j]));
TCHAR size[10];

View File

@ -182,7 +182,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
std::string tagName;
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
while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'')
while (position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'')
{
tagName.push_back(static_cast<char>(nextChar));
++position;
@ -246,7 +246,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
}
}
} while(inbetweenCloseTag.success);
} while (inbetweenCloseTag.success);
// If we didn't find any close tags between the open and our close,
// and there's no open tags remaining to find
@ -282,7 +282,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
std::string tagName;
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
while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'' )
while (position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'' )
{
tagName.push_back(static_cast<char>(nextChar));
++position;
@ -351,7 +351,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
currentStartPosition = inbetweenOpenTag.end;
}
} while(inbetweenOpenTag.success);
} while (inbetweenOpenTag.success);
// If we didn't find any open tags between our open and the close,
// and there's no close tags remaining to find
@ -537,7 +537,7 @@ XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findCloseTag(co
++whitespacePoint;
nextChar = static_cast<int32_t>(_pEditView->execute(SCI_GETCHARAT, whitespacePoint));
} while(isWhitespace(nextChar));
} while (isWhitespace(nextChar));
if (nextChar == '>')
{

View File

@ -168,7 +168,7 @@ const char* TiXmlBaseA::SkipWhiteSpace( const char* p )
#ifdef TIXMLA_USE_STL
/*static*/ bool TiXmlBaseA::StreamWhiteSpace( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag )
{
for( ;; )
for ( ;; )
{
if ( !in->good() ) return false;
@ -203,10 +203,10 @@ const char* TiXmlBaseA::ReadName( const char* p, TIXMLA_STRING * name )
// After that, they can be letters, underscores, numbers,
// hyphens, or colons. (Colons are valid ony for namespaces,
// but tinyxml can't tell namespaces from names.)
if ( p && *p
if ( p && *p
&& (isalpha(static_cast<unsigned char>(*p)) || *p == '_'))
{
while( p && *p
while ( p && *p
&& ( isalnum( (unsigned char ) *p )
|| *p == '_'
|| *p == '-'
@ -262,7 +262,7 @@ const char* TiXmlBaseA::GetEntity( const char* p, char* value )
}
// Now try to match it.
for( i=0; i<NUM_ENTITY; ++i )
for ( i=0; i<NUM_ENTITY; ++i )
{
if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
{
@ -594,7 +594,7 @@ void TiXmlElementA::StreamIn (TIXMLA_ISTREAM * in, TIXMLA_STRING * tag)
{
// We're called with some amount of pre-parsing. That is, some of "this"
// element is in "tag". Go ahead and stream to the closing ">"
while( in->good() )
while ( in->good() )
{
int c = in->get();
(*tag) += static_cast<char>(c);
@ -645,7 +645,7 @@ void TiXmlElementA::StreamIn (TIXMLA_ISTREAM * in, TIXMLA_STRING * tag)
bool closingTag = false;
bool firstCharFound = false;
for( ;; )
for ( ;; )
{
if ( !in->good() )
return;
@ -1145,7 +1145,7 @@ const char* TiXmlDeclarationA::Parse( const char* p, TiXmlParsingDataA* data )
else
{
// Read over whatever it is.
while( p && *p && *p != '>' && !isspace( *p ) )
while ( p && *p && *p != '>' && !isspace( *p ) )
++p;
}
}

View File

@ -169,7 +169,7 @@ const TCHAR* TiXmlBase::SkipWhiteSpace( const TCHAR* p )
#ifdef TIXML_USE_STL
/*static*/ bool TiXmlBase::StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag )
{
for( ;; )
for ( ;; )
{
if ( !in->good() ) return false;
@ -627,7 +627,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
bool closingTag = false;
bool firstCharFound = false;
for( ;; )
for ( ;; )
{
if ( !in->good() )
return;

View File

@ -106,7 +106,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
_currentThemeIndex = -1;
int defaultThemeIndex = 0;
ThemeSwitcher & themeSwitcher = nppParamInst->getThemeSwitcher();
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);
int j = static_cast<int32_t>(::SendMessage(_hSwitch2ThemeCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(themeInfo.first.c_str())));
@ -126,7 +126,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
}
::SendMessage(_hSwitch2ThemeCombo, CB_SETCURSEL, _currentThemeIndex, 0);
for(int i = 0 ; i < sizeof(fontSizeStrs)/(3*sizeof(TCHAR)) ; ++i)
for (int i = 0 ; i < sizeof(fontSizeStrs)/(3*sizeof(TCHAR)) ; ++i)
::SendMessage(_hFontSizeCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(fontSizeStrs[i]));
const std::vector<generic_string> & fontlist = (NppParameters::getInstance())->getFontList();

View File

@ -253,7 +253,7 @@ vector<tTbData*> DockingCont::getDataOfVisTb()
tcItem.mask = TCIF_PARAM;
for(int iItem = 0; iItem < iItemCnt; ++iItem)
for (int iItem = 0; iItem < iItemCnt; ++iItem)
{
::SendMessage(_hContTab, TCM_GETITEM, iItem, reinterpret_cast<LPARAM>(&tcItem));
vTbData.push_back((tTbData*)tcItem.lParam);
@ -268,7 +268,7 @@ bool DockingCont::isTbVis(tTbData* data)
tcItem.mask = TCIF_PARAM;
for(int iItem = 0; iItem < iItemCnt; ++iItem)
for (int iItem = 0; iItem < iItemCnt; ++iItem)
{
::SendMessage(_hContTab, TCM_GETITEM, iItem, reinterpret_cast<LPARAM>(&tcItem));
if (!tcItem.lParam)

View File

@ -3243,7 +3243,7 @@ int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext)
FOUND=FALSE;
while((!FOUND)&&((tail-head)>1))
while ((!FOUND)&&((tail-head)>1))
{
finger = head + ((tail - head) / 2);
lbTextLen = ::SendMessage(lbhWnd, LB_GETTEXTLEN, finger, 0);

View File

@ -276,7 +276,7 @@ void ShortcutMapper::fillOutBabyGrid()
{
vector<MacroShortcut> & cshortcuts = nppParam->getMacroList();
cs_index = 1;
for(size_t i = 0; i < nbItems; ++i)
for (size_t i = 0; i < nbItems; ++i)
{
if (isFilterValid(cshortcuts[i]))
{
@ -305,7 +305,7 @@ void ShortcutMapper::fillOutBabyGrid()
{
vector<UserCommand> & cshortcuts = nppParam->getUserCommandList();
cs_index = 1;
for(size_t i = 0; i < nbItems; ++i)
for (size_t i = 0; i < nbItems; ++i)
{
if (isFilterValid(cshortcuts[i]))
{
@ -335,7 +335,7 @@ void ShortcutMapper::fillOutBabyGrid()
{
vector<PluginCmdShortcut> & cshortcuts = nppParam->getPluginCommandList();
cs_index = 1;
for(size_t i = 0; i < nbItems; ++i)
for (size_t i = 0; i < nbItems; ++i)
{
if (isFilterValid(cshortcuts[i]))
{
@ -365,7 +365,7 @@ void ShortcutMapper::fillOutBabyGrid()
{
vector<ScintillaKeyMap> & cshortcuts = nppParam->getScintillaKeyList();
cs_index=1;
for(size_t i = 0; i < nbItems; ++i)
for (size_t i = 0; i < nbItems; ++i)
{
if (isFilterValid(cshortcuts[i]))
{

View File

@ -1792,7 +1792,7 @@ INT_PTR CALLBACK LangMenuDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
if ((lmi._langType >= L_EXTERNAL) && (lmi._langType < pNppParam->L_END))
{
bool found(false);
for(size_t x = 0; x < pNppParam->getExternalLexerDoc()->size() && !found; ++x)
for (size_t x = 0; x < pNppParam->getExternalLexerDoc()->size() && !found; ++x)
{
TiXmlNode *lexersRoot = pNppParam->getExternalLexerDoc()->at(x)->FirstChild(TEXT("NotepadPlus"))->FirstChildElement(TEXT("LexerStyles"));
for (TiXmlNode *childNode = lexersRoot->FirstChildElement(TEXT("LexerType"));
@ -2153,7 +2153,7 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
::SetDlgItemText(_hSelf, IDC_EDIT_FRIGHT, nppGUI._printSettings._footerRight.c_str());
TCHAR intStr[5];
for(size_t i = 6 ; i < 15 ; ++i)
for (size_t i = 6 ; i < 15 ; ++i)
{
wsprintf(intStr, TEXT("%d"), i);
::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTSIZE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(intStr));

View File

@ -25,8 +25,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <stdexcept>
#include "ToolBar.h"
#include "shortcut.h"
@ -104,8 +102,7 @@ void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
}
}
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type,
ToolBarButtonUnit *buttonUnitArray, int arraySize)
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBarButtonUnit *buttonUnitArray, int arraySize)
{
Window::init(hInst, hPere);
_state = type;
@ -149,7 +146,8 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type,
_pTBB[i].iString = 0;
}
if (_nbDynButtons > 0) {
if (_nbDynButtons > 0)
{
//add separator
_pTBB[i].iBitmap = 0;
_pTBB[i].idCommand = 0;
@ -178,8 +176,10 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type,
return true;
}
void ToolBar::destroy() {
if (_pRebar) {
void ToolBar::destroy()
{
if (_pRebar)
{
_pRebar->removeBand(_rbBand.wID);
_pRebar = NULL;
}
@ -189,17 +189,20 @@ void ToolBar::destroy() {
_toolBarIcons.destroy();
};
int ToolBar::getWidth() const {
int ToolBar::getWidth() const
{
RECT btnRect;
int totalWidth = 0;
for(size_t i = 0; i < _nbCurrentButtons; ++i) {
for (size_t i = 0; i < _nbCurrentButtons; ++i)
{
::SendMessage(_hSelf, TB_GETITEMRECT, i, reinterpret_cast<LPARAM>(&btnRect));
totalWidth += btnRect.right - btnRect.left;
}
return totalWidth;
}
int ToolBar::getHeight() const {
int ToolBar::getHeight() const
{
DWORD size = static_cast<DWORD>(SendMessage(_hSelf, TB_GETBUTTONSIZE, 0, 0));
DWORD padding = static_cast<DWORD>(SendMessage(_hSelf, TB_GETPADDING, 0, 0));
int totalHeight = HIWORD(size) + HIWORD(padding) - 3;
@ -250,7 +253,7 @@ void ToolBar::reset(bool create)
{
//Store current button state information
TBBUTTON tempBtn;
for(size_t i = 0; i < _nbCurrentButtons; ++i)
for (size_t i = 0; i < _nbCurrentButtons; ++i)
{
::SendMessage(_hSelf, TB_GETBUTTON, i, reinterpret_cast<LPARAM>(&tempBtn));
_pTBB[i].fsState = tempBtn.fsState;
@ -360,7 +363,7 @@ void ToolBar::doPopop(POINT chevPoint)
size_t start = 0;
RECT btnRect = {0,0,0,0};
while(start < _nbCurrentButtons)
while (start < _nbCurrentButtons)
{
::SendMessage(_hSelf, TB_GETITEMRECT, start, reinterpret_cast<LPARAM>(&btnRect));
if (btnRect.right > width)
@ -460,7 +463,7 @@ void ReBar::reNew(int id, REBARBANDINFO * rBand)
{
auto index = SendMessage(_hSelf, RB_IDTOINDEX, id, 0);
::SendMessage(_hSelf, RB_SETBANDINFO, index, reinterpret_cast<LPARAM>(rBand));
};
}
void ReBar::removeBand(int id)
{
@ -522,7 +525,7 @@ int ReBar::getNewID()
{
int idToUse = REBAR_BAR_EXTERNAL;
size_t size = usedIDs.size();
for(size_t i = 0; i < size; ++i)
for (size_t i = 0; i < size; ++i)
{
int curVal = usedIDs.at(i);
if (curVal < idToUse)
@ -546,7 +549,7 @@ int ReBar::getNewID()
void ReBar::releaseID(int id)
{
size_t size = usedIDs.size();
for(size_t i = 0; i < size; ++i)
for (size_t i = 0; i < size; ++i)
{
if (usedIDs.at(i) == id)
{
@ -559,7 +562,7 @@ void ReBar::releaseID(int id)
bool ReBar::isIDTaken(int id)
{
size_t size = usedIDs.size();
for(size_t i = 0; i < size; ++i)
for (size_t i = 0; i < size; ++i)
{
if (usedIDs.at(i) == id)
{

View File

@ -81,7 +81,10 @@ inline static BOOL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd) {
struct NumericStringEquivalence
{
int operator()(const TCHAR* s1, const TCHAR* s2) const
{ return numstrcmp(s1, s2); }
{
return numstrcmp(s1, s2);
}
static inline int numstrcmp_get(const TCHAR **str, int *length)
{
const TCHAR *p = *str;
@ -91,13 +94,15 @@ struct NumericStringEquivalence
*str = p;
return (value);
}
static int numstrcmp(const TCHAR *str1, const TCHAR *str2)
{
TCHAR *p1, *p2;
int c1, c2, lcmp = 0;
for(;;)
for (;;)
{
if (*str1 == 0 || *str2 == 0) {
if (*str1 == 0 || *str2 == 0)
{
if (*str1 != *str2)
lcmp = *str1 - *str2;
break;
@ -751,7 +756,8 @@ void WindowsDlg::doClose()
nmdlg.Items = new UINT[nmdlg.nItems];
vector<int> key;
key.resize(n, 0x7fffffff);
for(int i=-1, j=0;; ++j) {
for (int i=-1, j=0;; ++j)
{
i = ListView_GetNextItem(_hList, i, LVNI_SELECTED);
if (i == -1) break;
ListView_SetItemState(_hList, i, 0, LVIS_SELECTED); // deselect
@ -810,7 +816,7 @@ void WindowsDlg::doSortToTabs()
nmdlg.nItems = ListView_GetItemCount(_hList);
nmdlg.Items = new UINT[nmdlg.nItems];
for(int i=-1, j=0;; ++j)
for (int i=-1, j=0;; ++j)
{
i = ListView_GetNextItem(_hList, i, LVNI_ALL);
if (i == -1)
@ -850,7 +856,7 @@ void WindowsMenu::init(HINSTANCE hInst, HMENU hMainMenu, const TCHAR *translatio
}
int32_t pos = 0;
for(pos = GetMenuItemCount(hMainMenu) - 1; pos > 0; --pos)
for (pos = GetMenuItemCount(hMainMenu) - 1; pos > 0; --pos)
{
if ((GetMenuState(hMainMenu, pos, MF_BYPOSITION) & MF_POPUP) != MF_POPUP)
continue;

View File

@ -167,16 +167,22 @@ generic_string Shortcut::toString() const
return sc;
}
void Shortcut::setName(const TCHAR * name) {
void Shortcut::setName(const TCHAR * name)
{
lstrcpyn(_menuName, name, nameLenMax);
lstrcpyn(_name, name, nameLenMax);
int i = 0, j = 0;
while(name[j] != 0 && i < nameLenMax) {
if (name[j] != '&') {
while (name[j] != 0 && i < nameLenMax)
{
if (name[j] != '&')
{
_name[i] = name[j];
++i;
} else { //check if this ampersand is being escaped
if (name[j+1] == '&') { //escaped ampersand
}
else //check if this ampersand is being escaped
{
if (name[j+1] == '&') //escaped ampersand
{
_name[i] = name[j];
++i;
++j; //skip escaped ampersand
@ -187,10 +193,12 @@ void Shortcut::setName(const TCHAR * name) {
_name[i] = 0;
}
generic_string ScintillaKeyMap::toString() const {
generic_string ScintillaKeyMap::toString() const
{
generic_string sc = TEXT("");
size_t nbCombos = getSize();
for (size_t combo = 0; combo < nbCombos; ++combo){
for (size_t combo = 0; combo < nbCombos; ++combo)
{
sc += toString(combo);
if (combo < nbCombos - 1)
sc += TEXT(" or ");
@ -198,7 +206,8 @@ generic_string ScintillaKeyMap::toString() const {
return sc;
}
generic_string ScintillaKeyMap::toString(size_t index) const {
generic_string ScintillaKeyMap::toString(size_t index) const
{
generic_string sc = TEXT("");
if (!isEnabled())
return sc;
@ -217,7 +226,8 @@ generic_string ScintillaKeyMap::toString(size_t index) const {
return sc;
}
KeyCombo ScintillaKeyMap::getKeyComboByIndex(size_t index) const {
KeyCombo ScintillaKeyMap::getKeyComboByIndex(size_t index) const
{
return _keyCombos[index];
}
@ -248,7 +258,8 @@ int ScintillaKeyMap::addKeyCombo(KeyCombo combo)
_keyCombos[0] = combo;
return 0;
}
for(size_t i = 0; i < _size; ++i)
for (size_t i = 0; i < _size; ++i)
{ //if already in the list do not add it
KeyCombo & kc = _keyCombos[i];
if (combo._key == kc._key && combo._isCtrl == kc._isCtrl && combo._isAlt == kc._isAlt && combo._isShift == kc._isShift)
@ -259,11 +270,13 @@ int ScintillaKeyMap::addKeyCombo(KeyCombo combo)
return static_cast<int32_t>(_size - 1);
}
bool ScintillaKeyMap::isEnabled() const {
bool ScintillaKeyMap::isEnabled() const
{
return (_keyCombos[0]._key != 0);
}
size_t ScintillaKeyMap::getSize() const {
size_t ScintillaKeyMap::getSize() const
{
return _size;
}
@ -272,8 +285,10 @@ void getKeyStrFromVal(UCHAR keyVal, generic_string & str)
str = TEXT("");
bool found = false;
int i;
for (i = 0; i < nbKeys; ++i) {
if (keyVal == namedKeyArray[i].id) {
for (i = 0; i < nbKeys; ++i)
{
if (keyVal == namedKeyArray[i].id)
{
found = true;
break;
}
@ -496,7 +511,7 @@ void Accelerator::updateShortcuts()
int offset = 0;
size_t i = 0;
//no validation performed, it might be that invalid shortcuts are being used by default. Allows user to 'hack', might be a good thing
for(i = 0; i < nbMenu; ++i)
for (i = 0; i < nbMenu; ++i)
{
if (shortcuts[i].isEnabled())
{
@ -515,7 +530,7 @@ void Accelerator::updateShortcuts()
}
}
for(i = 0; i < nbMacro; ++i)
for (i = 0; i < nbMacro; ++i)
{
if (macros[i].isEnabled())
{
@ -526,7 +541,7 @@ void Accelerator::updateShortcuts()
}
}
for(i = 0; i < nbUserCmd; ++i)
for (i = 0; i < nbUserCmd; ++i)
{
if (userCommands[i].isEnabled())
{
@ -537,7 +552,7 @@ void Accelerator::updateShortcuts()
}
}
for(i = 0; i < nbPluginCmd; ++i)
for (i = 0; i < nbPluginCmd; ++i)
{
if (pluginCommands[i].isEnabled())
{
@ -586,25 +601,30 @@ void Accelerator::updateShortcuts()
return;
}
void Accelerator::updateFullMenu() {
void Accelerator::updateFullMenu()
{
NppParameters * pNppParam = NppParameters::getInstance();
vector<CommandShortcut> commands = pNppParam->getUserShortcuts();
for(size_t i = 0; i < commands.size(); ++i) {
for (size_t i = 0; i < commands.size(); ++i)
{
updateMenuItemByCommand(commands[i]);
}
vector<MacroShortcut> mcommands = pNppParam->getMacroList();
for(size_t i = 0; i < mcommands.size(); ++i) {
for (size_t i = 0; i < mcommands.size(); ++i)
{
updateMenuItemByCommand(mcommands[i]);
}
vector<UserCommand> ucommands = pNppParam->getUserCommandList();
for(size_t i = 0; i < ucommands.size(); ++i) {
for (size_t i = 0; i < ucommands.size(); ++i)
{
updateMenuItemByCommand(ucommands[i]);
}
vector<PluginCmdShortcut> pcommands = pNppParam->getPluginCommandList();
for(size_t i = 0; i < pcommands.size(); ++i) {
for (size_t i = 0; i < pcommands.size(); ++i)
{
updateMenuItemByCommand(pcommands[i]);
}
@ -868,13 +888,13 @@ void ScintillaAccelerator::updateKeys()
for (size_t i = 0; i < nb; ++i)
{
::SendMessage(_vScintillas[i], SCI_CLEARALLCMDKEYS, 0, 0);
for(int32_t j = static_cast<int32_t>(mapSize) - 1; j >= 0; j--) //reverse order, top of the list has highest priority
for (int32_t j = static_cast<int32_t>(mapSize) - 1; j >= 0; j--) //reverse order, top of the list has highest priority
{
ScintillaKeyMap skm = map[j];
if (skm.isEnabled())
{ //no validating, scintilla accepts more keys
size_t size = skm.getSize();
for(index = 0; index < size; ++index)
for (index = 0; index < size; ++index)
::SendMessage(_vScintillas[i], SCI_ASSIGNCMDKEY, skm.toKeyDef(index), skm.getScintillaKeyID());
}
if (skm.getMenuCmdID() != 0)
@ -893,7 +913,7 @@ void ScintillaAccelerator::updateMenuItemByID(const ScintillaKeyMap& skm, int id
TCHAR cmdName[commandSize];
::GetMenuString(_hAccelMenu, id, cmdName, commandSize, MF_BYCOMMAND);
int i = 0;
while(cmdName[i] != 0)
while (cmdName[i] != 0)
{
if (cmdName[i] == '\t')
{
@ -985,7 +1005,7 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_ADDSTRING, 0, reinterpret_cast<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, reinterpret_cast<LPARAM>(toString(i).c_str()));
}

View File

@ -247,7 +247,7 @@ public:
if (!equal)
return false;
size_t i = 0;
while(equal && (i < a._size))
while (equal && (i < a._size))
{
equal =
(a._keyCombos[i]._isCtrl == b._keyCombos[i]._isCtrl) &&

View File

@ -61,7 +61,7 @@ void LastRecentFileList::switchMode()
::RemoveMenu(_hMenu, IDM_OPEN_ALL_RECENT_FILE, MF_BYCOMMAND);
::RemoveMenu(_hMenu, IDM_CLEAN_RECENT_FILE_LIST, MF_BYCOMMAND);
for(int i = 0; i < _size; ++i)
for (int i = 0; i < _size; ++i)
{
::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND);
}
@ -153,12 +153,12 @@ void LastRecentFileList::updateMenu()
_pAccelerator->updateFullMenu();
//Remove all menu items
for(int i = 0; i < _size; ++i)
for (int i = 0; i < _size; ++i)
{
::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND);
}
//Then readd them, so everything stays in sync
for(int j = 0; j < _size; ++j)
for (int j = 0; j < _size; ++j)
{
generic_string strBuffer(BuildMenuFileName(pNppParam->getRecentFileCustomLength(), j, _lrfl.at(j)._name));
::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, strBuffer.c_str());
@ -216,7 +216,7 @@ void LastRecentFileList::clear()
if (_size == 0)
return;
for(int i = (_size-1); i >= 0; i--)
for (int i = (_size-1); i >= 0; i--)
{
::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND);
setAvailable(_lrfl.at(i)._id);
@ -230,7 +230,7 @@ void LastRecentFileList::clear()
generic_string & LastRecentFileList::getItem(int id)
{
int i = 0;
for(; i < _size; ++i)
for (; i < _size; ++i)
{
if (_lrfl.at(i)._id == id)
break;
@ -252,7 +252,7 @@ void LastRecentFileList::setUserMaxNbLRF(int size)
if (_size > _userMax)
{ //start popping items
int toPop = _size-_userMax;
while(toPop > 0)
while (toPop > 0)
{
::RemoveMenu(_hMenu, _lrfl.back()._id, MF_BYCOMMAND);
setAvailable(_lrfl.back()._id);
@ -272,7 +272,7 @@ void LastRecentFileList::saveLRFL()
NppParameters *pNppParams = NppParameters::getInstance();
if (pNppParams->writeRecentFileHistorySettings(_userMax))
{
for(int i = _size - 1; i >= 0; i--) //reverse order: so loading goes in correct order
for (int i = _size - 1; i >= 0; i--) //reverse order: so loading goes in correct order
{
pNppParams->writeHistory(_lrfl.at(i)._name.c_str());
}
@ -282,7 +282,7 @@ void LastRecentFileList::saveLRFL()
int LastRecentFileList::find(const TCHAR *fn)
{
for(int i = 0; i < _size; ++i)
for (int i = 0; i < _size; ++i)
{
if (OrdinalIgnoreCaseCompareStrings(_lrfl.at(i)._name.c_str(), fn) == 0)
{

View File

@ -239,7 +239,7 @@ MenuPosition & getMenuPosition(const char *id)
int nbSubMenuPos = sizeof(menuPos)/sizeof(MenuPosition);
for(int i = 0; i < nbSubMenuPos; ++i)
for (int i = 0; i < nbSubMenuPos; ++i)
{
if (strcmp(menuPos[i]._id, id) == 0)
return menuPos[i];