]> asedeno.scripts.mit.edu Git - PuTTY_svn.git/commitdiff
Implement `default-colours' on Windows based loosely on Michael Wardle's patch.
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Wed, 3 Sep 2003 20:14:38 +0000 (20:14 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Wed, 3 Sep 2003 20:14:38 +0000 (20:14 +0000)
git-svn-id: http://svn.tartarus.org/sgt/putty@3444 cda61777-01e9-0310-a592-d414129be87e

doc/config.but
putty.h
settings.c
wincfg.c
window.c
winhelp.h

index 1dc0ad458bbd76b552bc2c54ee63c8e2a678e0bd..ddfad40ebb2d6021a319ce967ec65e958d825e07 100644 (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
 worked very well.
 
 you can try enabling this option. However, be warned that it's never
 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
 
 \cfg{winhelp-topic}{colours.config}
 \S{config-colourcfg} Adjusting the colours in the terminal window
 
 \cfg{winhelp-topic}{colours.config}
diff --git a/putty.h b/putty.h
index 026448b729a91843bae4d884431c3535529d19ca..60aed037cfc94e86369e02461222aba743f94fc3 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -429,6 +429,7 @@ struct config_tag {
     char answerback[256];
     char printer[128];
     /* Colour options */
     char answerback[256];
     char printer[128];
     /* Colour options */
+    int system_colour;
     int try_palette;
     int bold_colour;
     unsigned char colours[22][3];
     int try_palette;
     int bold_colour;
     unsigned char colours[22][3];
index d5e0d2650e76ed5fb449f769496c79726ff116dc..470ccd248858936773b7ae3404404513f5cbae81 100644 (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_fontspec(sesskey, "Font", cfg->font);
     write_setting_i(sesskey, "FontVTMode", cfg->vtmode);
     write_setting_i(sesskey, "TermHeight", cfg->height);
     write_setting_fontspec(sesskey, "Font", cfg->font);
     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, "BoldAsColour", cfg->bold_colour);
     for (i = 0; i < 22; i++) {
     write_setting_i(sesskey, "TryPalette", cfg->try_palette);
     write_setting_i(sesskey, "BoldAsColour", cfg->bold_colour);
     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);
     gppfont(sesskey, "Font", &cfg->font);
     gppi(sesskey, "FontVTMode", VT_UNICODE, (int *) &cfg->vtmode);
     gppi(sesskey, "TermHeight", 24, &cfg->height);
     gppfont(sesskey, "Font", &cfg->font);
     gppi(sesskey, "FontVTMode", VT_UNICODE, (int *) &cfg->vtmode);
+    gppi(sesskey, "UseSystemColours", 0, &cfg->system_colour);
     gppi(sesskey, "TryPalette", 0, &cfg->try_palette);
     gppi(sesskey, "BoldAsColour", 1, &cfg->bold_colour);
     for (i = 0; i < 22; i++) {
     gppi(sesskey, "TryPalette", 0, &cfg->try_palette);
     gppi(sesskey, "BoldAsColour", 1, &cfg->bold_colour);
     for (i = 0; i < 22; i++) {
index c094eb7747c50c337089f02a5943a9a5317ef9a0..992d5dbf0710fc160a0b1d2240b397d4498065e4 100644 (file)
--- a/wincfg.c
+++ b/wincfg.c
@@ -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',
                  HELPCTX(colours_logpal),
                  dlg_stdcheckbox_handler, I(offsetof(Config,try_palette)));
     ctrl_checkbox(s, "Attempt to use logical palettes", 'l',
                  HELPCTX(colours_logpal),
                  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.
index ea0077d9f22aff41f4ed5fa63997ef5bc3a81841..1e84972e3c8fb5622c30ea3c21fcb892f22939b6 100644 (file)
--- 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 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);
 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];
     }
        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);
+    }
 }
 
 /*
 }
 
 /*
index e767aabc4cede5b97a6aa4e020d7f3b5b6b62840..8d69573fa5731a0e8502c3ca996b011ad6f735be 100644 (file)
--- a/winhelp.h
+++ b/winhelp.h
@@ -92,6 +92,7 @@
 #define WINHELP_CTX_selection_linedraw "selection.linedraw"
 #define WINHELP_CTX_selection_rtf "selection.rtf"
 #define WINHELP_CTX_colours_bold "colours.bold"
 #define WINHELP_CTX_selection_linedraw "selection.linedraw"
 #define WINHELP_CTX_selection_rtf "selection.rtf"
 #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_config "colours.config"
 #define WINHELP_CTX_translation_codepage "translation.codepage"
 #define WINHELP_CTX_colours_logpal "colours.logpal"
 #define WINHELP_CTX_colours_config "colours.config"
 #define WINHELP_CTX_translation_codepage "translation.codepage"