From 74eca99b6052df5018e8062142516ff497d2a891 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Thu, 16 Sep 2021 09:48:07 +0200 Subject: [PATCH] +fix: dark mode aware auto-completion-list-box +chg: use "round nearest displayed digit" method for estimated file size display --- src/Edit.c | 14 +++++++++----- src/Notepad3.c | 4 ++-- src/SciCall.h | 1 + src/TypeDefs.h | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index a0b0bbbfa..96c19d24f 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1122,11 +1122,10 @@ bool EditLoadFile( #else bool const bFileTooBig = true; // _WIN32: file size < 2GB only #endif - if (bFileTooBig) { // refuse to handle files of that size WCHAR sizeStr[64] = { L'\0' }; - StrFormatByteSize((LONGLONG)liFileSize.QuadPart, sizeStr, COUNTOF(sizeStr)); + StrFormatByteSizeEx(liFileSize.QuadPart, SFBS_FLAGS_ROUND_TO_NEAREST_DISPLAYED_DIGIT, sizeStr, COUNTOF(sizeStr)); InfoBoxLng(MB_ICONERROR, NULL, IDS_MUI_ERR_FILE_TOO_LARGE, sizeStr); CloseHandle(hFile); Encoding_Forced(CPI_NONE); @@ -1142,9 +1141,9 @@ bool EditLoadFile( size_t const fileSizeWarning = (size_t)Settings2.FileLoadWarningMB << 20; if ((fileSizeWarning != 0ULL) && (fileSizeWarning <= fileSize)) { WCHAR sizeStr[64] = { L'\0' }; - StrFormatByteSize((LONGLONG)liFileSize.QuadPart, sizeStr, COUNTOF(sizeStr)); + StrFormatByteSizeEx(liFileSize.QuadPart, SFBS_FLAGS_ROUND_TO_NEAREST_DISPLAYED_DIGIT, sizeStr, COUNTOF(sizeStr)); WCHAR sizeWarnStr[64] = { L'\0' }; - StrFormatByteSize((LONGLONG)fileSizeWarning, sizeWarnStr, COUNTOF(sizeWarnStr)); + StrFormatByteSizeEx(fileSizeWarning, SFBS_FLAGS_ROUND_TO_NEAREST_DISPLAYED_DIGIT, sizeWarnStr, COUNTOF(sizeWarnStr)); Flags.bHugeFileLoadState = true; if (INFOBOX_ANSW(InfoBoxLng(MB_YESNO, L"MsgFileSizeWarning", IDS_MUI_WARN_LOAD_BIG_FILE, sizeStr, sizeWarnStr)) != IDYES) { CloseHandle(hFile); @@ -7760,10 +7759,12 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) // -------------------------------------------------------------------------- if (iNumWords > 0) { + const char* const sep = " "; SciCall_AutoCCancel(); SciCall_ClearRegisteredImages(); - + + SciCall_AutoCSetOptions(SC_AUTOCOMPLETE_FIXED_SIZE); SciCall_AutoCSetSeperator(sep[0]); SciCall_AutoCSetIgnoreCase(true); //~SciCall_AutoCSetCaseInsensitiveBehaviour(SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE); @@ -7771,6 +7772,9 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) SciCall_AutoCSetOrder(SC_ORDER_PERFORMSORT); // already sorted SciCall_AutoCSetFillups(AutoCompleteFillUpChars); + SciCall_SetElementColour(SC_ELEMENT_LIST, RGBxA(GetModeTextColor(UseDarkMode()), SC_ALPHA_OPAQUE)); + SciCall_SetElementColour(SC_ELEMENT_LIST_BACK, RGBxA(GetModeBkColor(UseDarkMode()), SC_ALPHA_OPAQUE)); + ++iWListSize; // zero termination char* const pList = AllocMem(iWListSize + 1, HEAP_ZERO_MEMORY); if (pList) { diff --git a/src/Notepad3.c b/src/Notepad3.c index 42ad004a0..07d9bde86 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -9047,7 +9047,7 @@ static void _UpdateStatusbarDelayed(bool bForceRedraw) DocPos const iSel = Flags.bHugeFileLoadState ? (iSelEnd - iSelStart) : SciCall_CountCharacters(iSelStart, iSelEnd); StringCchPrintf(tchSel, COUNTOF(tchSel), DOCPOSFMTW, iSel); FormatNumberStr(tchSel, COUNTOF(tchSel), 0); - StrFormatByteSize((iSelEnd - iSelStart), tchSelB, COUNTOF(tchSelB)); + StrFormatByteSizeEx((ULONGLONG)(iSelEnd - iSelStart), SFBS_FLAGS_ROUND_TO_NEAREST_DISPLAYED_DIGIT, tchSelB, COUNTOF(tchSelB)); } else if (bIsMultiSelection) { StringCchPrintf(tchSel, COUNTOF(tchSel), L"# " DOCPOSFMTW, SciCall_GetSelections()); tchSelB[0] = L'0'; @@ -9221,7 +9221,7 @@ static void _UpdateStatusbarDelayed(bool bForceRedraw) DocPos const iTextLength = SciCall_GetTextLength(); if (bForceRedraw || (s_iTextLength != iTextLength)) { static WCHAR tchBytes[32] = { L'\0' }; - StrFormatByteSize(iTextLength, tchBytes, COUNTOF(tchBytes)); + StrFormatByteSizeEx((ULONGLONG)iTextLength, SFBS_FLAGS_ROUND_TO_NEAREST_DISPLAYED_DIGIT, tchBytes, COUNTOF(tchBytes)); StringCchPrintf(tchStatusBar[STATUS_DOCSIZE], txtWidth, L"%s%s%s", g_mxSBPrefix[STATUS_DOCSIZE], tchBytes, g_mxSBPostfix[STATUS_DOCSIZE]); diff --git a/src/SciCall.h b/src/SciCall.h index 01f7b2bbd..c4b4d5a8f 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -438,6 +438,7 @@ DeclareSciCallR0(AutoCActive, AUTOCACTIVE, bool); DeclareSciCallV0(AutoCComplete, AUTOCCOMPLETE); DeclareSciCallV0(AutoCCancel, AUTOCCANCEL); DeclareSciCallV0(ClearRegisteredImages, CLEARREGISTEREDIMAGES); +DeclareSciCallV1(AutoCSetOptions, AUTOCSETOPTIONS, int, options); DeclareSciCallV1(AutoCSetIgnoreCase, AUTOCSETIGNORECASE, bool, flag); DeclareSciCallV1(AutoCSetCaseInsensitiveBehaviour, AUTOCSETCASEINSENSITIVEBEHAVIOUR, int, options); DeclareSciCallV1(AutoCSetSeperator, AUTOCSETSEPARATOR, char, seperator); diff --git a/src/TypeDefs.h b/src/TypeDefs.h index a66dc8bf0..a6f63cf8b 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -14,10 +14,10 @@ *******************************************************************************/ #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x601 /*_WIN32_WINNT_WIN7*/ +#define _WIN32_WINNT 0x0601 /*_WIN32_WINNT_WIN7*/ #endif #ifndef WINVER -#define WINVER 0x601 /*_WIN32_WINNT_WIN7*/ +#define WINVER 0x0601 /*_WIN32_WINNT_WIN7*/ #endif #ifndef NTDDI_VERSION #define NTDDI_VERSION 0x06010000 /*NTDDI_WIN7*/