xref: /freebsd/share/examples/bootforth/menuconf.4th (revision 0e33efe4e4b5d24e2d416938af8bc6e6e4160ec8)
1\ Simple greeting screen, presenting basic options.
2\ XXX This is far too trivial - I don't have time now to think
3\ XXX about something more fancy... :-/
4\ $FreeBSD$
5
6: title
7	f_single
8	60 11 10 4 box
9	29 4 at-xy 15 fg 7 bg
10	." Welcome to BootFORTH!"
11	me
12;
13
14: menu
15	2 fg
16	20 7 at-xy
17	." 1.  Start FreeBSD with /boot/stable.conf."
18        20 8 at-xy
19        ." 2.  Start FreeBSD with /boot/current.conf."
20	20 9 at-xy
21	." 3.  Start FreeBSD with standard configuration. "
22	20 10 at-xy
23	." 4.  Reboot."
24	me
25;
26
27: tkey	( d -- flag | char )
28	seconds +
29	begin 1 while
30	    dup seconds u< if
31		drop
32		-1
33		exit
34	    then
35	    key? if
36		drop
37		key
38		exit
39	    then
40	repeat
41;
42
43: prompt
44	14 fg
45	20 12 at-xy
46	." Enter your option (1,2,3,4): "
47	10 tkey
48	dup 32 = if
49	    drop key
50	then
51	dup 0< if
52	    drop 51
53	then
54	dup emit
55	me
56;
57
58: help_text
59        10 18 at-xy ." * Choose 1 or 2 to run special configuration file."
60	10 19 at-xy ." * Choose 3 to proceed with standard bootstrapping."
61	12 20 at-xy ." See '?' for available commands, and 'words' for"
62	12 21 at-xy ." complete list of Forth words."
63	10 22 at-xy ." * Choose 4 in order to warm boot your machine."
64;
65
66: (reboot) 0 reboot ;
67
68: main_menu
69	begin 1 while
70		clear
71		f_double
72		79 23 1 1 box
73		title
74		menu
75		help_text
76		prompt
77		cr cr cr
78		dup 49 = if
79			drop
80			1 25 at-xy cr
81			." Loading /boot/stable.conf. Please wait..." cr
82			s" /boot/stable.conf" read-conf
83			0 boot-conf exit
84		then
85		dup 50 = if
86			drop
87			1 25 at-xy cr
88			." Loading /boot/current.conf. Please wait..." cr
89			s" /boot/current.conf" read-conf
90			0 boot-conf exit
91		then
92		dup 51 = if
93			drop
94			1 25 at-xy cr
95			." Proceeding with standard boot. Please wait..." cr
96			0 boot-conf exit
97		then
98		dup 52 = if
99			drop
100			1 25 at-xy cr
101			['] (reboot) catch abort" Error rebooting"
102		then
103		20 12 at-xy
104		." Key " emit ."  is not a valid option!"
105		20 13 at-xy
106		." Press any key to continue..."
107		key drop
108	repeat
109;
110
111