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