xref: /freebsd/stand/lua/color.lua.8 (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3.\"
4.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
29.Dd August 19, 2018
30.Dt COLOR.LUA 8
31.Os
32.Sh NAME
33.Nm color.lua
34.Nd FreeBSD color module
35.Sh DESCRIPTION
36.Nm
37contains functionality for working with colors.
38.Pp
39Before using the functionality provided by
40.Nm ,
41it must be included with a statement such as the following:
42.Pp
43.Dl local color = require("color")
44.Pp
45The following color constants are exported from
46.Nm :
47.Bl -tag -width "Ic color.MAGENTA" -offset indent
48.It Ic color.BLACK
49.It Ic color.RED
50.It Ic color.GREEN
51.It Ic color.YELLOW
52.It Ic color.BLUE
53.It Ic color.MAGENTA
54.It Ic color.CYAN
55.It Ic color.WHITE
56.El
57.Pp
58The following attribute constants are exported from
59.Nm :
60.Bl -tag -width "Ic color.DEFAULT" -offset indent
61.It Ic color.DEFAULT
62.It Ic color.BRIGHT
63.It Ic color.DIM
64.El
65.Pp
66The following functions are exported from
67.Nm :
68.Bl -tag -width "Fn color.isEnabled" -offset indent
69.It Fn color.isEnabled
70Returns True if
71.Xr loader 8
72has been configured to not allow color, False otherwise.
73This checks the
74.Ev loader_color
75.Xr loader.conf 5
76variable, along with
77.Fn core.isSerialBoot .
78.It Fn color.escapefg color_value
79Returns the escape sequence that encodes
80.Fa color_value
81as a foreground color.
82.Fn color.escapefg
83returns an empty string if color is disabled.
84.It Fn color.resetfg
85Returns the escape sequence for the default foreground color.
86.Fn color.resetfg
87returns an empty string if color is disabled.
88.It Fn color.escapebg color_value
89Returns the escape sequence that encodes
90.Fa color_value
91as a background color.
92.Fn color.escapebg
93returns an empty string if color is disabled.
94.It Fn color.resetbg
95Returns the escape sequence for the default background color.
96.Fn color.resetbg
97returns an empty string if color is disabled.
98.It Fn color.escape fg_color bg_color attribute
99Returns an escape sequence that encodes
100.Fa fg_color
101as the foreground color,
102.Fa bg_color
103as the background color, and
104.Fa attribute
105applied.
106.Fn color.escape
107returns an empty string if color is disabled.
108.It Fn color.default
109Returns the escape sequence for the default color scheme, white on black with
110no attributes applied.
111.Fn color.default
112returns an empty string if color is disabled.
113.It Fn color.highlight str
114Returns
115.Fa str
116with the
117.Ic color.BRIGHT
118attribute applied before it and reset after it.
119.Fn color.highlight
120returns
121.Fa str
122if color is disabled.
123.El
124.Sh SEE ALSO
125.Xr screen.lua 8
126.Sh AUTHORS
127The
128.Nm
129file was originally written by
130.An Pedro Souza Aq Mt pedrosouza@FreeBSD.org .
131Later work and this manual page was done by
132.An Kyle Evans Aq Mt kevans@FreeBSD.org .
133