From a04022883caaa616e4ae5334a5beccf079043a4b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 23 Apr 2017 17:32:33 -0700 Subject: [PATCH] GUACAMOLE-278: Provide constants defining locations of dark vs. intense colors in 16-color palette. --- src/terminal/display.c | 8 +++++--- src/terminal/terminal/palette.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/terminal/display.c b/src/terminal/display.c index 8d2b1311..cd9f6a6d 100644 --- a/src/terminal/display.c +++ b/src/terminal/display.c @@ -118,9 +118,11 @@ int __guac_terminal_set_colors(guac_terminal_display* display, } /* Handle bold */ - if (attributes->bold && foreground->palette_index >= 0 - && foreground->palette_index <= 7) { - foreground = &guac_terminal_palette[foreground->palette_index + 8]; + if (attributes->bold + && foreground->palette_index >= GUAC_TERMINAL_FIRST_DARK + && foreground->palette_index <= GUAC_TERMINAL_LAST_DARK) { + foreground = &guac_terminal_palette[foreground->palette_index + + GUAC_TERMINAL_INTENSE_OFFSET]; } display->glyph_foreground = *foreground; diff --git a/src/terminal/terminal/palette.h b/src/terminal/terminal/palette.h index 10163688..b18038fb 100644 --- a/src/terminal/terminal/palette.h +++ b/src/terminal/terminal/palette.h @@ -105,6 +105,36 @@ */ #define GUAC_TERMINAL_COLOR_WHITE 15 +/** + * The index of the first low-intensity color in the 16-color portion of the + * palette. + */ +#define GUAC_TERMINAL_FIRST_DARK 0 + +/** + * The index of the last low-intensity color in the 16-color portion of the + * palette. + */ +#define GUAC_TERMINAL_LAST_DARK 7 + +/** + * The index of the first high-intensity color in the 16-color portion of the + * palette. + */ +#define GUAC_TERMINAL_FIRST_INTENSE 8 + +/** + * The index of the last high-intensity color in the 16-color portion of the + * palette. + */ +#define GUAC_TERMINAL_LAST_INTENSE 15 + +/** + * The distance between the palette indices of the dark colors (0 through 7) + * and the bright colors (8 - 15) in the 16-color portion of the palette. + */ +#define GUAC_TERMINAL_INTENSE_OFFSET 8 + /** * An RGB color, where each component ranges from 0 to 255. */