menu.lua (ada26c4a885910e0b07367b260ba049cfbae4a10) | menu.lua (a7cf056239ff1366cb231f8c6f516b023922bf4e) |
---|---|
1-- 2-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 3-- All rights reserved. 4-- 5-- Redistribution and use in source and binary forms, with or without 6-- modification, are permitted provided that the following conditions 7-- are met: 8-- 1. Redistributions of source code must retain the above copyright --- 36 unchanged lines hidden (view full) --- 45--rooted at menu.welcome 46--submenu declarations: 47local boot_options; 48local welcome; 49 50menu.boot_options = { 51 -- return to welcome menu 52 { | 1-- 2-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 3-- All rights reserved. 4-- 5-- Redistribution and use in source and binary forms, with or without 6-- modification, are permitted provided that the following conditions 7-- are met: 8-- 1. Redistributions of source code must retain the above copyright --- 36 unchanged lines hidden (view full) --- 45--rooted at menu.welcome 46--submenu declarations: 47local boot_options; 48local welcome; 49 50menu.boot_options = { 51 -- return to welcome menu 52 { |
53 entry_type = "return", | 53 entry_type = core.MENU_RETURN, |
54 name = function() 55 return "Back to main menu"..color.highlight(" [Backspace]"); 56 end 57 }, 58 59 -- load defaults 60 { | 54 name = function() 55 return "Back to main menu"..color.highlight(" [Backspace]"); 56 end 57 }, 58 59 -- load defaults 60 { |
61 entry_type = "entry", | 61 entry_type = core.MENU_ENTRY, |
62 name = function() 63 return "Load System "..color.highlight("D").."efaults"; 64 end, 65 func = function() 66 core.setDefaults() 67 end, 68 alias = {"d", "D"} 69 }, 70 71 { | 62 name = function() 63 return "Load System "..color.highlight("D").."efaults"; 64 end, 65 func = function() 66 core.setDefaults() 67 end, 68 alias = {"d", "D"} 69 }, 70 71 { |
72 entry_type = "separator", | 72 entry_type = core.MENU_SEPARATOR, |
73 name = function() 74 return ""; 75 end 76 }, 77 78 { | 73 name = function() 74 return ""; 75 end 76 }, 77 78 { |
79 entry_type = "separator", | 79 entry_type = core.MENU_SEPARATOR, |
80 name = function() 81 return "Boot Options:"; 82 end 83 }, 84 85 -- acpi 86 { | 80 name = function() 81 return "Boot Options:"; 82 end 83 }, 84 85 -- acpi 86 { |
87 entry_type = "entry", | 87 entry_type = core.MENU_ENTRY, |
88 name = function() 89 return OnOff(color.highlight("A").."CPI :", core.acpi); 90 end, 91 func = function() 92 core.setACPI(); 93 end, 94 alias = {"a", "A"} 95 }, 96 -- safe mode 97 { | 88 name = function() 89 return OnOff(color.highlight("A").."CPI :", core.acpi); 90 end, 91 func = function() 92 core.setACPI(); 93 end, 94 alias = {"a", "A"} 95 }, 96 -- safe mode 97 { |
98 entry_type = "entry", | 98 entry_type = core.MENU_ENTRY, |
99 name = function() 100 return OnOff("Safe "..color.highlight("M").."ode :", core.sm); 101 end, 102 func = function() 103 core.setSafeMode(); 104 end, 105 alias = {"m", "M"} 106 }, 107 -- single user 108 { | 99 name = function() 100 return OnOff("Safe "..color.highlight("M").."ode :", core.sm); 101 end, 102 func = function() 103 core.setSafeMode(); 104 end, 105 alias = {"m", "M"} 106 }, 107 -- single user 108 { |
109 entry_type = "entry", | 109 entry_type = core.MENU_ENTRY, |
110 name = function() 111 return OnOff(color.highlight("S").."ingle user:", core.su); 112 end, 113 func = function() 114 core.setSingleUser(); 115 end, 116 alias = {"s", "S"} 117 }, 118 -- verbose boot 119 { | 110 name = function() 111 return OnOff(color.highlight("S").."ingle user:", core.su); 112 end, 113 func = function() 114 core.setSingleUser(); 115 end, 116 alias = {"s", "S"} 117 }, 118 -- verbose boot 119 { |
120 entry_type = "entry", | 120 entry_type = core.MENU_ENTRY, |
121 name = function() 122 return OnOff(color.highlight("V").."erbose :", core.verbose); 123 end, 124 func = function() 125 core.setVerbose(); 126 end, 127 alias = {"v", "V"} 128 }, 129}; 130 131menu.welcome = { 132 -- boot multi user 133 { | 121 name = function() 122 return OnOff(color.highlight("V").."erbose :", core.verbose); 123 end, 124 func = function() 125 core.setVerbose(); 126 end, 127 alias = {"v", "V"} 128 }, 129}; 130 131menu.welcome = { 132 -- boot multi user 133 { |
134 entry_type = "entry", | 134 entry_type = core.MENU_ENTRY, |
135 name = function() 136 return color.highlight("B").."oot Multi user "..color.highlight("[Enter]"); 137 end, 138 func = function() 139 core.setSingleUser(false); 140 core.boot(); 141 end, 142 alias = {"b", "B"} 143 }, 144 145 -- boot single user 146 { | 135 name = function() 136 return color.highlight("B").."oot Multi user "..color.highlight("[Enter]"); 137 end, 138 func = function() 139 core.setSingleUser(false); 140 core.boot(); 141 end, 142 alias = {"b", "B"} 143 }, 144 145 -- boot single user 146 { |
147 entry_type = "entry", | 147 entry_type = core.MENU_ENTRY, |
148 name = function() 149 return "Boot "..color.highlight("S").."ingle user"; 150 end, 151 func = function() 152 core.setSingleUser(true); 153 core.boot(); 154 end, 155 alias = {"s", "S"} 156 }, 157 158 -- escape to interpreter 159 { | 148 name = function() 149 return "Boot "..color.highlight("S").."ingle user"; 150 end, 151 func = function() 152 core.setSingleUser(true); 153 core.boot(); 154 end, 155 alias = {"s", "S"} 156 }, 157 158 -- escape to interpreter 159 { |
160 entry_type = "return", | 160 entry_type = core.MENU_RETURN, |
161 name = function() 162 return color.highlight("Esc").."ape to loader prompt"; 163 end, 164 alias = {core.KEYSTR_ESCAPE} 165 }, 166 167 -- reboot 168 { | 161 name = function() 162 return color.highlight("Esc").."ape to loader prompt"; 163 end, 164 alias = {core.KEYSTR_ESCAPE} 165 }, 166 167 -- reboot 168 { |
169 entry_type = "entry", | 169 entry_type = core.MENU_ENTRY, |
170 name = function() 171 return color.highlight("R").."eboot"; 172 end, 173 func = function() 174 loader.perform("reboot"); 175 end, 176 alias = {"r", "R"} 177 }, 178 179 180 { | 170 name = function() 171 return color.highlight("R").."eboot"; 172 end, 173 func = function() 174 loader.perform("reboot"); 175 end, 176 alias = {"r", "R"} 177 }, 178 179 180 { |
181 entry_type = "separator", | 181 entry_type = core.MENU_SEPARATOR, |
182 name = function() 183 return ""; 184 end 185 }, 186 187 { | 182 name = function() 183 return ""; 184 end 185 }, 186 187 { |
188 entry_type = "separator", | 188 entry_type = core.MENU_SEPARATOR, |
189 name = function() 190 return "Options:"; 191 end 192 }, 193 194 -- kernel options 195 { | 189 name = function() 190 return "Options:"; 191 end 192 }, 193 194 -- kernel options 195 { |
196 entry_type = "carousel_entry", | 196 entry_type = core.MENU_CAROUSEL_ENTRY, |
197 carousel_id = "kernel", 198 items = core.kernelList, 199 name = function(idx, choice, all_choices) 200 if #all_choices == 0 then 201 return "Kernel: "; 202 end 203 204 local kernel_name = color.escapef(color.GREEN) .. --- 8 unchanged lines hidden (view full) --- 213 func = function(choice) 214 config.reload(choice); 215 end, 216 alias = {"k", "K"} 217 }, 218 219 -- boot options 220 { | 197 carousel_id = "kernel", 198 items = core.kernelList, 199 name = function(idx, choice, all_choices) 200 if #all_choices == 0 then 201 return "Kernel: "; 202 end 203 204 local kernel_name = color.escapef(color.GREEN) .. --- 8 unchanged lines hidden (view full) --- 213 func = function(choice) 214 config.reload(choice); 215 end, 216 alias = {"k", "K"} 217 }, 218 219 -- boot options 220 { |
221 entry_type = "submenu", | 221 entry_type = core.MENU_SUBMENU, |
222 name = function() 223 return "Boot "..color.highlight("O").."ptions"; 224 end, 225 submenu = function() 226 return menu.boot_options; 227 end, 228 alias = {"o", "O"} 229 } --- 49 unchanged lines hidden (view full) --- 279 for k, v in pairs(alias_table) do 280 if (key == k) then 281 sel_entry = v; 282 end 283 end 284 285 -- if we have an alias do the assigned action: 286 if(sel_entry ~= nil) then | 222 name = function() 223 return "Boot "..color.highlight("O").."ptions"; 224 end, 225 submenu = function() 226 return menu.boot_options; 227 end, 228 alias = {"o", "O"} 229 } --- 49 unchanged lines hidden (view full) --- 279 for k, v in pairs(alias_table) do 280 if (key == k) then 281 sel_entry = v; 282 end 283 end 284 285 -- if we have an alias do the assigned action: 286 if(sel_entry ~= nil) then |
287 if (sel_entry.entry_type == "entry") then | 287 if (sel_entry.entry_type == core.MENU_ENTRY) then |
288 -- run function 289 sel_entry.func(); | 288 -- run function 289 sel_entry.func(); |
290 elseif (sel_entry.entry_type == "carousel_entry") then | 290 elseif (sel_entry.entry_type == core.MENU_CAROUSEL_ENTRY) then |
291 -- carousel (rotating) functionality 292 local carid = sel_entry.carousel_id; 293 local caridx = menu.getCarouselIndex(carid); 294 local choices = sel_entry.items(); 295 296 caridx = (caridx % #choices) + 1; 297 menu.setCarouselIndex(carid, caridx); 298 sel_entry.func(choices[caridx]); | 291 -- carousel (rotating) functionality 292 local carid = sel_entry.carousel_id; 293 local caridx = menu.getCarouselIndex(carid); 294 local choices = sel_entry.items(); 295 296 caridx = (caridx % #choices) + 1; 297 menu.setCarouselIndex(carid, caridx); 298 sel_entry.func(choices[caridx]); |
299 elseif (sel_entry.entry_type == "submenu") then | 299 elseif (sel_entry.entry_type == core.MENU_SUBMENU) then |
300 -- recurse 301 cont = menu.run(sel_entry.submenu()); | 300 -- recurse 301 cont = menu.run(sel_entry.submenu()); |
302 elseif (sel_entry.entry_type == "return") then | 302 elseif (sel_entry.entry_type == core.MENU_RETURN) then |
303 -- break recurse 304 cont = false; 305 end 306 -- if we got an alias key the screen is out of date: 307 screen.clear(); 308 screen.defcursor(); 309 alias_table = drawer.drawscreen(m); 310 end --- 80 unchanged lines hidden --- | 303 -- break recurse 304 cont = false; 305 end 306 -- if we got an alias key the screen is out of date: 307 screen.clear(); 308 screen.defcursor(); 309 alias_table = drawer.drawscreen(m); 310 end --- 80 unchanged lines hidden --- |