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