31 lines
1.0 KiB
Plaintext
31 lines
1.0 KiB
Plaintext
run_button = function(x, y)
|
|
styled_button('run', x,y,
|
|
function()
|
|
-- ## 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)
|
|
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
|
|
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)
|
|
local w = App.width('run')+10
|
|
return x+w+10, y
|
|
end |