1- #include " stdafx.h" // ADDED BY PYTHONSCRIPT
21#include " NppDarkMode.h"
2+ #include " PluginInterface.h"
3+
4+ extern NppData nppData;
5+
6+ static constexpr COLORREF HEXRGB (DWORD rrggbb) {
7+ // from 0xRRGGBB like natural #RRGGBB
8+ // to the little-endian 0xBBGGRR
9+ return
10+ ((rrggbb & 0xFF0000 ) >> 16 ) |
11+ ((rrggbb & 0x00FF00 )) |
12+ ((rrggbb & 0x0000FF ) << 16 );
13+ }
14+
315
416namespace NppDarkMode
517{
618 bool isEnabled ()
719 {
8- return false ;
20+ return ::SendMessage (nppData._nppHandle , NPPM_ISDARKMODEENABLED, 0 , 0 );
21+ }
22+
23+ HBRUSH getDarkerBackgroundBrush ()
24+ {
25+ return ::CreateSolidBrush (HEXRGB (0x202020 ));
26+ }
27+
28+ COLORREF getTextColor ()
29+ {
30+ return HEXRGB (0xE0E0E0 );
931 }
1032
11- HBRUSH getDlgBackgroundBrush ()
33+ COLORREF getDarkerTextColor ()
1234 {
13- return 0 ;
35+ return HEXRGB (0xC0C0C0 );
36+ }
37+
38+ COLORREF getLinkTextColor ()
39+ {
40+ return HEXRGB (0xFFFF00 );
41+ }
42+
43+ COLORREF getDarkerBackgroundColor ()
44+ {
45+ return HEXRGB (0x202020 );
1446 }
1547
1648 void setDarkTitleBar (HWND /* hwnd*/ )
@@ -19,6 +51,19 @@ namespace NppDarkMode
1951
2052 bool isWindows10 ()
2153 {
22- return true ;
54+ return false ;
2355 }
56+
57+ LRESULT onCtlColorDarker (HDC hdc)
58+ {
59+ if (!NppDarkMode::isEnabled ())
60+ {
61+ return FALSE ;
62+ }
63+
64+ ::SetTextColor (hdc, NppDarkMode::getTextColor());
65+ ::SetBkColor (hdc, NppDarkMode::getDarkerBackgroundColor());
66+ return reinterpret_cast <LRESULT>(NppDarkMode::getDarkerBackgroundBrush ());
67+ }
68+
2469}
0 commit comments