drawer.lua (322a2dddba49d04539cc130cd2264a00db45c20d) drawer.lua (04af422907599825aa89cce0399932835d414103)
1--
2-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3--
4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6-- All rights reserved.
7--
8-- Redistribution and use in source and binary forms, with or without

--- 251 unchanged lines hidden (view full) ---

260 -- drawlogo() must go first.
261 -- it determines the positions of other elements
262 drawer.drawlogo()
263 drawer.drawbrand()
264 drawer.drawbox()
265 return drawer.drawmenu(menu_opts)
266end
267
1--
2-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3--
4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6-- All rights reserved.
7--
8-- Redistribution and use in source and binary forms, with or without

--- 251 unchanged lines hidden (view full) ---

260 -- drawlogo() must go first.
261 -- it determines the positions of other elements
262 drawer.drawlogo()
263 drawer.drawbrand()
264 drawer.drawbox()
265 return drawer.drawmenu(menu_opts)
266end
267
268function drawer.drawmenu(m)
268function drawer.drawmenu(menudef)
269 local x = drawer.menu_position.x
270 local y = drawer.menu_position.y
271
272 -- print the menu and build the alias table
273 local alias_table = {}
274 local entry_num = 0
269 local x = drawer.menu_position.x
270 local y = drawer.menu_position.y
271
272 -- print the menu and build the alias table
273 local alias_table = {}
274 local entry_num = 0
275 local menu_entries = m.entries
275 local menu_entries = menudef.entries
276 local effective_line_num = 0
277 if type(menu_entries) == "function" then
278 menu_entries = menu_entries()
279 end
280 for _, e in ipairs(menu_entries) do
281 -- Allow menu items to be conditionally visible by specifying
282 -- a visible function.
283 if e.visible ~= nil and not e.visible() then
284 goto continue
285 end
286 effective_line_num = effective_line_num + 1
287 if e.entry_type ~= core.MENU_SEPARATOR then
288 entry_num = entry_num + 1
289 screen.setcursor(x, y + effective_line_num)
290
276 local effective_line_num = 0
277 if type(menu_entries) == "function" then
278 menu_entries = menu_entries()
279 end
280 for _, e in ipairs(menu_entries) do
281 -- Allow menu items to be conditionally visible by specifying
282 -- a visible function.
283 if e.visible ~= nil and not e.visible() then
284 goto continue
285 end
286 effective_line_num = effective_line_num + 1
287 if e.entry_type ~= core.MENU_SEPARATOR then
288 entry_num = entry_num + 1
289 screen.setcursor(x, y + effective_line_num)
290
291 print(entry_num .. ". " .. menuEntryName(m, e))
291 print(entry_num .. ". " .. menuEntryName(menudef, e))
292
293 -- fill the alias table
294 alias_table[tostring(entry_num)] = e
295 if e.alias ~= nil then
296 for _, a in ipairs(e.alias) do
297 alias_table[a] = e
298 end
299 end
300 else
301 screen.setcursor(x, y + effective_line_num)
292
293 -- fill the alias table
294 alias_table[tostring(entry_num)] = e
295 if e.alias ~= nil then
296 for _, a in ipairs(e.alias) do
297 alias_table[a] = e
298 end
299 end
300 else
301 screen.setcursor(x, y + effective_line_num)
302 print(menuEntryName(m, e))
302 print(menuEntryName(menudef, e))
303 end
304 ::continue::
305 end
306 return alias_table
307end
308
309
310function drawer.drawbox()

--- 91 unchanged lines hidden ---
303 end
304 ::continue::
305 end
306 return alias_table
307end
308
309
310function drawer.drawbox()

--- 91 unchanged lines hidden ---