mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-17 21:03:19 +08:00
+ cln: minor code cleanup
This commit is contained in:
parent
ab7b413968
commit
b1face37e4
10
src/Edit.c
10
src/Edit.c
@ -7274,10 +7274,12 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
|
||||
|
||||
if (dwId >= 200 && dwId <= 205) {
|
||||
SetBkMode(hdc,TRANSPARENT);
|
||||
if (GetSysColorBrush(COLOR_HOTLIGHT))
|
||||
SetTextColor(hdc,GetSysColor(COLOR_HOTLIGHT));
|
||||
else
|
||||
SetTextColor(hdc,RGB(0, 0, 0xFF));
|
||||
if (GetSysColorBrush(COLOR_HOTLIGHT)) {
|
||||
SetTextColor(hdc, GetSysColor(COLOR_HOTLIGHT));
|
||||
}
|
||||
else {
|
||||
SetTextColor(hdc, RGB(0, 0, 0xFF));
|
||||
}
|
||||
SelectObject(hdc,/*dwId == id_hover?*/hFontHover/*:hFontNormal*/);
|
||||
return (INT_PTR)GetSysColorBrush(COLOR_BTNFACE);
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ int IniSectionGetInt(LPCWSTR lpCachedIniSection, LPCWSTR lpName, int iDefault)
|
||||
{
|
||||
LPWSTR p = (LPWSTR)lpCachedIniSection;
|
||||
if (p) {
|
||||
int ich = (int)StringCchLen(lpName,0);
|
||||
int const ich = (int)StringCchLen(lpName,0);
|
||||
while (*p) {
|
||||
if ((StrCmpNI(p, lpName, ich) == 0) && (p[ich] == L'=')) {
|
||||
int i = 0;
|
||||
@ -873,8 +873,9 @@ bool PathGetLnkPath(LPCWSTR pszLnkFile,LPWSTR pszResPath,int cchResPath)
|
||||
}
|
||||
|
||||
// This additional check seems reasonable
|
||||
if (!StringCchLen(pszResPath,cchResPath))
|
||||
if (StrIsEmpty(pszResPath)) {
|
||||
bSucceeded = false;
|
||||
}
|
||||
|
||||
if (bSucceeded) {
|
||||
ExpandEnvironmentStringsEx(pszResPath,cchResPath);
|
||||
@ -935,8 +936,7 @@ bool PathCreateDeskLnk(LPCWSTR pszDocument)
|
||||
bool bSucceeded = false;
|
||||
BOOL fMustCopy;
|
||||
|
||||
if (!pszDocument || StringCchLen(pszDocument,MAX_PATH) == 0)
|
||||
return true;
|
||||
if (StrIsEmpty(pszDocument)) { return true; }
|
||||
|
||||
// init strings
|
||||
GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile));
|
||||
@ -1002,8 +1002,7 @@ bool PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir)
|
||||
IShellLink *psl;
|
||||
bool bSucceeded = false;
|
||||
|
||||
if (!pszName || StringCchLen(pszName,MAX_PATH) == 0)
|
||||
return true;
|
||||
if (StrIsEmpty(pszName)) { return true; }
|
||||
|
||||
StringCchCopy(tchLnkFileName,COUNTOF(tchLnkFileName),pszDir);
|
||||
PathCchAppend(tchLnkFileName,COUNTOF(tchLnkFileName),pszName);
|
||||
@ -1347,16 +1346,14 @@ DWORD NormalizePathEx(LPWSTR lpszPath, DWORD cchBuffer, bool bRealPath, bool bSe
|
||||
p += 2;
|
||||
*p = L'\\';
|
||||
}
|
||||
StringCchCopyW(lpszPath, MAX_PATH, p);
|
||||
StringCchCopy(lpszPath, cchBuffer, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
size_t pathLen = 0;
|
||||
StringCchLength(lpszPath, cchBuffer, &pathLen);
|
||||
return (DWORD)pathLen;
|
||||
return (DWORD)StringCchLen(lpszPath, cchBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ static bool _GetUserPreferredLanguage(LPWSTR pszPrefLocaleName, int cchBuffer, L
|
||||
LANGID lngID = *pLangID;
|
||||
WCHAR wchLngLocalName[LOCALE_NAME_MAX_LENGTH+1];
|
||||
|
||||
if (StringCchLen(pszPrefLocaleName, cchBuffer) > 0)
|
||||
if (StrIsNotEmpty(pszPrefLocaleName))
|
||||
{
|
||||
res = ResolveLocaleName(pszPrefLocaleName, wchLngLocalName, COUNTOF(wchLngLocalName));
|
||||
if (res > 0) {
|
||||
|
||||
@ -1804,7 +1804,7 @@ bool SelectExternalToolBar(HWND hwnd)
|
||||
|
||||
if (GetOpenFileName(&ofn)) {
|
||||
PathQuoteSpaces(szFile);
|
||||
if (StringCchLen(szArg2, COUNTOF(szArg2)))
|
||||
if (StrIsNotEmpty(szArg2))
|
||||
{
|
||||
StringCchCat(szFile, COUNTOF(szFile), L" ");
|
||||
StringCchCat(szFile, COUNTOF(szFile), szArg2);
|
||||
@ -9790,7 +9790,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
|
||||
//
|
||||
bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc)
|
||||
{
|
||||
if (StringCchLen(szFileName, MAX_PATH) != 0) {
|
||||
if (StrIsNotEmpty(szFileName)) {
|
||||
|
||||
const DocPos iCurPos = SciCall_IsSelectionRectangle() ? SciCall_GetRectangularSelectionCaret() : SciCall_GetCurrentPos();
|
||||
const DocPos iAnchorPos = SciCall_IsSelectionRectangle() ? SciCall_GetRectangularSelectionAnchor() : SciCall_GetAnchor();
|
||||
@ -10645,7 +10645,7 @@ void CancelCallTip()
|
||||
void InstallFileWatching(LPCWSTR lpszFile)
|
||||
{
|
||||
// Terminate
|
||||
if (!Settings.FileWatchingMode || !lpszFile || StringCchLen(lpszFile,MAX_PATH) == 0)
|
||||
if (!Settings.FileWatchingMode || StrIsEmpty(lpszFile))
|
||||
{
|
||||
if (s_bRunningWatch)
|
||||
{
|
||||
|
||||
21
src/Styles.c
21
src/Styles.c
@ -943,23 +943,23 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
|
||||
// Occurrences Marker
|
||||
if (!Style_StrGetColor(pCurrentStandard->Styles[STY_MARK_OCC].szValue, FOREGROUND_LAYER, &dColor))
|
||||
{
|
||||
WCHAR* sty = L"";
|
||||
switch (Settings.MarkOccurrences) {
|
||||
case 1:
|
||||
sty = L"fore:0xFF0000";
|
||||
dColor = RGB(0xFF, 0x00, 0x00);
|
||||
break;
|
||||
case 2:
|
||||
sty = L"fore:0x00FF00";
|
||||
dColor = RGB(0x00, 0xFF, 0x00);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
sty = L"fore:0x0000FF";
|
||||
dColor = RGB(0x00, 0xFF, 0x00);
|
||||
break;
|
||||
default:
|
||||
dColor = GetSysColor(COLOR_HIGHLIGHT);
|
||||
break;
|
||||
}
|
||||
StringCchCopyW(pCurrentStandard->Styles[STY_MARK_OCC].szValue, COUNTOF(pCurrentStandard->Styles[0].szValue), sty);
|
||||
WCHAR sty[32] = { L'\0' };
|
||||
StringCchPrintf(sty, COUNTOF(sty), L"fore:#%02X%02X%02X", (int)GetRValue(dColor), (int)GetGValue(dColor), (int)GetBValue(dColor));
|
||||
StringCchCopy(pCurrentStandard->Styles[STY_MARK_OCC].szValue, COUNTOF(pCurrentStandard->Styles[0].szValue), sty);
|
||||
}
|
||||
SendMessage(hwnd, SCI_INDICSETFORE, INDIC_NP3_MARK_OCCURANCE, dColor);
|
||||
|
||||
@ -1403,14 +1403,13 @@ void Style_SetLongLineColors(HWND hwnd)
|
||||
if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, FOREGROUND_LAYER, &rgb)) { // edge fore
|
||||
rgb = GetSysColor(COLOR_3DLIGHT);
|
||||
}
|
||||
SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0);
|
||||
}
|
||||
else {
|
||||
if (Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, BACKGROUND_LAYER, &rgb)) { // edge back
|
||||
rgb = GetSysColor(COLOR_3DLIGHT);
|
||||
if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, BACKGROUND_LAYER, &rgb)) { // edge back
|
||||
rgb = GetSysColor(COLOR_3DSHADOW);
|
||||
}
|
||||
SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0);
|
||||
}
|
||||
SendMessage(hwnd, SCI_SETEDGECOLOUR, rgb, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1764,7 +1763,7 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
|
||||
}
|
||||
|
||||
if (!bFound && s_bAutoSelect && /* s_bAutoSelect == false skips lexer search */
|
||||
(lpszFile && StringCchLen(lpszFile,MAX_PATH) > 0 && *lpszExt)) {
|
||||
(StrIsNotEmpty(lpszFile) && *lpszExt)) {
|
||||
|
||||
if (*lpszExt == L'.') ++lpszExt;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user