term: Initial support for RGB
This commit is contained in:
parent
b2a390c4d5
commit
67498a6967
@ -523,6 +523,14 @@ void gterm_set_text_bg_bright(size_t bg) {
|
||||
text_bg = ansi_bright_colours[bg];
|
||||
}
|
||||
|
||||
void gterm_set_text_fg_rgb(uint32_t fg) {
|
||||
text_fg = fg;
|
||||
}
|
||||
|
||||
void gterm_set_text_bg_rgb(uint32_t bg) {
|
||||
text_bg = bg;
|
||||
}
|
||||
|
||||
void gterm_set_text_fg_default(void) {
|
||||
text_fg = default_fg;
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ void gterm_set_text_fg(size_t fg);
|
||||
void gterm_set_text_bg(size_t bg);
|
||||
void gterm_set_text_fg_bright(size_t fg);
|
||||
void gterm_set_text_bg_bright(size_t bg);
|
||||
void gterm_set_text_fg_rgb(uint32_t fg);
|
||||
void gterm_set_text_bg_rgb(uint32_t bg);
|
||||
void gterm_set_text_fg_default(void);
|
||||
void gterm_set_text_bg_default(void);
|
||||
bool gterm_scroll_disable(void);
|
||||
|
@ -56,6 +56,8 @@ void term_vbe(char *config, size_t width, size_t height) {
|
||||
set_text_bg = gterm_set_text_bg;
|
||||
set_text_fg_bright = gterm_set_text_fg_bright;
|
||||
set_text_bg_bright = gterm_set_text_bg_bright;
|
||||
set_text_fg_rgb = gterm_set_text_fg_rgb;
|
||||
set_text_bg_rgb = gterm_set_text_bg_rgb;
|
||||
set_text_fg_default = gterm_set_text_fg_default;
|
||||
set_text_bg_default = gterm_set_text_bg_default;
|
||||
scroll_disable = gterm_scroll_disable;
|
||||
@ -155,6 +157,8 @@ void term_textmode(void) {
|
||||
|
||||
term_reinit();
|
||||
|
||||
term_notready();
|
||||
|
||||
raw_putchar = text_putchar;
|
||||
clear = text_clear;
|
||||
enable_cursor = text_enable_cursor;
|
||||
@ -427,7 +431,40 @@ set_bg_bright:
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// 256/RGB
|
||||
else if (esc_values[i] == 38 || esc_values[i] == 48) {
|
||||
bool fg = esc_values[i] == 38;
|
||||
|
||||
i++;
|
||||
if (i >= esc_values_i) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (esc_values[i]) {
|
||||
case 2: { // RGB
|
||||
if (i + 3 >= esc_values_i) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
uint32_t rgb_value = 0;
|
||||
|
||||
rgb_value |= esc_values[i + 1] << 16;
|
||||
rgb_value |= esc_values[i + 2] << 8;
|
||||
rgb_value |= esc_values[i + 3];
|
||||
|
||||
i += 3;
|
||||
|
||||
fg ? set_text_fg_rgb(rgb_value) : set_text_bg_rgb(rgb_value);
|
||||
|
||||
break;
|
||||
}
|
||||
default: continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out:;
|
||||
}
|
||||
|
||||
static void dec_private_parse(uint8_t c) {
|
||||
|
@ -71,6 +71,8 @@ extern void (*set_text_fg)(size_t fg);
|
||||
extern void (*set_text_bg)(size_t bg);
|
||||
extern void (*set_text_fg_bright)(size_t fg);
|
||||
extern void (*set_text_bg_bright)(size_t bg);
|
||||
extern void (*set_text_fg_rgb)(uint32_t fg);
|
||||
extern void (*set_text_bg_rgb)(uint32_t bg);
|
||||
extern void (*set_text_fg_default)(void);
|
||||
extern void (*set_text_bg_default)(void);
|
||||
extern bool (*scroll_disable)(void);
|
||||
|
@ -22,6 +22,8 @@ void (*set_text_fg)(size_t fg);
|
||||
void (*set_text_bg)(size_t bg);
|
||||
void (*set_text_fg_bright)(size_t fg);
|
||||
void (*set_text_bg_bright)(size_t bg);
|
||||
void (*set_text_fg_rgb)(uint32_t fg);
|
||||
void (*set_text_bg_rgb)(uint32_t bg);
|
||||
void (*set_text_fg_default)(void);
|
||||
void (*set_text_bg_default)(void);
|
||||
bool (*scroll_disable)(void);
|
||||
@ -184,6 +186,9 @@ static void notready_move_character(size_t a, size_t b, size_t c, size_t d) {
|
||||
static uint64_t notready_context_size(void) {
|
||||
return 0;
|
||||
}
|
||||
static void notready_uint32_t(uint32_t n) {
|
||||
(void)n;
|
||||
}
|
||||
static void notready_uint64_t(uint64_t n) {
|
||||
(void)n;
|
||||
}
|
||||
@ -201,6 +206,8 @@ void term_notready(void) {
|
||||
set_text_bg = notready_size_t;
|
||||
set_text_fg_bright = notready_size_t;
|
||||
set_text_bg_bright = notready_size_t;
|
||||
set_text_fg_rgb = notready_uint32_t;
|
||||
set_text_bg_rgb = notready_uint32_t;
|
||||
set_text_fg_default = notready_void;
|
||||
set_text_bg_default = notready_void;
|
||||
scroll_disable = notready_disable;
|
||||
|
Loading…
Reference in New Issue
Block a user