right align
This commit is contained in:
parent
357d1601b4
commit
778ce7b8e2
1 changed files with 4 additions and 8 deletions
|
|
@ -96,23 +96,19 @@ local function center(text, width)
|
||||||
if pad <= 0 then
|
if pad <= 0 then
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
local left = math.floor(pad / 2)
|
local left = math.ceil(pad / 2)
|
||||||
return string.rep(' ', left) .. text .. string.rep(' ', pad - left)
|
return string.rep(' ', left) .. text .. string.rep(' ', pad - left)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function format_num_column(prefix, idx, width)
|
local function format_num_column(prefix, idx, width)
|
||||||
local num_str = tostring(idx)
|
local num_str = tostring(idx)
|
||||||
local content
|
local content = (#num_str == 1) and (' ' .. prefix .. ' ' .. num_str .. ' ')
|
||||||
if #num_str == 1 then
|
or (' ' .. prefix .. num_str .. ' ')
|
||||||
content = ' ' .. prefix .. ' ' .. num_str .. ' '
|
|
||||||
else
|
|
||||||
content = ' ' .. prefix .. num_str .. ' '
|
|
||||||
end
|
|
||||||
local total_pad = width - #content
|
local total_pad = width - #content
|
||||||
if total_pad <= 0 then
|
if total_pad <= 0 then
|
||||||
return content
|
return content
|
||||||
end
|
end
|
||||||
local left_pad = math.floor(total_pad / 2)
|
local left_pad = math.ceil(total_pad / 2)
|
||||||
local right_pad = total_pad - left_pad
|
local right_pad = total_pad - left_pad
|
||||||
return string.rep(' ', left_pad) .. content .. string.rep(' ', right_pad)
|
return string.rep(' ', left_pad) .. content .. string.rep(' ', right_pad)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue