From 863c5362e83ad7d153bc39fdbc526f9d0674a0c2 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 9 Jun 2012 15:09:22 +0000 Subject: [PATCH] Introduce a third setting for the 'bold as colour' mode, which lets you both brighten the colour _and_ bold the font at the same time. (Fixes 'bold-font-colour' and Debian #193352.) git-svn-id: svn://svn.tartarus.org/sgt/putty@9559 cda61777-01e9-0310-a592-d414129be87e --- config.c | 10 +++++++--- doc/config.but | 22 ++++++++++++---------- doc/man-ptel.but | 8 ++++---- doc/man-pter.but | 19 ++++++++++--------- doc/man-putt.but | 8 ++++---- macosx/osxwin.m | 6 +++--- putty.h | 2 +- settings.c | 4 ++-- unix/gtkwin.c | 10 +++++----- windows/window.c | 45 +++++++++++++++++++++++---------------------- 10 files changed, 71 insertions(+), 63 deletions(-) diff --git a/config.c b/config.c index c50d97da..a8f388e4 100644 --- a/config.c +++ b/config.c @@ -1790,9 +1790,13 @@ 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, "Bolded text is a different colour", 'b', - HELPCTX(colours_bold), - conf_checkbox_handler, I(CONF_bold_colour)); + ctrl_radiobuttons(s, "Indicate bolded text by changing:", 'b', 3, + HELPCTX(colours_bold), + conf_radiobutton_handler, I(CONF_bold_style), + "The font", I(1), + "The colour", I(2), + "Both", I(3), + NULL); str = dupprintf("Adjust the precise colours %s displays", appname); s = ctrl_getset(b, "Window/Colours", "adjust", str); diff --git a/doc/config.but b/doc/config.but index 106cc5bc..98427584 100644 --- a/doc/config.but +++ b/doc/config.but @@ -1541,20 +1541,22 @@ 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-boldcolour} \q{Bolded text is a different colour} +\S{config-boldcolour} \q{Indicate bolded text by changing} \cfg{winhelp-topic}{colours.bold} When the server sends a \i{control sequence} indicating that some text -should be displayed in \i{bold}, PuTTY can handle this two ways. It can -either change the \i{font} for a bold version, or use the same font in a -brighter colour. This control lets you choose which. - -By default the box is checked, so non-bold text is displayed in -light grey and bold text is displayed in bright white (and similarly -in other colours). If you uncheck the box, bold and non-bold text -will be displayed in the same colour, and instead the font will -change to indicate the difference. +should be displayed in \i{bold}, PuTTY can handle this in several +ways. It can either change the \i{font} for a bold version, or use the +same font in a brighter colour, or it can do both (brighten the colour +\e{and} embolden the font). This control lets you choose which. + +By default bold is indicated by colour, so non-bold text is displayed +in light grey and bold text is displayed in bright white (and +similarly in other colours). If you change the setting to \q{The font} +box, bold and non-bold text will be displayed in the same colour, and +instead the font will change to indicate the difference. If you select +\q{Both}, the font and the colour will both change. \S{config-logpalette} \q{Attempt to use \i{logical palettes}} diff --git a/doc/man-ptel.but b/doc/man-ptel.but index 08004f28..c0ee9c64 100644 --- a/doc/man-ptel.but +++ b/doc/man-ptel.but @@ -37,7 +37,7 @@ Sorry.) \dd Specify the font to use for bold text displayed in the terminal. If the \cw{BoldAsColour} resource is set to 1 (the default), bold text will be displayed in different colours instead of a different font, -so this option will be ignored. If \cw{BoldAsColour} is set to 0 +so this option will be ignored. If \cw{BoldAsColour} is set to 0 or 2 and you do not specify a bold font, \cw{puttytel} will overprint the normal font to make it look bolder. @@ -50,7 +50,7 @@ Chinese, Japanese and Korean text) displayed in the terminal. \dd Specify the font to use for bold double-width characters (typically Chinese, Japanese and Korean text). Like \cw{-fb}, this -will be ignored unless the \cw{BoldAsColour} resource is set to 0. +will be ignored unless the \cw{BoldAsColour} resource is set to 0 or 2. \dt \cw{\-geometry} \e{geometry} @@ -74,12 +74,12 @@ terminal. \dt \cw{\-bfg} \e{colour} \dd Specify the foreground colour to use for bold text, if the -\cw{BoldAsColour} resource is set to 1 (the default). +\cw{BoldAsColour} resource is set to 1 (the default) or 2. \dt \cw{\-bbg} \e{colour} \dd Specify the foreground colour to use for bold reverse-video text, if -the \cw{BoldAsColour} resource is set to 1 (the default). (This +the \cw{BoldAsColour} resource is set to 1 (the default) or 2. (This colour is best thought of as the bold version of the background colour; so it only appears when text is displayed \e{in} the background colour.) diff --git a/doc/man-pter.but b/doc/man-pter.but index df7b1728..a357e3e3 100644 --- a/doc/man-pter.but +++ b/doc/man-pter.but @@ -57,7 +57,7 @@ sets of defaults and choose between them. \dd Specify the font to use for bold text displayed in the terminal. If the \cw{BoldAsColour} resource is set to 1 (the default), bold text will be displayed in different colours instead of a different font, -so this option will be ignored. If \cw{BoldAsColour} is set to 0 +so this option will be ignored. If \cw{BoldAsColour} is set to 0 or 2 and you do not specify a bold font, \cw{pterm} will overprint the normal font to make it look bolder. @@ -70,7 +70,7 @@ Chinese, Japanese and Korean text) displayed in the terminal. \dd Specify the font to use for bold double-width characters (typically Chinese, Japanese and Korean text). Like \cw{-fb}, this -will be ignored unless the \cw{BoldAsColour} resource is set to 0. +will be ignored unless the \cw{BoldAsColour} resource is set to 0 or 2. \dt \cw{\-geometry} \e{geometry} @@ -94,12 +94,12 @@ terminal. \dt \cw{\-bfg} \e{colour} \dd Specify the foreground colour to use for bold text, if the -\cw{BoldAsColour} resource is set to 1 (the default). +\cw{BoldAsColour} resource is set to 1 (the default) or 2. \dt \cw{\-bbg} \e{colour} \dd Specify the foreground colour to use for bold reverse-video text, if -the \cw{BoldAsColour} resource is set to 1 (the default). (This +the \cw{BoldAsColour} resource is set to 1 (the default) or 2. (This colour is best thought of as the bold version of the background colour; so it only appears when text is displayed \e{in} the background colour.) @@ -498,7 +498,7 @@ controls the font used to display normal text. The default is \dd This resource is the same as the \cw{\-fb} command-line option: it controls the font used to display bold text when \cw{BoldAsColour} -is turned off. The default is unset (the font will be bolded by +is set to 0 or 2. The default is unset (the font will be bolded by printing it twice at a one-pixel offset). \dt \cw{pterm.WideFont} @@ -511,7 +511,7 @@ default is unset (double-width characters cannot be displayed). \dd This resource is the same as the \cw{\-fwb} command-line option: it controls the font used to display double-width characters in bold, -when \cw{BoldAsColour} is turned off. The default is unset +when \cw{BoldAsColour} is set to 0 or 2. The default is unset (double-width characters are displayed in bold by printing them twice at a one-pixel offset). @@ -529,10 +529,11 @@ than 1 (in one direction or the other). \dt \cw{pterm.BoldAsColour} -\dd This option should be set to either 0 or 1; the default is 1. It -specifies the default state of auto wrap mode. When set to 1, bold +\dd This option should be set to either 0, 1, or 2; the default is 1. +It specifies how bold text should be displayed. When set to 1, bold text is shown by displaying it in a brighter colour; when set to 0, -bold text is shown by displaying it in a heavier font. +bold text is shown by displaying it in a heavier font; when set to 2, +both effects happen at once (a heavy font \e{and} a brighter colour). \dt \cw{pterm.Colour0}, \cw{pterm.Colour1}, ..., \cw{pterm.Colour21} diff --git a/doc/man-putt.but b/doc/man-putt.but index 74c14b59..4c680121 100644 --- a/doc/man-putt.but +++ b/doc/man-putt.but @@ -37,7 +37,7 @@ Sorry.) If the \cw{BoldAsColour} resource is set to 1 (the default), bold text will be displayed in different colours instead of a different font, so this option will be ignored. If \cw{BoldAsColour} is set to -0 and you do not specify a bold font, \cw{putty} will overprint the +0 or 2 and you do not specify a bold font, \cw{putty} will overprint the normal font to make it look bolder. \dt \cw{\-fw} \e{font-name} @@ -49,7 +49,7 @@ Chinese, Japanese and Korean text) displayed in the terminal. \dd Specify the font to use for bold double-width characters (typically Chinese, Japanese and Korean text). Like \cw{-fb}, this -will be ignored unless the \cw{BoldAsColour} resource is set to 0. +will be ignored unless the \cw{BoldAsColour} resource is set to 0 or 2. \dt \cw{\-geometry} \e{geometry} @@ -73,12 +73,12 @@ terminal. \dt \cw{\-bfg} \e{colour} \dd Specify the foreground colour to use for bold text, if the -\cw{BoldAsColour} resource is set to 1 (the default). +\cw{BoldAsColour} resource is set to 1 (the default) or 2. \dt \cw{\-bbg} \e{colour} \dd Specify the foreground colour to use for bold reverse-video -text, if the \cw{BoldAsColour} resource is set to 1 (the default). +text, if the \cw{BoldAsColour} resource is set to 1 (the default) or 2. (This colour is best thought of as the bold version of the background colour; so it only appears when text is displayed \e{in} the background colour.) diff --git a/macosx/osxwin.m b/macosx/osxwin.m index 7c9118b8..169ae648 100644 --- a/macosx/osxwin.m +++ b/macosx/osxwin.m @@ -109,11 +109,11 @@ nfg = nbg; nbg = t; } - if (cfg.bold_colour && (attr & ATTR_BOLD)) { + if ((cfg.bold_style & 2) && (attr & ATTR_BOLD)) { if (nfg < 16) nfg |= 8; else if (nfg >= 256) nfg |= 1; } - if (cfg.bold_colour && (attr & ATTR_BLINK)) { + if ((cfg.bold_style & 2) && (attr & ATTR_BLINK)) { if (nbg < 16) nbg |= 8; else if (nbg >= 256) nbg |= 1; } @@ -129,7 +129,7 @@ widefactor = 1; } - /* FIXME: ATTR_BOLD without cfg.bold_colour */ + /* FIXME: ATTR_BOLD if cfg.bold_style & 1 */ if ((lattr & LATTR_MODE) != LATTR_NORM) { x *= 2; diff --git a/putty.h b/putty.h index 93b683e1..dcc80db5 100644 --- a/putty.h +++ b/putty.h @@ -791,7 +791,7 @@ void cleanup_exit(int); X(INT, NONE, xterm_256_colour) \ X(INT, NONE, system_colour) \ X(INT, NONE, try_palette) \ - X(INT, NONE, bold_colour) \ + X(INT, NONE, bold_style) \ X(INT, INT, colours) \ /* Selection options */ \ X(INT, NONE, mouse_is_xterm) \ diff --git a/settings.c b/settings.c index c189ad39..5d8f0c41 100644 --- a/settings.c +++ b/settings.c @@ -562,7 +562,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, "BoldAsColour", conf_get_int(conf, CONF_bold_colour)); + write_setting_i(sesskey, "BoldAsColour", conf_get_int(conf, CONF_bold_style)-1); for (i = 0; i < 22; i++) { char buf[20], buf2[30]; @@ -865,7 +865,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, "BoldAsColour", 1, conf, CONF_bold_colour); + i = gppi_raw(sesskey, "BoldAsColour", 0); conf_set_int(conf, CONF_bold_style, i+1); for (i = 0; i < 22; i++) { static const char *const defaults[] = { diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 616a69ad..550ec8c6 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -104,14 +104,14 @@ struct gui_data { guint32 input_event_time; /* Timestamp of the most recent input event. */ int reconfiguring; /* Cached things out of conf that we refer to a lot */ - int bold_colour; + int bold_style; int window_border; int cursor_type; }; static void cache_conf_values(struct gui_data *inst) { - inst->bold_colour = conf_get_int(inst->conf, CONF_bold_colour); + inst->bold_style = conf_get_int(inst->conf, CONF_bold_style); inst->window_border = conf_get_int(inst->conf, CONF_window_border); inst->cursor_type = conf_get_int(inst->conf, CONF_cursor_type); } @@ -2061,11 +2061,11 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, nfg = nbg; nbg = t; } - if (inst->bold_colour && (attr & ATTR_BOLD)) { + if ((inst->bold_style & 2) && (attr & ATTR_BOLD)) { if (nfg < 16) nfg |= 8; else if (nfg >= 256) nfg |= 1; } - if (inst->bold_colour && (attr & ATTR_BLINK)) { + if ((inst->bold_style & 2) && (attr & ATTR_BLINK)) { if (nbg < 16) nbg |= 8; else if (nbg >= 256) nbg |= 1; } @@ -2083,7 +2083,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, widefactor = 1; } - if ((attr & ATTR_BOLD) && !inst->bold_colour) { + if ((attr & ATTR_BOLD) && (inst->bold_style & 1)) { bold = 1; fontid |= 1; } else { diff --git a/windows/window.c b/windows/window.c index a0a52685..d970dd19 100644 --- a/windows/window.c +++ b/windows/window.c @@ -174,8 +174,9 @@ static HFONT fonts[FONT_MAXNO]; static LOGFONT lfont; static int fontflag[FONT_MAXNO]; static enum { - BOLD_COLOURS, BOLD_SHADOW, BOLD_FONT -} bold_mode; + BOLD_NONE, BOLD_SHADOW, BOLD_FONT +} bold_font_mode; +static int bold_colours; static enum { UND_LINE, UND_FONT } und_mode; @@ -1409,8 +1410,9 @@ static void init_fonts(int pick_width, int pick_height) for (i = 0; i < FONT_MAXNO; i++) fonts[i] = NULL; - bold_mode = conf_get_int(conf, CONF_bold_colour) ? - BOLD_COLOURS : BOLD_FONT; + bold_font_mode = conf_get_int(conf, CONF_bold_style) & 1 ? + BOLD_FONT : BOLD_NONE; + bold_colours = conf_get_int(conf, CONF_bold_style) & 2 ? TRUE : FALSE; und_mode = UND_FONT; font = conf_get_fontspec(conf, CONF_font); @@ -1535,7 +1537,7 @@ static void init_fonts(int pick_width, int pick_height) } } - if (bold_mode == BOLD_FONT) { + if (bold_font_mode == BOLD_FONT) { f(FONT_BOLD, font->charset, fw_bold, FALSE); } #undef f @@ -1562,9 +1564,9 @@ static void init_fonts(int pick_width, int pick_height) fonts[FONT_UNDERLINE] = 0; } - if (bold_mode == BOLD_FONT && + if (bold_font_mode == BOLD_FONT && fontsize[FONT_BOLD] != fontsize[FONT_NORMAL]) { - bold_mode = BOLD_SHADOW; + bold_font_mode = BOLD_SHADOW; DeleteObject(fonts[FONT_BOLD]); fonts[FONT_BOLD] = 0; } @@ -2333,8 +2335,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, conf_get_int(prev_conf, CONF_font_quality) || conf_get_int(conf, CONF_vtmode) != conf_get_int(prev_conf, CONF_vtmode) || - conf_get_int(conf, CONF_bold_colour) != - conf_get_int(prev_conf, CONF_bold_colour) || + conf_get_int(conf, CONF_bold_style) != + conf_get_int(prev_conf, CONF_bold_style) || resize_action == RESIZE_DISABLED || resize_action == RESIZE_EITHER || resize_action != conf_get_int(prev_conf, @@ -3323,6 +3325,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, int text_adjust = 0; int xoffset = 0; int maxlen, remaining, opaque; + int is_cursor = FALSE; static int *lpDx = NULL; static int lpDx_len = 0; int *lpDx_maybe; @@ -3346,11 +3349,9 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, if ((attr & TATTR_ACTCURS) && (cursor_type == 0 || term->big_cursor)) { attr &= ~(ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS); - if (bold_mode == BOLD_COLOURS) - attr &= ~ATTR_BOLD; - /* cursor fg and bg */ attr |= (260 << ATTR_FGSHIFT) | (261 << ATTR_BGSHIFT); + is_cursor = TRUE; } nfont = 0; @@ -3412,7 +3413,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT); nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT); - if (bold_mode == BOLD_FONT && (attr & ATTR_BOLD)) + if (bold_font_mode == BOLD_FONT && (attr & ATTR_BOLD)) nfont |= FONT_BOLD; if (und_mode == UND_FONT && (attr & ATTR_UNDER)) nfont |= FONT_UNDERLINE; @@ -3432,11 +3433,11 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, nfg = nbg; nbg = t; } - if (bold_mode == BOLD_COLOURS && (attr & ATTR_BOLD)) { + if (bold_colours && (attr & ATTR_BOLD) && !is_cursor) { if (nfg < 16) nfg |= 8; else if (nfg >= 256) nfg |= 1; } - if (bold_mode == BOLD_COLOURS && (attr & ATTR_BLINK)) { + if (bold_colours && (attr & ATTR_BLINK)) { if (nbg < 16) nbg |= 8; else if (nbg >= 256) nbg |= 1; } @@ -3586,7 +3587,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0), &line_box, uni_buf, nlen, lpDx_maybe); - if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) { + if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) { SetBkMode(hdc, TRANSPARENT); ExtTextOutW(hdc, x + xoffset - 1, y - font_height * (lattr == @@ -3611,7 +3612,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, y - font_height * (lattr == LATTR_BOT) + text_adjust, ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0), &line_box, directbuf, len, lpDx_maybe); - if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) { + if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) { SetBkMode(hdc, TRANSPARENT); /* GRR: This draws the character outside its box and @@ -3650,7 +3651,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, opaque && !(attr & TATTR_COMBINING)); /* And the shadow bold hack. */ - if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) { + if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) { SetBkMode(hdc, TRANSPARENT); ExtTextOutW(hdc, x + xoffset - 1, y - font_height * (lattr == @@ -4930,7 +4931,7 @@ void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des bgcolour = tmpcolour; } - if (bold_mode == BOLD_COLOURS && (attr[i] & ATTR_BOLD)) { + if (bold_colours && (attr[i] & ATTR_BOLD)) { if (fgcolour < 8) /* ANSI colours */ fgcolour += 8; else if (fgcolour >= 256) /* Default colours */ @@ -5021,7 +5022,7 @@ void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des bgcolour = tmpcolour; } - if (bold_mode == BOLD_COLOURS && (attr[tindex] & ATTR_BOLD)) { + if (bold_colours && (attr[tindex] & ATTR_BOLD)) { if (fgcolour < 8) /* ANSI colours */ fgcolour += 8; else if (fgcolour >= 256) /* Default colours */ @@ -5038,7 +5039,7 @@ void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des /* * Collect other attributes */ - if (bold_mode != BOLD_COLOURS) + if (bold_font_mode != BOLD_NONE) attrBold = attr[tindex] & ATTR_BOLD; else attrBold = 0; @@ -5057,7 +5058,7 @@ void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des bgcolour = -1; /* No coloring */ if (fgcolour >= 256) { /* Default colour */ - if (bold_mode == BOLD_COLOURS && (fgcolour & 1) && bgcolour == -1) + if (bold_colours && (fgcolour & 1) && bgcolour == -1) attrBold = ATTR_BOLD; /* Emphasize text with bold attribute */ fgcolour = -1; /* No coloring */ -- 2.11.0