xref: /freebsd/contrib/bsddialog/lib/bsddialog_theme.h (revision ca457394fccfc7d712cd9cc6a66e574767a0a32b)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2021 Alfonso Sabato Siciliano
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 
28 #ifndef _LIBBSDDIALOG_THEME_H_
29 #define _LIBBSDDIALOG_THEME_H_
30 
31 /* f_ focus/active element */
32 struct bsddialog_theme {
33 	struct {
34 		int color;
35 	} terminal;
36 	struct {
37 		int color;
38 		unsigned int h;
39 		unsigned int w;
40 	} shadow;
41 	struct {
42 		int  color;
43 		bool delimtitle;
44 		int  titlecolor;
45 		int  lineraisecolor;
46 		int  linelowercolor;
47 		int  bottomtitlecolor;
48 	} dialog;
49 	struct {
50 		unsigned int hmargin;
51 	} text;
52 	struct {
53 		int arrowcolor;
54 		int selectorcolor;
55 		int f_namecolor;
56 		int namecolor;
57 		int f_desccolor;
58 		int desccolor;
59 		int namesepcolor;
60 		int descsepcolor;
61 		int f_shortcutcolor;
62 		int shortcutcolor;
63 	} menu;
64 	struct {
65 		int f_fieldcolor;
66 		int fieldcolor;
67 		int readonlycolor;
68 	} form;
69 	struct {
70 		int f_color;
71 		int color;
72 	} bar;
73 	struct {
74 		unsigned int space;
75 		int leftch;
76 		int rightch;
77 		int delimcolor;
78 		int f_delimcolor;
79 		int color;
80 		int f_color;
81 		int shortcutcolor;
82 		int f_shortcutcolor;
83 	} button;
84 };
85 
86 enum bsddialog_default_theme {
87 	BSDDIALOG_THEME_BLACKWHITE,
88 	BSDDIALOG_THEME_BSDDIALOG,
89 	BSDDIALOG_THEME_DEFAULT,
90 	BSDDIALOG_THEME_DIALOG,
91 };
92 
93 enum bsddialog_color {
94 	BSDDIALOG_BLACK = 0,
95 	BSDDIALOG_RED,
96 	BSDDIALOG_GREEN,
97 	BSDDIALOG_YELLOW,
98 	BSDDIALOG_BLUE,
99 	BSDDIALOG_MAGENTA,
100 	BSDDIALOG_CYAN,
101 	BSDDIALOG_WHITE,
102 };
103 
104 #define BSDDIALOG_BOLD         1U
105 #define BSDDIALOG_REVERSE      2U
106 #define BSDDIALOG_UNDERLINE    4U
107 
108 int
109 bsddialog_color(enum bsddialog_color foreground,
110     enum bsddialog_color background, unsigned int flags);
111 int bsddialog_get_theme(struct bsddialog_theme *theme);
112 int bsddialog_set_default_theme(enum bsddialog_default_theme theme);
113 int bsddialog_set_theme(struct bsddialog_theme *theme);
114 
115 #endif
116