From 2f9738a282c9b738b135198d34c61f7d81aa69c1 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 5 Oct 2017 20:27:27 +0100 Subject: [PATCH] Make terminal true-colour mode configurable. I know some users don't like any colour _at all_, and we have a separate option to turn off xterm-style 256-colour sequences, so it seems remiss not to have an option to disable true colour as well. --- config.c | 3 +++ doc/config.but | 9 +++++++++ putty.h | 1 + settings.c | 2 ++ terminal.c | 8 +++++++- terminal.h | 1 + windows/winhelp.h | 1 + 7 files changed, 24 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index efe1ff1e..cc5e726b 100644 --- a/config.c +++ b/config.c @@ -1898,6 +1898,9 @@ void setup_config_box(struct controlbox *b, int midsession, ctrl_checkbox(s, "Allow terminal to use xterm 256-colour mode", '2', HELPCTX(colours_xterm256), conf_checkbox_handler, I(CONF_xterm_256_colour)); + ctrl_checkbox(s, "Allow terminal to use 24-bit colours", '4', + HELPCTX(colours_truecolour), conf_checkbox_handler, + I(CONF_true_colour)); ctrl_radiobuttons(s, "Indicate bolded text by changing:", 'b', 3, HELPCTX(colours_bold), conf_radiobutton_handler, I(CONF_bold_style), diff --git a/doc/config.but b/doc/config.but index bd12efb2..7ad5e282 100644 --- a/doc/config.but +++ b/doc/config.but @@ -1549,6 +1549,15 @@ If you do not see \cq{colors#256} in the output, you may need to change your terminal setting. On modern Linux machines, you could try \cq{xterm-256color}. +\S{config-truecolour} \q{Allow terminal to use 24-bit colour} + +\cfg{winhelp-topic}{colours.truecolour} + +This option is enabled by default. If it is disabled, PuTTY will +ignore any control sequences sent by the server which use the control +sequences supported by modern terminals to specify arbitrary 24-bit +RGB colour value. + \S{config-boldcolour} \q{Indicate bolded text by changing...} \cfg{winhelp-topic}{colours.bold} diff --git a/putty.h b/putty.h index 61d6278d..8a8b5425 100644 --- a/putty.h +++ b/putty.h @@ -859,6 +859,7 @@ void cleanup_exit(int); /* Colour options */ \ X(INT, NONE, ansi_colour) \ X(INT, NONE, xterm_256_colour) \ + X(INT, NONE, true_colour) \ X(INT, NONE, system_colour) \ X(INT, NONE, try_palette) \ X(INT, NONE, bold_style) \ diff --git a/settings.c b/settings.c index 00c01c54..47e5b9f7 100644 --- a/settings.c +++ b/settings.c @@ -609,6 +609,7 @@ void save_open_settings(void *sesskey, Conf *conf) write_setting_i(sesskey, "TryPalette", conf_get_int(conf, CONF_try_palette)); write_setting_i(sesskey, "ANSIColour", conf_get_int(conf, CONF_ansi_colour)); write_setting_i(sesskey, "Xterm256Colour", conf_get_int(conf, CONF_xterm_256_colour)); + write_setting_i(sesskey, "TrueColour", conf_get_int(conf, CONF_true_colour)); write_setting_i(sesskey, "BoldAsColour", conf_get_int(conf, CONF_bold_style)-1); for (i = 0; i < 22; i++) { @@ -1005,6 +1006,7 @@ void load_open_settings(void *sesskey, Conf *conf) gppi(sesskey, "TryPalette", 0, conf, CONF_try_palette); gppi(sesskey, "ANSIColour", 1, conf, CONF_ansi_colour); gppi(sesskey, "Xterm256Colour", 1, conf, CONF_xterm_256_colour); + gppi(sesskey, "TrueColour", 1, conf, CONF_true_colour); i = gppi_raw(sesskey, "BoldAsColour", 1); conf_set_int(conf, CONF_bold_style, i+1); for (i = 0; i < 22; i++) { diff --git a/terminal.c b/terminal.c index 433b3fa5..5102db12 100644 --- a/terminal.c +++ b/terminal.c @@ -1458,6 +1458,7 @@ void term_copy_stuff_from_conf(Terminal *term) term->scroll_on_disp = conf_get_int(term->conf, CONF_scroll_on_disp); term->scroll_on_key = conf_get_int(term->conf, CONF_scroll_on_key); term->xterm_256_colour = conf_get_int(term->conf, CONF_xterm_256_colour); + term->true_colour = conf_get_int(term->conf, CONF_true_colour); /* * Parse the control-character escapes in the configured @@ -5171,7 +5172,6 @@ static void do_paint(Terminal *term, Context ctx, int may_optimise) tattr = (tattr & ~(ATTR_FGMASK | ATTR_BGMASK)) | ATTR_DEFFG | ATTR_DEFBG; - tc = d->truecolour; if (!term->xterm_256_colour) { int colour; colour = (tattr & ATTR_FGMASK) >> ATTR_FGSHIFT; @@ -5182,6 +5182,12 @@ static void do_paint(Terminal *term, Context ctx, int may_optimise) tattr = (tattr &~ ATTR_BGMASK) | ATTR_DEFBG; } + if (term->true_colour) { + tc = d->truecolour; + } else { + tc.fg = tc.bg = optionalrgb_none; + } + switch (tchar & CSET_MASK) { case CSET_ASCII: tchar = term->ucsdata->unitab_line[tchar & 0xFF]; diff --git a/terminal.h b/terminal.h index 21b8774a..4a205a77 100644 --- a/terminal.h +++ b/terminal.h @@ -325,6 +325,7 @@ struct terminal_tag { int scroll_on_disp; int scroll_on_key; int xterm_256_colour; + int true_colour; }; #define in_utf(term) ((term)->utf || (term)->ucsdata->line_codepage==CP_UTF8) diff --git a/windows/winhelp.h b/windows/winhelp.h index 761c8c76..dbe32c91 100644 --- a/windows/winhelp.h +++ b/windows/winhelp.h @@ -125,6 +125,7 @@ #define WINHELP_CTX_selection_rtf "selection.rtf:config-rtfpaste" #define WINHELP_CTX_colours_ansi "colours.ansi:config-ansicolour" #define WINHELP_CTX_colours_xterm256 "colours.xterm256:config-xtermcolour" +#define WINHELP_CTX_colours_truecolour "colours.truecolour:config-truecolour" #define WINHELP_CTX_colours_bold "colours.bold:config-boldcolour" #define WINHELP_CTX_colours_system "colours.system:config-syscolour" #define WINHELP_CTX_colours_logpal "colours.logpal:config-logpalette"