Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Mar 2018 16:04:13 -0700
From:      Devin Teske <dteske@freebsd.org>
To:        Kyle Evans <kevans@FreeBSD.org>
Cc:        Devin Teske <dteske@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r331259 - head/stand/lua
Message-ID:  <401EA542-5E2B-4342-B098-7C8D78FAD721@freebsd.org>
In-Reply-To: <201803202026.w2KKQOP2036471@repo.freebsd.org>
References:  <201803202026.w2KKQOP2036471@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

> On Mar 20, 2018, at 1:26 PM, Kyle Evans <kevans@FreeBSD.org> wrote:
>=20
> Author: kevans
> Date: Tue Mar 20 20:26:24 2018
> New Revision: 331259
> URL: https://svnweb.freebsd.org/changeset/base/331259
>=20
> Log:
>  lualoader: Use less atomic options for resetting colors/attributes
>=20
>  Noted by dteske:
>=20
>  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
>=20
>  - Provide resetf/resetb to match escapef/escapeb
>  - Use CSI 22m to undo a bold
>=20
>  This is a more reasonable approach than what was previously taken.
>=20
>  Reported by:	dteske
>=20
> Modified:
>  head/stand/lua/color.lua
>  head/stand/lua/menu.lua
>=20
> Modified: head/stand/lua/color.lua
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- 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
>=20
> +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
>=20
> +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
>=20
> return color
>=20
> Modified: head/stand/lua/menu.lua
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- 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 =3D {
> 					name_color =3D =
color.escapef(color.BLUE)
> 				end
> 				bootenv_name =3D 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 =3D {
> 					name_color =3D =
color.escapef(color.BLUE)
> 				end
> 				kernel_name =3D kernel_name .. =
name_color ..
> -				    choice .. color.default()
> +				    choice .. color.resetf()
> 				return color.highlight("K") .. "ernel: " =
..
> 				    kernel_name .. " (" .. idx .. " of " =
..
> 				    #all_choices .. ")"
>=20


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).
--=20
Devin=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?401EA542-5E2B-4342-B098-7C8D78FAD721>