Skip to content

Commit

Permalink
Rename variables & clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
donho committed Jul 27, 2017
1 parent 8342da3 commit 385746d
Show file tree
Hide file tree
Showing 16 changed files with 133 additions and 239 deletions.
4 changes: 2 additions & 2 deletions PowerEditor/src/Notepad_plus.cpp
Expand Up @@ -1906,7 +1906,7 @@ void Notepad_plus::checkDocState()
bool isFileExisting = PathFileExists(curBuf->getFullPathName()) != FALSE;
if (!isCurrentDirty)
{
for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i)
for (size_t i = 0; i < MainFileManager->getNbBuffers(); ++i)
{
if (MainFileManager->getBufferByIndex(i)->isDirty())
{
Expand Down Expand Up @@ -4959,7 +4959,7 @@ bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) {
TCHAR savePath[MAX_PATH] = {0};

//rescue primary
for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i)
for (size_t i = 0; i < MainFileManager->getNbBuffers(); ++i)
{
Buffer * docbuf = MainFileManager->getBufferByIndex(i);
if (!docbuf->isDirty()) //skip saved documents
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/NppBigSwitch.cpp
Expand Up @@ -177,7 +177,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
generic_string name{userLangName};

//loop through buffers and reset the language (L_USER, TEXT("")) if (L_USER, name)
for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i)
for (size_t i = 0; i < MainFileManager->getNbBuffers(); ++i)
{
Buffer* buf = MainFileManager->getBufferByIndex(i);
if (buf->getLangType() == L_USER && name == buf->getUserDefineLangName())
Expand All @@ -195,7 +195,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
generic_string newName{ reinterpret_cast<TCHAR *>(wParam) };

//loop through buffers and reset the language (L_USER, newName) if (L_USER, oldName)
for (size_t i = 0; i < MainFileManager->getNrBuffers(); ++i)
for (size_t i = 0; i < MainFileManager->getNbBuffers(); ++i)
{
Buffer* buf = MainFileManager->getBufferByIndex(i);
if (buf->getLangType() == L_USER && oldName == buf->getUserDefineLangName())
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/NppIO.cpp
Expand Up @@ -643,7 +643,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
}
}

size_t nrDocs = whichOne==MAIN_VIEW?(_mainDocTab.nbItem()):(_subDocTab.nbItem());
size_t nbDocs = whichOne==MAIN_VIEW?(_mainDocTab.nbItem()):(_subDocTab.nbItem());

if (buf->isMonitoringOn())
{
Expand All @@ -658,7 +658,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
//Do all the works
bool isBufRemoved = removeBufferFromView(id, whichOne);
BufferID hiddenBufferID = BUFFER_INVALID;
if (nrDocs == 1 && canHideView(whichOne))
if (nbDocs == 1 && canHideView(whichOne))
{ //close the view if both visible
hideView(whichOne);

Expand Down
8 changes: 4 additions & 4 deletions PowerEditor/src/Parameters.cpp
Expand Up @@ -1709,9 +1709,9 @@ bool NppParameters::getBlackListFromXmlTree()

void NppParameters::initMenuKeys()
{
int nrCommands = sizeof(winKeyDefs)/sizeof(WinMenuKeyDefinition);
int nbCommands = sizeof(winKeyDefs)/sizeof(WinMenuKeyDefinition);
WinMenuKeyDefinition wkd;
for(int i = 0; i < nrCommands; ++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));
Expand All @@ -1721,13 +1721,13 @@ void NppParameters::initMenuKeys()

void NppParameters::initScintillaKeys() {

int nrCommands = sizeof(scintKeyDefs)/sizeof(ScintillaKeyDefinition);
int nbCommands = sizeof(scintKeyDefs)/sizeof(ScintillaKeyDefinition);

//Warning! Matching function have to be consecutive
ScintillaKeyDefinition skd;
int prevIndex = -1;
int prevID = -1;
for(int i = 0; i < nrCommands; ++i)
for(int i = 0; i < nbCommands; ++i)
{
skd = scintKeyDefs[i];
if (skd.functionId == prevID)
Expand Down
22 changes: 11 additions & 11 deletions PowerEditor/src/ScitillaComponent/Buffer.cpp
Expand Up @@ -489,14 +489,14 @@ void FileManager::init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratch

void FileManager::checkFilesystemChanges()
{
for (int i = int(_nrBufs) - 1; i >= 0 ; i--)
for (int i = int(_nbBufs) - 1; i >= 0 ; i--)
{
if (i >= int(_nrBufs))
if (i >= int(_nbBufs))
{
if (_nrBufs == 0)
if (_nbBufs == 0)
return;

i = int(_nrBufs) - 1;
i = int(_nbBufs) - 1;
}
_buffers[i]->checkFileState(); //something has changed. Triggers update automatically
}
Expand All @@ -505,7 +505,7 @@ void FileManager::checkFilesystemChanges()

int FileManager::getBufferIndexByID(BufferID id)
{
for(size_t i = 0; i < _nrBufs; ++i)
for(size_t i = 0; i < _nbBufs; ++i)
{
if (_buffers[i]->_id == id)
return static_cast<int>(i);
Expand Down Expand Up @@ -546,7 +546,7 @@ void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier)
_pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, buf->_doc); //release for FileManager, Document is now gone
_buffers.erase(_buffers.begin() + index);
delete buf;
_nrBufs--;
_nbBufs--;
}
}

Expand Down Expand Up @@ -597,8 +597,8 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
newBuf->_timeStamp = fileNameTimestamp;

_buffers.push_back(newBuf);
++_nrBufs;
Buffer* buf = _buffers.at(_nrBufs - 1);
++_nbBufs;
Buffer* buf = _buffers.at(_nbBufs - 1);

// restore the encoding (ANSI based) while opening the existing file
NppParameters *pNppParamInst = NppParameters::getInstance();
Expand Down Expand Up @@ -1196,7 +1196,7 @@ BufferID FileManager::newEmptyDocument()
BufferID id = static_cast<BufferID>(newBuf);
newBuf->_id = id;
_buffers.push_back(newBuf);
++_nrBufs;
++_nbBufs;
++_nextBufferID;
return id;
}
Expand All @@ -1214,7 +1214,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d
BufferID id = static_cast<BufferID>(newBuf);
newBuf->_id = id;
_buffers.push_back(newBuf);
++_nrBufs;
++_nbBufs;

if (!dontIncrease)
++_nextBufferID;
Expand Down Expand Up @@ -1517,7 +1517,7 @@ BufferID FileManager::getBufferFromName(const TCHAR* name)

BufferID FileManager::getBufferFromDocument(Document doc)
{
for (size_t i = 0; i < _nrBufs; ++i)
for (size_t i = 0; i < _nbBufs; ++i)
{
if (_buffers[i]->_doc == doc)
return _buffers[i]->_id;
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/ScitillaComponent/Buffer.h
Expand Up @@ -76,7 +76,7 @@ class FileManager final
//void activateBuffer(int index);
void checkFilesystemChanges();

size_t getNrBuffers() { return _nrBufs; };
size_t getNbBuffers() { return _nbBufs; };
int getBufferIndexByID(BufferID id);
Buffer * getBufferByIndex(size_t index);
Buffer * getBufferByID(BufferID id) {return static_cast<Buffer*>(id);}
Expand Down Expand Up @@ -127,7 +127,7 @@ class FileManager final
Document _scratchDocDefault;
std::vector<Buffer*> _buffers;
BufferID _nextBufferID = 0;
size_t _nrBufs = 0;
size_t _nbBufs = 0;
};

#define MainFileManager FileManager::getInstance()
Expand Down
24 changes: 12 additions & 12 deletions PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp
Expand Up @@ -111,14 +111,14 @@ bool FunctionCallTip::updateCalltip(int ch, bool needShown)
void FunctionCallTip::showNextOverload() {
if (!isVisible())
return;
_currentOverload = (_currentOverload+1) % _currentNrOverloads;
_currentOverload = (_currentOverload+1) % _currentNbOverloads;
showCalltip();
}

void FunctionCallTip::showPrevOverload() {
if (!isVisible())
return;
_currentOverload = _currentOverload > 0 ? (_currentOverload-1) : (_currentNrOverloads-1);
_currentOverload = _currentOverload > 0 ? (_currentOverload-1) : (_currentNbOverloads-1);
showCalltip();
}

Expand Down Expand Up @@ -363,20 +363,20 @@ bool FunctionCallTip::loadFunction()
_overloads.push_back(paramVec);
paramVec.clear();

++_currentNrOverloads;
++_currentNbOverloads;
}

_currentNrOverloads = _overloads.size();
_currentNbOverloads = _overloads.size();

if (_currentNrOverloads == 0) //malformed node
if (_currentNbOverloads == 0) //malformed node
return false;

return true;
}

void FunctionCallTip::showCalltip()
{
if (_currentNrOverloads == 0)
if (_currentNbOverloads == 0)
{
//ASSERT
return;
Expand All @@ -401,25 +401,25 @@ void FunctionCallTip::showCalltip()

generic_stringstream callTipText;

if (_currentNrOverloads > 1)
if (_currentNbOverloads > 1)
{
callTipText << TEXT("\001") << _currentOverload + 1 << TEXT(" of ") << _currentNrOverloads << TEXT("\002");
callTipText << TEXT("\001") << _currentOverload + 1 << TEXT(" of ") << _currentNbOverloads << TEXT("\002");
}

callTipText << _retVals.at(_currentOverload) << TEXT(' ') << _funcName << TEXT(' ') << _start;

int highlightstart = 0;
int highlightend = 0;
size_t nrParams = params.size();
for (size_t i = 0; i < nrParams; ++i)
size_t nbParams = params.size();
for (size_t i = 0; i < nbParams; ++i)
{
if (int(i) == _currentParam)
{
highlightstart = static_cast<int>(callTipText.str().length());
highlightend = highlightstart + lstrlen(params.at(i));
}
callTipText << params.at(i);
if (i < nrParams - 1)
if (i < nbParams - 1)
callTipText << _param << TEXT(' ');
}

Expand Down Expand Up @@ -448,7 +448,7 @@ void FunctionCallTip::reset() {
//_curPos = 0;
_startPos = 0;
_overloads.clear();
_currentNrOverloads = 0;
_currentNbOverloads = 0;
_retVals.clear();
_descriptions.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/ScitillaComponent/FunctionCallTip.h
Expand Up @@ -59,7 +59,7 @@ class FunctionCallTip {
stringVec _retVals; //vector of overload return values/types
std::vector<stringVec> _overloads; //vector of overload params (=vector)
stringVec _descriptions; //vecotr of function descriptions
size_t _currentNrOverloads = 0; //current amount of overloads
size_t _currentNbOverloads = 0; //current amount of overloads
size_t _currentOverload = 0; //current chosen overload
int _currentParam = 0; //current highlighted param

Expand Down
6 changes: 3 additions & 3 deletions PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp
Expand Up @@ -3089,12 +3089,12 @@ void ScintillaEditView::hideLines()
int endLine = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONEND)));
//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
int nrLines = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
if (nrLines < 3)
int nbLines = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
if (nbLines < 3)
return; //cannot possibly hide anything
if (!startLine)
++startLine;
if (endLine == (nrLines-1))
if (endLine == (nbLines-1))
--endLine;

if (startLine > endLine)
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp
Expand Up @@ -46,8 +46,8 @@ void SmartHighlighter::highlightViewWithWord(ScintillaEditView * pHighlightView,
// Get the range of text visible and highlight everything in it
auto firstLine = static_cast<int>(pHighlightView->execute(SCI_GETFIRSTVISIBLELINE));
auto nbLineOnScreen = pHighlightView->execute(SCI_LINESONSCREEN);
auto nrLines = min(nbLineOnScreen, MAXLINEHIGHLIGHT) + 1;
auto lastLine = firstLine + nrLines;
auto nbLines = min(nbLineOnScreen, MAXLINEHIGHLIGHT) + 1;
auto lastLine = firstLine + nbLines;
int startPos = 0;
int endPos = 0;
auto currentLine = firstLine;
Expand Down
83 changes: 0 additions & 83 deletions PowerEditor/src/WinControls/Grid/BabyGrid.cpp
Expand Up @@ -3020,89 +3020,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
break;

/* case WM_SIZE: //obsolete
{
static int SI,cheight;
static int savewidth,saveheight;
int intin,intout;
SI=SelfIndex;





if(BGHS[SI].SIZING)
{
BGHS[SI].SIZING = FALSE;
break;
}
ShowHscroll(hWnd,SI);
ShowVscroll(hWnd,SI);

if((BGHS[SI].SHOWINTEGRALROWS)&&(BGHS[SI].VSCROLL))
{
saveheight=HIWORD(lParam);
intin=saveheight;
savewidth=LOWORD(lParam);
cheight=HIWORD(lParam);
cheight-=BGHS[SI].titleheight;
cheight-=BGHS[SI].headerrowheight;

{
int sbheight;
sbheight=GetSystemMetrics(SM_CYHSCROLL);
if(BGHS[SI].HSCROLL)
{
cheight-=sbheight;
}
if(BGHS[SI].VSCROLL)
{
RECT grect,prect;
GetClientRect(hWnd,&grect);
GetClientRect(GetParent(hWnd),&prect);
if((grect.right+sbheight) < prect.right)
{
savewidth+=sbheight;
}
}

}



if(cheight <= BGHS[SI].rowheight)
{
break;
}
else
{
//calculate fractional part of cheight/rowheight
int remainder,nrows;
nrows=(int)(cheight/BGHS[SI].rowheight);
remainder=cheight-(nrows * BGHS[SI].rowheight);
//make the window remainder pixels shorter
saveheight -= remainder;
saveheight +=4; //+=4
intout=saveheight;
WINDOWPLACEMENT wp;
RECT crect;
wp.length = sizeof(wp);
GetWindowPlacement(hWnd,&wp);
crect=wp.rcNormalPosition;
crect.bottom=intout;
//crect.bottom = NppParameters::getInstance()->_dpiManager.ScaleY(intout);
crect.right=savewidth;
BGHS[SI].SIZING = TRUE;

BGHS[SI].wannabeheight = HIWORD(lParam);
BGHS[SI].wannabewidth = LOWORD(lParam);
//NppParameters::getInstance()->_dpiManager.ScaleRect(&crect);
MoveWindow(hWnd,crect.left,crect.top,crect.right,crect.bottom,TRUE);
}
}

}
break; */
case WM_CREATE:
lpcs = (LPCREATESTRUCT)lParam;

Expand Down

0 comments on commit 385746d

Please sign in to comment.