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", ovfl = "auto",
justify = "left", justify = "left",
autoupdate = true, autoupdate = true,
drawsep = false,
} }
_p_opts.max_line = max_lines(_p_opts) _p_opts.max_line = max_lines(_p_opts)
@ -292,7 +293,12 @@ local _print = {} do
col_buf_insert(msg, o.line, o) col_buf_insert(msg, o.line, o)
end end
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 --only update the line we changed
update_line(o.autoupdate, o, line, h) update_line(o.autoupdate, o, line, h)

View file

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