sokoban.love/0051-run_button

28 lines
872 B
Plaintext
Raw Normal View History

run_button = function(x, y)
2023-11-26 07:03:20 +00:00
styled_button('run', x,y,
function()
2023-12-05 06:09:47 +00:00
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
2024-01-01 00:59:34 +00:00
local error = eval_all()
-- ## run: save some stuff, clean up the rest
2024-01-01 00:59:34 +00:00
if error == nil then
Show_code = nil
else
print = Real_print
clear_handlers()
-- could be either output or error
2024-01-01 00:59:34 +00:00
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)
2023-11-26 07:03:20 +00:00
end)
local w = App.width('run')+10
return x+w+10, y
2023-12-17 21:30:17 +00:00
end