+fix: dark mode aware auto-completion-list-box

+chg: use "round nearest displayed digit" method for estimated file size display
This commit is contained in:
METANEOCORTEX\Kotti 2021-09-16 09:48:07 +02:00
parent ca7cfdb18d
commit 74eca99b60
4 changed files with 14 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@ -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*/