Some code improvements

Close #16876
This commit is contained in:
Christian Grasser 2024-03-29 10:45:38 +01:00 committed by Don Ho
parent bf6fd373d4
commit c367ab8966
6 changed files with 21 additions and 34 deletions

View File

@ -3911,15 +3911,6 @@ void Notepad_plus::command(int id)
{
WindowsDlg _windowsDlg;
_windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
const TiXmlNodeA *nativeLangA = _nativeLangSpeaker.getNativeLangA();
TiXmlNodeA *dlgNode = NULL;
if (nativeLangA)
{
dlgNode = nativeLangA->FirstChild("Dialog");
if (dlgNode)
dlgNode = _nativeLangSpeaker.searchDlgNode(dlgNode, "Window");
}
_windowsDlg.doDialog();
}
break;

View File

@ -623,6 +623,7 @@ int hexStrVal(const wchar_t *str)
int getKwClassFromName(const wchar_t *str)
{
if(!str) return -1;
if (!lstrcmp(L"instre1", str)) return LANG_INDEX_INSTR;
if (!lstrcmp(L"instre2", str)) return LANG_INDEX_INSTR2;
if (!lstrcmp(L"type1", str)) return LANG_INDEX_TYPE;

View File

@ -352,13 +352,16 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
if (_defaultCharList.empty())
{
auto defaultCharListLen = execute(SCI_GETWORDCHARS);
char *defaultCharList = new char[defaultCharListLen + 1];
if(defaultCharList)
if(defaultCharListLen > 0)
{
execute(SCI_GETWORDCHARS, 0, reinterpret_cast<LPARAM>(defaultCharList));
defaultCharList[defaultCharListLen] = '\0';
_defaultCharList = defaultCharList;
delete[] defaultCharList;
char *defaultCharList = new char[defaultCharListLen + 1];
if(defaultCharList)
{
execute(SCI_GETWORDCHARS, 0, reinterpret_cast<LPARAM>(defaultCharList));
defaultCharList[defaultCharListLen] = '\0';
_defaultCharList = defaultCharList;
delete[] defaultCharList;
}
}
}
unsigned long MODEVENTMASK_ON = nppParams.getScintillaModEventMask();

View File

@ -409,7 +409,7 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begin
// dataToSearch & data2ToSearch are optional
if (!_functionNameExprArray.size() && !_classNameExprArray.size())
{
wchar_t foundData[1024];
wchar_t foundData[1024] {};
(*ppEditView)->getGenericText(foundData, 1024, targetStart, targetEnd);
fi._data = foundData; // whole found data
@ -418,7 +418,7 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begin
}
else
{
intptr_t foundPos;
intptr_t foundPos = -1;
if (_functionNameExprArray.size())
{
fi._data = parseSubLevel(targetStart, targetEnd, _functionNameExprArray, foundPos, ppEditView);

View File

@ -27,8 +27,6 @@ bool Splitter::_isHorizontalFixedRegistered = false;
bool Splitter::_isVerticalFixedRegistered = false;
#define SPLITTER_SIZE 8
void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, double iSplitRatio, DWORD dwFlags)
{
if (hPere == NULL)
@ -205,7 +203,7 @@ int Splitter::getClickZone(WH which)
? (which == WH::width ? _splitterSize : HIEGHT_MINIMAL)
: (which == WH::width ? HIEGHT_MINIMAL : _splitterSize);
}
else // (_spiltterSize > 8)
else // (_splitterSize > 8)
{
return isVertical()
? ((which == WH::width) ? 8 : 15)
@ -514,8 +512,8 @@ void Splitter::gotoRightBottom()
void Splitter::drawSplitter()
{
PAINTSTRUCT ps;
RECT rc, rcToDraw1, rcToDraw2, TLrc, BRrc;
PAINTSTRUCT ps {};
RECT rc {}, rcToDraw1 {}, rcToDraw2 {}, TLrc {}, BRrc {};
HDC hdc = ::BeginPaint(_hSelf, &ps);
getClientRect(rc);
@ -649,7 +647,7 @@ void Splitter::rotate()
void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir)
{
RECT rc;
RECT rc {};
rc.left = rect.left;
rc.top = rect.top;
rc.right = rect.right;
@ -717,14 +715,14 @@ void Splitter::adjustZoneToDraw(RECT& rc2def, ZONE_TYPE whichZone)
if (_splitterSize < 4)
return;
int x0, y0, x1, y1, w, h;
int x0 = 0, y0 = 0, x1 = 0, y1 = 0, w = 0, h = 0;
if (/*(4 <= _splitterSize) && */(_splitterSize <= 8))
{
w = (isVertical() ? 4 : 7);
h = (isVertical() ? 7 : 4);
}
else // (_spiltterSize > 8)
else // (_splitterSize > 8)
{
w = (isVertical() ? 6 : 11);
h = (isVertical() ? 11 : 6);

View File

@ -1392,9 +1392,9 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
const COLORREF colorActiveBg = isDarkMode ? NppDarkMode::getCtrlBackgroundColor() : ::GetSysColor(COLOR_BTNFACE);
const COLORREF colorInactiveBgBase = isDarkMode ? NppDarkMode::getBackgroundColor() : ::GetSysColor(COLOR_BTNFACE);
COLORREF colorInactiveBg = liteGrey;
COLORREF colorActiveText = ::GetSysColor(COLOR_BTNTEXT);
COLORREF colorInactiveText = grey;
COLORREF colorInactiveBg = _inactiveBgColour;
COLORREF colorActiveText = _activeTextColour;
COLORREF colorInactiveText = _inactiveTextColour;
if (!NppDarkMode::useTabTheme() && isDarkMode)
{
@ -1402,12 +1402,6 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
colorActiveText = NppDarkMode::getTextColor();
colorInactiveText = NppDarkMode::getDarkerTextColor();
}
else
{
colorInactiveBg = _inactiveBgColour;
colorActiveText = _activeTextColour;
colorInactiveText = _inactiveTextColour;
}
HDC hDC = pDrawItemStruct->hDC;