xref: /freebsd/share/examples/bootforth/menu.4th (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
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 /kernel."
18	20 8 at-xy
19	." 2.  Interact with BootFORTH."
20	20 9 at-xy
21	." 3.  Reboot."
22	me
23;
24
25: tkey	( d -- flag | char )
26	seconds +
27	begin 1 while
28	    dup seconds u< if
29		drop
30		-1
31		exit
32	    then
33	    key? if
34		drop
35		key
36		exit
37	    then
38	repeat
39;
40
41: prompt
42	14 fg
43	20 11 at-xy
44	." Enter your option (1,2,3): "
45	10 tkey
46	dup 32 = if
47	    drop key
48	then
49	dup 0< if
50	    drop 49
51	then
52	dup emit
53	me
54;
55
56: help_text
57	10 18 at-xy ." * Choose 1 if you just want to run FreeBSD."
58	10 19 at-xy ." * Choose 2 if you want to use bootloader facilities."
59	12 20 at-xy ." See '?' for available commands, and 'words' for"
60	12 21 at-xy ." complete list of Forth words."
61	10 22 at-xy ." * Choose 3 in order to warm boot your machine."
62;
63
64: (boot) 0 boot ;
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 kernel. Please wait..." cr
81			['] (boot) catch abort" Error booting"
82		then
83		dup 50 = if
84			drop
85			1 25 at-xy cr
86			exit
87		then
88		dup 51 = if
89			drop
90			1 25 at-xy cr
91			['] (reboot) catch abort" Error rebooting"
92		then
93		20 12 at-xy
94		." Key " emit ."  is not a valid option!"
95		20 13 at-xy
96		." Press any key to continue..."
97		key drop
98	repeat
99;
100