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