root/trunk/max-genlive/gfxboot/common.inc @ 235

Revision 235, 32.0 KB (checked in by max, 19 months ago)

mario.izquierdo
max-genlive (4.0.max0.46)

  • Update gfxboot-theme-ubuntu package (0.5.20)
    • Better language support
Line 
1% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2%
3% Main part.
4%
5% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6
7% max command line length
8/cmdlinelength 512 def
9
10% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11%
12% Install source is 64bit?
13%
14% ( ) ==> ( true|false )
15%
16/64bit_source {
17  % 64 bit dir exists and is != 32 bit dir
18  64bit_boot_dir 32bit_boot_dir ne
19  64bit_boot_dir .undef ne and
20} def
21
22
23% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24%
25% Are we a dvd?
26%
27% ( ) ==> ( true|false )
28%
29/is_dvd {
30  % check only once
31  is_dvd.result .undef ne { is_dvd.result return } if
32
33  /is_dvd.result
34    mediatype m_cdrom eq {
35      0x10 readsector
36      dup 0x50 add getdword exch free
37      9 shr % iso size in MB
38      720 gt % assume dvd if > 720 MB
39    } {
40      false
41    } ifelse
42  def
43
44  is_dvd.result return
45} def
46
47
48% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
49%
50% Are we a live image?
51%
52% ( ) ==> ( true|false )
53%
54/is_live {
55  % check only once
56  is_live.result .undef ne { is_live.result return } if
57
58  /is_live.result "/casper/filesystem.manifest" filesize .undef ne def
59
60  is_live.result return
61} def
62
63% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
64%
65% Install source is 32 & 64bit?
66%
67% ( ) ==> ( true|false )
68%
69/32+64bit_source {
70  32bit_boot_dir .undef ne
71  % uncomment next line to automatically warn about 32bit software on 64bit machines, too
72  % 64bit_boot_dir .undef ne and
73} def
74
75
76% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
77%
78% Enough memory?
79%
80% ( ) ==> ( true|false )
81%
82/enough_mem {
83  biosmem 4 20 shl lt
84  biosmem 200 20 shl ge or
85  syslinux not or
86} def
87
88
89% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90%
91% Check if there are boot directories for 32 & 64bit.
92%
93% Assumes 32bit to be in *i386* and 64bit in *x86_64*.
94%
95% ( ) ==> ( )
96%
97/check_arch_boot_dir {
98  getcwd dup .undef ne {
99    /64bit.tmp 256 string def
100
101    dup "i386" strstr 0 ne over "x86_64" strstr 0 ne or {
102      dup "i386" strstr {
103        /32bit_boot_dir exch def
104        /64bit_boot_dir 32bit_boot_dir "i386" "x86_64" strreplace
105      } {
106        /64bit_boot_dir exch def
107        /32bit_boot_dir 64bit_boot_dir "x86_64" "i386" strreplace
108      } ifelse
109
110      dup "%s/isolinux.cfg" 64bit.tmp sprintf
111      64bit.tmp filesize .undef ne { def } { free pop } ifelse
112
113    } {
114      /32bit_boot_dir over def
115      /64bit_boot_dir exch def
116    } ifelse
117
118    64bit.tmp free
119
120    % font.normal setfont
121    % 0 400 moveto 32bit_boot_dir print
122    % 0 420 moveto 64bit_boot_dir print dtrace
123
124  } {
125    pop
126  } ifelse
127} def
128
129
130% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
131%
132% input event handling
133%
134% ( key ) ==> ( input_buffer menu_entry action )
135%
136% key
137%  bit 0-7      ascii
138%  bit 8-15     scan code
139%  bit 16-32    status bits (ctrl, shift...)
140%
141% action
142%    0:         ok, stay in input loop
143%    1:         switch to text mode
144%  >=2:         start linux
145%
146/KeyEvent {
147  % timeout
148
149  dup 0 eq { boot.buf buildcmdline 2 return } if
150
151  debug 4 ge {
152    % print keycode somewhere
153    -1 settransparentcolor
154    white setcolor
155    500 0 moveto dup print "  " print
156  } if
157
158  dup 0xff00 and 16 shl over 0xff and dup 0xe0 eq { pop 0 } if add /key exch def
159  16 shr 0xffff and /keystat exch def
160
161  key keyTab eq keyStatus statusShift and 0 ne and {
162    /key keyShiftTab def
163  } if
164
165  key
166
167  config.keymap .km.map get { mapkey } if
168
169  dup 0xffffff and dup { exch } if pop
170
171  debug 4 ge {
172    % print mapped key somewhere
173    -1 settransparentcolor
174    white setcolor
175    500 20 moveto dup print "  " print
176  } if
177
178  % some special keys
179  debug.input
180
181  % put key through normal input queue
182  window.input
183
184  pop
185
186  window.action actExit eq {
187    /window.action actNothing def
188    "" -1 1 return
189  } if
190
191  window.action actCloseInfo eq {
192    /window.action actNothing def
193    "" -1 3 return
194  } if
195
196  window.action actPassword eq {
197    /window.action actNothing def
198    password.dialog {
199      password.dialog .ed.buffer.list get 0 get
200    } { "" } ifelse
201    -1 3 return
202  } if
203
204  window.action actStart eq {
205    /window.action actNothing def
206    boot.buf buildcmdline 2 return
207  } if
208
209  window.action actRedraw eq {
210    /window.action actNothing def
211    main.redraw
212  } if
213
214  window.action actRedrawPanel eq {
215    /window.action actNothing def
216    panel.show
217  } if
218
219  boot.buf menu.entry 0
220} def
221
222
223/bc.cmd cmdlinelength string def
224
225% ( option_string ) ==> ( cmdline menu_entry )
226%
227% grub:
228%   just return
229%
230% syslinux & lilo:
231%   check if the commmand line starts with the current kernel name or
232%   "linux"; if not, put the kernel name in front of the command line. (This
233%   is to keep compatibility with the old scheme requiring the user to write
234%   the kernel name explicitly.)
235%
236/buildcmdline {
237  menu.entry 0 lt { -1 return } if
238  menu.entry menu.texts length ge { -1 return } if
239
240  /bc.opts exch def
241  /bc.kernel menu.texts menu.entry get def
242
243  grub {
244
245    /bc.addkernel false def
246
247  } {
248
249    /bc.addkernel true def
250
251    [ bc.kernel "linux" ] 0 over length 1 sub 1 exch {
252      over exch get
253
254      bc.opts over eq {
255        /bc.addkernel false def
256      } {
257        bc.opts over strstr 1 eq {
258           bc.opts over length get ' ' eq {
259             /bc.addkernel false def
260           } if
261        } if
262      } ifelse
263
264      pop
265
266      bc.addkernel not { exit } if
267
268    } for
269
270    pop
271
272    % special case: option is identical to label
273    bc.kernel "apic" eq { /bc.addkernel true def } if
274
275  } ifelse
276
277  syslinux {
278    /add_suffix .undef def
279
280    % set new working directory
281    xmenu.bits .xm_current get 1 eq { 64bit_boot_dir } { 32bit_boot_dir } ifelse
282    dup .undef ne {
283      dup getcwd ne { chdir } { pop } ifelse
284    } {
285      pop
286    } ifelse
287  } if
288
289  % getcwd 0 300 moveto show trace
290
291  bc.addkernel {
292    bc.kernel
293    dup "linux" eq add_suffix .undef ne and {
294      add_suffix exch "%s%s "
295    } {
296      "%s "
297    } ifelse
298    bc.cmd sprintf
299  } {
300    bc.cmd 0 0 put
301  } ifelse
302
303  cmdline.hidden "" ne {
304    /add_suffix 32 string def
305
306    video.modes.list .undef ne {
307      video.modes.list xmenu.video .xm_current get get
308      dup .vm_mode get 0 ge {
309        dup .vm_height get exch .vm_width get
310        ",%04d%04d.spl" add_suffix sprintf
311      } { pop } ifelse
312    } if
313
314    % find out splash size for kernel loading progress bar
315    add_suffix 1 add filesize dup .undef ne {
316      sectorsize 1 sub add sectorsize div /progress_extra exch def
317    } {
318      pop
319      add_suffix 0 0 put        % empty string
320    } ifelse
321
322    add_suffix {
323      /bc.tmp cmdline.hidden length add_suffix length add string def
324      cmdline.hidden "initrd" bootopt.find dup .undef ne {
325        skipnonspaces
326        dup
327        dup 0 get over 0 0 put
328        add_suffix cmdline.hidden "%s%s" bc.tmp sprintf
329        0 exch put
330        "%s" bc.tmp dup length add sprintf
331      } {
332        pop
333        bc.tmp cmdline.hidden strcpy pop
334      } ifelse
335
336      bc.tmp "%s " bc.cmd dup length add sprintf
337
338      bc.tmp free /bc.tmp .undef def
339    } {
340      cmdline.hidden "%s " bc.cmd dup length add sprintf
341    } ifelse
342
343    % find out initrd size for kernel loading progress bar
344    "initrd" filesize dup .undef ne {
345      sectorsize 1 sub add sectorsize div /progress_extra exch progress_extra add def
346    } {
347      pop
348    } ifelse
349
350  } if
351
352  xmenu.fulloptions {
353    fulloptions.option .undef ne {
354      fulloptions.option "%s " bc.cmd dup length add sprintf
355    } if
356  } if
357
358  bc.opts "%s " bc.cmd dup length add sprintf
359
360  syslinux {
361    video.modes.list .undef ne {
362      video.modes.list xmenu.video .xm_current get get .vm_mode get
363
364      dup 0 ge {
365        0x200 add "vga=0x%x " bc.cmd dup length add sprintf
366      } if
367    } if
368
369    config.lang {
370      config.lang "en" ne {
371        config.lang
372        config.lang "_" strstr 0 eq {
373          "debian-installer/language=%s "
374        } {
375          "locale=%s "
376        } ifelse
377        bc.cmd dup length add sprintf
378      } if
379    } if
380
381    config.keymap .km.name get dup "us" ne {
382      dup "_" strstr dup 0 eq {
383        pop
384        "console-setup/layoutcode=%s " bc.cmd dup length add sprintf
385      } {
386        over over 1 sub 0 put
387        over "console-setup/layoutcode=%s " bc.cmd dup length add sprintf
388        add "console-setup/variantcode=%s " bc.cmd dup length add sprintf
389      } ifelse
390      config.keymap .km.model get dup {
391        "console-setup/modelcode=%s " bc.cmd dup length add sprintf
392      } {
393        pop
394      } ifelse
395    } {
396      pop
397    } ifelse
398
399    modes.selected.append .undef ne {
400      modes.selected.append "%s " bc.cmd dup length add sprintf
401    } if
402
403    modes.selected.replace .undef ne {
404      modes.selected.replace "=" strstr dup 0 ne {
405        modes.selected.replace exch strndup /bc.tmp exch def  % e.g. "file="
406        bc.cmd {
407          dup 0 get 0 eq { exit } if
408          dup getword
409          dup "=" strstr dup 0 ne { over exch 0 put } { pop } ifelse
410          dup bc.tmp eq exch free {
411            bc.tmp free
412            dup strdup /bc.tmp exch def
413            bc.tmp modes.selected.replace "%s%s" 4 index sprintf
414            bc.tmp free /bc.tmp .undef def
415            exch pop exit
416          } if
417          exch pop
418          skipspace
419        } loop
420        pop
421        bc.tmp free /bc.tmp .undef def
422      } {
423        pop
424      } ifelse
425    } if
426  } if
427
428  xmenu.access {
429    access.option .undef ne {
430      access.option "%s " bc.cmd dup length add sprintf
431    } if
432  } if
433
434  xmenu.profile {
435    profile.options xmenu.profile .xm_current get get dup "" ne {
436      "%s " bc.cmd dup length add sprintf
437    } { pop } ifelse
438  } if
439
440  bc.cmd dropspaces
441
442  debug 3 ge {
443    0 0 moveto white setcolor
444    bc.cmd print "<<  (press ESC) " print trace
445  } if
446
447  bc.cmd menu.entry
448} def
449
450
451% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
452% ( menu_entries_array cmdline_args_array defaultentry ) == > ( )
453/MenuInit {
454  colorbits 8 le {
455    0 setcolor 0 0 moveto screen.size fillrect loadpalette
456  } if
457
458  init
459
460  /menu.entry -1 def
461
462  /menu.dentry exch def
463
464  menuconfig.init
465
466  % keep in sync with menuconfig.inc:menuconfig.init
467  "foreground" getgfxconfig dup .undef ne {
468    strtol
469    /menu.text.select over def
470    /boot.text.options over def
471    /boot.text.normal over def
472    /panel.high exch def
473  } { pop } ifelse
474  "background" getgfxconfig dup .undef ne {
475    strtol
476    /menu.text.normal over def
477    /panel.normal over def
478    /loading_color over def
479    /title.bg exch def
480  } { pop } ifelse
481  "access-options" getgfxconfig dup .undef ne {
482    /access.optionnames [
483      .undef
484      3 index
485      {
486        skipspace dup 0 get 0 eq { exit } if
487        getword exch
488      } loop
489      pop
490    ] def
491    pop
492  } { pop } ifelse
493
494  /menu.args exch def
495  /menu.texts exch def
496  /menu.humans exch def
497
498  window.main
499  dup window.init
500      window.show
501
502  32+64bit_source not {
503
504    64bit {
505      64bit_source not { notimeout 32bit_popup } if
506    } {
507      64bit_source { notimeout 64bit_popup } if
508    } ifelse
509
510  } if
511
512  lang.displayed not { panel.lang } if
513
514  50 sound.setvolume
515  "startup.mod" findfile dup .undef ne {
516    /player.startup 0 def
517    player.startup over mod.load
518    player.startup 0 mod.play
519    free
520  } { pop } ifelse
521} def
522
523
524% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
525% Setup boot option input field.
526%
527% ( ) == > ( )
528%
529/bootoptions.init {
530  window.current .color.fg get setcolor
531  window.current .ed.font get setfont
532
533  boot.ed edit.hidecursor
534  menu.args menu.entry get
535  bootpromptmap
536
537  boot.show {
538    boot.ed over edit.init
539    "" ne { boot.ed ' ' edit.input } if
540  } {
541    "%s" boot.ed 3 get sprintf
542  } ifelse
543
544} def
545
546
547% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
548% Split command line into hidden and normal part.
549%
550% ( cmdline_args ) == > ( new_cmdline_args )
551%
552/bootpromptmap {
553  /cmdline exch def
554
555  cmdline "showopts" getoption
556  dup "" eq {
557    cmdline.shown 0 0 put
558    pop cmdline "%s" cmdline.shown sprintf
559    cmdline.hidden 0 0 put
560  } {
561    "showopts" length add skipspaces
562    "%s" cmdline.shown sprintf
563    cmdline "%s" cmdline.hidden sprintf
564    cmdline.hidden "showopts" getoption 0 0 put
565  } ifelse
566
567  cmdline.shown dropspaces
568  cmdline.hidden dropspaces
569
570  cmdline.shown
571} def
572
573
574% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
575% Get boot option.
576%
577% ( cmdline option_name ) ==> ( option_start )
578%
579/getoption {
580  /go.name exch def
581  /go.cmdline exch def
582  /go.pos 0 def
583  {
584    go.cmdline go.pos add go.name strstr dup {
585       1 sub /go.pos exch def
586
587       go.cmdline go.pos iswordboundary
588       go.cmdline go.pos go.name length add iswordboundary
589       and {
590         go.cmdline go.pos add exit
591       } {
592         /go.pos go.pos 1 add def
593       } ifelse
594    } {
595      pop "" exit
596    } ifelse
597  } loop
598} def
599
600
601% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
602/redrawmenu {
603  menu.visible.entries menu.texts length lt menu.scrollbar and {
604    /menu.vsb.height1
605      menu.shift
606      menu.sb.height mul menu.texts length div
607    def
608
609    /menu.vsb.height3
610      menu.texts length menu.visible.entries menu.shift add sub
611      menu.sb.height mul menu.texts length div
612    def
613
614    lightgray setcolor
615    menu.sb.x menu.sb.y menu.vsb.height1 add moveto
616    menu.sb.width menu.sb.height menu.vsb.height1 menu.vsb.height3 add sub
617    fillrect
618
619    menu.vsb.height1 0 ne {
620      menu.sb.x menu.sb.y moveto
621      currentpoint menu.sb.width menu.vsb.height1 image
622    } if
623
624    menu.vsb.height3 0 ne {
625      menu.sb.x menu.sb.y menu.sb.height menu.vsb.height3 sub add moveto
626      currentpoint menu.sb.width menu.vsb.height3 image
627    } if
628
629  } if
630
631  menu.text.normal setcolor
632
633  /x menu.start.x def
634  /y menu.start.y def
635
636  0 1 menu.visible.entries 1 sub {
637   x y moveto currentpoint menu.bar.width menu.bar.height image
638   menu.texts exch menu.shift add get menuitemmap
639   x menu.bar.width 2 index strsize pop sub 2 div add
640   y menu.text.yofs add
641   moveto
642   currentfont exch font.large setfont show setfont
643   /y y menu.item.height add def
644  } for
645
646} def
647
648
649% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
650% ( entry status ) ==> ( )
651%
652% status:
653%  false        not selected
654%  true         selected
655%
656/MenuSelect {
657  /menu.status exch def
658
659  /menu.idx over def
660
661  menu.shift sub
662  menu.item.height mul menu.start.y add
663  menu.start.x exch
664  moveto
665
666  currentpoint
667  menu.status {
668    menu.bar.color setcolor
669    currenttransparency
670    70 settransparency
671    menu.bar.width menu.bar.height
672    fillrect
673    settransparency
674  } {
675    currentpoint menu.bar.width menu.bar.height image
676  } ifelse
677  moveto
678
679  menu.status {
680    menu.text.select
681  } {
682    menu.text.normal
683  } ifelse
684  setcolor
685  menu.texts menu.idx get menuitemmap
686  menu.bar.width over strsize pop sub 2 div menu.text.yofs rmoveto
687  currentfont exch font.large setfont show setfont
688
689  menu.status {
690    % init boot options
691    keepbootoptions .undef eq { bootoptions.init } if
692
693    % set help context
694    "main" help.setcontext
695    menu.texts menu.idx get
696    dup help.findpage "" eq {
697      pop
698    } {
699      help.setcontext
700    } ifelse
701
702    % update installation modes menu
703    menu.idx modes.filter
704  } if
705
706} def
707
708
709% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
710% ( text errorcode ) ==> ( )
711% errorcode:
712%   0   normal info
713%   1   fatal error
714%   2   missing kernel
715%   3   disk change
716%   4   disk change failed
717%
718
719/info.tmpmsg 127 string def
720
721/InfoBoxInit {
722  /info.type exch def
723  /info.msg exch def
724
725  window.dialog
726
727  info.type 1 eq {
728    dup .title.bg red put
729    dup .title txt_error_title put
730    dup .buttons
731    [
732      button.reboot button.default actCloseInfo button.setaction
733    ] put
734  } {
735    dup .title txt_info_title put
736    dup .buttons
737    [
738      button.ok button.default actCloseInfo button.setaction
739%      button.cancel button.notdefault actCloseInfo button.setaction
740    ] put
741  } ifelse
742
743  syslinux info.type 3 eq and {
744    dup .title txt_change_disk_title put
745    0 getinfo 1 add txt_insert_disk info.tmpmsg sprintf
746    /info.msg info.tmpmsg def
747  } if
748
749  syslinux info.type 4 eq and {
750    dup .title txt_change_disk_title put
751    1 getinfo 15 not and {
752      0 getinfo 1 add
753      txt_insert_disk3 info.tmpmsg sprintf
754    } {
755      0 getinfo 1 add 1 getinfo 1 add
756      txt_insert_disk2 info.tmpmsg sprintf
757    } ifelse
758    /info.msg info.tmpmsg def
759  } if
760
761  dup .text info.msg put
762
763  dup window.init
764      window.show
765
766} def
767
768
769
770% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
771% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
772
773% progress bar code
774
775
776% Show percentage of progress bar.
777%
778% ( percentage ) ==> ( )
779%
780/progress.percent {
781  0 max 100 min         % so people don't ask silly questions...
782  "100%" strsize over neg progress.text.x add progress.text.y moveto
783  window.current .color.bg get setcolor
784  fillrect 
785
786  "%3u%%" 8 dup string dup 5 1 roll snprintf
787
788  dup strsize pop neg progress.text.x add progress.text.y moveto
789  window.current .color.fg get setcolor
790  dup show
791  free
792
793} def
794
795
796% Show n-th progress bar symbol.
797%
798% ( n ) ==> ( )
799%
800/progress.sym.show {
801  /progress.sym.current exch def
802
803  progress.bar.x progress.bar.y moveto
804  progress.sym.width progress.sym.current 1 sub mul 1 add 1 rmoveto
805  progress.sym.width 2 sub
806  progress.bar.height 2 sub
807  loading_color setcolor
808  fillrect
809
810} def
811
812
813% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
814% ( kernel_name ) ==> ( )
815/ProgressInit {
816  /progress.kname exch def
817
818  boot.ed edit.hidecursor
819
820  /dia window.dialog def
821
822  dia .width.min 330 put
823  dia .position 10 put
824
825  dia .title txt_load_kernel_title put
826  dia .text
827    progress.kname "memtest" eq {
828      txt_load_memtest
829    } {
830      txt_load_kernel
831    } ifelse
832  put
833
834  dia window.init
835  dia window.show
836
837  % now add progress bar
838
839  dia .x get dia .y get moveto
840  dia .text.x get dia .text.y get 28 add rmoveto
841
842  /progress.bar.height 19 def
843  /progress.bar.width dia .width get 60 sub def
844
845  /progress.sym.width 10 def
846  /progress.bar.width
847    progress.bar.width progress.sym.width div
848    /progress.syms over def progress.sym.width mul
849  def
850
851  currentpoint over 1 sub over 2 sub moveto
852  black white progress.bar.width 2 add progress.bar.height 4 add drawborder
853
854  /progress.bar.y exch def
855  /progress.bar.x exch def
856
857  /progress.text.x progress.bar.x progress.bar.width 37 add add def
858  /progress.text.y progress.bar.y progress.bar.height fontheight sub 2 div add def
859
860  /progress.sym.current 0 def
861
862  0 progress.percent
863
864} def
865
866
867% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
868% ( ) ==> ( )
869/ProgressDone {
870  window.done
871} def
872
873
874% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
875% ( max current ) ==> ( )
876%
877% Note: max is just kernel size (in sectors).
878%
879/ProgressUpdate {
880  exch progress_extra add exch
881
882  over over 100 mul exch 1 max div progress.percent
883
884  progress.syms mul progress.syms 2 div add exch 1 max div
885
886  0 max progress.syms min
887
888  dup progress.sym.current gt {
889    progress.sym.current 1 add over 1 exch {
890      progress.sym.show
891    } for
892  } if
893  pop
894
895} def
896
897% initrd size (in sectors)
898/progress_extra 0 def
899
900
901% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
902% ( time ) ==> ( )
903% /Timer { pop } def
904
905
906% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
907% ( label correct_password ) ==> ( )
908%
909/PasswordInit {
910  /password.key exch def pop
911
912  /dia window.dialog def
913
914  /password.dialog dia def
915
916  dia .title txt_password_title put
917  dia .text "" put
918
919  % Must all be of same size!
920  dia .ed.list 1 array put
921  dia .ed.buffer.list [ 31 string ] put
922  dia .ed.text.list [ txt_password ] put
923
924  dia .ed.focus 0 put
925
926  dia .ed.width 200 put
927
928  dia .ed.font font.normal pwmode put
929
930  dia .buttons
931    [ button.ok button.default actPassword button.setaction ]
932  put
933
934  dia window.init
935  dia window.show
936
937} def
938
939
940% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
941% ( password ) ==> ( error )
942%
943% error:
944%   true   password ok
945%   false  wrong password
946%
947% ****** FIXME: test result seems to be unused
948%
949/PasswordDone {
950
951  password.key eq
952} def
953
954
955% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
956% ( text ) == > ( new_text )
957% If text is in menu.texts (it should be), return the corresponding item
958% from menu.humans. Otherwise, return text as-is.
959/menuitemmap {
960  0 menu.texts {
961    2 index eq { menu.humans over get rot pop exch exit } if
962    1 add
963  } forall pop
964  translate
965
966  % Remove ^ from the string; eventually, this should define hotkeys, but it
967  % doesn't yet.
968  dup length string /menuitemmap.text exch def
969  /menuitemmap.idx 0 def
970  {
971    dup '^' ne {
972      menuitemmap.text menuitemmap.idx rot put
973      /menuitemmap.idx inc
974    } { pop } ifelse
975  } forall
976  menuitemmap.text menuitemmap.idx 0 put
977
978  menuitemmap.text
979} def
980
981
982% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
983% ( color0 color1 width height ) ==> ( )
984/drawborder {
985  currentpoint /db.y0 exch def /db.x0 exch def
986
987  /db.y1 exch 1 sub db.y0 add def
988  /db.x1 exch 1 sub db.x0 add def
989  /db.col1 exch def
990  /db.col0 exch def
991
992  db.x0 db.y1 moveto
993
994  db.col0 setcolor
995  db.x0 db.y0 lineto db.x1 db.y0 lineto
996
997  db.col1 setcolor
998  db.x1 db.y1 lineto db.x0 db.y1 lineto
999} def
1000
1001
1002% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1003% ( color0 color1 color2 width height ) ==> ( )
1004% draw frame with shadow
1005% color0: upper left, color1: lower right, color2: shadow
1006/drawborder3 {
1007  currentpoint /db.y0 exch def /db.x0 exch def
1008
1009  /db.y1 exch 1 sub db.y0 add def
1010  /db.x1 exch 1 sub db.x0 add def
1011  /db.col2 exch def
1012  /db.col1 exch def
1013  /db.col0 exch def
1014
1015  db.x0 db.y1 moveto
1016
1017  db.col0 setcolor
1018  db.x0 db.y0 lineto db.x1 db.y0 lineto
1019
1020  db.col1 setcolor
1021  db.x1 db.y1 lineto db.x0 db.y1 lineto
1022
1023  db.col2 -1 ne {
1024    db.col2 setcolor
1025    1 1 rmoveto
1026    db.x1 1 add db.y1 1 add lineto
1027    db.x1 1 add db.y0 1 add lineto
1028  } if
1029} def
1030
1031
1032% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1033% ( color0 color1 width height ) ==> ( )
1034/drawborder4 {
1035  3 index 4 1 roll rot dup 3 index 3 index
1036  currentpoint 6 2 roll
1037  1 1 rmoveto drawborder
1038  moveto drawborder
1039} def
1040
1041
1042% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1043% center text
1044% ( text width height ) ==> ( )
1045/centertext {
1046  3 -1 roll strsize
1047  4 2 roll
1048  4 1 roll exch 4 1 roll sub 2 div neg 3 1 roll sub 2 div neg
1049} def
1050
1051
1052% Allocate and define a new color.
1053%
1054% ( palette ) ==> ( color )
1055%
1056/newcolor {
1057  colorbits 8 le {
1058    newcolor.count .undef eq { /newcolor.count 0 def } if
1059    max_image_colors newcolor.count add
1060    dup rot setpalette
1061    /newcolor.count newcolor.count 1 add def
1062  } if
1063  def
1064} def
1065
1066
1067% ( img ) => ( width heigh )
1068/imgsize {
1069  dup .undef eq {
1070    pop 0 0
1071  } {
1072    getdword dup
1073    0xffff and exch 16 shr
1074  } ifelse
1075} def
1076
1077
1078% ( pic pic_a -- )
1079/showlogo {
1080  /tmp.sc over imgsize savescreen def
1081
1082  currentpoint 4 2 roll
1083  0 0 moveto tmp.sc blend
1084  moveto tmp.sc restorescreen
1085
1086  tmp.sc free
1087} def
1088
1089
1090% ( file_name ) ==> ( image )
1091/readimage {
1092  findfile dup setimage 0 0 image.size unpackimage exch free
1093} def
1094
1095
1096/boot.pos.init {
1097  /boot.label.len txt_bootoptions strsize pop def
1098  /boot.pos { boot.label.len 10 add small_layout { 410 } { 510 } ifelse } def
1099} def
1100
1101/init {
1102  0 0 moveto currentpoint clip.size image
1103
1104  small_layout {
1105    /head.x 70 def
1106    /head.y 141 def
1107  } {
1108    /head.x 234 def
1109    /head.y 185 def
1110  } ifelse
1111
1112  timeout.init
1113
1114  % set default language
1115  "lang" findfile dup {
1116    /tmp over length 1 add 2 max string def
1117    tmp exch {
1118      dup ' ' eq over '\n' eq or { pop pop exit } if
1119      over exch 0 exch put
1120      1 add
1121    } forall
1122    tmp dup setlang pop setkeymap
1123    /lang.displayed true def
1124  } {
1125    pop
1126    "en" dup setlang pop setkeymap
1127  } ifelse
1128
1129  font.large setfont
1130
1131  /menu.text.xofs      10 def
1132  /menu.text.yofs       2 def
1133  /menu.item.height    fontheight dup 3 div add def
1134  /menu.bar.height     fontheight menu.text.yofs dup add add def
1135
1136  font.normal setfont
1137
1138  /menu.text.normal    lightblue         def
1139  /menu.text.select    white             def
1140  /boot.text.options   white             def
1141  /boot.text.normal    white             def
1142  /infobox.bg          lightgray         def
1143  /infobox.text.normal black             def
1144
1145  /menu.bar.color      black       def
1146
1147  small_layout {
1148    /frame1.pos  {  80 208 } def
1149    /frame1.size { 480 160 } def
1150    /frame4.pos  { 560  62 } def
1151  } {
1152    /frame1.pos  { 160 288 } def
1153    /frame1.size { 480 170 } def
1154    /frame4.pos  { 640  62 } def
1155  } ifelse
1156
1157  /frame4.size {  22 264 } def
1158
1159  /menu.start.x frame1.pos pop 10 add def
1160  /menu.start.y frame1.pos exch pop 12 add def
1161
1162  /menu.bar.width frame1.size pop 20 sub def
1163  /menu.max.entries 8 def
1164  /menu.scrollbar false def
1165
1166  boot.pos.init
1167
1168  /boot.buf.size cmdlinelength def
1169  /boot.buf boot.buf.size string def
1170
1171  % no boot options line initially
1172  /boot.show false def
1173
1174  /ms.size     {  22  22 } def
1175  /ms.up       {   0 480 }  def
1176  /ms.down     {  23 480 }  def
1177
1178} def
1179
1180
1181% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1182% Some special debug & test keys.
1183%
1184% ( key_in ) ==> ( key_out )
1185%
1186/debug.input {
1187  dup keyShiftF4 eq debug 3 ge and {
1188    currentcolor white setcolor
1189    currentpoint 0 0 moveto
1190    64 string biosmem "mem = %u  " 2 index sprintf dup show free
1191    moveto setcolor
1192    pop 0
1193  } if
1194
1195  dup keyShiftF3 eq syslinux and debug 3 ge and {
1196    currentcolor white setcolor
1197    currentpoint 0 0 moveto
1198    "eject  " print bootdrive eject print
1199    moveto setcolor
1200    pop 0
1201  } if
1202
1203  dup keyShiftF5 eq syslinux and debug 3 ge and {
1204    currentcolor white setcolor
1205    currentpoint 100 0 moveto
1206    bootdrive print
1207    moveto setcolor
1208    pop 0
1209  } if
1210
1211  dup keyShiftF8 eq debug 3 ge and {
1212    currentcolor white setcolor
1213
1214    currentpoint 300 0 moveto
1215    0 memsize print "/" print print "  " print
1216    moveto
1217
1218    currentpoint 300 20 moveto
1219    1 memsize print "/" print print "  " print
1220    moveto
1221
1222    currentpoint 300 40 moveto
1223    2 memsize print "/" print print "  " print
1224    moveto
1225
1226    setcolor
1227    pop 0
1228  } if
1229
1230  dup keyShiftF9 eq debug 3 ge and {
1231    dumpmem
1232    pop 0
1233  } if
1234
1235  dup keyShiftF10 eq {
1236    /debug debug 1 add def ""
1237    pop 0
1238  } if
1239
1240  dup keyShiftF11 eq {
1241    /transp transp 0x10 sub 0 max def
1242    pop 0
1243  } if
1244
1245  dup keyF11 eq debug 1 ge and {
1246
1247    dtrace
1248
1249    0 1 screen.size exch pop {
1250      0 1 screen.size pop {
1251        over moveto
1252        currentpoint 8 shl screen.size exch pop div 8 shl exch 8 shl screen.size pop div add
1253        screen.size add currentpoint add sub 8 shl screen.size add div 2 div 16 shl add
1254        setcolor
1255        putpixel
1256      } for
1257      pop
1258    } for
1259
1260    pop 0
1261  } if
1262
1263  dup keyF12 eq debug 3 ge and {
1264    % mouse support testing
1265
1266    1 keepmode
1267
1268    /mouse xxx def
1269    red setcolor
1270    mouse .undef eq {
1271      700 580 moveto "no mouse" show
1272    } {
1273      {
1274        mouse getdword 16 shl 16 shr screen.size pop 2 div add
1275        mouse getdword 16 shr neg screen.size exch pop 2 div add
1276        moveto 4 4 fillrect
1277
1278        mouse 4 add getdword 7 and
1279        dup 1 and { red setcolor } if
1280        dup 2 and { blue setcolor } if
1281        dup 4 and { green setcolor } if
1282
1283        3 and 3 eq { exit } if
1284
1285      } loop
1286    } ifelse
1287    pop 0
1288  } if
1289
1290  dup keyShiftF12 eq {
1291    /transp transp 0x10 add 0x100 min def
1292    pop 0
1293  } if
1294
1295} def
1296
1297
1298% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1299% Show exit popup.
1300%
1301% ( ) ==> ( )
1302%
1303/exit_popup {
1304  window.dialog
1305
1306  dup .title txt_exit_title put
1307  dup .text txt_exit_dialog put
1308  dup .buttons [
1309    button.ok button.default actExit button.setaction
1310    button.cancel button.notdefault actNothing button.setaction
1311  ] put
1312  dup window.init
1313      window.show
1314
1315} def
1316
1317
1318% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1319% Show help window.
1320%
1321% ( ) ==> ( )
1322%
1323/show_help {
1324  window.help
1325 
1326  dup window.init
1327  window.show
1328
1329} def
1330
1331
1332% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1333% Show dvd popup.
1334%
1335% ( ) ==> ( )
1336%
1337/dvd_popup {
1338  window.dialog
1339
1340  dup .title txt_dvd_warning_title put
1341  dup .text txt_dvd_warning2 put
1342  dup .buttons [
1343%    button.eject    button.default    actEject actNoClose or button.setaction
1344    button.continue button.default actNothing button.setaction
1345  ] put
1346  dup window.init
1347      window.show
1348
1349} def
1350
1351
1352% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1353% Warn that we are about to install 32bit software on a 64bit system.
1354%
1355% ( ) ==> ( )
1356%
1357/32bit_popup {
1358  window.dialog
1359
1360  dup .title "Cool computer, but..." put
1361  dup .text "You are about to install 32-bit software on a 64-bit computer." put
1362  dup .buttons [
1363    button.continue button.default actNothing button.setaction
1364  ] put
1365  dup window.init
1366      window.show
1367
1368} def
1369
1370
1371% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1372% Warn that we are about to install 64bit software on a 32bit system.
1373%
1374% ( ) ==> ( )
1375%
1376/64bit_popup {
1377  window.dialog
1378
1379  dup .title "Cool software, but..." put
1380  dup .text "This is a 32-bit computer. You cannot use 64-bit software on it." put
1381  dup .buttons [
1382    button.reboot button.default actReboot actNoClose or button.setaction
1383  ] put
1384  dup window.init
1385      window.show
1386
1387} def
1388
1389
1390% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1391% Warn that we don't have enough memory.
1392%
1393% ( ) ==> ( )
1394%
1395/nomem_popup {
1396  window.dialog
1397
1398  dup .title "Cool computer, but..." put
1399  dup .text
1400    "Sorry, but SUSE Linux 10.1 LiveCD needs at least 256MB main memory."
1401  put
1402  dup .buttons [
1403    button.reboot button.default actReboot actNoClose or button.setaction
1404  ] put
1405  dup window.init
1406      window.show
1407
1408} def
1409
1410
1411% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1412% Show "power off" popup.
1413%
1414% ( ) ==> ( )
1415%
1416/power_off {
1417  window.dialog
1418
1419  dup .title txt_power_off_title put
1420  dup .text txt_power_off put
1421  dup .buttons [
1422    button.ok     button.notdefault    actPowerOff actNoClose or button.setaction
1423    button.cancel button.default       actNothing                button.setaction
1424  ] put
1425  dup window.init
1426      window.show
1427
1428} def
1429
1430
1431% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1432% Search for option in cmdline.
1433% Returns .undef if not found.
1434%
1435% ( cmdline option_name ) ==> ( option_start )
1436%
1437/bootopt.find {
1438  /bo.opt exch def
1439  /bo.cmdline exch def
1440
1441  {
1442    bo.cmdline bo.opt strstr
1443    dup {
1444      dup 1 eq {
1445        true
1446      } {
1447        dup 2 sub bo.cmdline exch get ' ' eq
1448      } ifelse
1449
1450      {
1451        bo.cmdline over bo.opt length add 1 sub get
1452        dup '=' eq
1453        over ' ' eq or
1454        exch 0 eq or
1455      } {
1456        false
1457      } ifelse
1458
1459      bo.cmdline rot add exch
1460
1461      {
1462        1 sub exit
1463      } {
1464        /bo.cmdline exch def
1465      } ifelse
1466    } {
1467      pop
1468      .undef exit
1469    } ifelse
1470  } loop
1471
1472} def
1473
1474
1475% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1476% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1477
1478% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1479% Global variables.
1480%
1481
1482/transp 0 def
1483
1484640 480 16 findmode setmode not {
1485  640 480 32 findmode setmode not {
1486    640 400 4 findmode setmode not {
1487      false .end
1488    } if
1489  } if
1490} if
1491
1492% /with_transp vscreen.size exch pop screen.size exch pop div 1 gt colorbits 8 gt and def
1493
1494/clip.size { screen.size } def
1495
1496/small_layout screen.size pop 640 eq def
1497
1498"splash.pcx" findfile
1499dup .undef eq { pop "back.jpg" findfile } if
1500/background.file over def setimage loadpalette
1501/max_image_colors image.colors def
1502
1503% 7 dup 0xffffff setpalette setcolor
1504
1505% color & font definitions must be global
1506
1507/black               0x000000          newcolor
1508/white               0xffffff          newcolor
1509/blue                0x0000a0          newcolor
1510/red                 0xc00000          newcolor
1511/green               0x009000          newcolor
1512/yellow              0xffff20          newcolor
1513/lightgray           0xd8deed          newcolor
1514/dotcolor            0xa9bbcd          newcolor
1515/lightdotcolor       0xeff2f6          newcolor
1516/somegreen           0x78a424          newcolor
1517
1518/lightblue 0x7da3d1 def
1519
1520%% include theme_colors.inc
1521
1522/font.normal "16x16.fnt" findfile def
1523/font.large font.normal def
1524
1525/cmdline.hidden cmdlinelength string def
1526/cmdline.shown cmdlinelength string def
1527
1528/debug 0 def
1529
1530check_arch_boot_dir
1531
1532
1533
Note: See TracBrowser for help on using the browser.