From 20cd89908d3b7276c50295ccd6c4f09f7324f6e2 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Thu, 29 Apr 2021 01:56:49 -0400 Subject: lua submenus add a way to dynamically add items updated example script and renamed some functions as well fixed bug in printtable cursor position if greater than maxlines for the screen would reset to item 1 now we move the list start and select it (and try to center it on the screen) fixed a few bugs in the add_menu code Change-Id: I01dead0481ef2e925af8b4cc6c14e36c2859dbba --- apps/plugins/lua/include_lua/printtable.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apps/plugins/lua/include_lua/printtable.lua') diff --git a/apps/plugins/lua/include_lua/printtable.lua b/apps/plugins/lua/include_lua/printtable.lua index bf81c7b060..7a883367b7 100644 --- a/apps/plugins/lua/include_lua/printtable.lua +++ b/apps/plugins/lua/include_lua/printtable.lua @@ -336,6 +336,16 @@ function print_table(t, t_count, settings) table_p = init_position(15, 5) line, maxline = _print.opt.area(5, 1, rb.LCD_WIDTH - 10 - sb_width, rb.LCD_HEIGHT - 2) + + if curpos > maxline then + local c = maxline / 2 + start = (start or 1) + curpos - maxline + curpos = maxline + while start + maxline <= t_count and curpos > c do + curpos = curpos - 1 + start = start + 1 + end + end maxline = math.min(maxline, t_count) -- allow user to start at a position other than the beginning -- cgit v1.2.3