:: commit b3c08f81227c361e92d300b5ae99fc3c9cda65d5

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

parents: fc6b69f0ac

term: Compatibility with latest terminal changes

diff --git a/common/drivers/vga_textmode.c b/common/drivers/vga_textmode.c
index fb13aa46..014c0f95 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;
 
@@ -342,6 +352,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 a2d0a495..4811fb73 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -366,6 +366,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;
@@ -638,6 +639,9 @@ bool gterm_init(struct fb_info **_fbs, size_t *_fbs_count,
     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);
@@ -648,6 +652,16 @@ bool gterm_init(struct fb_info **_fbs, size_t *_fbs_count,
         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) {
@@ -774,6 +788,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