From 042a07592319a0ddbbf3f300115064a1f43f9731 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 14 Dec 2022 16:19:23 +0100 Subject: [PATCH] term: Compatibility with latest terminal changes --- common/drivers/vga_textmode.c | 12 ++++++++++++ common/lib/gterm.c | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/common/drivers/vga_textmode.c b/common/drivers/vga_textmode.c index fbc517b9..7833337b 100644 --- a/common/drivers/vga_textmode.c +++ b/common/drivers/vga_textmode.c @@ -218,6 +218,16 @@ static void text_set_text_bg_default(struct term_context *_ctx) { ctx->text_palette &= 0x0f; } +static void text_set_text_fg_default_bright(struct term_context *_ctx) { + struct textmode_context *ctx = (void *)_ctx; + ctx->text_palette = (ctx->text_palette & 0xf0) | (7 | (1 << 3)); +} + +static void text_set_text_bg_default_bright(struct term_context *_ctx) { + struct textmode_context *ctx = (void *)_ctx; + ctx->text_palette = (ctx->text_palette & 0x0f) | ((1 << 3) << 4); +} + static void text_putchar(struct term_context *_ctx, uint8_t c) { struct textmode_context *ctx = (void *)_ctx; @@ -338,6 +348,8 @@ void vga_textmode_init(bool managed) { term->set_text_bg_rgb = text_set_text_bg_rgb; term->set_text_fg_default = text_set_text_fg_default; term->set_text_bg_default = text_set_text_bg_default; + term->set_text_fg_default_bright = text_set_text_fg_default_bright; + term->set_text_bg_default_bright = text_set_text_bg_default_bright; term->move_character = text_move_character; term->scroll = text_scroll; term->revscroll = text_revscroll; diff --git a/common/lib/gterm.c b/common/lib/gterm.c index 7a11da59..3c5ca71c 100644 --- a/common/lib/gterm.c +++ b/common/lib/gterm.c @@ -368,6 +368,7 @@ static size_t margin = 64; static size_t margin_gradient = 4; static uint32_t default_bg, default_fg; +static uint32_t default_bg_bright, default_fg_bright; static size_t bg_canvas_size; static uint32_t *bg_canvas; @@ -663,6 +664,9 @@ bool gterm_init(char *config, size_t width, size_t height) { default_bg = 0x00000000; // background (black) default_fg = 0x00aaaaaa; // foreground (grey) + default_bg_bright = 0x00555555; // background (black) + default_fg_bright = 0x00ffffff; // foreground (grey) + char *theme_background = config_get_value(config, 0, "TERM_BACKGROUND"); if (theme_background != NULL) { default_bg = strtoui(theme_background, NULL, 16); @@ -673,6 +677,16 @@ bool gterm_init(char *config, size_t width, size_t height) { default_fg = strtoui(theme_foreground, NULL, 16) & 0xffffff; } + char *theme_background_bright = config_get_value(config, 0, "TERM_BACKGROUND_BRIGHT"); + if (theme_background_bright != NULL) { + default_bg_bright = strtoui(theme_background_bright, NULL, 16); + } + + char *theme_foreground_bright = config_get_value(config, 0, "TERM_FOREGROUND_BRIGHT"); + if (theme_foreground_bright != NULL) { + default_fg_bright = strtoui(theme_foreground_bright, NULL, 16); + } + background = NULL; char *background_path = config_get_value(config, 0, "TERM_WALLPAPER"); if (background_path != NULL) { @@ -783,6 +797,7 @@ no_load_font:; bg_canvas, ansi_colours, ansi_bright_colours, &default_bg, &default_fg, + &default_bg_bright, &default_fg_bright, font, font_width, font_height, font_spacing, font_scale_x, font_scale_y, margin);