I52S4E5FT6E6FHH3QEDJPWO7C6W7AIMAFDP2KQ5FEWXFQX7RY6CAC
VAVXKWZVOFJGWHCWYLTPDKSKKMSJEBKXNKXUW3T6IZAC3HE6HOIQC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
PRE6XPRNICDCHMF7C45A6DRPVT47IPAIWW6Q7AHNGW3D2PBGOPNAC
5RUFNRJOK3PXQKJTPDEN5K5PI67MGB25QUA44WOCCH2O5KHXT45QC
6RYGW5H3J44O73WFXGFVTBW5N5UEQ4E732AJJUZNBVQLYDA5LGLAC
WR2WMEPEKNFAB4CAUBVFBACAJJSX2VX5B2VHKKSNTJSJBIIXFVZQC
Z5M23NTKKGEACSQJT27DRNS7NEK6OSLR2IOWVAH2C2PRAIU46BIQC
run_button = function()
button(Global_state, 'run', {x=Menu_left+5, y=Menu_top+5, w=App.width('Run')+10, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
icon = function(p)
App.color(Normal_color)
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
love.graphics.print('Run', p.x+5,p.y+2)
end,
onpress1 = function()
-- ## run: initialize
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)
love.graphics.setColor(0,0,0)
Current_pane.output_editor_state.lines = {}
Text.redraw_all(Current_pane.output_editor_state)
local real_print = print
print = print_to_output
-- ## run
local status, result = live.eval(buf)
-- ## run: save some stuff, clean up the rest
print = real_print
print(status, result)
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,
})
end
print_to_output = function(...)
local line = table.concat(map({...}, tostring), ' ')
table.insert(Current_pane.output_editor_state.lines,
{data=line})
end
button(Global_state, 'run', {x=Menu_left+5, y=Menu_top+5, w=App.width('Run')+10, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
icon = function(p)
App.color(Normal_color)
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
love.graphics.print('Run', p.x+5,p.y+2)
end,
onpress1 = function()
print('run')
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)
love.graphics.setColor(0,0,0)
local status, result = live.eval(buf)
print(status, result)
if result then
-- could be either output or error
Current_pane.output_editor_state.lines = {
{data=tostring(result)},
}
Text.redraw_all(Current_pane.output_editor_state)
end
love.graphics.pop()
love.graphics.setCanvas()
end,
})
run_button()