:: commit 72f074bfc21a19c27b2dfa1a8ebc4e06861113b4

mintsuki <mintsuki@protonmail.com> — 2022-12-14 15:19

parents: e1c0d71b97

term: Compatibility with latest terminal changes

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);
tab: 248 wrap: offon