escape hatch when print is overridden

This commit is contained in:
Kartik K. Agaram 2023-12-17 13:30:17 -08:00
parent 38d21ab237
commit 0873264a6a
3 changed files with 4 additions and 5 deletions

View File

@ -10,12 +10,11 @@ run_button = function(x, y)
love.graphics.push('all')
love.graphics.setBackgroundColor(1,1,1)
edit.clear(Current_pane.output_editor_state)
local real_print = print
print = print_to_output
-- ## run
local status, result = live.eval(buf, 'editor')
-- ## run: save some stuff, clean up the rest
print = real_print
print = Real_print
if result then
-- could be either output or error
table.insert(Current_pane.output_editor_state.lines, {data=tostring(result)})
@ -29,4 +28,4 @@ run_button = function(x, y)
end)
local w = App.width('run')+10
return x+w+10, y
end
end

View File

@ -2,10 +2,9 @@ call_protected = function(f, ...)
local args = {...}
xpcall(
function()
local old_print = print
print = print_to_output
f(unpack(args))
print = old_print
print = Real_print
end,
send_errors_to_output)
end

1
0152-Real_print Normal file
View File

@ -0,0 +1 @@
Real_print = print