build: add a format target and one shared editor config
The Lua modules were split between tabs and spaces because nothing pinned a style; .editorconfig is what lua-language-server reads on save, so the editor and the tree now agree. clang-format already had a config and left native/ unchanged. Embedded modules regenerate from the reformatted ui.lua.
This commit is contained in:
+31
-13
@@ -1,25 +1,43 @@
|
||||
package.path = "./lua/lib/?.lua;" .. package.path
|
||||
|
||||
local drawn = {}
|
||||
local roles = {"confirm", "back", "right"}
|
||||
local roles = { "confirm", "back", "right" }
|
||||
|
||||
gui = {
|
||||
FONT_SMALL = 0,
|
||||
STYLE_NORMAL = 0,
|
||||
color = function(r, g, b) return r * 65536 + g * 256 + b end,
|
||||
getWidth = function() return 300 end,
|
||||
getHeight = function() return 240 end,
|
||||
getFontHeight = function() return 8 end,
|
||||
getTextWidth = function(_, text) return #text * 6 end,
|
||||
fillRect = function(x, y, w, h) drawn.strip = {x, y, w, h} end,
|
||||
drawText = function(_, x, _, text) drawn[#drawn + 1] = {text = text, x = x} end,
|
||||
color = function(r, g, b)
|
||||
return r * 65536 + g * 256 + b
|
||||
end,
|
||||
getWidth = function()
|
||||
return 300
|
||||
end,
|
||||
getHeight = function()
|
||||
return 240
|
||||
end,
|
||||
getFontHeight = function()
|
||||
return 8
|
||||
end,
|
||||
getTextWidth = function(_, text)
|
||||
return #text * 6
|
||||
end,
|
||||
fillRect = function(x, y, w, h)
|
||||
drawn.strip = { x, y, w, h }
|
||||
end,
|
||||
drawText = function(_, x, _, text)
|
||||
drawn[#drawn + 1] = { text = text, x = x }
|
||||
end,
|
||||
}
|
||||
|
||||
input = {getButtons = function() return roles end}
|
||||
input = {
|
||||
getButtons = function()
|
||||
return roles
|
||||
end,
|
||||
}
|
||||
|
||||
local hints = require("hints")
|
||||
local hints = require "hints"
|
||||
|
||||
local height = hints.draw({back = "Close", confirm = "Select", up = "Scroll"})
|
||||
local height = hints.draw { back = "Close", confirm = "Select", up = "Scroll" }
|
||||
assert(height == 14, "height covers the font plus padding")
|
||||
assert(drawn.strip[2] == 226, "the strip sits at the bottom by default")
|
||||
|
||||
@@ -30,7 +48,7 @@ assert(drawn[1].x == 60 and drawn[2].x == 207, "each label centres in its slot")
|
||||
|
||||
drawn = {}
|
||||
roles = {}
|
||||
assert(hints.draw({confirm = "Select"}) == 14, "a device with no buttons still clears the strip")
|
||||
assert(hints.draw { confirm = "Select" } == 14, "a device with no buttons still clears the strip")
|
||||
assert(#drawn == 0 and drawn.strip, "nothing is labelled, but the strip is cleared")
|
||||
|
||||
print("ok")
|
||||
print "ok"
|
||||
|
||||
Reference in New Issue
Block a user