From 6e6341cc61accf57608a7c8c0df8603c49441bdb Mon Sep 17 00:00:00 2001 From: Don HO Date: Tue, 28 Jan 2020 02:20:44 +0100 Subject: [PATCH] Make some codes conform to the defined coding style --- PowerEditor/src/EncodingMapper.cpp | 4 +- .../MISC/PluginsManager/PluginsManager.cpp | 3 +- PowerEditor/src/Notepad_plus.cpp | 78 +++++++++++++------ PowerEditor/src/NppBigSwitch.cpp | 6 +- PowerEditor/src/NppIO.cpp | 16 ++-- PowerEditor/src/Parameters.cpp | 7 +- .../src/ScitillaComponent/AutoCompletion.cpp | 29 ++++--- .../src/ScitillaComponent/FindReplaceDlg.cpp | 16 ++-- .../src/ScitillaComponent/FunctionCallTip.cpp | 15 ++-- .../ScitillaComponent/ScintillaEditView.cpp | 40 +++++++--- PowerEditor/src/UniConversion.cpp | 43 ++++++---- .../WinControls/DockingWnd/DockingCont.cpp | 7 +- .../WinControls/DockingWnd/DockingManager.cpp | 3 +- .../src/WinControls/Grid/ShortcutMapper.cpp | 6 +- .../OpenSaveFileDialog/FileDialog.cpp | 7 +- .../src/WinControls/ToolBar/ToolBar.cpp | 9 ++- .../src/WinControls/WindowsDlg/WinRect.cpp | 15 ++-- .../src/WinControls/WindowsDlg/WindowsDlg.cpp | 5 +- .../src/WinControls/shortcut/shortcut.cpp | 22 ++++-- PowerEditor/src/lastRecentFileList.cpp | 11 ++- PowerEditor/src/uchardet/CharDistribution.cpp | 3 +- PowerEditor/src/winmain.cpp | 6 +- 22 files changed, 242 insertions(+), 109 deletions(-) diff --git a/PowerEditor/src/EncodingMapper.cpp b/PowerEditor/src/EncodingMapper.cpp index beadc6da..b81fd5af 100644 --- a/PowerEditor/src/EncodingMapper.cpp +++ b/PowerEditor/src/EncodingMapper.cpp @@ -83,9 +83,11 @@ static EncodingUnit encodings[] = { {20866, "koi8_r csKOI8R"} //IDM_FORMAT_KOI8R_CYRILLIC }; -bool isInListA(const char *token, const char *list) { +bool isInListA(const char *token, const char *list) +{ if ((!token) || (!list)) return false; + char word[64]; size_t i = 0; size_t j = 0; diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index e832f3b7..c606b728 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -416,7 +416,8 @@ bool PluginsManager::getShortcutByCmdID(int cmdID, ShortcutKey *sk) // returns false if cmdID not provided, true otherwise bool PluginsManager::removeShortcutByCmdID(int cmdID) { - if (cmdID == 0) { return false; } + if (cmdID == 0) + return false; NppParameters& nppParam = NppParameters::getInstance(); vector & pluginCmdSCList = nppParam.getPluginCommandList(); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 0c441762..b5b5bad0 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1068,7 +1068,8 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const } -bool Notepad_plus::replaceInOpenedFiles() { +bool Notepad_plus::replaceInOpenedFiles() +{ ScintillaEditView *pOldView = _pEditView; _pEditView = &_invisibleEditView; @@ -2995,11 +2996,14 @@ LangType Notepad_plus::menuID2LangType(int cmdID) return L_VISUALPROLOG; case IDM_LANG_USER : return L_USER; - default: { - if (cmdID >= IDM_LANG_USER && cmdID <= IDM_LANG_USER_LIMIT) { + default: + { + if (cmdID >= IDM_LANG_USER && cmdID <= IDM_LANG_USER_LIMIT) + { return L_USER; } - break; } + break; + } } return L_EXTERNAL; } @@ -3372,17 +3376,23 @@ void Notepad_plus::showView(int whichOne) if (viewVisible(whichOne)) //no use making visible view visible return; - if (_mainWindowStatus & WindowUserActive) { + if (_mainWindowStatus & WindowUserActive) + { _pMainSplitter->setWin0(&_subSplitter); _pMainWindow = _pMainSplitter; - } else { + } + else + { _pMainWindow = &_subSplitter; } - if (whichOne == MAIN_VIEW) { + if (whichOne == MAIN_VIEW) + { _mainEditView.display(true); _mainDocTab.display(true); - } else if (whichOne == SUB_VIEW) { + } + else if (whichOne == SUB_VIEW) + { _subEditView.display(true); _subDocTab.display(true); } @@ -3394,7 +3404,8 @@ void Notepad_plus::showView(int whichOne) ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); } -bool Notepad_plus::viewVisible(int whichOne) { +bool Notepad_plus::viewVisible(int whichOne) +{ int viewToCheck = (whichOne == SUB_VIEW?WindowSubActive:WindowMainActive); return (_mainWindowStatus & viewToCheck) != 0; } @@ -3422,10 +3433,13 @@ void Notepad_plus::hideView(int whichOne) _subSplitter.display(false); //hide splitter //hide scintilla and doctab - if (whichOne == MAIN_VIEW) { + if (whichOne == MAIN_VIEW) + { _mainEditView.display(false); _mainDocTab.display(false); - } else if (whichOne == SUB_VIEW) { + } + else if (whichOne == SUB_VIEW) + { _subEditView.display(false); _subDocTab.display(false); } @@ -3566,10 +3580,13 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne) int Notepad_plus::switchEditViewTo(int gid) { - if (currentView() == gid) { //make sure focus is ok, then leave + if (currentView() == gid) + { + //make sure focus is ok, then leave _pEditView->getFocus(); //set the focus return gid; } + if (!viewVisible(gid)) return currentView(); //cannot activate invisible view @@ -3658,13 +3675,16 @@ void Notepad_plus::docOpenInNewInstance(FileTransferMode mode, int x, int y) command += TEXT("\""); command += TEXT(" \"$(FULL_CURRENT_PATH)\" -multiInst -nosession"); - if (x) { + if (x) + { TCHAR pX[10]; generic_itoa(x, pX, 10); command += TEXT(" -x"); command += pX; } - if (y) { + + if (y) + { TCHAR pY[10]; generic_itoa(y, pY, 10); command += TEXT(" -y"); @@ -3826,15 +3846,19 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne) return true; } -void Notepad_plus::performPostReload(int whichOne) { +void Notepad_plus::performPostReload(int whichOne) +{ NppParameters& nppParam = NppParameters::getInstance(); const NppGUI & nppGUI = nppParam.getNppGUI(); bool toEnd = (nppGUI._fileAutoDetection & cdGo2end) ? true : false; if (!toEnd) return; - if (whichOne == MAIN_VIEW) { + if (whichOne == MAIN_VIEW) + { _mainEditView.execute(SCI_GOTOLINE, _mainEditView.execute(SCI_GETLINECOUNT) -1); - } else { + } + else + { _subEditView.execute(SCI_GOTOLINE, _subEditView.execute(SCI_GETLINECOUNT) -1); } } @@ -4336,7 +4360,8 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode) _pEditView->execute(SCI_ENDUNDOACTION); // undoStreamComment: If there were no block-comments to un-comment try uncommenting of stream-comment. - if ((currCommentMode == cm_uncomment) && (nUncomments == 0)) { + if ((currCommentMode == cm_uncomment) && (nUncomments == 0)) + { return undoStreamComment(false); } return true; @@ -4384,7 +4409,8 @@ bool Notepad_plus::doStreamComment() } // BlockToStreamComment: If there is no stream-comment symbol, try the block comment: - if ((!commentStart) || (!commentStart[0]) || (commentStart == NULL) || (!commentEnd) || (!commentEnd[0]) || (commentEnd == NULL)) { + if ((!commentStart) || (!commentStart[0]) || (commentStart == NULL) || (!commentEnd) || (!commentEnd[0]) || (commentEnd == NULL)) + { if (!(!commentLineSymbol || !commentLineSymbol[0] || commentLineSymbol == NULL)) return doBlockComment(cm_comment); else @@ -4695,7 +4721,9 @@ void Notepad_plus::fullScreenToggle() if (!_beforeSpecialView.isPostIt) { _beforeSpecialView.preStyle = ::SetWindowLongPtr(_pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP); - if (!_beforeSpecialView.preStyle) { //something went wrong, use default settings + if (!_beforeSpecialView.preStyle) + { + //something went wrong, use default settings _beforeSpecialView.preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; } } @@ -4830,7 +4858,9 @@ void Notepad_plus::postItToggle() //Hide window so windows can properly update it ::ShowWindow(_pPublicInterface->getHSelf(), SW_HIDE); _beforeSpecialView.preStyle = ::SetWindowLongPtr( _pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP ); - if (!_beforeSpecialView.preStyle) { //something went wrong, use default settings + if (!_beforeSpecialView.preStyle) + { + //something went wrong, use default settings _beforeSpecialView.preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; } //Redraw the window and refresh windowmanager cache, dont do anything else, sizing is done later on @@ -5066,7 +5096,8 @@ bool Notepad_plus::emergency(const generic_string& emergencySavedDir) return dumpFiles(emergencySavedDir.c_str(), TEXT("File")); } -bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) { +bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) +{ //start dumping unsaved files to recovery directory bool somethingsaved = false; bool somedirty = false; @@ -6845,7 +6876,8 @@ bool Notepad_plus::undoStreamComment(bool tryBlockComment) // BlockToStreamComment: If there is no stream-comment symbol and we came not from doBlockComment, try the block comment: - if ((!commentStart) || (!commentStart[0]) || (commentStart == NULL) || (!commentEnd) || (!commentEnd[0]) || (commentEnd == NULL)) { + if ((!commentStart) || (!commentStart[0]) || (commentStart == NULL) || (!commentEnd) || (!commentEnd[0]) || (commentEnd == NULL)) + { if (!(!commentLineSymbol || !commentLineSymbol[0] || commentLineSymbol == NULL) && tryBlockComment) return doBlockComment(cm_uncomment); else diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 9aa3dd0a..fe82e693 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -302,7 +302,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return FALSE; BufferID id = (BufferID)wParam; Buffer * b = MainFileManager.getBufferByID(id); - if (b && b->getStatus() == DOC_UNNAMED) { + if (b && b->getStatus() == DOC_UNNAMED) + { b->setFileName(reinterpret_cast(lParam)); return TRUE; } @@ -607,7 +608,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa switchEditViewTo(MAIN_VIEW); else if (hSec == hFocus) switchEditViewTo(SUB_VIEW); - else { + else + { //Other Scintilla, ignore } return TRUE; diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index a18811b0..4b9fa6f8 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1747,13 +1747,16 @@ void Notepad_plus::fileOpen() if (stringVector *pfns = fDlg.doOpenMultiFilesDlg()) { size_t sz = pfns->size(); - for (size_t i = 0 ; i < sz ; ++i) { + for (size_t i = 0 ; i < sz ; ++i) + { BufferID test = doOpen(pfns->at(i).c_str(), fDlg.isReadOnly()); if (test != BUFFER_INVALID) lastOpened = test; } } - if (lastOpened != BUFFER_INVALID) { + + if (lastOpened != BUFFER_INVALID) + { switchToFile(lastOpened); } } @@ -1776,7 +1779,8 @@ bool Notepad_plus::fileReload() } -bool Notepad_plus::isFileSession(const TCHAR * filename) { +bool Notepad_plus::isFileSession(const TCHAR * filename) +{ // if file2open matches the ext of user defined session file ext, then it'll be opened as a session const TCHAR *definedSessionExt = NppParameters::getInstance().getNppGUI()._definedSessionExt.c_str(); if (*definedSessionExt != '\0') @@ -1950,7 +1954,8 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode) { const TCHAR *pFn = session._subViewFiles[k]._fileName.c_str(); - if (isFileSession(pFn) || isFileWorkspace(pFn)) { + if (isFileSession(pFn) || isFileWorkspace(pFn)) + { vector::iterator posIt = session._subViewFiles.begin() + k; session._subViewFiles.erase(posIt); continue; //skip session files, not supporting recursive sessions or embedded workspace files @@ -1970,7 +1975,8 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode) lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding); //check if already open in main. If so, clone - if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) { + if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) + { loadBufferIntoView(lastOpened, SUB_VIEW); } } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 6ea729ca..79c3610b 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1790,8 +1790,8 @@ void NppParameters::initMenuKeys() } } -void NppParameters::initScintillaKeys() { - +void NppParameters::initScintillaKeys() +{ int nbCommands = sizeof(scintKeyDefs)/sizeof(ScintillaKeyDefinition); //Warning! Matching function have to be consecutive @@ -6139,7 +6139,8 @@ TiXmlElement * NppParameters::insertGUIConfigBoolNode(TiXmlNode *r2w, const TCHA return GUIConfigElement; } -int RGB2int(COLORREF color) { +int RGB2int(COLORREF color) +{ return (((((DWORD)color) & 0x0000FF) << 16) | ((((DWORD)color) & 0x00FF00)) | ((((DWORD)color) & 0xFF0000) >> 16)); } diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp index 1b757a15..c20d1505 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp @@ -105,7 +105,8 @@ bool AutoCompletion::showApiAndWordComplete() wordArray.push_back(_keyWordArray[i]); canStop = true; } - else if (canStop) { + else if (canStop) + { // Early out since no more strings will match break; } @@ -754,18 +755,23 @@ void AutoCompletion::update(int character) } } -void AutoCompletion::callTipClick(size_t direction) { +void AutoCompletion::callTipClick(size_t direction) +{ if (!_funcCompletionActive) return; - if (direction == 1) { + if (direction == 1) + { _funcCalltip.showPrevOverload(); - } else if (direction == 2) { + } + else if (direction == 2) + { _funcCalltip.showNextOverload(); } } -bool AutoCompletion::setLanguage(LangType language) { +bool AutoCompletion::setLanguage(LangType language) +{ if (_curLang == language) return true; _curLang = language; @@ -783,7 +789,8 @@ bool AutoCompletion::setLanguage(LangType language) { _funcCompletionActive = _pXmlFile->LoadFile(); TiXmlNode * pAutoNode = NULL; - if (_funcCompletionActive) { + if (_funcCompletionActive) + { _funcCompletionActive = false; //safety TiXmlNode * pNode = _pXmlFile->FirstChild(TEXT("NotepadPlus")); if (!pNode) @@ -816,7 +823,8 @@ bool AutoCompletion::setLanguage(LangType language) { { const TCHAR * val = 0; val = pElem->Attribute(TEXT("ignoreCase")); - if (val && !lstrcmp(val, TEXT("no"))) { + if (val && !lstrcmp(val, TEXT("no"))) + { _ignoreCase = false; _funcCalltip._ignoreCase = false; } @@ -838,9 +846,12 @@ bool AutoCompletion::setLanguage(LangType language) { } } - if (_funcCompletionActive) { + if (_funcCompletionActive) + { _funcCalltip.setLanguageXML(_pXmlKeyword); - } else { + } + else + { _funcCalltip.setLanguageXML(NULL); } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 21111104..476347c6 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1553,7 +1553,8 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op TCHAR *pText = new TCHAR[stringSizeFind + 1]; wcscpy_s(pText, stringSizeFind + 1, txt2find); - if (pOptions->_searchType == FindExtended) { + if (pOptions->_searchType == FindExtended) + { stringSizeFind = Searching::convertExtendedToString(txt2find, pText, stringSizeFind); } @@ -1982,7 +1983,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl if (op == ProcessMarkAll && colourStyleID == -1) //if marking, check if purging is needed { - if (_env->_doPurge) { + if (_env->_doPurge) + { clearMarks(*_env); } } @@ -2006,7 +2008,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl targetEnd = int(pEditView->execute(SCI_GETTARGETEND)); - if (targetEnd > findReplaceInfo._endRange) { //we found a result but outside our range, therefore do not process it + if (targetEnd > findReplaceInfo._endRange) + { + //we found a result but outside our range, therefore do not process it break; } @@ -2402,7 +2406,8 @@ bool FindReplaceDlg::removeFinder(Finder *finder2remove) return false; } -void FindReplaceDlg::setSearchText(TCHAR * txt2find) { +void FindReplaceDlg::setSearchText(TCHAR * txt2find) +{ HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); if (txt2find && txt2find[0]) { @@ -2584,7 +2589,8 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus } else if (staus == FSTopReached || staus == FSEndReached) { - if (!isVisible()) { + if (!isVisible()) + { FLASHWINFO flashInfo; flashInfo.cbSize = sizeof(FLASHWINFO); flashInfo.hwnd = GetParent(_hSelf); diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp index 10a64d10..47684be4 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp @@ -61,7 +61,8 @@ inline bool match(TCHAR c1, TCHAR c2) { //0 if equal, <0 of before, >0 if after (name1 that is) int testNameNoCase(const TCHAR * name1, const TCHAR * name2, int len = -1) { - if (len == -1) { + if (len == -1) + { len = 1024; //magic value, but it probably fails way before it reaches this } int i = 0; @@ -344,7 +345,8 @@ bool FunctionCallTip::loadFunction() TiXmlElement *overloadNode = _curFunction->FirstChildElement(TEXT("Overload")); TiXmlElement *paramNode = NULL; - for (; overloadNode ; overloadNode = overloadNode->NextSiblingElement(TEXT("Overload")) ) { + for (; overloadNode ; overloadNode = overloadNode->NextSiblingElement(TEXT("Overload")) ) + { const TCHAR * retVal = overloadNode->Attribute(TEXT("retVal")); if (!retVal) continue; //malformed node @@ -357,7 +359,8 @@ bool FunctionCallTip::loadFunction() _descriptions.push_back(TEXT("")); //"no description available" paramNode = overloadNode->FirstChildElement(TEXT("Param")); - for (; paramNode ; paramNode = paramNode->NextSiblingElement(TEXT("Param")) ) { + for (; paramNode ; paramNode = paramNode->NextSiblingElement(TEXT("Param")) ) + { const TCHAR * param = paramNode->Attribute(TEXT("name")); if (!param) continue; //malformed node @@ -445,7 +448,8 @@ void FunctionCallTip::showCalltip() } } -void FunctionCallTip::reset() { +void FunctionCallTip::reset() +{ _currentOverload = 0; _currentParam = 0; //_curPos = 0; @@ -456,7 +460,8 @@ void FunctionCallTip::reset() { _descriptions.clear(); } -void FunctionCallTip::cleanup() { +void FunctionCallTip::cleanup() +{ reset(); delete [] _funcName; _funcName = 0; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index a4d970cd..b879566d 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -396,7 +396,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa return TRUE; } - if (LOWORD(wParam) & MK_SHIFT) { + if (LOWORD(wParam) & MK_SHIFT) + { // move 3 columns at a time ::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, ((short)HIWORD(wParam) < 0) ? SB_LINERIGHT : SB_LINELEFT, NULL); ::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, ((short)HIWORD(wParam) < 0) ? SB_LINERIGHT : SB_LINELEFT, NULL); @@ -1895,13 +1896,15 @@ void ScintillaEditView::restoreCurrentPosPostStep() } } -void ScintillaEditView::restyleBuffer() { +void ScintillaEditView::restyleBuffer() +{ execute(SCI_CLEARDOCUMENTSTYLE); execute(SCI_COLOURISE, 0, -1); _currentBuffer->setNeedsLexing(false); } -void ScintillaEditView::styleChange() { +void ScintillaEditView::styleChange() +{ defineDocType(_currentBuffer->getLangType()); restyleBuffer(); } @@ -2641,23 +2644,31 @@ void ScintillaEditView::setLineIndent(int line, int indent) const execute(SCI_SETLINEINDENTATION, line, indent); int32_t posAfter = static_cast(execute(SCI_GETLINEINDENTPOSITION, line)); int posDifference = posAfter - posBefore; - if (posAfter > posBefore) { + if (posAfter > posBefore) + { // Move selection on - if (crange.cpMin >= posBefore) { + if (crange.cpMin >= posBefore) + { crange.cpMin += posDifference; } - if (crange.cpMax >= posBefore) { + if (crange.cpMax >= posBefore) + { crange.cpMax += posDifference; } - } else if (posAfter < posBefore) { + } + else if (posAfter < posBefore) + { // Move selection back - if (crange.cpMin >= posAfter) { + if (crange.cpMin >= posAfter) + { if (crange.cpMin >= posBefore) crange.cpMin += posDifference; else crange.cpMin = posAfter; } - if (crange.cpMax >= posAfter) { + + if (crange.cpMax >= posAfter) + { if (crange.cpMax >= posBefore) crange.cpMax += posDifference; else @@ -2974,7 +2985,8 @@ pair ScintillaEditView::getWordRange() bool ScintillaEditView::expandWordSelection() { pair wordRange = getWordRange(); - if (wordRange.first != wordRange.second) { + if (wordRange.first != wordRange.second) + { execute(SCI_SETSELECTIONSTART, wordRange.first); execute(SCI_SETSELECTIONEND, wordRange.second); return true; @@ -3316,7 +3328,9 @@ void ScintillaEditView::hideLines() execute(SCI_MARKERDELETE, i, MARK_HIDELINESEND); if (scope > 0) scope--; } - if (openPresent) { + + if (openPresent) + { execute(SCI_MARKERDELETE, i, MARK_HIDELINESBEGIN); execute(SCI_MARKERDELETE, i, MARK_HIDELINESUNDERLINE); ++scope; @@ -3364,11 +3378,13 @@ bool ScintillaEditView::markerMarginClick(int lineNumber) return true; } -void ScintillaEditView::notifyMarkers(Buffer * buf, bool isHide, int location, bool del) { +void ScintillaEditView::notifyMarkers(Buffer * buf, bool isHide, int location, bool del) +{ if (buf != _currentBuffer) //if not visible buffer dont do a thing return; runMarkers(isHide, location, false, del); } + //Run through full document. When switching in or opening folding //hide is false only when user click on margin void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDoc, bool doDelete) diff --git a/PowerEditor/src/UniConversion.cpp b/PowerEditor/src/UniConversion.cpp index bff612c6..66b9f71b 100644 --- a/PowerEditor/src/UniConversion.cpp +++ b/PowerEditor/src/UniConversion.cpp @@ -8,9 +8,11 @@ #include #include "UniConversion.h" -unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) { +unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) +{ unsigned int len = 0; - for (unsigned int i = 0; i < tlen && uptr[i]; ++i) { + for (unsigned int i = 0; i < tlen && uptr[i]; ++i) + { unsigned int uch = uptr[i]; if (uch < 0x80) ++len; @@ -22,16 +24,23 @@ unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) { return len; } -void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) { +void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) +{ int k = 0; - for (unsigned int i = 0; i < tlen && uptr[i]; ++i) { + for (unsigned int i = 0; i < tlen && uptr[i]; ++i) + { unsigned int uch = uptr[i]; - if (uch < 0x80) { + if (uch < 0x80) + { putf[k++] = static_cast(uch); - } else if (uch < 0x800) { + } + else if (uch < 0x800) + { putf[k++] = static_cast(0xC0 | (uch >> 6)); putf[k++] = static_cast(0x80 | (uch & 0x3f)); - } else { + } + else + { putf[k++] = static_cast(0xE0 | (uch >> 12)); putf[k++] = static_cast(0x80 | ((uch >> 6) & 0x3f)); putf[k++] = static_cast(0x80 | (uch & 0x3f)); @@ -40,9 +49,11 @@ void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned i putf[len] = '\0'; } -unsigned int UCS2Length(const char *s, unsigned int len) { +unsigned int UCS2Length(const char *s, unsigned int len) +{ unsigned int ulen = 0; - for (unsigned int i=0; i(s[i]); if ((ch < 0x80) || (ch > (0x80 + 0x40))) ++ulen; @@ -55,15 +66,21 @@ unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsign unsigned int ui=0; const UCHAR *us = reinterpret_cast(s); unsigned int i=0; - while ((i((ch & 0x1F) << 6); ch = us[i++]; tbuf[ui] = static_cast(tbuf[ui] + (ch & 0x7F)); - } else { + } + else + { tbuf[ui] = static_cast((ch & 0xF) << 12); ch = us[i++]; tbuf[ui] = static_cast(tbuf[ui] + ((ch & 0x7F) << 6)); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index fa1e133a..c4cda47f 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -463,10 +463,13 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) // begin with paint ::SetBkMode(hDc, TRANSPARENT); - if (_isActive == TRUE) { + if (_isActive == TRUE) + { bgbrush = ::CreateSolidBrush(::GetSysColor(COLOR_ACTIVECAPTION)); ::SetTextColor(hDc, ::GetSysColor(COLOR_CAPTIONTEXT)); - } else { + } + else + { bgbrush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE)); } diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index 824abea5..845fbd79 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -247,7 +247,8 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l case WM_DESTROY: { // unregister window event hooking BEFORE EVERYTHING ELSE - if (hWndServer == hwnd) { + if (hWndServer == hwnd) + { UnhookWindowsHookEx(gWinCallHook); gWinCallHook = NULL; hWndServer = NULL; diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index 05459cb8..3cecf5cf 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -98,7 +98,8 @@ generic_string ShortcutMapper::getTabString(size_t i) const } -void ShortcutMapper::initBabyGrid() { +void ShortcutMapper::initBabyGrid() +{ RECT rect; getClientRect(rect); @@ -153,7 +154,8 @@ bool ShortcutMapper::isFilterValid(Shortcut sc) { bool match = false; generic_string shortcut_name = stringToLower(generic_string(sc.getName())); - if (_shortcutFilter.empty()) { + if (_shortcutFilter.empty()) + { return true; } // test the filter on the shortcut name diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 4887cbfa..b9179f76 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -348,7 +348,9 @@ static LRESULT CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPAR }; -static TCHAR * get1stExt(TCHAR *ext) { // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt) +static TCHAR * get1stExt(TCHAR *ext) +{ + // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt) TCHAR *begin = ext; for ( ; *begin != '.' ; begin++); TCHAR *end = ++begin; @@ -359,7 +361,8 @@ static TCHAR * get1stExt(TCHAR *ext) { // precondition : ext should be under the return begin; }; -static generic_string addExt(HWND textCtrl, HWND typeCtrl) { +static generic_string addExt(HWND textCtrl, HWND typeCtrl) +{ TCHAR fn[MAX_PATH]; ::GetWindowText(textCtrl, fn, MAX_PATH); diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp index 83c47036..c2442b40 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp @@ -447,12 +447,15 @@ bool ReBar::addBand(REBARBANDINFO * rBand, bool useID) } else rBand->fStyle = RBBS_GRIPPERALWAYS; + rBand->fMask |= RBBIM_ID | RBBIM_STYLE; - if (useID) { + if (useID) + { if (isIDTaken(rBand->wID)) return false; - - } else { + } + else + { rBand->wID = getNewID(); } ::SendMessage(_hSelf, RB_INSERTBAND, static_cast(-1), reinterpret_cast(rBand)); //add to end of list diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinRect.cpp b/PowerEditor/src/WinControls/WindowsDlg/WinRect.cpp index 3dcb68f0..097bdd6e 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinRect.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WinRect.cpp @@ -28,9 +28,11 @@ WINRECT::WINRECT(WORD f, int id, LONG p) WINRECT* WINRECT::Parent() { WINRECT* pEntry = NULL; - for (pEntry=this; pEntry->Prev(); pEntry=pEntry->Prev()) { - ; // go backwards to the end + for (pEntry=this; pEntry->Prev(); pEntry=pEntry->Prev()) + { + // go backwards to the end } + // the entry before the first child is the group WINRECT *parent = pEntry-1; assert(parent->IsGroup()); @@ -42,7 +44,8 @@ WINRECT* WINRECT::Parent() // BOOL WINRECT::GetMargins(int& w, int& h) { - if (IsGroup()) { + if (IsGroup()) + { w=(short)LOWORD(param); h=(short)HIWORD(param); return TRUE; @@ -62,13 +65,15 @@ WINRECT* WINRECT::InitMap(WINRECT* pWinMap, WINRECT* parent) WINRECT* pwrc = pWinMap; // current table entry WINRECT* prev = NULL; // previous entry starts out none - while (!pwrc->IsEndGroup()) { + while (!pwrc->IsEndGroup()) + { pwrc->prev=prev; pwrc->next=NULL; if (prev) prev->next = pwrc; prev = pwrc; - if (pwrc->IsGroup()) { + if (pwrc->IsGroup()) + { pwrc = InitMap(pwrc+1,pwrc); // recurse! Returns end-of-grp assert(pwrc->IsEndGroup()); } diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index c3a307cc..ae01a669 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -55,6 +55,7 @@ const UINT WDN_NOTIFY = RegisterWindowMessage(TEXT("WDN_NOTIFY")); inline static DWORD GetStyle(HWND hWnd) { return (DWORD)GetWindowLongPtr(hWnd, GWL_STYLE); } + inline static DWORD GetExStyle(HWND hWnd) { return (DWORD)GetWindowLongPtr(hWnd, GWL_EXSTYLE); } @@ -705,7 +706,8 @@ void WindowsDlg::doSave() nmdlg.code = WDN_NOTIFY; nmdlg.nItems = ListView_GetSelectedCount(_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_SELECTED); if (i == -1) break; nmdlg.Items[j] = _idxMap[i]; @@ -723,7 +725,6 @@ void WindowsDlg::destroy() HWND hSelf = _hSelf; _hSelf = NULL; ::DestroyWindow(hSelf); - } void WindowsDlg::activateCurrent() diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index a9ff68db..ef6b98e9 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -440,10 +440,13 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) return TRUE; case IDOK : - if (!isEnabled()) { + if (!isEnabled()) + { _keyCombo._isCtrl = _keyCombo._isAlt = _keyCombo._isShift = false; } - if (_canModifyName) { + + if (_canModifyName) + { TCHAR editName[nameLenMax]; ::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXT, nameLenMax, reinterpret_cast(editName)); setName(editName); @@ -645,8 +648,10 @@ void Accelerator::updateMenuItemByCommand(const CommandShortcut& csc) recordedMacroStep::recordedMacroStep(int iMessage, uptr_t wParam, uptr_t lParam, int codepage) : _message(iMessage), _wParameter(wParam), _lParameter(lParam), _macroType(mtUseLParameter) { - if (_lParameter) { - switch (_message) { + if (_lParameter) + { + switch (_message) + { case SCI_SETTEXT : case SCI_REPLACESEL : case SCI_REPLACETARGET : @@ -971,7 +976,8 @@ void ScintillaKeyMap::validateDialog() updateConflictState(); } -void ScintillaKeyMap::showCurrentSettings() { +void ScintillaKeyMap::showCurrentSettings() +{ auto keyIndex = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0); _keyCombo = _keyCombos[keyIndex]; ::SendDlgItemMessage(_hSelf, IDC_CTRL_CHECK, BM_SETCHECK, _keyCombo._isCtrl?BST_CHECKED:BST_UNCHECKED, 0); @@ -987,7 +993,8 @@ void ScintillaKeyMap::showCurrentSettings() { } } -void ScintillaKeyMap::updateListItem(int index) { +void ScintillaKeyMap::updateListItem(int index) +{ ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, index, reinterpret_cast(toString(index).c_str())); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, index+1, 0); } @@ -1129,7 +1136,8 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA //return FALSE; } -CommandShortcut::CommandShortcut(const Shortcut& sc, long id) : Shortcut(sc), _id(id) { +CommandShortcut::CommandShortcut(const Shortcut& sc, long id) : Shortcut(sc), _id(id) +{ if ( _id < IDM_EDIT) _category = TEXT("File"); else if ( _id < IDM_SEARCH) diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index 2bfccb3d..56eb3ad9 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -174,14 +174,19 @@ void LastRecentFileList::add(const TCHAR *fn) RecentItem itemToAdd(fn); int index = find(fn); - if (index != -1) { //already in list, bump upwards + if (index != -1) + { + //already in list, bump upwards remove(index); } - if (_size == _userMax) { + if (_size == _userMax) + { itemToAdd._id = _lrfl.back()._id; _lrfl.pop_back(); //remove oldest - } else { + } + else + { itemToAdd._id = popFirstAvailableID(); ++_size; } diff --git a/PowerEditor/src/uchardet/CharDistribution.cpp b/PowerEditor/src/uchardet/CharDistribution.cpp index 488d9bc3..2ccda334 100644 --- a/PowerEditor/src/uchardet/CharDistribution.cpp +++ b/PowerEditor/src/uchardet/CharDistribution.cpp @@ -55,7 +55,8 @@ float CharDistributionAnalysis::GetConfidence(void) if (mTotalChars <= 0 || mFreqChars <= mDataThreshold) return SURE_NO; - if (mTotalChars != mFreqChars) { + if (mTotalChars != mFreqChars) + { float r = mFreqChars / ((mTotalChars - mFreqChars) * mTypicalDistributionRatio); if (r < SURE_YES) diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index d9bdc738..3ef7bb77 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -146,7 +146,8 @@ bool getParamVal(TCHAR c, ParamVector & params, generic_string & value) for (size_t i = 0; i < nbItems; ++i) { const TCHAR * token = params.at(i).c_str(); - 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 + { value = (token+2); params.erase(params.begin() + i); return true; @@ -191,7 +192,8 @@ generic_string getLocalizationPathFromParam(ParamVector & params) return NppParameters::getLocPathFromStr(locStr.c_str()); } -int getNumberFromParam(char paramName, ParamVector & params, bool & isParamePresent) { +int getNumberFromParam(char paramName, ParamVector & params, bool & isParamePresent) +{ generic_string numStr; if (!getParamVal(paramName, params, numStr)) {