From c77cd7027f3597384f4474c049b28014027845b6 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Thu, 8 Apr 2021 00:03:18 -0400 Subject: [PATCH] lua print_table add ability to draw a line separator allows you to draw a line between items Change-Id: I7e6e2f56738e12ff06d06a24f0f9d0769932a7b1 --- apps/plugins/lua/include_lua/print.lua | 8 +++++++- apps/plugins/lua/include_lua/printtable.lua | 12 +++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/plugins/lua/include_lua/print.lua b/apps/plugins/lua/include_lua/print.lua index 3e92a155ba..3fb19bef1f 100644 --- a/apps/plugins/lua/include_lua/print.lua +++ b/apps/plugins/lua/include_lua/print.lua @@ -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) diff --git a/apps/plugins/lua/include_lua/printtable.lua b/apps/plugins/lua/include_lua/printtable.lua index 24c4f73b0a..b289beeb0e 100644 --- a/apps/plugins/lua/include_lua/printtable.lua +++ b/apps/plugins/lua/include_lua/printtable.lua @@ -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