[ENHANCEMENT] Enhance the source code.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@873 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2012-02-27 01:05:24 +00:00
parent f08c29f2b5
commit d6f66b1d73
11 changed files with 21 additions and 31 deletions

View File

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

View File

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

View File

@ -163,7 +163,7 @@ struct CmdLineParams {
bool _isPointXValid;
bool _isPointYValid;
bool isPointValid() {
return _isPointXValid && _isPointXValid;
return _isPointXValid && _isPointYValid;
};
LangType _langType;

View File

@ -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<int>(headerMiddle.length()), NULL);
}
// Right part
if (headerR != '\0')
if (headerR[0] != '\0')
{
generic_string headerRight(headerR);
size_t pos = headerRight.find(pageVar);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -798,18 +798,17 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
rect.bottom -= 2;
rect.left += ::GetSystemMetrics(SM_CXEDGE) + 4;
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);

View File

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