svn commit: r352680 - head/sys/kern
Toomas Soome
tsoome at FreeBSD.org
Wed Sep 25 13:21:08 UTC 2019
Author: tsoome
Date: Wed Sep 25 13:21:07 2019
New Revision: 352680
URL: https://svnweb.freebsd.org/changeset/base/352680
Log:
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.
Modified:
head/sys/kern/subr_terminal.c
Modified: head/sys/kern/subr_terminal.c
==============================================================================
--- head/sys/kern/subr_terminal.c Wed Sep 25 13:04:34 2019 (r352679)
+++ head/sys/kern/subr_terminal.c Wed Sep 25 13:21:07 2019 (r352680)
@@ -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);
}
More information about the svn-src-all
mailing list