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

@ -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);

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);

View File

@ -491,7 +491,7 @@ public:
}
delete [] selected;
return length;
}
};
long getLineLength(int line) const {

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;
@ -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)
{

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 (;;)
{
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

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,6 +258,7 @@ int ScintillaKeyMap::addKeyCombo(KeyCombo combo)
_keyCombos[0] = combo;
return 0;
}
for (size_t i = 0; i < _size; ++i)
{ //if already in the list do not add it
KeyCombo & kc = _keyCombos[i];
@ -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;
}
@ -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]);
}