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

Revision 235, 5.2 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% Read syslinux configuration to get human-readable names for menu items, and
4% to decide whether to hide menu items. The configuration used is the same as
5% that used by the syslinux simple menu system, so you can use the same
6% configuration file for both.
7%
8% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9
10/menuconfig.find {
11  [
12    "/syslinux.cfg"
13    "/isolinux.cfg"
14    "/isolinux/isolinux.cfg"
15    "/boot/isolinux/isolinux.cfg"
16  ] {
17    dup filesize .undef ne { findfile return } if
18    pop
19  } forall
20  .undef
21} def
22
23% Set the human-readable text for the current menu item.
24% ( string -- )
25/menuconfig.sethuman {
26  menuconfig.curlabel .undef eq { pop return } if
27
28  /menuconfig.human exch def
29
30  /menuconfig.idx 0 def
31  menuconfig.entries {
32    menuconfig.curlabel eq {
33      menuconfig.humans menuconfig.idx menuconfig.human put
34      return
35    } if
36    /menuconfig.idx inc
37  } forall
38} def
39
40% Remove the current menu item from the menu.
41% ( -- )
42/menuconfig.hidelabel {
43  menuconfig.curlabel .undef eq { return } if
44
45  /menuconfig.idx 0 def
46  menuconfig.entries {
47    menuconfig.curlabel eq {
48      % Copy everything up to here into new arrays.
49      /menuconfig.newargs menuconfig.args length 1 sub array def
50      /menuconfig.newentries menuconfig.entries length 1 sub array def
51      /menuconfig.newhumans menuconfig.humans length 1 sub array def
52      menuconfig.idx 0 ne {
53        0 1 menuconfig.idx 1 sub {
54          menuconfig.args over get
55          menuconfig.newargs 2 index rot put
56          menuconfig.entries over get
57          menuconfig.newentries 2 index rot put
58          menuconfig.humans over get
59          menuconfig.newhumans 3 1 roll put
60        } for
61      } if
62
63      % Slide everything else down one place.
64      menuconfig.idx 1 menuconfig.entries length 2 sub {
65        menuconfig.args over 1 add get
66        menuconfig.newargs 2 index rot put
67        menuconfig.entries over 1 add get
68        menuconfig.newentries 2 index rot put
69        menuconfig.humans over 1 add get
70        menuconfig.newhumans 3 1 roll put
71      } for
72
73      /menuconfig.args menuconfig.newargs def
74      /menuconfig.entries menuconfig.newentries def
75      /menuconfig.humans menuconfig.newhumans def
76
77      return
78    } if
79    /menuconfig.idx inc
80  } forall
81} def
82
83% ( menu_entries_array menu_args_array -- menu_humans_array menu_entries_array menu_args_array )
84% The returned menu_args_array (kernel parameters), menu_entries_array
85% (identifiers), and menu_humans_array (human-readable names) will have any
86% hidden entries removed.
87/menuconfig.init {
88  dup length array /menuconfig.args exch def
89  over length array /menuconfig.entries exch def
90  over length array /menuconfig.humans exch def
91
92  % copy input arrays; initialise menuconfig.humans
93  /menuconfig.idx 0 def
94  {
95    menuconfig.args menuconfig.idx rot put
96    /menuconfig.idx inc
97  } forall
98  /menuconfig.idx 0 def
99  {
100    dup menuconfig.entries menuconfig.idx rot put
101    menuconfig.humans menuconfig.idx rot put
102    /menuconfig.idx inc
103  } forall
104
105  % we only understand syslinux configuration
106  syslinux not {
107    menuconfig.humans menuconfig.entries menuconfig.args return
108  } if
109
110  % load configuration file; return if not found
111  menuconfig.find dup .undef eq {
112    menuconfig.humans menuconfig.entries menuconfig.args return
113  } if
114  /menuconfig.file exch cvs def
115
116  /menuconfig.curlabel .undef def
117
118  menuconfig.file {
119    % skip over any NULs we've left behind; exit if there's really no more
120    % memory left to go
121    {
122      dup cvp length 0 eq { exit } if
123      dup 0 get 0 ne { exit } if
124      1 add
125    } loop
126    dup cvp length 0 eq { exit } if
127
128    % break lines at \r or \n
129    0 1 2 index length 1 sub {
130      over over get
131      dup '\x0d' eq exch '\n' eq or { over exch 0 put exit } { pop } ifelse
132    } for
133
134    skipspace getword tolower
135    % keep in sync with common.inc:MenuInit
136    % deprecated; will be removed after Ubuntu 8.04
137    dup "gfxboot-foreground" eq {
138      over skipspace strtol dup .undef ne {
139        /menu.text.select over def
140        /boot.text.options over def
141        /boot.text.normal over def
142        /panel.high exch def
143      } { pop } ifelse
144    } if
145    % deprecated; will be removed after Ubuntu 8.04
146    dup "gfxboot-background" eq {
147      over skipspace strtol dup .undef ne {
148        /menu.text.normal over def
149        /panel.normal over def
150        /loading_color over def
151        /title.bg exch def
152      } { pop } ifelse
153    } if
154    % deprecated; will be removed after Ubuntu 8.04
155    dup "gfxboot-access-options" eq {
156      /access.optionnames [
157        .undef
158        4 index
159        {
160          skipspace dup 0 get 0 eq { exit } if
161          getword exch
162        } loop
163        pop
164      ] def
165    } if
166    dup "label" eq {
167      over skipspace strdup /menuconfig.curlabel exch def
168    } if
169    dup "menu" eq {
170      over skipspace getword tolower
171      dup "label" eq { over skipspace strdup menuconfig.sethuman } if
172      dup "hide" eq { menuconfig.hidelabel } if
173      free rot pop exch
174    } if
175    free
176
177    % skip to end of line
178    dup length add
179  } loop pop
180  menuconfig.file free
181
182  menuconfig.humans menuconfig.entries menuconfig.args
183} def
Note: See TracBrowser for help on using the browser.