diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index 10b1a808b..73d79d417 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -880,8 +880,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define CARETSTYLE_BLOCK 2 #define CARETSTYLE_OVERSTRIKE_BAR 0 #define CARETSTYLE_OVERSTRIKE_BLOCK 0x10 -#define CARETSTYLE_BLOCK_AFTER 0x100 #define CARETSTYLE_INS_MASK 0xF +#define CARETSTYLE_BLOCK_AFTER 0x100 #define SCI_SETCARETSTYLE 2512 #define SCI_GETCARETSTYLE 2513 #define SCI_SETINDICATORCURRENT 2500 diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 75f17012c..c00e3044a 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1307,7 +1307,7 @@ void LoadSettings() Defaults2.DarkModeBkgColor = RGB(0x33, 0x33, 0x33); StringCchPrintf(color, COUNTOF(color), L"%#08x", Defaults2.DarkModeBkgColor); IniSectionGetString(IniSecSettings2, L"DarkModeBkgColor", color, wchBuffer, COUNTOF(wchBuffer)); - if (swscanf_s(wchBuffer, L"%xu", &iValue) == 1) { + if (swscanf_s(wchBuffer, L"%x", &iValue) == 1) { Settings2.DarkModeBkgColor = RGB((iValue & 0xFF0000) >> 16, (iValue & 0xFF00) >> 8, iValue & 0xFF); } else { Settings2.DarkModeBkgColor = Defaults2.DarkModeBkgColor; @@ -1320,7 +1320,7 @@ void LoadSettings() Defaults2.DarkModeTxtColor = RGB(0xEF, 0xEF, 0xEF); StringCchPrintf(color, COUNTOF(color), L"%#08x", Defaults2.DarkModeTxtColor); IniSectionGetString(IniSecSettings2, L"DarkModeTxtColor", color, wchBuffer, COUNTOF(wchBuffer)); - if (swscanf_s(wchBuffer, L"%xu", &iValue) == 1) { + if (swscanf_s(wchBuffer, L"%x", &iValue) == 1) { Settings2.DarkModeTxtColor = RGB((iValue & 0xFF0000) >> 16, (iValue & 0xFF00) >> 8, iValue & 0xFF); } else { Settings2.DarkModeTxtColor = Defaults2.DarkModeTxtColor; diff --git a/src/StyleLexers/styleLexStandard.c b/src/StyleLexers/styleLexStandard.c index d1a072a61..d8c719f26 100644 --- a/src/StyleLexers/styleLexStandard.c +++ b/src/StyleLexers/styleLexStandard.c @@ -8,7 +8,7 @@ EDITLEXER lexStandard = { SCLEX_NULL, IDS_LEX_DEF_TXT, L"Common Base", L"", L"", &KeyWords_NULL, { /* 0 */ { {STYLE_DEFAULT}, IDS_LEX_STD_STYLE, L"Default Style", L"font:Default", L"" }, - /* 1 */ { {STYLE_LINENUMBER}, IDS_LEX_STD_MARGIN, L"Margins and Line Numbers", L"size:-2; fore:#008080", L"" }, + /* 1 */ { {STYLE_LINENUMBER}, IDS_LEX_STD_MARGIN, L"Margins and Line Numbers", L"size:-2; fore:#008080; back:#F0F0F0", L"" }, /* 2 */ { {STYLE_BRACELIGHT}, IDS_LEX_STD_BRACE, L"Matching Braces (Indicator)", L"fore:#00FF40; alpha:80; alpha2:80; indic_roundbox", L"" }, /* 3 */ { {STYLE_BRACEBAD}, IDS_LEX_STD_BRACE_FAIL, L"Matching Braces Error (Indicator)", L"fore:#FF0080; alpha:140; alpha2:140; indic_roundbox", L"" }, /* 4 */ { {STYLE_CONTROLCHAR}, IDS_LEX_STD_CTRL_CHAR, L"Control Characters (Font)", L"size:-1", L"" }, @@ -32,7 +32,7 @@ EDITLEXER lexStandard2nd = { SCLEX_NULL, IDS_LEX_STR_63266, L"2nd Common Base", L"", L"", &KeyWords_NULL,{ /* 0 */ { {STYLE_DEFAULT}, IDS_LEX_2ND_STYLE, L"2nd Default Style", L"font:Courier New", L"" }, - /* 1 */ { {STYLE_LINENUMBER}, IDS_LEX_2ND_MARGIN, L"2nd Margins and Line Numbers", L"font:Courier New; size:-2; fore:#008080", L"" }, + /* 1 */ { {STYLE_LINENUMBER}, IDS_LEX_2ND_MARGIN, L"2nd Margins and Line Numbers", L"font:Courier New; size:-2; fore:#008080; back:#F0F0F0", L"" }, /* 2 */ { {STYLE_BRACELIGHT}, IDS_LEX_2ND_BRACE, L"2nd Matching Braces (Indicator)", L"fore:#00FF40; alpha:80; alpha2:220; indic_roundbox", L"" }, /* 3 */ { {STYLE_BRACEBAD}, IDS_LEX_2ND_BRACE_FAIL, L"2nd Matching Braces Error (Indicator)", L"fore:#FF0080; alpha:140; alpha2:220; indic_roundbox", L"" }, /* 4 */ { {STYLE_CONTROLCHAR}, IDS_LEX_2ND_CTRL_CHAR, L"2nd Control Characters (Font)", L"size:-1", L"" }, diff --git a/src/Styles.c b/src/Styles.c index b278a45a1..803046dd3 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -107,8 +107,9 @@ static PEDITLEXER g_pLexArray[NUMLEXERS] = // Currently used lexer -static int s_iDefaultLexer = 2; // (Constants.StdDefaultLexerID) Pure Text Files static PEDITLEXER s_pLexCurrent = &lexStandard; +static int s_iDefaultLexer = 2; // (Constants.StdDefaultLexerID) Pure Text Files + const COLORREF s_colorDefault[16] = { @@ -348,21 +349,17 @@ void Style_DynamicThemesMenuCmd(int cmd) } - - - - //============================================================================= // // IsLexerStandard() // -inline bool IsLexerStandard(PEDITLEXER pLexer) +inline bool IsLexerStandard(PEDITLEXER pLexer) { - return ( pLexer && ((pLexer == &lexStandard) || (pLexer == &lexStandard2nd)) ); + return (pLexer && ((pLexer == &lexStandard) || (pLexer == &lexStandard2nd))); } -inline PEDITLEXER GetCurrentStdLexer() +inline PEDITLEXER GetCurrentStdLexer() { return (Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard); } @@ -2346,7 +2343,7 @@ void Style_ToggleUse2ndDefault(HWND hwnd) bool const use2ndDefStyle = Style_GetUse2ndDefault(); Style_SetUse2ndDefault(use2ndDefStyle ? false : true); // swap if (IsLexerStandard(s_pLexCurrent)) { - s_pLexCurrent = Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard; // sync + s_pLexCurrent = GetCurrentStdLexer(); // sync } Style_ResetCurrentLexer(hwnd); } @@ -2841,8 +2838,7 @@ bool Style_StrGetColor(LPCWSTR lpszStyle, COLOR_LAYER layer, COLORREF* rgb) *p = L'\0'; TrimSpcW(tch); unsigned int iValue = 0; - int itok = swscanf_s(tch, L"%x", &iValue); - if (itok == 1) + if (swscanf_s(tch, L"%x", &iValue) == 1) { *rgb = RGB((iValue & 0xFF0000) >> 16, (iValue & 0xFF00) >> 8, iValue & 0xFF); return true; @@ -3793,20 +3789,30 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle, bool bInitDefault } COLORREF dColor = 0L; - // Fore + // Foregr if (Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &dColor)) { SendMessage(hwnd, SCI_STYLESETFORE, iStyle, (LPARAM)dColor); - } + } else if (bInitDefault) { - SendMessage(hwnd, SCI_STYLESETFORE, iStyle, (LPARAM)GetSysColor(COLOR_WINDOWTEXT)); // default text color +#ifdef D_NP3_WIN10_DARK_MODE + COLORREF const rgbFore = UseDarkMode() ? Settings2.DarkModeTxtColor : GetSysColor(COLOR_WINDOWTEXT); + SendMessage(hwnd, SCI_STYLESETFORE, iStyle, (LPARAM)rgbFore); // default text color +#else + SendMessage(hwnd, SCI_STYLESETFORE, iStyle, (LPARAM)GetSysColor(COLOR_WINDOWTEXT)); // default text color +#endif } - // Back + // Backgr if (Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &dColor)) { SendMessage(hwnd, SCI_STYLESETBACK, iStyle, (LPARAM)dColor); } else if (bInitDefault) { - SendMessage(hwnd, SCI_STYLESETBACK, iStyle, (LPARAM)GetSysColor(COLOR_WINDOW)); // default window color +#ifdef D_NP3_WIN10_DARK_MODE + COLORREF const rgbBack = UseDarkMode() ? Settings2.DarkModeBkgColor : GetSysColor(COLOR_WINDOW); + SendMessage(hwnd, SCI_STYLESETBACK, iStyle, (LPARAM)rgbBack); +#else + SendMessage(hwnd, SCI_STYLESETBACK, iStyle, (LPARAM)GetSysColor(COLOR_WINDOW)); // default window color +#endif } // Weight @@ -3892,7 +3898,6 @@ int Style_GetCurrentLexerRID() void Style_GetLexerDisplayName(PEDITLEXER pLexer, LPWSTR lpszName, int cchName) { if (!pLexer) { - //pLexer = Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard; pLexer = &lexStandard; // don't distinguish between STD/2ND } if (!GetLngString(pLexer->resID, lpszName, cchName)) {