26 lines
921 B
Plaintext
26 lines
921 B
Plaintext
|
press_run_button = function()
|
||
|
Show_menu = nil
|
||
|
-- ## run: initialize
|
||
|
clear_handlers()
|
||
|
local buf = table.concat(map(Current_pane.editor_state.lines, function(line) return line.data end), '\n')
|
||
|
Current_pane.canvas = love.graphics.newCanvas()
|
||
|
love.graphics.setCanvas(Current_pane.canvas)
|
||
|
love.graphics.push('all')
|
||
|
love.graphics.setBackgroundColor(1,1,1)
|
||
|
edit.clear(Current_pane.output_editor_state)
|
||
|
print = print_to_output
|
||
|
-- ## run
|
||
|
local status, result = live.eval(buf, 'editor')
|
||
|
-- ## run: save some stuff, clean up the rest
|
||
|
print = Real_print
|
||
|
if result then
|
||
|
-- could be either output or error
|
||
|
table.insert(Current_pane.output_editor_state.lines, {data=tostring(result)})
|
||
|
end
|
||
|
if #Current_pane.output_editor_state.lines == 0 then
|
||
|
table.insert(Current_pane.output_editor_state.lines, {data=''})
|
||
|
end
|
||
|
Text.redraw_all(Current_pane.output_editor_state)
|
||
|
love.graphics.pop()
|
||
|
love.graphics.setCanvas()
|
||
|
end
|