Add core.on_quit function for plugins

To be used for plugins like workspace from exi/lite-plugins
This commit is contained in:
Francesco Abbate 2020-12-14 13:57:24 +01:00
parent e50d67df85
commit eadbe41064
1 changed files with 15 additions and 8 deletions

View File

@ -329,22 +329,29 @@ function core.temp_filename(ext)
.. string.format("%06x", temp_file_counter) .. (ext or "") .. string.format("%06x", temp_file_counter) .. (ext or "")
end end
-- override to perform an operation before quit
function core.on_quit()
end
function core.quit(force) local function quit_with_function(quit_fn, force)
if force then if force then
delete_temp_files() delete_temp_files()
os.exit() core.on_quit()
end quit_fn()
else
if core.confirm_close_all() then if core.confirm_close_all() then
core.quit(true) quit_with_function(quit_fn, true)
end end
end end
end
function core.quit(force)
quit_with_function(os.exit, force)
end
function core.restart() function core.restart()
if core.confirm_close_all() then quit_with_function(function() core.restart_request = true end)
core.restart_request = true
end
end end