From 2146200dfde612029303787d40d1f53581d77a37 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 21 May 2017 13:34:30 -0700 Subject: [PATCH 1/2] GUACAMOLE-280: Add support for faint (low) intensity SGR. --- src/terminal/display.c | 7 +++++++ src/terminal/terminal.c | 11 ++++++----- src/terminal/terminal/types.h | 6 ++++++ src/terminal/terminal_handlers.c | 8 +++++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/terminal/display.c b/src/terminal/display.c index cd9f6a6d..a1f37b3e 100644 --- a/src/terminal/display.c +++ b/src/terminal/display.c @@ -128,6 +128,13 @@ int __guac_terminal_set_colors(guac_terminal_display* display, display->glyph_foreground = *foreground; display->glyph_background = *background; + /* Modify color if half-bright (low intensity) */ + if (attributes->half_bright) { + display->glyph_foreground.red /= 2; + display->glyph_foreground.green /= 2; + display->glyph_foreground.blue /= 2; + } + return 0; } diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index 711a0fa8..bba95f06 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -296,11 +296,12 @@ guac_terminal* guac_terminal_create(guac_client* client, guac_terminal_char default_char = { .value = 0, .attributes = { - .foreground = guac_terminal_palette[default_foreground], - .background = guac_terminal_palette[default_background], - .bold = false, - .reverse = false, - .underscore = false + .foreground = guac_terminal_palette[default_foreground], + .background = guac_terminal_palette[default_background], + .bold = false, + .half_bright = false, + .reverse = false, + .underscore = false }, .width = 1 }; diff --git a/src/terminal/terminal/types.h b/src/terminal/terminal/types.h index 7d3cd537..0d054f8f 100644 --- a/src/terminal/terminal/types.h +++ b/src/terminal/terminal/types.h @@ -46,6 +46,12 @@ typedef struct guac_terminal_attributes { */ bool bold; + /** + * Whether the character should be rendered with half brightness (faint + * or low intensity). + */ + bool half_bright; + /** * Whether the character should be rendered with reversed colors * (background becomes foreground and vice-versa). diff --git a/src/terminal/terminal_handlers.c b/src/terminal/terminal_handlers.c index 55fd6824..e0be18f6 100644 --- a/src/terminal/terminal_handlers.c +++ b/src/terminal/terminal_handlers.c @@ -897,6 +897,10 @@ int guac_terminal_csi(guac_terminal* term, unsigned char c) { else if (value == 1) term->current_attributes.bold = true; + /* Faint (low intensity) */ + else if (value == 2) + term->current_attributes.half_bright = true; + /* Underscore on */ else if (value == 4) term->current_attributes.underscore = true; @@ -906,8 +910,10 @@ int guac_terminal_csi(guac_terminal* term, unsigned char c) { term->current_attributes.reverse = true; /* Normal intensity (not bold) */ - else if (value == 21 || value == 22) + else if (value == 21 || value == 22) { term->current_attributes.bold = false; + term->current_attributes.half_bright = false; + } /* Reset underscore */ else if (value == 24) From 9da27ad5785093d18bbe85f65c3a96e26ee21816 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 21 May 2017 13:48:10 -0700 Subject: [PATCH 2/2] GUACAMOLE-280: Ensure bold and half-bright attributes cancel each other out. --- src/terminal/display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/terminal/display.c b/src/terminal/display.c index a1f37b3e..de2cae5a 100644 --- a/src/terminal/display.c +++ b/src/terminal/display.c @@ -118,7 +118,7 @@ int __guac_terminal_set_colors(guac_terminal_display* display, } /* Handle bold */ - if (attributes->bold + if (attributes->bold && !attributes->half_bright && foreground->palette_index >= GUAC_TERMINAL_FIRST_DARK && foreground->palette_index <= GUAC_TERMINAL_LAST_DARK) { foreground = &guac_terminal_palette[foreground->palette_index @@ -129,7 +129,7 @@ int __guac_terminal_set_colors(guac_terminal_display* display, display->glyph_background = *background; /* Modify color if half-bright (low intensity) */ - if (attributes->half_bright) { + if (attributes->half_bright && !attributes->bold) { display->glyph_foreground.red /= 2; display->glyph_foreground.green /= 2; display->glyph_foreground.blue /= 2;