drawer.lua (6697f577d1216a312dd6ed27aa30f8a5d0d587d4) | drawer.lua (546f18f3dadc50e6978e02b1479bc55cfa677094) |
---|---|
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 --- 47 unchanged lines hidden (view full) --- 56 return name_handler(drawing_menu, entry) 57 end 58 if type(entry.name) == "function" then 59 return entry.name() 60 end 61 return entry.name 62end 63 | 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 --- 47 unchanged lines hidden (view full) --- 56 return name_handler(drawing_menu, entry) 57 end 58 if type(entry.name) == "function" then 59 return entry.name() 60 end 61 return entry.name 62end 63 |
64local function processFile(gfxname) 65 if gfxname == nil then 66 return false, "Missing filename" 67 end 68 69 local ret = try_include('gfx-' .. gfxname) 70 if ret == nil then 71 return false, "Failed to include gfx-" .. gfxname 72 end 73 74 -- Legacy format 75 if type(ret) ~= "table" then 76 return true 77 end 78 79 for gfxtype, def in pairs(ret) do 80 if gfxtype == "brand" then 81 drawer.addBrand(gfxname, def) 82 elseif gfxtype == "logo" then 83 drawer.addLogo(gfxname, def) 84 else 85 return false, "Unknown graphics type '" .. gfxtype .. 86 "'" 87 end 88 end 89 90 return true 91end 92 |
|
64local function getBranddef(brand) 65 if brand == nil then 66 return nil 67 end 68 -- Look it up 69 local branddef = branddefs[brand] 70 71 -- Try to pull it in 72 if branddef == nil then | 93local function getBranddef(brand) 94 if brand == nil then 95 return nil 96 end 97 -- Look it up 98 local branddef = branddefs[brand] 99 100 -- Try to pull it in 101 if branddef == nil then |
73 try_include('brand-' .. brand) | 102 local res, err = processFile(brand) 103 if not res then 104 -- This fallback should go away after FreeBSD 13. 105 try_include('brand-' .. brand) 106 -- If the fallback also failed, print whatever error 107 -- we encountered in the original processing. 108 if branddefs[brand] == nil then 109 print(err) 110 return nil 111 end 112 end 113 |
74 branddef = branddefs[brand] 75 end 76 77 return branddef 78end 79 80local function getLogodef(logo) 81 if logo == nil then 82 return nil 83 end 84 -- Look it up 85 local logodef = logodefs[logo] 86 87 -- Try to pull it in 88 if logodef == nil then | 114 branddef = branddefs[brand] 115 end 116 117 return branddef 118end 119 120local function getLogodef(logo) 121 if logo == nil then 122 return nil 123 end 124 -- Look it up 125 local logodef = logodefs[logo] 126 127 -- Try to pull it in 128 if logodef == nil then |
89 try_include('logo-' .. logo) | 129 local res, err = processFile(logo) 130 if not res then 131 -- This fallback should go away after FreeBSD 13. 132 try_include('logo-' .. logo) 133 -- If the fallback also failed, print whatever error 134 -- we encountered in the original processing. 135 if logodefs[logo] == nil then 136 print(err) 137 return nil 138 end 139 end 140 |
90 logodef = logodefs[logo] 91 end 92 93 return logodef 94end 95 96local function draw(x, y, logo) 97 for i = 1, #logo do --- 261 unchanged lines hidden (view full) --- 359-- Module exports 360drawer.default_brand = 'fbsd' 361drawer.default_color_logodef = 'orb' 362drawer.default_bw_logodef = 'orbbw' 363-- For when things go terribly wrong; this def should be present here in the 364-- drawer module in case it's a filesystem issue. 365drawer.default_fallback_logodef = 'none' 366 | 141 logodef = logodefs[logo] 142 end 143 144 return logodef 145end 146 147local function draw(x, y, logo) 148 for i = 1, #logo do --- 261 unchanged lines hidden (view full) --- 410-- Module exports 411drawer.default_brand = 'fbsd' 412drawer.default_color_logodef = 'orb' 413drawer.default_bw_logodef = 'orbbw' 414-- For when things go terribly wrong; this def should be present here in the 415-- drawer module in case it's a filesystem issue. 416drawer.default_fallback_logodef = 'none' 417 |
418-- These should go away after FreeBSD 13; only available for backwards 419-- compatibility with old logo- files. |
|
367function drawer.addBrand(name, def) 368 branddefs[name] = def 369end 370 371function drawer.addLogo(name, def) 372 logodefs[name] = def 373end 374 --- 40 unchanged lines hidden --- | 420function drawer.addBrand(name, def) 421 branddefs[name] = def 422end 423 424function drawer.addLogo(name, def) 425 logodefs[name] = def 426end 427 --- 40 unchanged lines hidden --- |