summaryrefslogtreecommitdiff
path: root/stand/lua/drawer.lua
AgeCommit message (Collapse)Author
2025-06-18lualoader: adapt builtin brand/logo definitions as wellKyle Evans
While these should be moved to the new format, it wasn't my intention to force them over immediately. Downstreams may embed their own brands in drawer.lua, and we shouldn't break them for something like this. Move adapt_fb_shim() up and use it for preloaded definitions to avoid forcing the matter for now. Perhaps in the future we'll start writing out warnings for those that do need adapted. Reported by: 0x1eef on IRC
2025-06-17loader: Fix loader_brand = noneEmmanuel Vadot
Setting loader_brand to none in loader.conf now result in a lua error as we try to get a non-existant table Defines it Differential Revision: https://reviews.freebsd.org/D50875 Fixes: bef6d85b6de5 ("lualoader: allow graphical bits to be disabled with loader_gfx") Reviewed by: kevans, tsoome Sponsored by: Beckhoff Automation GmbH & Co. KG
2025-06-12stand: lua: add a more productive commentKyle Evans
The global `shift` is a special little hack for shifting everything when the logo is gone, and we should explain that. Fixes: 33d3373faf30d ("stand: lua: convert orb to a new format [...]")
2025-06-12stand: lua: convert orb to a new format that allows per-graphic shiftKyle Evans
Previously, we had one shift that had to work for both the ASCII version and the image that we may draw if we have a framebuffer to play with. That makes it more difficult to get the positioning just right, so split them out into their own tables for convenience. While we're here, stop clipping off the bottom of the orb when the autoboot sequence is interrupted. There's plenty of space for it to move up a hair, so let's do that.. Reviewed by: imp, tsoome Differential Revision: https://reviews.freebsd.org/D50801
2025-06-06lualoader: allow graphical bits to be disabled with loader_gfxKyle Evans
Some people prefer the old ASCII art look and it's good to have a way to confirm that the fallbacks still work right on systems that have a functional framebuffer available. Add a loader_gfx loader.conf(5) variable to disable the eager use of graphics for these use-cases. While we're here, clean up the style in the area a little bit; the early porting that I did to lualoader did a lot of redundant ~= nil that has carried over into some of the later work. We can drop some of that, and also re-organize some of these variables to improve readability. ziaee notes that the positioning of the orb is a bit off; this is due to a change in positioning that happened in 1b4e1171315398dec ("loader: Fix orb position") to account for the image dimensions. This should be partially reverted to get it right; we shouldn't assume that we can use the same shift in gfx-* definitions for both the ASCII art and the associated image -- the {image, image_rl} pair should be converted to something more like an fbimg or gfx table that has the image, image width and a shift override to avoid messing up the ASCII positioning when disabled (or with no graphics available). Reviewed by: imp, manu, ziaee (manpages) Differential Revision: https://reviews.freebsd.org/D50706
2025-04-17loader: Add loader_menuEmmanuel Vadot
If set to 'none' then the menu isn't displayed. The 'brand' and 'logo' part are stil displayed. Differential Revision: https://reviews.freebsd.org/D49820 Reviewed by: imp, kevans Sponsored by: Beckhoff Automation GmbH & Co. KG
2025-02-24stand: Fix brand positioning on framebuffer consoleJose Luis Duran
The drawer.lua script ignores the values in loader_brand_x and loader_brand_y on framebuffer consoles, always positioning the brand at (1, 1). Allow it to be positioned by accepting the x and y values just like the text version. For example: /boot/lua/gfx-nanobsd.lua: return { brand = { graphic = { "" }, requires_color = true, image = "/boot/images/freebsd-logo-rev.png" } } /boot/loader.conf.d/bootloader.conf: loader_logo="none" loader_brand="nanobsd" loader_brand_x="15" PR: 255202 Reviewed by: manu, imp Approved by: emaste (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D49092
2025-01-09loader: Fix orb positionEmmanuel Vadot
Fix the orb position to be aligned with the menu Differential Revision: https://reviews.freebsd.org/D48353 Reviewed by: imp, tsoome Sponsored by: Beckhoff Automation GmbH & Co. KG
2024-11-02loader: Fix boot menu on BIOSWarner Losh
Only the gfx-enabled boot loader supports unicode. Otherwise, we have to use the old cons25 / ibmpc upper code page drawing characters. Check to see if we have the gfx.term_drawbox function. If we do, we support the unicode drawing characters. If we don't, then we have an older loader that doesn't support it *OR* we have the reduced function, text-only boot loader. In either of those cases, we need to use the old graphics characters. Abstract all those details into core.hasUnicode function. PR: 282465 MFC After: 2 day Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D47403
2024-08-22loader/menu: tweak for added lineWarner Losh
I added a line to the menu, but didn't adjust so things were a line off. Make the necessary adjustments. Fixes: 7cb65be96d47 Sponsored by: Netflix MFC After: 3 days
2024-02-15loader: Move drawer.lua over to gfx table.Warner Losh
Drawer.lua is the only bit of lua code in the base that uses any of the functons moved from the loader table to the gfx table. Move the main code to using the gfx dispatch. Add compat code for running on old loaders that creates the newer-style gfx table with the term_* functions we call in it populated. This will even work on the super old versions of the loader that don't have them (we'll still skip using them). Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43908
2023-08-16Remove $FreeBSD$: two-line lua tagWarner Losh
Remove /^--\n--\s*\$FreeBSD\$.*$\n/
2023-05-12spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
2021-09-09lualoader: allow brands to specify a shiftKyle Evans
Some brands will want to specify a shift to make sure they're properly centered; let it happen.
2021-09-09lualoader: remove shadowed local from graphics:drawitem()Kyle Evans
for loop vars are local already and distinct from this earlier declaration; remove it.
2021-04-21loader: do not output empty menu titleToomas Soome
As we output spaces around the menu title, we should also check, if the title is actually empty string. PR: 255299 Submitted by: Jose Luis Duran Reported by: Jose Luis Duran MFC after: 1 week
2021-03-23loader: insert spaces around menu titleToomas Soome
Small visual nit, make menu title more clean MFC after: 3 days
2021-02-09loader: remove BORDER_PIXELSToomas Soome
BORDER_PIXELS is left over from picking up the source from illumos port. Since FreeBSD VT does not use border in terminal size calculation, there is no reason why should loader use it. MFC after: 1 week
2021-01-15lualoader: use floor division to get correct typeKyle Evans
This fixes the positioning of the "Welcome to FreeBSD" heading, which was misplaced after the recent update to Lua 5.4. The issue was previously masked by a compatibility knob in Lua 5.3 that would cause float-tagged numbers to render faithfully without the decimal component. Lua 5.4 dropped that and ensures that it always prints a decimal component, even if it has to append a ".0" to the value. Standard division produces a "float", floor division (//) can be used to guarantee an integer. Floating point operations have been completely ripped out of the liblua compiled for the bootloader, so this is a nop. This is decidedly better than trying to hack out the float tag entirely. Reported-by: mjg, probably others MFC-after: 3 days
2021-01-02loader: implement framebuffer consoleToomas Soome
Draw console on efi. Add vbe framebuffer for BIOS loader (vbe off, vbe on, vbe list, vbe set xxx). autoload font (/boot/fonts) based on resolution and font size. Add command loadfont (set font by file) and variable screen.font (set font by size). Pass loaded font to kernel. Export variables: screen.height screen.width screen.depth Add gfx primitives to draw the screen and put png image on the screen. Rework menu draw to iterate list of consoles to enamble device specific output. Probably something else I forgot... Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27420
2020-10-04lualoader: improve the design of the brand-/logo- mechanismKyle Evans
In the previous world order, any brand/logo was forced to pull in the drawer and call drawer.add{Brand,Logo} with the name their brand/logo is taking and a table describing it. In the new world order, these files just need to return a table that maps out graphics types to a table of the exact same format as what was previously being passed back into the drawer. The appeal here is not needing to grab a reference back to the drawer module and having a cleaner data-driven looking format for these. The format has been renamed to 'gfx-*' prefixes and each one can provide a logo and a brand. drawer.addBrand/drawer.addLogo will remain in place until FreeBSD 13, as there's no overhead to them and it's not yet worth the break in compatibility with any pre-existing brands and logos. Reviewed by: freqlabs MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24966 Notes: svn path=/head/; revision=366435
2020-06-01lualoader: improve drawer error handlingKyle Evans
At least one user has landed in a scenario where logo files appear to be misnamed, and we failed to find them. Our fallback for missing logodefs is orb/orbbw, based on the color status. In a scenario where we can't locate the logos, though, this is not ideal. Add in one more layer of fallback to properly just don't draw any logo if the fan has been jam packed with foreign material. PR: 246046 MFC after: 3 days Notes: svn path=/head/; revision=361709
2019-09-10lualoader: Revert to ASCII menu frame for serial consoleKyle Evans
The box drawing characters we use aren't necessarily safe with a serial console; for instance, in the report by npn@, these were causing his xterm to send back a sequence that lua picked up as input and halted the boot. This is less than ideal. Fallback to ASCII frames for console with 'comconsole' in it. This is a partial revert r338108 by imp@ -- instead of removing the menu entirely and disabling color/cursor sequences, just reverting the default frame to ASCII is enough to not break in this setup. Reported by: npn Triaged and recommended by: tsoome Notes: svn path=/head/; revision=352194
2019-09-05loader: use teken teminal emulator for x86 and uefiToomas Soome
Replace mini cons25 emulator with teken, this does enable us proper console terminal for loader and will make it possible to implement different back end callbacks to draw to screen. At this time we still only "draw" in text mode. Notes: svn path=/head/; revision=351900
2018-08-19lualoader: Add drawer-exported variables for default logodefsKyle Evans
Uncovered while writing the documentation from this, we previously explicitly fell back to orb or orbbw if an invalid or incompatible logodef was selected -- in contrast to branddefs, which have an exported variable that one can whip up a quick local.lua to override in a safe manner that works regardless of whether or not loader.conf(5) successfully loads. Notes: svn path=/head/; revision=338067
2018-08-19lualoader: Hide the rest of the private interfacesKyle Evans
These are less controversial than the others, thus done in a separate commit. These are all used internally and ways to override are provided via soon-to-be-documented API or loader.conf(5) variables. Notes: svn path=/head/; revision=338066
2018-08-19lualoader: Hide most of the internal drawing functionsKyle Evans
Ideally, all of the functionality to revamp the loader screen has associated APIs that are flexible enough that third-party scripts wouldn't need to override these. Notes: svn path=/head/; revision=338065
2018-08-19lualoader: Stop exporting drawer.drawKyle Evans
drawer.draw is the back-end for drawlogo and drawbrand and should not be used directly. Notes: svn path=/head/; revision=338063
2018-06-11lualoader: Allow brand-*.lua for adding new brandsKyle Evans
dteske@, I believe, had originally pointed out that lualoader failed to allow logo-*.lua for new logos to be added. When correcting this mistake, I failed to do the same for brands. Correct the sub-mistake: creating new brands is almost identical to creating new logos, except one must use `drawer.addBrand` and 'graphic' is the only valid key for a branddef at the moment. While here, I've added `drawer.default_brand` to be set to name of brand to be used (e.g. 'fbsd', project default). Eventually this whole goolash will be documented. Reported by: kmoore, iXsystems Notes: svn path=/head/; revision=334939
2018-04-01lualoader: Don't try to lookup a nil logoKyle Evans
Notes: svn path=/head/; revision=331860
2018-04-01lualoader: Split logodefs out into logo-* filesKyle Evans
This commit splits all of the logodefs/graphics out into their own own files and provides a method for these files to register their logodefs with the drawer. Graphics are now loaded on demand if they don't exist in the current set of logodefs. The drawer module becomes a little easier to navigate through without all of the graphics mixed in. It's also easy to do one-off graphics like the 9.2 Die Hard tribute by dteske@ without adding even more to our memory requirements. Notes: svn path=/head/; revision=331859
2018-03-21lualoader: Use printc when we expect ANSI escape sequencesKyle Evans
Notes: svn path=/head/; revision=331314
2018-03-04lualoader: logdef -> logodef typoKyle Evans
Notes: svn path=/head/; revision=330370
2018-03-03lualoader: Shift menu+brand even for logo=none with customized posKyle Evans
Notes: svn path=/head/; revision=330346
2018-03-03lualoader: Tweak positioning and fix an off-by-oneKyle Evans
- All of our default positions were offset from forth - Our menu frame size was smaller than in forth - Logo/brand drawing had an off-by-one, drawing one column lower on the screen than they should have been. - While here, switch a print() to printc() as it's expected that logos may contain color and other escpae sequences that we'll need to honor. Notes: svn path=/head/; revision=330345
2018-03-03lualoader: Respect loader_menu_title_alignKyle Evans
It may be set to "left" or "right" -- any other value will cause the title to be centered. I've chosen to position these things just inside the vertical borders, rather than overlapping the corners. This is an arbitrary choice and easily amendable if this looks terrible. Notes: svn path=/head/; revision=330342
2018-03-03lualoader: Respect loader_menu_title, prepare for alignKyle Evans
Notes: svn path=/head/; revision=330341
2018-03-02lualoader: Use global printc instead of loader.printcKyle Evans
r330282 registered loader.printc as printc, so use it instead. This makes sense for a couple reasons, the major point being that it reads a little bit easier and pairs nicely with the global 'print'. Similar cases can not really be made for other loader.* functions as most of them are either highly specific to our use-case or usually available in other modules, such as `os`. printc does not have a standard implementation in the Lua world(*), so we have a little more leeway with it, and it's kind of a special case of the globally available 'print'. (*) I've been in the Lua world for all of two weeks, so this could be wrong. Notes: svn path=/head/; revision=330283
2018-03-02lualoader: Steamroll the box-drawingKyle Evans
- Add drawer.frame_styles to map out the kinds of characters we need for the different loader_menu_frame values - Respect loader_menu_frame, default to double[*] - (imp) Use loader.printc instead of print- print adds a newline to the output, which is not the right thing we want to be doing. - (imp) Draw horizontal frames a little more efficiently- setting the cursor after every line segment is horribly inefficient, especially on serial consoles. Halve the number of characters written at the expense of an additional loop to draw the bottom frame, which is likely more efficient in the long run for some of less ideal scenarios. [*] menu.4th(8) claims that the default here was single, but unset loader_menu_frame yielded double and we didn't have any overrides in the default loader.conf(5), so double it is. Notes: svn path=/head/; revision=330281
2018-03-02lualoader: Use string literal \xNN instead of string.char()Kyle Evans
Notes: svn path=/head/; revision=330263
2018-02-26lualoader: More argument name expansion, part 2Kyle Evans
screen also has some instances, but it also has other cleanup to go with it. Because of this, I will be committing the screen changes separately. Notes: svn path=/head/; revision=330009
2018-02-24lualoader: Clean up naming conventions a little bitKyle Evans
We mostly use camel case for function names, but some local functions got mixed in using internal underscores. Doubles down on camel case. Notes: svn path=/head/; revision=329927
2018-02-24lualoader: Remove unused variable; we now use the effective line numberKyle Evans
Notes: svn path=/head/; revision=329902
2018-02-23lualoader: Track effective line number, use it for drawingKyle Evans
Takes into account hidden entries, so that we don't draw blank lines in place of a hidden item. Notes: svn path=/head/; revision=329861
2018-02-23lualoader: Use "local function x()" instead of "local x = function()"Kyle Evans
The latter is good, but the former is more elegant and clear about what 'x' is. Adopt it, preferably only using the latter kind of notation where needed as values for tables. Notes: svn path=/head/; revision=329856
2018-02-23Add SPDX tags to lua filesKyle Evans
Notes: svn path=/head/; revision=329851
2018-02-22lualoader: Attend to some 80-col issues, pointed out by luacheckKyle Evans
Graphics have a tendency to cause 80-col issues, so make an exception to our standard indentation guidelines for these graphics. This does not hamper readability too badly. Two 40-column strings of spaces is trivially replaced with string.rep(" ", 80) Notes: svn path=/head/; revision=329836
2018-02-22lualoader: Address some 'luacheck' concernsKyle Evans
luacheck pointed out an assortment of issues, ranging from non-standard globals being created as well as unused parameters, variables, and redundant assignments. Using '_' as a placeholder for values unused (whether it be parameters unused or return values unused, assuming multiple return values) feels clean and gets the point across, so I've adopted it. It also helps flag candidates for cleanup later in some of the lambdas I've created, giving me an easy way to re-evaluate later if we're still not using some of these features. Notes: svn path=/head/; revision=329809
2018-02-21lualoader: Replace 8-space indentation with a single tabKyle Evans
Notes: svn path=/head/; revision=329747
2018-02-21lualoader: Allow carousel 'items' to be a table as well as a functionKyle Evans
We don't have any in-tree users of this, but for a static set of carousel options having to define a callback is excessive. Notes: svn path=/head/; revision=329700