1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-21 22:28:37 -05:00

Implement `default-colours' on Windows based loosely on Michael Wardle's patch.

[originally from svn r3444]
This commit is contained in:
Jacob Nevins 2003-09-03 20:14:38 +00:00
parent dbe68abfff
commit 95d5a91c24
6 changed files with 54 additions and 1 deletions

View File

@ -1,4 +1,4 @@
\versionid $Id: config.but,v 1.66 2003/06/25 15:52:29 jacob Exp $ \versionid $Id: config.but,v 1.67 2003/09/03 20:14:38 jacob Exp $
\C{config} Configuring PuTTY \C{config} Configuring PuTTY
@ -1315,6 +1315,18 @@ If you are not getting the colours you ask for on an 8-bit display,
you can try enabling this option. However, be warned that it's never you can try enabling this option. However, be warned that it's never
worked very well. worked very well.
\S{config-syscolour} \q{Use system colours}
\cfg{winhelp-topic}{colours.system}
Enabling this option will cause PuTTY to ignore the configured colours
for \q{Default Background/Foreground} and \q{Cursor Colour/Text} (see
\k{config-colourcfg}), instead going with the system-wide defaults.
Note that non-bold and bold text will be the same colour if this
option is enabled. You might want to change to indicating bold text
by font changes (see \k{config-boldcolour}).
\S{config-colourcfg} Adjusting the colours in the terminal window \S{config-colourcfg} Adjusting the colours in the terminal window
\cfg{winhelp-topic}{colours.config} \cfg{winhelp-topic}{colours.config}

View File

@ -429,6 +429,7 @@ struct config_tag {
char answerback[256]; char answerback[256];
char printer[128]; char printer[128];
/* Colour options */ /* Colour options */
int system_colour;
int try_palette; int try_palette;
int bold_colour; int bold_colour;
unsigned char colours[22][3]; unsigned char colours[22][3];

View File

@ -280,6 +280,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg)
write_setting_i(sesskey, "TermHeight", cfg->height); write_setting_i(sesskey, "TermHeight", cfg->height);
write_setting_fontspec(sesskey, "Font", cfg->font); write_setting_fontspec(sesskey, "Font", cfg->font);
write_setting_i(sesskey, "FontVTMode", cfg->vtmode); write_setting_i(sesskey, "FontVTMode", cfg->vtmode);
write_setting_i(sesskey, "UseSystemColours", cfg->system_colour);
write_setting_i(sesskey, "TryPalette", cfg->try_palette); write_setting_i(sesskey, "TryPalette", cfg->try_palette);
write_setting_i(sesskey, "BoldAsColour", cfg->bold_colour); write_setting_i(sesskey, "BoldAsColour", cfg->bold_colour);
for (i = 0; i < 22; i++) { for (i = 0; i < 22; i++) {
@ -534,6 +535,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg)
gppi(sesskey, "TermHeight", 24, &cfg->height); gppi(sesskey, "TermHeight", 24, &cfg->height);
gppfont(sesskey, "Font", &cfg->font); gppfont(sesskey, "Font", &cfg->font);
gppi(sesskey, "FontVTMode", VT_UNICODE, (int *) &cfg->vtmode); gppi(sesskey, "FontVTMode", VT_UNICODE, (int *) &cfg->vtmode);
gppi(sesskey, "UseSystemColours", 0, &cfg->system_colour);
gppi(sesskey, "TryPalette", 0, &cfg->try_palette); gppi(sesskey, "TryPalette", 0, &cfg->try_palette);
gppi(sesskey, "BoldAsColour", 1, &cfg->bold_colour); gppi(sesskey, "BoldAsColour", 1, &cfg->bold_colour);
for (i = 0; i < 22; i++) { for (i = 0; i < 22; i++) {

View File

@ -271,6 +271,10 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
ctrl_checkbox(s, "Attempt to use logical palettes", 'l', ctrl_checkbox(s, "Attempt to use logical palettes", 'l',
HELPCTX(colours_logpal), HELPCTX(colours_logpal),
dlg_stdcheckbox_handler, I(offsetof(Config,try_palette))); dlg_stdcheckbox_handler, I(offsetof(Config,try_palette)));
ctrl_checkbox(s, "Use system colours", 's',
HELPCTX(colours_system),
dlg_stdcheckbox_handler, I(offsetof(Config,system_colour)));
/* /*
* Resize-by-changing-font is a Windows insanity. * Resize-by-changing-font is a Windows insanity.

View File

@ -75,6 +75,7 @@ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
unsigned char *output); unsigned char *output);
static void cfgtopalette(void); static void cfgtopalette(void);
static void systopalette(void);
static void init_palette(void); static void init_palette(void);
static void init_fonts(int, int); static void init_fonts(int, int);
static void another_font(int); static void another_font(int);
@ -1015,6 +1016,38 @@ static void cfgtopalette(void)
defpal[i].rgbtGreen = cfg.colours[w][1]; defpal[i].rgbtGreen = cfg.colours[w][1];
defpal[i].rgbtBlue = cfg.colours[w][2]; 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);
}
} }
/* /*

View File

@ -92,6 +92,7 @@
#define WINHELP_CTX_selection_linedraw "selection.linedraw" #define WINHELP_CTX_selection_linedraw "selection.linedraw"
#define WINHELP_CTX_selection_rtf "selection.rtf" #define WINHELP_CTX_selection_rtf "selection.rtf"
#define WINHELP_CTX_colours_bold "colours.bold" #define WINHELP_CTX_colours_bold "colours.bold"
#define WINHELP_CTX_colours_system "colours.system"
#define WINHELP_CTX_colours_logpal "colours.logpal" #define WINHELP_CTX_colours_logpal "colours.logpal"
#define WINHELP_CTX_colours_config "colours.config" #define WINHELP_CTX_colours_config "colours.config"
#define WINHELP_CTX_translation_codepage "translation.codepage" #define WINHELP_CTX_translation_codepage "translation.codepage"