summaryrefslogtreecommitdiff
path: root/stand/lua/screen.lua
AgeCommit message (Collapse)Author
2024-09-24loader: Fix 0 vs 1 confusion for column numbersWarner Losh
In two places we use '0' for a column number. However, the upper left hand corner of the screen is 1, 1. Fix those two confusions. Also, fix a comment that flipped the coordinates in a comment (I'm used to the vt100 convention where it's row, column (eg y, x)) and didn't notice the rest of the code uses x, y. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D46777
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
2019-10-21lualoader: don't botch disabling of colorKyle Evans
When colors are disabled, color.escape{fg,bg} would return the passed in color rather than the proper ANSI sequence for the color. color.escape{fg,bg} would be wrong. Instead return '', as the associated reset* functions will also return ''. This should get rid of the funky '2' and '4' in the kernel selector if you're booting serial. Reported by: npn Notes: svn path=/head/; revision=353872
2018-08-20Serial console menus for lua.Warner Losh
Remove a bunch of special cases for UEFI and serial consoles. We do want to do curses and menu things here. This makes us match what we do in FORTH, with the possible exception of boxes around menus. Differential Revision: https://reviews.freebsd.org/D16816 Notes: svn path=/head/; revision=338108
2018-03-21lualoader: Clear up some possible naming confusionKyle Evans
In the original lualoader project, 'escapef' and 'escapeb' were chosen for 'escape fg' and 'escape bg'. We've carried on this naming convention, and as our use of attributes grow the likeliness of 'escapeb'/'resetb' being confused upon glance for 'escape bold'/'reset bold' increases. Fix this by renaming these four functions to {escape,reset}{fg,bg} rather than {escape,reset}{f,b} for clarity. Reported by: dteske Notes: svn path=/head/; revision=331304
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-02-28lualoader: Further screen cleanupKyle Evans
- Add screen.default_x and screen.default_y to determine where screen.defcursor resets the cursor to. - Use screen.setcursor in screen.defcursor instead of rewriting the escape sequence. - Use screen.default_y when resetting the cursor after writing the new twiddle character, add a comment verbally describing the position just in case. Notes: svn path=/head/; revision=330099
2018-02-28lualoader: Re-do twiddleKyle Evans
It worked on my test setup, but is clearly non-functional on others. Further examination of check-password.4th showed that it actually reset the cursor to 0,25 every time and overwrote the previous password prompt. Do that, and also clear the "Incorrect Password" text if the correct password gets entered. Notes: svn path=/head/; revision=330098
2018-02-27lualoader: Convert instances of KEYSTR_ESCAPE .. "[" -> KEYSTR_CSIKyle Evans
Notes: svn path=/head/; revision=330087
2018-02-27lualoader: Replace instances of \027 with KEYSTR_ESCAPEKyle Evans
With exception to drawing bits, which should probably be kept as-is to not make a mess out of things. Reported by: rpokala (a while ago) Notes: svn path=/head/; revision=330084
2018-02-27lualoader: Add a twiddle at password promptKyle Evans
This gives some form of feedback while typing, and matches-(ish*) Forth behavior. The cursor generally rests two column after the password prompt, then the twiddle is drawn three columns later and the cursor reset to resting position after being drawn. I've removed the note about re-evaluating it for security considerations and instead set it up as a module-local variable that we can set later depending on environment or something. It's set to false with no chance of changing at the moment. *As close as I can tell from reading check-password.4th, because I don't have an easy test (or deployed) setup for forth loader to check how close it is. Please do mention if it's not close enough. Notes: svn path=/head/; revision=330082
2018-02-26lualoader: screen argument fixesKyle Evans
screen was also guilty of not-so-great argument names, but it was also guilty of handling color sequences on its own. Change those bits to using the color module instead. As a side note, between color and screen, I'm not 100% sure that returning the color_value is the right thing to do if we won't generate the escape sequences. This should be re-evaluated at a later time, and they should likely return nil instead. Notes: svn path=/head/; revision=330010
2018-02-23Add SPDX tags to lua filesKyle Evans
Notes: svn path=/head/; revision=329851
2018-02-21lualoader: Remove nasty hack for not printing out ".0"Kyle Evans
luaconf.h has a LUA_COMPAT_FLOATSTRING option that may be defined to do this instead of needing intstring. Reported by: Dan Nelson Notes: svn path=/head/; revision=329756
2018-02-21lualoader: Drop excessive parenthesizingKyle Evans
This was also a convenience convention (for me) that is not very lua-tic. Drop it. I've maintained some parentheses where I'd prefer them, for example, 'if x or y or (z and w) then', but these situations are far and few between. Notes: svn path=/head/; revision=329685
2018-02-21lualoader: Drop terminating semicolonsKyle Evans
This was previously chosen out of convenience, as we had a mixed style and needed to be consistent. I started learning Lua on Friday, so I switched everything over. It is not a very lua-nic convention, though, so drop it. Excessive parenthesizing around conditionals is next on the chopping block. Notes: svn path=/head/; revision=329684
2018-02-20stand/lua: Consistently organize modulesKyle Evans
We follow pretty closely the following structure of a module: 1. Copyright notice 2. Module requires 3. Module local declarations 4. Module local definitions 5. Module exports 6. return Re-organize the one-offs (config/drawer) and denote the start of module exports with a comment. Notes: svn path=/head/; revision=329641
2018-02-20stand/lua: Consistently declare local functions at module scopeKyle Evans
Declare these adjacent to the local definitions at the top of the module, and make sure they're actually declared local to pollute global namespace a little bit less. Notes: svn path=/head/; revision=329640
2018-02-19stand/lua: Round up some more style.lua(9) concernsKyle Evans
Notes: svn path=/head/; revision=329594
2018-02-19stand/lua: Rename bootserial for clarityKyle Evans
Notes: svn path=/head/; revision=329577
2018-02-17stand/lua: Style passKyle Evans
These are the style points that I'd like to try and maintain in our lua scripts: - Parentheses around conditionals - Trailing semicolons, except on block terminators - s:method(...) instead of string.method(s, ...) where applicable There's likely more, but that'll get hammered out as we continue. Notes: svn path=/head/; revision=329435
2018-02-16stand/lua: Use escaped dot instead of single character classKyle Evans
Notes: svn path=/head/; revision=329393
2018-02-16stand/lua: Chop off the decimal for numbers passed to setcursorKyle Evans
Decimals screw up the escape sequence and the cursor will not get set. Right now this only affects setting the cursor for drawing "Welcome to FreeBSD" -- the resulting number after our (x+(w/2)-9) calculation gets output as "14.0." This should be fixed at the interpreter level, rather than here, but this is not a widespread problem at the moment so we'll fix it up in further work. Reported by: David Wolfskill <david@catwhisker.org> Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D14375 Notes: svn path=/head/; revision=329387
2018-02-12Add the lua scripts from the lua-bootloader SoCWarner Losh
These are the .lua files from from Pedro Souza's 2014 Summer of Code project. Rui Paulo, Pedro Arthur and Wojciech A. Koszek also contributed. Obtained from: https://wiki.freebsd.org/SummerOfCode2014/LuaLoader Sponsored by: Google Summer of Code Improve the SoC lua menu code to bring it in line with forth menu functionality Submitted by: Zakary Nafziger Sponsored by: FreeBSD Foundation Use loader.setenv and loader.unsetenv instead of loader.perform Convert from include("/boot/foo.lua") to foo = require("foo"); to bring in line with latest lua module conventions. Enforce a uniform style for the new .lua files: o hard tab indenation for 8 spaces o don't have if foo then bar; else bas; end on one line MFC After: 1 month Relnotes: yes Differential Review: https://reviews.freebsd.org/D14295 Notes: svn path=/head/; revision=329167