Merge pull request #3663 from RaiKoHoff/Dev_RC

Dark Mode aware auto-completion-list-box
This commit is contained in:
Rainer Kottenhoff 2021-09-16 10:10:50 +02:00 committed by GitHub
commit 67e7e47816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 12 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);
@ -7677,7 +7676,10 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert)
PWLIST pListHead = NULL;
// --------------------------------------------------------------------------
if (Settings.AutoCompleteWords || (autoInsert && !Settings.AutoCLexerKeyWords)) {
// --------------------------------------------------------------------------
struct Sci_TextToFind ft = { { 0, 0 }, 0, { 0, 0 } };
ft.lpstrText = pRoot;
ft.chrg.cpMax = (DocPosCR)iDocEndPos;
@ -7717,10 +7719,11 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert)
FreeMem(pwlNewWord);
pwlNewWord = NULL;
}
// --------------------------------------------------------------------------
if (Settings.AutoCLexerKeyWords || (autoInsert && !Settings.AutoCompleteWords))
// --------------------------------------------------------------------------
{
if (Settings.AutoCLexerKeyWords || (autoInsert && !Settings.AutoCompleteWords)) {
// --------------------------------------------------------------------------
PKEYWORDLIST const pKeyWordList = Style_GetCurrentLexerPtr()->pKeyWords;
PWLIST pwlNewWord = NULL;
@ -7760,10 +7763,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 +7776,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*/