From d6f66b1d732c12a174e574ecbf4c5ba40341f6bd Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 27 Feb 2012 01:05:24 +0000 Subject: [PATCH] [ENHANCEMENT] Enhance the source code. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@873 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 5 +++-- PowerEditor/src/NppBigSwitch.cpp | 5 +++-- PowerEditor/src/Parameters.h | 2 +- PowerEditor/src/ScitillaComponent/Printer.cpp | 4 ++-- .../src/ScitillaComponent/UserDefineDialog.cpp | 2 +- .../src/WinControls/ColourPicker/WordStyleDlg.cpp | 2 +- PowerEditor/src/WinControls/DockingWnd/Gripper.cpp | 8 -------- .../src/WinControls/Preference/preferenceDlg.cpp | 4 ++-- .../src/WinControls/ProjectPanel/TreeView.cpp | 2 +- PowerEditor/src/WinControls/TabBar/TabBar.cpp | 14 +++++--------- PowerEditor/src/WinControls/shortcut/shortcut.cpp | 4 ++-- 11 files changed, 21 insertions(+), 31 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index b7fd471c..edf186d4 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -850,6 +850,7 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const } NppParameters *pNppParamInst = NppParameters::getInstance(); LangType langT = pNppParamInst->getLangFromExt(ext); + if (langT != L_XML && langT != L_HTML && langT == L_PHP) return -1; @@ -4964,7 +4965,7 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params) char charToShow[2] = {text2display[i], '\0'}; - if (text2display[i] == ' ' && text2display[i] == '.') + if (text2display[i] == ' ' || text2display[i] == '.') Sleep(ranNum + pauseTimeArray[ranNum%nbPauseTime]); else Sleep(ranNum + intervalTimeArray[ranNum%nbIntervalTime]); @@ -5029,7 +5030,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params) { char charToShow[2] = {text2display[i], '\0'}; int ranNum = getRandomNumber(maxRange); - if (text2display[i] == ' ' && text2display[i] == '.') + if (text2display[i] == ' ' || text2display[i] == '.') Sleep(ranNum + pauseTimeArray[ranNum%nbPauseTime]); else Sleep(ranNum + intervalTimeArray[ranNum%nbIntervalTime]); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 0e2d709c..f843a4dc 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -945,9 +945,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa auxVerStr[k] = '\0'; int mainVer = 0, auxVer = 0; - if (mainVerStr) + if (mainVerStr[0]) mainVer = generic_atoi(mainVerStr); - if (auxVerStr) + + if (auxVerStr[0]) auxVer = generic_atoi(auxVerStr); return MAKELONG(auxVer, mainVer); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index a4a63099..f1f64878 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -163,7 +163,7 @@ struct CmdLineParams { bool _isPointXValid; bool _isPointYValid; bool isPointValid() { - return _isPointXValid && _isPointXValid; + return _isPointXValid && _isPointYValid; }; LangType _langType; diff --git a/PowerEditor/src/ScitillaComponent/Printer.cpp b/PowerEditor/src/ScitillaComponent/Printer.cpp index 5a96a1a6..5d920f19 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.cpp +++ b/PowerEditor/src/ScitillaComponent/Printer.cpp @@ -377,7 +377,7 @@ size_t Printer::doPrint(bool justDoIt) } // Middle part - if (headerM != '\0') + if (headerM[0] != '\0') { generic_string headerMiddle(headerM); size_t pos = headerMiddle.find(pageVar); @@ -389,7 +389,7 @@ size_t Printer::doPrint(bool justDoIt) ETO_CLIPPED, &rcw, headerMiddle.c_str(), static_cast(headerMiddle.length()), NULL); } // Right part - if (headerR != '\0') + if (headerR[0] != '\0') { generic_string headerRight(headerR); size_t pos = headerRight.find(pageVar); diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 0e5ff2ac..ac52484b 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -219,7 +219,7 @@ BOOL CALLBACK SharedParametersDialog::run_dlgProc(UINT Message, WPARAM wParam, L if (i != 0) { ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETLBTEXT, i, (LPARAM)intStr); - if ((!intStr) || (!intStr[0])) + if (!intStr[0]) style._fontSize = -1; else { diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 4611839f..ee77512e 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -536,7 +536,7 @@ void WordStyleDlg::updateFontSize() if (iFontSizeSel != 0) { ::SendMessage(_hFontSizeCombo, CB_GETLBTEXT, iFontSizeSel, (LPARAM)intStr); - if ((!intStr) || (!intStr[0])) + if (!intStr[0]) style._fontSize = -1; else { diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp index 21fad534..4da948fc 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp @@ -480,14 +480,6 @@ void Gripper::doTabReordering(POINT pt) /* delete item on switch between tabs */ ::SendMessage(_hTab, TCM_DELETEITEM, iItemOld, 0); } - else - { - if (_hTab == hTabOld) - { - /* delete item on switch between tabs */ - ::SendMessage(_hTab, TCM_DELETEITEM, iItemOld, 0); - } - } } else if (inTab == FALSE) { diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 0d0b5274..3c9d4357 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -979,7 +979,7 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) int selIndex = -1; generic_string str; EncodingMapper *em = EncodingMapper::getInstance(); - for (int i = 0 ; i <= sizeof(encodings)/sizeof(int) ; i++) + for (int i = 0 ; i < sizeof(encodings)/sizeof(int) ; i++) { int cmdID = em->getIndexFromEncoding(encodings[i]); if (cmdID != -1) @@ -1868,7 +1868,7 @@ BOOL CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) int *pVal = (LOWORD(wParam) == IDC_COMBO_HFONTSIZE)?&(nppGUI._printSettings._headerFontSize):&(nppGUI._printSettings._footerFontSize); - if ((!intStr) || (!intStr[0])) + if (!intStr[0]) *pVal = 0; else *pVal = generic_strtol(intStr, NULL, 10); diff --git a/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp b/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp index a8442cc5..7bf31f5c 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp @@ -85,7 +85,7 @@ HTREEITEM TreeView::addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iI // Set the item label. tvi.pszText = (LPTSTR)itemName; - tvi.cchTextMax = sizeof(tvi.pszText)/sizeof(tvi.pszText[0]); + tvi.cchTextMax = MAX_PATH; // Set icon tvi.iImage = iImage;//isNode?INDEX_CLOSED_NODE:INDEX_LEAF; diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 1c3e324a..eb65d140 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -797,19 +797,18 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct) { rect.bottom -= 2; rect.left += ::GetSystemMetrics(SM_CXEDGE) + 4; - rect.top += (_drawTabCloseButton)?spaceUnit:0; + rect.top += (_drawTabCloseButton)?spaceUnit:0; + + Flags |= DT_BOTTOM; } else { rect.top -= ::GetSystemMetrics(SM_CYEDGE); rect.top += 3; rect.left += _drawTabCloseButton?spaceUnit:0; - } - if (!_isVertical) Flags |= DT_VCENTER; - else - Flags |= DT_BOTTOM; + } } else { @@ -825,10 +824,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct) rect.left += (_drawTabCloseButton)?spaceUnit:0; } - if (!_isVertical) - Flags |= DT_BOTTOM; - else - Flags |= DT_BOTTOM; + Flags |= DT_BOTTOM; } ::DrawText(hDC, label, lstrlen(label), &rect, Flags); ::RestoreDC(hDC, nSavedDC); diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 78bb4d14..4c97c700 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -714,8 +714,8 @@ void ScintillaKeyMap::validateDialog() { } void ScintillaKeyMap::showCurrentSettings() { - int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0); - _keyCombo = _keyCombos[i]; + int 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); ::SendDlgItemMessage(_hSelf, IDC_ALT_CHECK, BM_SETCHECK, _keyCombo._isAlt?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_SHIFT_CHECK, BM_SETCHECK, _keyCombo._isShift?BST_CHECKED:BST_UNCHECKED, 0);