xref: /freebsd/stand/lua/color.lua.8 (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
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.Dd August 19, 2018
28.Dt COLOR.LUA 8
29.Os
30.Sh NAME
31.Nm color.lua
32.Nd FreeBSD color module
33.Sh DESCRIPTION
34.Nm
35contains functionality for working with colors.
36.Pp
37Before using the functionality provided by
38.Nm ,
39it must be included with a statement such as the following:
40.Pp
41.Dl local color = require("color")
42.Pp
43The following color constants are exported from
44.Nm :
45.Bl -tag -width "Ic color.MAGENTA" -offset indent
46.It Ic color.BLACK
47.It Ic color.RED
48.It Ic color.GREEN
49.It Ic color.YELLOW
50.It Ic color.BLUE
51.It Ic color.MAGENTA
52.It Ic color.CYAN
53.It Ic color.WHITE
54.El
55.Pp
56The following attribute constants are exported from
57.Nm :
58.Bl -tag -width "Ic color.DEFAULT" -offset indent
59.It Ic color.DEFAULT
60.It Ic color.BRIGHT
61.It Ic color.DIM
62.El
63.Pp
64The following functions are exported from
65.Nm :
66.Bl -tag -width "Fn color.isEnabled" -offset indent
67.It Fn color.isEnabled
68Returns True if
69.Xr loader 8
70has been configured to not allow color, False otherwise.
71This checks the
72.Ev loader_color
73.Xr loader.conf 5
74variable, along with
75.Fn core.isSerialBoot .
76.It Fn color.escapefg color_value
77Returns the escape sequence that encodes
78.Fa color_value
79as a foreground color.
80.Fn color.escapefg
81returns an empty string if color is disabled.
82.It Fn color.resetfg
83Returns the escape sequence for the default foreground color.
84.Fn color.resetfg
85returns an empty string if color is disabled.
86.It Fn color.escapebg color_value
87Returns the escape sequence that encodes
88.Fa color_value
89as a background color.
90.Fn color.escapebg
91returns an empty string if color is disabled.
92.It Fn color.resetbg
93Returns the escape sequence for the default background color.
94.Fn color.resetbg
95returns an empty string if color is disabled.
96.It Fn color.escape fg_color bg_color attribute
97Returns an escape sequence that encodes
98.Fa fg_color
99as the foreground color,
100.Fa bg_color
101as the background color, and
102.Fa attribute
103applied.
104.Fn color.escape
105returns an empty string if color is disabled.
106.It Fn color.default
107Returns the escape sequence for the default color scheme, white on black with
108no attributes applied.
109.Fn color.default
110returns an empty string if color is disabled.
111.It Fn color.highlight str
112Returns
113.Fa str
114with the
115.Ic color.BRIGHT
116attribute applied before it and reset after it.
117.Fn color.highlight
118returns
119.Fa str
120if color is disabled.
121.El
122.Sh SEE ALSO
123.Xr screen.lua 8
124.Sh AUTHORS
125The
126.Nm
127file was originally written by
128.An Pedro Souza Aq Mt pedrosouza@FreeBSD.org .
129Later work and this manual page was done by
130.An Kyle Evans Aq Mt kevans@FreeBSD.org .
131