stop mixing ncurses with print

This commit is contained in:
Kartik K. Agaram 2022-04-25 22:19:04 -07:00
parent dfd67aed3c
commit 8fb1885348

18
mu.lua
View File

@ -37,12 +37,16 @@ while true do
new_expr = true new_expr = true
local success, results = gather_results(xpcall(f, function(...) return debug.traceback() end)) local success, results = gather_results(xpcall(f, function(...) return debug.traceback() end))
if success then if success then
for _, result in ipairs(results) do for i, result in ipairs(results) do
print(result) if i > 1 then
stdscr:addch('\t')
end
stdscr:addstr(tostring(result))
end end
else else
print(results[1]) stdscr:addstr(tostring(result[1]))
end end
stdscr:addch('\n')
else else
local f, err = load(buf, 'REPL') local f, err = load(buf, 'REPL')
if f then if f then
@ -51,11 +55,15 @@ while true do
local success, results = gather_results(xpcall(f, function(...) return debug.traceback() end)) local success, results = gather_results(xpcall(f, function(...) return debug.traceback() end))
if success then if success then
for _, result in ipairs(results) do for _, result in ipairs(results) do
print(result) if i > 1 then
stdscr:addch('\t')
end
stdscr:addstr(tostring(result))
end end
else else
print(results[1]) stdscr:addstr(tostring(result[1]))
end end
stdscr:addch('\n')
else else
stdscr:addstr(err..'\n') stdscr:addstr(err..'\n')
if string.match(err, "'<eof>'$") or string.match(err, "<eof>$") then if string.match(err, "'<eof>'$") or string.match(err, "<eof>$") then