util spaces function

This commit is contained in:
Mikayla Fischler 2022-06-11 12:20:49 -04:00
parent 1fa87132d6
commit dc867095fd
3 changed files with 9 additions and 2 deletions

View File

@ -38,7 +38,7 @@ local function rectangle(args)
assert(border_width_h * 2 <= e.frame.h, "graphics.elements.rectangle: border too thick for height")
-- form the basic and top/bottom blit strings
spaces = util.strrep(" ", e.frame.w)
spaces = util.spaces(e.frame.w)
blit_fg = util.strrep(e.fg_bg.blit_fgd, e.frame.w)
blit_bg_top_bot = util.strrep(border_blit, e.frame.w)

View File

@ -25,7 +25,7 @@ local function vbar(args)
-- blit strings
local fgd = util.strrep(e.fg_bg.blit_fgd, e.frame.w)
local bkg = util.strrep(e.fg_bg.blit_bkg, e.frame.w)
local spaces = util.strrep(" ", e.frame.w)
local spaces = util.spaces(e.frame.w)
local one_third = util.strrep("\x8f", e.frame.w)
local two_thirds = util.strrep("\x83", e.frame.w)

View File

@ -68,6 +68,13 @@ function util.strrep(str, n)
return repeated
end
-- repeat a space n times
---@param n integer
---@return string
function util.spaces(n)
return util.strrep(" ", n)
end
-- wrap a string into a table of lines, supporting single dash splits
---@param str string
---@param limit integer line limit