Add core:restart function to restart the editor

This commit is contained in:
Francesco Abbate
2020-12-10 12:44:01 +01:00
parent 33109e6110
commit 6409b67ea2
4 changed files with 35 additions and 4 deletions
+9
View File
@@ -229,6 +229,7 @@ function core.init()
core.project_files = {}
core.redraw = true
core.visited_files = {}
core.restart_request = false
core.root_view = RootView()
core.command_view = CommandView()
@@ -289,6 +290,13 @@ function core.quit(force)
end
function core.restart()
if core.confirm_close_all() then
core.restart_request = true
end
end
function core.load_plugins()
local no_errors = true
local files = system.list_dir(DATADIR .. "/plugins")
@@ -590,6 +598,7 @@ function core.run()
core.frame_start = system.get_time()
local did_redraw = core.step()
local need_more_work = run_threads()
if core.restart_request then break end
if not did_redraw and not need_more_work then
idle_iterations = idle_iterations + 1
-- do not wait of events at idle_iterations = 1 to give a chance at core.step to run