X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/e4a6f5371e3768e111e566ddeff061b5247e53b1..26d1da7b02a1b4190877777183bd7be2087bc6d2:/window.c diff --git a/window.c b/window.c index ea0077d9..1e84972e 100644 --- a/window.c +++ b/window.c @@ -75,6 +75,7 @@ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, unsigned char *output); static void cfgtopalette(void); +static void systopalette(void); static void init_palette(void); static void init_fonts(int, int); static void another_font(int); @@ -1015,6 +1016,38 @@ static void cfgtopalette(void) defpal[i].rgbtGreen = cfg.colours[w][1]; defpal[i].rgbtBlue = cfg.colours[w][2]; } + + /* Override with system colours if appropriate */ + if (cfg.system_colour) + systopalette(); +} + +/* + * Override bit of defpal with colours from the system. + * (NB that this takes a copy the system colours at the time this is called, + * so subsequent colour scheme changes don't take effect. To fix that we'd + * probably want to be using GetSysColorBrush() and the like.) + */ +static void systopalette(void) +{ + int i; + static const struct { int nIndex; int norm; int bold; } or[] = + { + { COLOR_WINDOWTEXT, 16, 17 }, /* Default Foreground */ + { COLOR_WINDOW, 18, 19 }, /* Default Background */ + { COLOR_HIGHLIGHTTEXT, 20, 21 }, /* Cursor Text */ + { COLOR_HIGHLIGHT, 22, 23 }, /* Cursor Colour */ + }; + + for (i = 0; i < (sizeof(or)/sizeof(or[0])); i++) { + COLORREF colour = GetSysColor(or[i].nIndex); + defpal[or[i].norm].rgbtRed = + defpal[or[i].bold].rgbtRed = GetRValue(colour); + defpal[or[i].norm].rgbtGreen = + defpal[or[i].bold].rgbtGreen = GetGValue(colour); + defpal[or[i].norm].rgbtBlue = + defpal[or[i].bold].rgbtBlue = GetBValue(colour); + } } /*