Date: Fri, 25 Oct 2019 00:47:38 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354059 - in stable: 11/stand/lua 12/stand/lua Message-ID: <201910250047.x9P0lcU2001922@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Fri Oct 25 00:47:37 2019 New Revision: 354059 URL: https://svnweb.freebsd.org/changeset/base/354059 Log: MFC r353872-r353873: lualoader color handling fixes r353872: lualoader: don't botch disabling of color When colors are disabled, color.escape{fg,bg} would return the passed in color rather than the proper ANSI sequence for the color. color.escape{fg,bg} would be wrong. Instead return '', as the associated reset* functions will also return ''. This should get rid of the funky '2' and '4' in the kernel selector if you're booting serial. r353873: lualoader: fix setting of loader_color=NO in loader.conf(5) Previously color.disabled would be calculated at color module load time, then never touched again. We can detect serial boots beyond just what we're told by loader.conf(5) so this works out in many cases, but we must re-evaluate the situation after the config is loaded to make sure we're not supposed to be forcing it enabled/disabled. Discovered while trying to test r353872. Modified: stable/11/stand/lua/color.lua stable/11/stand/lua/screen.lua Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/stand/lua/color.lua stable/12/stand/lua/screen.lua Directory Properties: stable/12/ (props changed) Modified: stable/11/stand/lua/color.lua ============================================================================== --- stable/11/stand/lua/color.lua Fri Oct 25 00:16:57 2019 (r354058) +++ stable/11/stand/lua/color.lua Fri Oct 25 00:47:37 2019 (r354059) @@ -29,9 +29,14 @@ -- local core = require("core") +local hook = require("hook") local color = {} +local function recalcDisabled() + color.disabled = not color.isEnabled() +end + -- Module exports color.BLACK = 0 color.RED = 1 @@ -54,11 +59,9 @@ function color.isEnabled() return not core.isSerialBoot() end -color.disabled = not color.isEnabled() - function color.escapefg(color_value) if color.disabled then - return color_value + return '' end return core.KEYSTR_CSI .. "3" .. color_value .. "m" end @@ -72,7 +75,7 @@ end function color.escapebg(color_value) if color.disabled then - return color_value + return '' end return core.KEYSTR_CSI .. "4" .. color_value .. "m" end @@ -112,5 +115,8 @@ function color.highlight(str) -- case the terminal defaults don't match what we're expecting. return core.KEYSTR_CSI .. "1m" .. str .. core.KEYSTR_CSI .. "22m" end + +recalcDisabled() +hook.register("config.loaded", recalcDisabled) return color Modified: stable/11/stand/lua/screen.lua ============================================================================== --- stable/11/stand/lua/screen.lua Fri Oct 25 00:16:57 2019 (r354058) +++ stable/11/stand/lua/screen.lua Fri Oct 25 00:47:37 2019 (r354059) @@ -47,14 +47,14 @@ end function screen.setforeground(color_value) if color.disabled then - return color_value + return end printc(color.escapefg(color_value)) end function screen.setbackground(color_value) if color.disabled then - return color_value + return end printc(color.escapebg(color_value)) end
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910250047.x9P0lcU2001922>