svn commit: r331259 - head/stand/lua

Devin Teske dteske at freebsd.org
Tue Mar 20 23:04:16 UTC 2018


> On Mar 20, 2018, at 1:26 PM, Kyle Evans <kevans at FreeBSD.org> wrote:
> 
> Author: kevans
> Date: Tue Mar 20 20:26:24 2018
> New Revision: 331259
> URL: https://svnweb.freebsd.org/changeset/base/331259
> 
> Log:
>  lualoader: Use less atomic options for resetting colors/attributes
> 
>  Noted by dteske:
> 
>  CSI 1m ... CSI 22m
>  CSI 2m ... CSI 22m
>  CSI 4m ... CSI 24m
>  CSI 5m ... CSI 25m
>  CSI 7m ... CSI 27m
>  CSI 8m ... CSI 28m
>  CSI (30-37)m ... CSI 39m
>  CSI (40-47)m ... CSI 49m
> 
>  - Provide resetf/resetb to match escapef/escapeb
>  - Use CSI 22m to undo a bold
> 
>  This is a more reasonable approach than what was previously taken.
> 
>  Reported by:	dteske
> 
> Modified:
>  head/stand/lua/color.lua
>  head/stand/lua/menu.lua
> 
> Modified: head/stand/lua/color.lua
> ==============================================================================
> --- head/stand/lua/color.lua	Tue Mar 20 20:20:49 2018	(r331258)
> +++ head/stand/lua/color.lua	Tue Mar 20 20:26:24 2018	(r331259)
> @@ -65,6 +65,13 @@ function color.escapef(color_value)
> 	return core.KEYSTR_CSI .. "3" .. color_value .. "m"
> end
> 
> +function color.resetf()
> +	if color.disabled then
> +		return ''
> +	end
> +	return core.KEYSTR_CSI .. "39m"
> +end
> +
> function color.escapeb(color_value)
> 	if color.disabled then
> 		return color_value
> @@ -72,6 +79,13 @@ function color.escapeb(color_value)
> 	return core.KEYSTR_CSI .. "4" .. color_value .. "m"
> end
> 
> +function color.resetb()
> +	if color.disabled then
> +		return ''
> +	end
> +	return core.KEYSTR_CSI .. "49m"
> +end
> +
> function color.escape(fg_color, bg_color, attribute)
> 	if color.disabled then
> 		return ""
> @@ -98,7 +112,7 @@ function color.highlight(str)
> 	end
> 	-- We need to reset attributes as well as color scheme here, just in
> 	-- case the terminal defaults don't match what we're expecting.
> -	return core.KEYSTR_CSI .. "1m" .. str .. color.default()
> +	return core.KEYSTR_CSI .. "1m" .. str .. core.KEYSTR_CSI .. "22m"
> end
> 
> return color
> 
> Modified: head/stand/lua/menu.lua
> ==============================================================================
> --- head/stand/lua/menu.lua	Tue Mar 20 20:20:49 2018	(r331258)
> +++ head/stand/lua/menu.lua	Tue Mar 20 20:26:24 2018	(r331259)
> @@ -120,7 +120,7 @@ menu.boot_environments = {
> 					name_color = color.escapef(color.BLUE)
> 				end
> 				bootenv_name = bootenv_name .. name_color ..
> -				    choice .. color.default()
> +				    choice .. color.resetf()
> 				return color.highlight("A").."ctive: " ..
> 				    bootenv_name .. " (" .. idx .. " of " ..
> 				    #all_choices .. ")"
> @@ -306,7 +306,7 @@ menu.welcome = {
> 					name_color = color.escapef(color.BLUE)
> 				end
> 				kernel_name = kernel_name .. name_color ..
> -				    choice .. color.default()
> +				    choice .. color.resetf()
> 				return color.highlight("K") .. "ernel: " ..
> 				    kernel_name .. " (" .. idx .. " of " ..
> 				    #all_choices .. ")"
> 


Minor nit ...

While resetf is unlikely to be mistaken for anything other than "reset foreground", ...

"resetb" could easily be mistaken for "reset bold".

I would like to suggest, in tradition, that resetf/resetb be renamed to resetfg/resetbg

You know... should you want to add a "resetb" later that actually resets bold (e.g., if you have to use CSI 22m in more than one place).
-- 
Devin


More information about the svn-src-head mailing list