Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/bsddialog/examples_library/theme.c
39476 views
1
/*-
2
* SPDX-License-Identifier: CC0-1.0
3
*
4
* Written in 2021 by Alfonso Sabato Siciliano.
5
* To the extent possible under law, the author has dedicated all copyright
6
* and related and neighboring rights to this software to the public domain
7
* worldwide. This software is distributed without any warranty, see:
8
* <http://creativecommons.org/publicdomain/zero/1.0/>.
9
*/
10
11
#include <bsddialog.h>
12
#include <bsddialog_theme.h>
13
#include <stdio.h>
14
15
int main()
16
{
17
int output, focusitem;
18
struct bsddialog_conf conf;
19
enum bsddialog_default_theme theme;
20
struct bsddialog_menuitem items[4] = {
21
{"", false, 0, "Flat", "default flat theme",
22
"enum bsddialog_default_theme BSDDIALOG_THEME_FLAT" },
23
{"", false, 0, "3D", "pseudo 3D theme",
24
"enum bsddialog_default_theme BSDDIALOG_THEME_3D" },
25
{"", false, 0, "BlackWhite","black and white theme",
26
"enum bsddialog_default_theme BSDDIALOG_THEME_BLACKWHITE" },
27
{"", false, 0, "Quit", "Exit", "Quit, Cancel or ESC to exit" }
28
};
29
30
if (bsddialog_init() == BSDDIALOG_ERROR) {
31
printf("Error: %s\n", bsddialog_geterror());
32
return (1);
33
}
34
bsddialog_initconf(&conf);
35
conf.ascii_lines = true;
36
bsddialog_backtitle(&conf, "Theme Example");
37
bsddialog_initconf(&conf);
38
conf.key.enable_esc = true;
39
conf.title = " Theme ";
40
focusitem = -1;
41
while (true) {
42
output = bsddialog_menu(&conf, "Choose theme", 15, 45, 4, 4,
43
items, &focusitem);
44
45
if (output != BSDDIALOG_OK || items[3].on)
46
break;
47
48
if (items[0].on) {
49
theme = BSDDIALOG_THEME_FLAT;
50
focusitem = 0;
51
} else if (items[1].on) {
52
theme = BSDDIALOG_THEME_3D;
53
focusitem = 1;
54
} else if (items[2].on) {
55
theme = BSDDIALOG_THEME_BLACKWHITE;
56
focusitem = 2;
57
}
58
bsddialog_set_default_theme(theme);
59
}
60
61
bsddialog_end();
62
63
return (0);
64
}
65