From 80c3b84e08a1debc0e5af8567f9eeb0b1716303a Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 2 Oct 2020 14:30:41 -0400 Subject: lua Add scrollable stack traceback WIP lua currently splashes a stack traceback on error for deep tracebacks and especially on devices with smaller screens this leaves out a lot of vital information in the past I have resorted to splitting the traceback string or even saving the return to a file This patch provides a scrollable buffer with rudimentary text reflow to allow you to read the whole traceback string Upon traceback if you press nothing the screen will display for 5 seconds If you press OK or CANCEL it will quit immediately PREV/NEXT scrolls the list on button press timeout is disabled lua now provides rb.splash_scroller(timeout, str) example script provided too Change-Id: Idbc8ce0c514196f0fae48c43aeaea8b60d6da1a5 --- apps/plugins/lua/rocklua.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'apps/plugins/lua/rocklua.c') diff --git a/apps/plugins/lua/rocklua.c b/apps/plugins/lua/rocklua.c index 79f6bae953..3909f3008f 100644 --- a/apps/plugins/lua/rocklua.c +++ b/apps/plugins/lua/rocklua.c @@ -86,7 +86,7 @@ static int db_errorfb (lua_State *L) { if (lua_gettop(L) == arg) lua_pushliteral(L, ""); else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ - else lua_pushliteral(L, "\n"); + else lua_pushliteral(L, "\n\n"); lua_pushliteral(L, "stack traceback: "); while (lua_getstack(L1, level++, &ar)) { if (level > LEVELS1 && firstpart) { @@ -101,7 +101,7 @@ static int db_errorfb (lua_State *L) { firstpart = 0; continue; } - lua_pushliteral(L, "\n\t"); + lua_pushliteral(L, "\n\n\t"); lua_getinfo(L1, "Snl", &ar); char* filename = rb->strrchr(ar.short_src, '/'); /* remove path */ lua_pushfstring(L, "%s:", filename ? filename : ar.short_src); @@ -118,8 +118,10 @@ static int db_errorfb (lua_State *L) { lua_pushfstring(L, " in function <%s:%d>", ar.short_src, ar.linedefined); } + lua_concat(L, lua_gettop(L) - arg); } + lua_pushfstring(L, "\n\nRam Used: %d Kb", lua_gc (L, LUA_GCCOUNT, 0)); lua_concat(L, lua_gettop(L) - arg); return 1; } @@ -225,6 +227,14 @@ static int lua_split_arguments(lua_State *L, const char *filename) return 2; } +static void display_traceback(const char *errstr) +{ +#if 1 + splash_scroller(HZ * 5, errstr); /*rockaux.c*/ +#else + rb->splash(10 * HZ, errstr); +#endif +} /***************** Plugin Entry Point *****************/ enum plugin_status plugin_start(const void* parameter) { @@ -251,7 +261,8 @@ enum plugin_status plugin_start(const void* parameter) if (lu_status) { DEBUGF("%s\n", lua_tostring(Ls, -1)); - rb->splash(10 * HZ, lua_tostring(Ls, -1)); + display_traceback(lua_tostring(Ls, -1)); + //rb->splash(10 * HZ, lua_tostring(Ls, -1)); /*lua_pop(Ls, 1);*/ } lua_close(Ls); -- cgit v1.2.3