sokoban.love/0051-run_button

28 lines
872 B
Plaintext

run_button = function(x, y)
styled_button('run', x,y,
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')
edit.clear(Current_pane.output_editor_state)
print = print_to_output
-- ## run
local error = eval_all()
-- ## run: save some stuff, clean up the rest
if error == nil then
Show_code = nil
else
print = Real_print
clear_handlers()
-- could be either output or error
table.insert(Current_pane.output_editor_state.lines, {data=tostring(error)})
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)
end)
local w = App.width('run')+10
return x+w+10, y
end