diff --git a/putty.h b/putty.h index f89d0709..a9433fa7 100644 --- a/putty.h +++ b/putty.h @@ -104,15 +104,16 @@ typedef struct terminal_tag Terminal; */ #define UCSWIDE 0xDFFF -#define ATTR_NARROW 0x800000U -#define ATTR_WIDE 0x400000U -#define ATTR_BOLD 0x040000U -#define ATTR_UNDER 0x080000U -#define ATTR_REVERSE 0x100000U -#define ATTR_BLINK 0x200000U -#define ATTR_FGMASK 0x0001FFU -#define ATTR_BGMASK 0x03FE00U -#define ATTR_COLOURS 0x03FFFFU +#define ATTR_NARROW 0x0800000U +#define ATTR_WIDE 0x0400000U +#define ATTR_BOLD 0x0040000U +#define ATTR_UNDER 0x0080000U +#define ATTR_REVERSE 0x0100000U +#define ATTR_BLINK 0x0200000U +#define ATTR_FGMASK 0x00001FFU +#define ATTR_BGMASK 0x003FE00U +#define ATTR_COLOURS 0x003FFFFU +#define ATTR_DIM 0x1000000U #define ATTR_FGSHIFT 0 #define ATTR_BGSHIFT 9 diff --git a/terminal.c b/terminal.c index 0fa52e17..de5748e9 100644 --- a/terminal.c +++ b/terminal.c @@ -3881,6 +3881,10 @@ static void term_out(Terminal *term) compatibility(VT100AVO); term->curr_attr |= ATTR_BOLD; break; + case 2: /* enable dim */ + compatibility(OTHER); + term->curr_attr |= ATTR_DIM; + break; case 21: /* (enable double underline) */ compatibility(OTHER); case 4: /* enable underline */ @@ -3912,9 +3916,9 @@ static void term_out(Terminal *term) compatibility(SCOANSI); if (term->no_remote_charset) break; term->sco_acs = 2; break; - case 22: /* disable bold */ + case 22: /* disable bold and dim */ compatibility2(OTHER, VT220); - term->curr_attr &= ~ATTR_BOLD; + term->curr_attr &= ~(ATTR_BOLD | ATTR_DIM); break; case 24: /* disable underline */ compatibility2(OTHER, VT220); diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 969c42ff..5c629519 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -3023,24 +3023,44 @@ static void draw_update(struct draw_ctx *dctx, int x, int y, int w, int h) gtk_widget_queue_draw_area(dctx->inst->area, x, y, w, h); } -static void draw_set_colour(struct draw_ctx *dctx, int col) +#ifdef DRAW_TEXT_CAIRO +static void cairo_set_source_rgb_dim(cairo_t *cr, double r, double g, double b, + int dim) +{ + if (dim) + cairo_set_source_rgb(cr, r * 2 / 3, g * 2 / 3, b * 2 / 3); + else + cairo_set_source_rgb(cr, r, g, b); +} +#endif + +static void draw_set_colour(struct draw_ctx *dctx, int col, int dim) { #ifdef DRAW_TEXT_GDK if (dctx->uctx.type == DRAWTYPE_GDK) { - gdk_gc_set_foreground(dctx->uctx.u.gdk.gc, &dctx->inst->cols[col]); + if (dim) { + GdkColor color; + color.red = dctx->inst->cols[col].red * 2 / 3; + color.green = dctx->inst->cols[col].green * 2 / 3; + color.blue = dctx->inst->cols[col].blue * 2 / 3; + gdk_gc_set_rgb_fg_color(dctx->uctx.u.gdk.gc, &color); + } else { + gdk_gc_set_foreground(dctx->uctx.u.gdk.gc, &dctx->inst->cols[col]); + } } #endif #ifdef DRAW_TEXT_CAIRO if (dctx->uctx.type == DRAWTYPE_CAIRO) { - cairo_set_source_rgb(dctx->uctx.u.cairo.cr, - dctx->inst->cols[col].red / 65535.0, - dctx->inst->cols[col].green / 65535.0, - dctx->inst->cols[col].blue / 65535.0); + cairo_set_source_rgb_dim(dctx->uctx.u.cairo.cr, + dctx->inst->cols[col].red / 65535.0, + dctx->inst->cols[col].green / 65535.0, + dctx->inst->cols[col].blue / 65535.0, dim); } #endif } -static void draw_set_colour_rgb(struct draw_ctx *dctx, optionalrgb orgb) +static void draw_set_colour_rgb(struct draw_ctx *dctx, optionalrgb orgb, + int dim) { #ifdef DRAW_TEXT_GDK if (dctx->uctx.type == DRAWTYPE_GDK) { @@ -3048,13 +3068,19 @@ static void draw_set_colour_rgb(struct draw_ctx *dctx, optionalrgb orgb) color.red = orgb.r * 256; color.green = orgb.g * 256; color.blue = orgb.b * 256; + if (dim) { + color.red = color.red * 2 / 3; + color.green = color.green * 2 / 3; + color.blue = color.blue * 2 / 3; + } gdk_gc_set_rgb_fg_color(dctx->uctx.u.gdk.gc, &color); } #endif #ifdef DRAW_TEXT_CAIRO - if (dctx->uctx.type == DRAWTYPE_CAIRO) - cairo_set_source_rgb(dctx->uctx.u.cairo.cr, - orgb.r / 255.0, orgb.g / 255.0, orgb.b / 255.0); + if (dctx->uctx.type == DRAWTYPE_CAIRO) { + cairo_set_source_rgb_dim(dctx->uctx.u.cairo.cr, orgb.r / 255.0, + orgb.g / 255.0, orgb.b / 255.0, dim); + } #endif } @@ -3238,7 +3264,7 @@ static void draw_backing_rect(struct gui_data *inst) struct draw_ctx *dctx = get_ctx(inst); int w = inst->width * inst->font_width + 2*inst->window_border; int h = inst->height * inst->font_height + 2*inst->window_border; - draw_set_colour(dctx, 258); + draw_set_colour(dctx, 258, FALSE); draw_rectangle(dctx, 1, 0, 0, w, h); draw_update(dctx, 0, 0, w, h); free_ctx(dctx); @@ -3288,6 +3314,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, truecolour.fg = truecolour.bg = optionalrgb_none; nfg = 260; nbg = 261; + attr &= ~ATTR_DIM; /* don't dim the cursor */ } fontid = shadow = 0; @@ -3350,18 +3377,18 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, } if (truecolour.bg.enabled) - draw_set_colour_rgb(dctx, truecolour.bg); + draw_set_colour_rgb(dctx, truecolour.bg, attr & ATTR_DIM); else - draw_set_colour(dctx, nbg); + draw_set_colour(dctx, nbg, attr & ATTR_DIM); draw_rectangle(dctx, TRUE, x*inst->font_width+inst->window_border, y*inst->font_height+inst->window_border, rlen*widefactor*inst->font_width, inst->font_height); if (truecolour.fg.enabled) - draw_set_colour_rgb(dctx, truecolour.fg); + draw_set_colour_rgb(dctx, truecolour.fg, attr & ATTR_DIM); else - draw_set_colour(dctx, nfg); + draw_set_colour(dctx, nfg, attr & ATTR_DIM); if (ncombining > 1) { assert(len == 1); unifont_draw_combining(&dctx->uctx, inst->fonts[fontid], @@ -3475,7 +3502,7 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len, * if it's passive. */ if (passive) { - draw_set_colour(dctx, 261); + draw_set_colour(dctx, 261, FALSE); draw_rectangle(dctx, FALSE, x*inst->font_width+inst->window_border, y*inst->font_height+inst->window_border, @@ -3514,7 +3541,7 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len, length = inst->font_height; } - draw_set_colour(dctx, 261); + draw_set_colour(dctx, 261, FALSE); if (passive) { for (i = 0; i < length; i++) { if (i % 2 == 0) { diff --git a/windows/window.c b/windows/window.c index aa96a578..be7b4379 100644 --- a/windows/window.c +++ b/windows/window.c @@ -3440,7 +3440,7 @@ 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)) { truecolour.fg = truecolour.bg = optionalrgb_none; - attr &= ~(ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS); + attr &= ~(ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS|ATTR_DIM); /* cursor fg and bg */ attr |= (260 << ATTR_FGSHIFT) | (261 << ATTR_BGSHIFT); is_cursor = TRUE; @@ -3543,6 +3543,12 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, else bg = colours[nbg]; + if (!pal && (attr & ATTR_DIM)) { + fg = RGB(GetRValue(fg) * 2 / 3, + GetGValue(fg) * 2 / 3, + GetBValue(fg) * 2 / 3); + } + SelectObject(hdc, fonts[nfont]); SetTextColor(hdc, fg); SetBkColor(hdc, bg);