| 1 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 2 | % |
|---|
| 3 | % Main menu (boot entry + boot options + panel). |
|---|
| 4 | % |
|---|
| 5 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 9 | % Create new main window. |
|---|
| 10 | % |
|---|
| 11 | % ( ) ==> ( window ) |
|---|
| 12 | % |
|---|
| 13 | /window.main { |
|---|
| 14 | widget.size array |
|---|
| 15 | dup .type t_main put |
|---|
| 16 | dup .font font.normal put |
|---|
| 17 | dup .ed.font font.normal put |
|---|
| 18 | dup .color.fg boot.text.normal put |
|---|
| 19 | |
|---|
| 20 | } def |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 24 | % Initialize main window. |
|---|
| 25 | % |
|---|
| 26 | % ( window ) ==> ( ) |
|---|
| 27 | % |
|---|
| 28 | /main.init { |
|---|
| 29 | pop |
|---|
| 30 | } def |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 34 | % Redraw main window. |
|---|
| 35 | % (E.g. after selecting a new language.) |
|---|
| 36 | % |
|---|
| 37 | % ( window ) ==> ( ) |
|---|
| 38 | % |
|---|
| 39 | /main.redraw { |
|---|
| 40 | boot.text.options setcolor |
|---|
| 41 | window.current .font get setfont |
|---|
| 42 | boot.pos.init |
|---|
| 43 | % clear to far right of screen |
|---|
| 44 | boot.pos moveto boot.label.len neg 1 neg rmoveto |
|---|
| 45 | currentpoint screen.size pop 2 index sub boot.ed.height 2 add image |
|---|
| 46 | % redraw boot line |
|---|
| 47 | boot.setup |
|---|
| 48 | |
|---|
| 49 | redrawmenu |
|---|
| 50 | /keepbootoptions 1 def |
|---|
| 51 | menu.entry true MenuSelect |
|---|
| 52 | /keepbootoptions .undef def |
|---|
| 53 | |
|---|
| 54 | panel.show |
|---|
| 55 | } def |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | /boot.setup { |
|---|
| 59 | boot.show { |
|---|
| 60 | boot.window .ed boot.ed put |
|---|
| 61 | } if |
|---|
| 62 | |
|---|
| 63 | boot.pos.init |
|---|
| 64 | boot.pos moveto |
|---|
| 65 | |
|---|
| 66 | boot.show { |
|---|
| 67 | txt_bootoptions showright |
|---|
| 68 | |
|---|
| 69 | currenttransparency |
|---|
| 70 | white setcolor |
|---|
| 71 | boot.pos moveto 10 boot.ed.height rmoveto |
|---|
| 72 | 0xe0 settransparency |
|---|
| 73 | boot.ed.width 1 fillrect |
|---|
| 74 | settransparency |
|---|
| 75 | boot.ed edit.redraw |
|---|
| 76 | } { |
|---|
| 77 | lang.displayed { |
|---|
| 78 | boot.label.len neg 0 rmoveto |
|---|
| 79 | txt_modes_help show |
|---|
| 80 | } if |
|---|
| 81 | } ifelse |
|---|
| 82 | } def |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 86 | % Draw main window. |
|---|
| 87 | % |
|---|
| 88 | % ( window ) ==> ( ) |
|---|
| 89 | % |
|---|
| 90 | /main.show { |
|---|
| 91 | window.push |
|---|
| 92 | |
|---|
| 93 | /menu.shift 0 def |
|---|
| 94 | /menu.visible.entries menu.texts length menu.max.entries min def |
|---|
| 95 | |
|---|
| 96 | % get index of default entry |
|---|
| 97 | /menu.entry 0 def |
|---|
| 98 | 0 1 menu.texts length 1 sub { |
|---|
| 99 | dup menu.texts exch get menu.dentry eq { /menu.entry exch def exit } { pop } ifelse |
|---|
| 100 | } for |
|---|
| 101 | |
|---|
| 102 | menu.entry menu.visible.entries sub 0 ge { |
|---|
| 103 | /menu.shift menu.entry menu.texts length menu.visible.entries sub min def |
|---|
| 104 | } if |
|---|
| 105 | |
|---|
| 106 | menu.visible.entries menu.texts length lt menu.scrollbar and { |
|---|
| 107 | /menu.bar.width frame1.size pop frame4.size pop sub def |
|---|
| 108 | |
|---|
| 109 | -1 settransparentcolor |
|---|
| 110 | |
|---|
| 111 | frame4.pos moveto black dup frame4.size drawborder |
|---|
| 112 | frame4.pos moveto |
|---|
| 113 | ms.up ms.size image |
|---|
| 114 | frame4.pos moveto frame4.size exch pop 0 exch ms.size exch pop 0 add sub rmoveto |
|---|
| 115 | ms.down ms.size image |
|---|
| 116 | |
|---|
| 117 | /menu.sb.x frame4.pos pop 1 add def |
|---|
| 118 | /menu.sb.y frame4.pos exch pop 22 add def |
|---|
| 119 | /menu.sb.width frame4.size pop 2 sub def |
|---|
| 120 | /menu.sb.height frame4.size exch pop 22 2 mul sub def |
|---|
| 121 | |
|---|
| 122 | menu.sb.x menu.sb.y 1 sub moveto |
|---|
| 123 | menu.sb.x menu.sb.width add menu.sb.y 1 sub lineto |
|---|
| 124 | |
|---|
| 125 | menu.sb.x menu.sb.y menu.sb.height add moveto |
|---|
| 126 | menu.sb.x menu.sb.width add menu.sb.y menu.sb.height add lineto |
|---|
| 127 | } if |
|---|
| 128 | |
|---|
| 129 | boot.text.options setcolor |
|---|
| 130 | |
|---|
| 131 | window.current .font get setfont |
|---|
| 132 | |
|---|
| 133 | boot.pos.init |
|---|
| 134 | |
|---|
| 135 | /boot.ed.width screen.size pop boot.pos pop sub 20 sub def |
|---|
| 136 | /boot.ed.height fontheight 2 add def |
|---|
| 137 | |
|---|
| 138 | /boot.window window.current def |
|---|
| 139 | |
|---|
| 140 | /boot.ed [ |
|---|
| 141 | boot.pos exch 10 add exch 1 sub |
|---|
| 142 | over over moveto boot.ed.width boot.ed.height savescreen |
|---|
| 143 | boot.buf |
|---|
| 144 | boot.buf.size |
|---|
| 145 | .undef |
|---|
| 146 | ] def |
|---|
| 147 | |
|---|
| 148 | boot.setup |
|---|
| 149 | |
|---|
| 150 | redrawmenu |
|---|
| 151 | menu.entry true MenuSelect |
|---|
| 152 | |
|---|
| 153 | panel.init |
|---|
| 154 | |
|---|
| 155 | "main" help.setcontext |
|---|
| 156 | |
|---|
| 157 | } def |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 161 | % Handle keyboard input. |
|---|
| 162 | % |
|---|
| 163 | % ( key_in ) ==> ( key_out ) |
|---|
| 164 | % |
|---|
| 165 | /main.input { |
|---|
| 166 | dup 0 eq { return } if |
|---|
| 167 | |
|---|
| 168 | % handle panel entries |
|---|
| 169 | panel.input |
|---|
| 170 | |
|---|
| 171 | dup keyF10 eq { |
|---|
| 172 | power_off |
|---|
| 173 | pop 0 |
|---|
| 174 | } if |
|---|
| 175 | |
|---|
| 176 | dup keyEsc eq { exit_popup pop 0 } if |
|---|
| 177 | |
|---|
| 178 | dup keyEnter eq { |
|---|
| 179 | /window.action actStart def |
|---|
| 180 | pop 0 |
|---|
| 181 | } if |
|---|
| 182 | |
|---|
| 183 | dup keyUp eq { |
|---|
| 184 | menu.entry 0 gt { |
|---|
| 185 | menu.entry false MenuSelect |
|---|
| 186 | menu.entry menu.shift eq { |
|---|
| 187 | /menu.shift dec redrawmenu |
|---|
| 188 | } if |
|---|
| 189 | /menu.entry dec |
|---|
| 190 | menu.entry true MenuSelect |
|---|
| 191 | } if |
|---|
| 192 | pop 0 |
|---|
| 193 | } if |
|---|
| 194 | |
|---|
| 195 | dup keyDown eq { |
|---|
| 196 | menu.entry menu.texts length 1 sub lt { |
|---|
| 197 | menu.entry false MenuSelect |
|---|
| 198 | menu.visible.entries menu.entry menu.shift sub sub 1 eq { |
|---|
| 199 | /menu.shift menu.shift 1 add def redrawmenu |
|---|
| 200 | } if |
|---|
| 201 | /menu.entry menu.entry 1 add def |
|---|
| 202 | menu.entry true MenuSelect |
|---|
| 203 | } if |
|---|
| 204 | pop 0 |
|---|
| 205 | } if |
|---|
| 206 | |
|---|
| 207 | dup keyPgUp eq { |
|---|
| 208 | menu.entry 0 gt { |
|---|
| 209 | menu.entry false MenuSelect |
|---|
| 210 | /menu.entry 0 def |
|---|
| 211 | menu.shift 0 ne { |
|---|
| 212 | /menu.shift 0 def redrawmenu |
|---|
| 213 | } if |
|---|
| 214 | menu.entry true MenuSelect |
|---|
| 215 | } if |
|---|
| 216 | pop 0 |
|---|
| 217 | } if |
|---|
| 218 | |
|---|
| 219 | dup keyPgDown eq { |
|---|
| 220 | menu.entry menu.texts length 1 sub lt { |
|---|
| 221 | menu.entry false MenuSelect |
|---|
| 222 | /menu.entry menu.texts length 1 sub def |
|---|
| 223 | menu.texts length menu.visible.entries sub dup menu.shift ne { |
|---|
| 224 | /menu.shift exch def redrawmenu |
|---|
| 225 | } { |
|---|
| 226 | pop |
|---|
| 227 | } ifelse |
|---|
| 228 | menu.entry true MenuSelect |
|---|
| 229 | } if |
|---|
| 230 | pop 0 |
|---|
| 231 | } if |
|---|
| 232 | |
|---|
| 233 | dup 0 ne { |
|---|
| 234 | "opt" help.setcontext |
|---|
| 235 | } if |
|---|
| 236 | |
|---|
| 237 | } def |
|---|
| 238 | |
|---|
| 239 | |
|---|