diff options
Diffstat (limited to 'src/lua/embed/debug.lua.h')
-rw-r--r-- | src/lua/embed/debug.lua.h | 253 |
1 files changed, 130 insertions, 123 deletions
diff --git a/src/lua/embed/debug.lua.h b/src/lua/embed/debug.lua.h index f3838a0..7ccc99d 100644 --- a/src/lua/embed/debug.lua.h +++ b/src/lua/embed/debug.lua.h @@ -1,125 +1,132 @@ /* debug.lua */ -static const char debug_lua[] = -{45,45,91,91,32,13,10,32,32,32,32,102,111,114,32,100,101,98,117,103,32,112,117, -114,112,111,115,101,32,13,10,32,32,32,32,43,45,45,45,45,45,45,45,45,45,45,45, -45,45,45,45,45,45,45,45,43,13,10,32,32,32,32,124,100,101,98,117,103,32,109, -115,103,32,111,108,100,32,32,32,32,32,32,124,13,10,32,32,32,32,124,46,46,46, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,124,13,10,32,32,32,32,124,46, -46,46,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,124,13,10,32,32,32,32, -124,46,46,46,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,124,13,10,32,32, -32,32,124,100,101,98,117,103,32,109,115,103,32,110,101,119,32,32,32,32,32,32, -124,13,10,32,32,32,32,43,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, -45,45,43,13,10,93,93,32,13,10,13,10,106,105,110,46,100,101,98,117,103,32,61, -32,106,105,110,46,100,101,98,117,103,32,111,114,32,123,125,32,13,10,13,10,45, -45,32,114,101,110,100,101,114,32,112,97,110,101,108,32,13,10,108,111,99,97, -108,32,112,97,110,101,108,32,61,32,110,105,108,32,13,10,13,10,108,111,99,97, -108,32,100,101,98,117,103,32,61,32,102,97,108,115,101,13,10,13,10,45,45,32, -100,101,98,117,103,32,109,115,103,32,98,117,102,102,101,114,32,13,10,108,111, -99,97,108,32,98,117,102,102,101,114,32,61,32,123,125,32,13,10,13,10,45,45,32, -99,111,110,102,105,103,117,114,101,32,13,10,108,111,99,97,108,32,98,115,105, -122,101,32,32,32,61,32,49,48,13,10,108,111,99,97,108,32,102,115,105,122,101, -32,32,32,61,32,49,53,13,10,108,111,99,97,108,32,108,104,101,105,103,104,116, -32,61,32,49,56,13,10,108,111,99,97,108,32,97,108,112,104,97,32,32,32,61,32,50, -50,48,13,10,108,111,99,97,108,32,109,97,114,103,105,110,32,32,61,32,49,48,13, -10,13,10,45,45,32,114,101,102,114,101,115,104,32,98,117,102,102,101,114,32, -111,114,32,110,111,116,32,13,10,108,111,99,97,108,32,114,101,102,114,101,115, -104,32,61,32,116,114,117,101,32,13,10,13,10,102,117,110,99,116,105,111,110,32, -106,105,110,46,100,101,98,117,103,46,105,110,105,116,40,41,13,10,32,32,32,32, -100,101,98,117,103,32,61,32,116,114,117,101,13,10,9,112,97,110,101,108,32,61, -32,106,105,110,46,103,114,97,112,104,105,99,115,46,67,97,110,118,97,115,40, -106,105,110,46,103,114,97,112,104,105,99,115,46,115,105,122,101,40,41,41,32, -13,10,101,110,100,13,10,13,10,45,45,32,115,101,116,32,98,117,102,102,101,114, -32,115,105,122,101,32,13,10,102,117,110,99,116,105,111,110,32,106,105,110,46, -100,101,98,117,103,46,115,105,122,101,40,99,41,13,10,9,98,115,105,122,101,32, -61,32,99,13,10,101,110,100,32,13,10,13,10,102,117,110,99,116,105,111,110,32, -106,105,110,46,100,101,98,117,103,46,112,114,105,110,116,40,109,115,103,41,13, -10,9,105,102,32,110,111,116,32,100,101,98,117,103,32,116,104,101,110,32,114, -101,116,117,114,110,32,101,110,100,32,13,10,13,10,9,109,115,103,32,61,32,116, -111,115,116,114,105,110,103,40,109,115,103,41,13,10,9,108,111,99,97,108,32, -116,112,32,61,32,116,121,112,101,40,109,115,103,41,13,10,9,105,102,32,116,112, -32,126,61,32,34,115,116,114,105,110,103,34,32,97,110,100,32,116,112,32,126,61, -32,34,110,117,109,98,101,114,34,32,116,104,101,110,32,13,10,9,9,109,115,103, -32,61,32,115,116,114,105,110,103,46,102,111,114,109,97,116,40,34,112,114,105, -110,116,32,102,97,105,108,101,100,44,32,101,120,112,101,99,116,32,115,116,114, -105,110,103,32,111,114,32,110,117,109,98,101,114,32,98,117,116,32,103,101,116, -32,97,32,37,115,34,44,32,116,112,41,13,10,9,101,110,100,13,10,9,13,10,32,32, -32,32,45,45,32,114,101,109,111,118,101,32,116,104,101,32,102,105,114,115,116, -32,111,110,101,32,40,111,108,100,32,109,115,103,41,13,10,9,105,102,32,35,98, -117,102,102,101,114,32,62,61,32,98,115,105,122,101,32,116,104,101,110,32,13, -10,9,9,116,97,98,108,101,46,114,101,109,111,118,101,40,98,117,102,102,101,114, -44,32,49,41,13,10,9,101,110,100,32,13,10,32,32,32,32,13,10,32,32,32,32,98,117, -102,102,101,114,91,35,98,117,102,102,101,114,32,43,32,49,93,32,61,32,109,115, -103,13,10,32,32,32,32,114,101,102,114,101,115,104,32,61,32,116,114,117,101,13, -10,101,110,100,13,10,13,10,45,45,32,99,108,101,97,114,32,100,101,98,117,103, -32,98,117,102,102,101,114,32,13,10,102,117,110,99,116,105,111,110,32,106,105, -110,46,100,101,98,117,103,46,99,108,101,97,114,40,41,13,10,9,98,117,102,102, -101,114,32,61,32,123,125,32,13,10,101,110,100,13,10,13,10,108,111,99,97,108, -32,102,117,110,99,116,105,111,110,32,103,101,116,83,116,114,72,101,105,103, -104,116,40,115,116,114,44,32,108,104,101,105,103,104,116,41,32,13,10,9,108, -111,99,97,108,32,104,32,61,32,108,104,101,105,103,104,116,13,10,9,105,102,32, -35,115,116,114,32,61,61,32,48,32,116,104,101,110,32,13,10,9,9,104,32,61,32,48, -13,10,9,101,110,100,32,13,10,9,102,111,114,32,105,32,61,32,49,44,32,35,115, -116,114,32,100,111,32,13,10,9,9,108,111,99,97,108,32,99,32,61,32,115,116,114, -105,110,103,46,115,117,98,40,115,116,114,44,32,105,44,32,105,41,13,10,9,9,105, -102,32,99,32,61,61,32,39,92,110,39,32,116,104,101,110,32,13,10,9,9,9,104,32, -61,32,104,32,43,32,108,104,101,105,103,104,116,13,10,9,9,101,110,100,32,13,10, -9,101,110,100,32,13,10,9,114,101,116,117,114,110,32,104,32,13,10,101,110,100, -13,10,13,10,108,111,99,97,108,32,32,102,117,110,99,116,105,111,110,32,103,101, -116,66,103,81,117,97,100,40,41,32,13,10,9,108,111,99,97,108,32,119,105,100, -116,104,44,32,104,101,105,103,104,116,32,61,32,48,44,32,48,32,9,13,10,9,102, -111,114,32,105,32,61,32,49,44,32,35,98,117,102,102,101,114,32,100,111,13,10,9, -9,108,111,99,97,108,32,119,44,32,104,32,61,32,106,105,110,46,103,114,97,112, -104,105,99,115,46,98,111,120,40,32,98,117,102,102,101,114,91,105,93,44,32,102, -115,105,122,101,44,32,49,44,32,108,104,101,105,103,104,116,41,13,10,9,9,104, -101,105,103,104,116,32,61,32,104,101,105,103,104,116,32,43,32,104,32,13,10,9, -9,105,102,32,119,105,100,116,104,32,60,32,119,32,116,104,101,110,13,10,9,9,9, -119,105,100,116,104,32,61,32,119,32,13,10,9,9,101,110,100,32,13,10,9,101,110, -100,9,13,10,9,114,101,116,117,114,110,32,119,105,100,116,104,44,32,104,101, -105,103,104,116,13,10,101,110,100,32,13,10,13,10,45,45,32,114,101,110,100,101, -114,32,116,111,32,115,99,114,101,101,110,13,10,102,117,110,99,116,105,111,110, -32,106,105,110,46,100,101,98,117,103,46,114,101,110,100,101,114,40,41,32,13, -10,32,32,32,32,105,102,32,110,111,116,32,100,101,98,117,103,32,116,104,101, -110,32,114,101,116,117,114,110,32,101,110,100,13,10,32,32,32,32,13,10,32,32, -32,32,105,102,32,114,101,102,114,101,115,104,32,116,104,101,110,32,13,10,32, -32,32,32,32,32,32,13,10,32,32,32,32,32,32,32,32,106,105,110,46,103,114,97,112, -104,105,99,115,46,98,105,110,100,40,112,97,110,101,108,41,13,10,13,10,32,32, -32,32,32,32,32,32,32,32,32,32,106,105,110,46,103,114,97,112,104,105,99,115,46, -99,108,101,97,114,40,48,44,32,48,44,32,48,44,32,48,41,13,10,32,32,32,32,32,32, -32,32,32,32,32,32,13,10,32,32,32,32,32,32,32,32,32,32,32,32,106,105,110,46, -103,114,97,112,104,105,99,115,46,115,116,117,100,121,40,41,13,10,32,32,32,32, -32,32,32,32,32,32,32,32,13,10,32,32,32,32,32,32,32,32,32,32,32,32,108,111,99, -97,108,32,119,119,44,32,119,104,32,61,32,106,105,110,46,103,114,97,112,104, -105,99,115,46,115,105,122,101,40,41,13,10,32,32,32,32,32,32,32,32,32,32,32,32, -108,111,99,97,108,32,98,103,119,44,32,98,103,104,32,61,32,103,101,116,66,103, -81,117,97,100,40,41,13,10,32,32,32,32,32,32,32,32,32,32,32,32,106,105,110,46, -103,114,97,112,104,105,99,115,46,99,111,108,111,114,40,48,44,32,48,44,32,48, -44,32,97,108,112,104,97,41,13,10,32,32,32,32,32,32,32,32,32,32,32,32,106,105, -110,46,103,114,97,112,104,105,99,115,46,114,101,99,116,40,34,102,105,108,108, -34,44,32,48,44,32,119,104,32,45,32,98,103,104,32,45,32,109,97,114,103,105,110, -44,32,98,103,119,32,43,32,109,97,114,103,105,110,44,32,98,103,104,32,43,32, -109,97,114,103,105,110,41,13,10,32,32,32,32,32,32,32,32,32,32,32,32,13,10,32, -32,32,32,32,32,32,32,32,32,32,32,106,105,110,46,103,114,97,112,104,105,99,115, -46,99,111,108,111,114,40,41,13,10,32,32,32,32,32,32,32,32,32,32,32,32,108,111, -99,97,108,32,121,32,61,32,119,104,32,13,10,32,32,32,32,32,32,32,32,32,32,32, -32,102,111,114,32,105,32,61,32,35,98,117,102,102,101,114,44,32,49,44,32,45,49, -32,100,111,13,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,108,111,99, -97,108,32,109,115,103,32,61,32,98,117,102,102,101,114,91,105,93,32,13,10,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,108,111,99,97,108,32,104,32,61, -32,103,101,116,83,116,114,72,101,105,103,104,116,40,109,115,103,44,32,108,104, -101,105,103,104,116,41,13,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -121,32,61,32,121,32,45,32,104,32,13,10,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,106,105,110,46,103,114,97,112,104,105,99,115,46,119,114,105,116,101, -40,109,115,103,44,32,109,97,114,103,105,110,32,47,32,50,44,32,121,32,45,32, -109,97,114,103,105,110,47,32,50,44,32,102,115,105,122,101,44,32,49,44,32,108, -104,101,105,103,104,116,41,32,13,10,32,32,32,32,32,32,32,32,32,32,32,32,101, -110,100,13,10,9,13,10,32,32,32,32,32,32,32,32,106,105,110,46,103,114,97,112, -104,105,99,115,46,98,105,110,100,40,41,13,10,32,32,32,32,13,10,32,32,32,32,32, -32,32,32,114,101,102,114,101,115,104,32,61,32,102,97,108,115,101,13,10,32,32, -32,32,101,110,100,32,13,10,32,32,32,32,13,10,32,32,32,32,106,105,110,46,103, -114,97,112,104,105,99,115,46,99,111,108,111,114,40,41,13,10,32,32,32,32,106, -105,110,46,103,114,97,112,104,105,99,115,46,100,114,97,119,40,112,97,110,101, -108,44,32,48,44,32,48,41,13,10,101,110,100,13,10,13,10,102,117,110,99,116,105, -111,110,32,106,105,110,46,100,101,98,117,103,46,115,116,97,116,117,115,40,41, -32,13,10,9,114,101,116,117,114,110,32,100,101,98,117,103,32,13,10,101,110,100, -13,10}; +static const char* debug_lua = R"( +--[[ + for debug purpose + +-------------------+ + |debug msg old | + |... | + |... | + |... | + |debug msg new | + +-------------------+ +]] +jin.debug = jin.debug or {} + +-- render panel +local panel = nil + +local debug = false + +-- debug msg buffer +local buffer = {} + +-- configure +local bsize = 10 +local fsize = 15 +local lheight = 18 +local alpha = 220 +local margin = 10 + +-- refresh buffer or not +local refresh = true + +function jin.debug.init() + debug = true + panel = jin.graphics.Canvas(jin.graphics.size()) +end + +-- set buffer size +function jin.debug.size(c) + bsize = c +end + +function jin.debug.print(msg) + if not debug then return end + + msg = tostring(msg) + local tp = type(msg) + if tp ~= "string" and tp ~= "number" then + msg = string.format("print failed, expect string or number but get a %s", tp) + end + + -- remove the first one (old msg) + if #buffer >= bsize then + table.remove(buffer, 1) + end + + buffer[#buffer + 1] = msg + refresh = true +end + +-- clear debug buffer +function jin.debug.clear() + buffer = {} +end + +local function getStrHeight(str, lheight) + local h = lheight + if #str == 0 then + h = 0 + end + for i = 1, #str do + local c = string.sub(str, i, i) + if c == '\n' then + h = h + lheight + end + end + return h +end + +local function getBgQuad() + local width, height = 0, 0 + for i = 1, #buffer do + local w, h = jin.graphics.box( buffer[i], fsize, 1, lheight) + height = height + h + if width < w then + width = w + end + end + return width, height +end + +-- render to screen +function jin.debug.render() + if not debug then return end + + if refresh then + + jin.graphics.bind(panel) + + jin.graphics.clear(0, 0, 0, 0) + + jin.graphics.study() + + local ww, wh = jin.graphics.size() + local bgw, bgh = getBgQuad() + jin.graphics.color(0, 0, 0, alpha) + jin.graphics.rect("fill", 0, wh - bgh - margin, bgw + margin, bgh + margin) + + jin.graphics.color() + local y = wh + for i = #buffer, 1, -1 do + local msg = buffer[i] + local h = getStrHeight(msg, lheight) + y = y - h + jin.graphics.write(msg, margin / 2, y - margin/ 2, fsize, 1, lheight) + end + + jin.graphics.bind() + + refresh = false + end + + jin.graphics.color() + jin.graphics.draw(panel, 0, 0) +end + +function jin.debug.status() + return debug +end + +)";
\ No newline at end of file |