term: Compatibility with latest terminal changes

This commit is contained in:
mintsuki 2022-12-14 16:19:23 +01:00
parent e1c0d71b97
commit 72f074bfc2
2 changed files with 27 additions and 0 deletions

View File

@ -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;

View File

@ -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);