lua print_table add ability to draw a line separator

allows you to draw a line between items

Change-Id: I7e6e2f56738e12ff06d06a24f0f9d0769932a7b1
This commit is contained in:
William Wilgus 2021-04-08 00:03:18 -04:00 committed by William Wilgus
parent f8ce18c286
commit c77cd7027f
2 changed files with 16 additions and 4 deletions

View File

@ -141,6 +141,7 @@ local _print = {} do
ovfl = "auto",
justify = "left",
autoupdate = true,
drawsep = false,
}
_p_opts.max_line = max_lines(_p_opts)
@ -292,7 +293,12 @@ local _print = {} do
col_buf_insert(msg, o.line, o)
end
end
if o.drawsep == true then
if s_lines[o.line] == true then
rb.set_viewport(o) --nned to revert drawmode if selected
end
rb.lcd_drawline(0, line * h, o.width, line * h)
end
--only update the line we changed
update_line(o.autoupdate, o, line, h)

View File

@ -152,14 +152,15 @@ function print_table(t, t_count, settings)
end
local wrap, justify, start, curpos, co_routine, hasheader, m_sel
local header_fgc, header_bgc, item_fgc, item_bgc, item_selc
local header_fgc, header_bgc, item_fgc, item_bgc, item_selc, drawsep
do
local s = settings or _print.get_settings()
wrap, justify = s.wrap, s.justify
start, curpos = s.start, s.curpos
co_routine = s.co_routine
hasheader = s.hasheader
m_sel = false
drawsep = s.drawsep
m_sel = false
if co_routine == nil then
--no multi select in incremental mode
m_sel = s.msel
@ -351,6 +352,11 @@ function print_table(t, t_count, settings)
_print.opt.overflow("manual")
_print.opt.justify(justify)
local opts = _print.opt.get()
opts.drawsep = drawsep
_print.opt.set(opts)
-- initialize vertical scrollbar
set_vsb(); do
local vsb =_print.opt.get()
@ -359,7 +365,7 @@ function print_table(t, t_count, settings)
vsb.bg_pattern = 3 - vsb.bg_pattern
end
set_vsb = function (item)
set_vsb = function (item)
if t_count > (maxline or t_count) then
rb.set_viewport(vsb)
item = item or 0