implement 'Run' button
Error flow is still klunky. We'll need to implement the output region for that.
This commit is contained in:
parent
8958100df1
commit
e53245e62d
|
@ -1,5 +1,7 @@
|
|||
on.draw = function()
|
||||
Editor_state.button_handlers = {}
|
||||
draw_canvas()
|
||||
--if Canvas then return end
|
||||
draw_editor_border()
|
||||
-- love.graphics.rectangle('line', 100-5-Line_number_padding,100-5, 300+Line_number_padding+10, 200+10, 5,5)
|
||||
edit.draw(Editor_state)
|
||||
|
|
|
@ -10,6 +10,18 @@ draw_menu = function()
|
|||
end,
|
||||
onpress1 = function()
|
||||
print('run')
|
||||
local buf = table.concat(map(Editor_state.lines, function(line) return line.data end), '\n')
|
||||
Canvas = love.graphics.newCanvas()
|
||||
love.graphics.setCanvas(Canvas)
|
||||
love.graphics.push('all')
|
||||
love.graphics.setBackgroundColor(1,1,1)
|
||||
love.graphics.setColor(0,0,0)
|
||||
local status, result = live.eval(buf)
|
||||
if not status then
|
||||
print(result)
|
||||
end
|
||||
love.graphics.pop()
|
||||
love.graphics.setCanvas()
|
||||
end,
|
||||
})
|
||||
-- settings button on right
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Canvas = nil
|
|
@ -0,0 +1,7 @@
|
|||
draw_canvas = function()
|
||||
if Canvas == nil then return end
|
||||
love.graphics.setBlendMode('alpha', 'premultiplied')
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
love.graphics.draw(Canvas, 0,0)
|
||||
love.graphics.setBlendMode('alpha')
|
||||
end
|
Loading…
Reference in New Issue