kernel: terminal_init() should check for teken colors from kenv
Check for teken.fg_color and teken.bg_color and prepare the color attributes accordingly. When white background is used, make it light to improve visibility. When black background is used, make kernel messages light.
This commit is contained in:
parent
8f60fde790
commit
ff5d84bffd
@ -124,13 +124,13 @@ static teken_funcs_t terminal_drawmethods = {
|
||||
};
|
||||
|
||||
/* Kernel message formatting. */
|
||||
static const teken_attr_t kernel_message = {
|
||||
static teken_attr_t kernel_message = {
|
||||
.ta_fgcolor = TCHAR_FGCOLOR(TERMINAL_KERN_ATTR),
|
||||
.ta_bgcolor = TCHAR_BGCOLOR(TERMINAL_KERN_ATTR),
|
||||
.ta_format = TCHAR_FORMAT(TERMINAL_KERN_ATTR)
|
||||
};
|
||||
|
||||
static const teken_attr_t default_message = {
|
||||
static teken_attr_t default_message = {
|
||||
.ta_fgcolor = TCHAR_FGCOLOR(TERMINAL_NORM_ATTR),
|
||||
.ta_bgcolor = TCHAR_BGCOLOR(TERMINAL_NORM_ATTR),
|
||||
.ta_format = TCHAR_FORMAT(TERMINAL_NORM_ATTR)
|
||||
@ -168,10 +168,33 @@ static const teken_attr_t default_message = {
|
||||
static void
|
||||
terminal_init(struct terminal *tm)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if (tm->tm_flags & TF_CONS)
|
||||
mtx_init(&tm->tm_mtx, "trmlck", NULL, MTX_SPIN);
|
||||
|
||||
teken_init(&tm->tm_emulator, &terminal_drawmethods, tm);
|
||||
|
||||
TUNABLE_INT_FETCH("teken.fg_color", &fg);
|
||||
TUNABLE_INT_FETCH("teken.bg_color", &bg);
|
||||
|
||||
if (fg != -1) {
|
||||
default_message.ta_fgcolor = fg;
|
||||
kernel_message.ta_fgcolor = fg;
|
||||
}
|
||||
if (bg != -1) {
|
||||
default_message.ta_bgcolor = bg;
|
||||
kernel_message.ta_bgcolor = bg;
|
||||
}
|
||||
|
||||
if (default_message.ta_bgcolor == TC_WHITE) {
|
||||
default_message.ta_bgcolor |= TC_LIGHT;
|
||||
kernel_message.ta_bgcolor |= TC_LIGHT;
|
||||
}
|
||||
|
||||
if (default_message.ta_bgcolor == TC_BLACK &&
|
||||
default_message.ta_fgcolor < TC_NCOLORS)
|
||||
kernel_message.ta_fgcolor |= TC_LIGHT;
|
||||
teken_set_defattr(&tm->tm_emulator, &default_message);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user