Add core:restart function to restart the editor
This commit is contained in:
@@ -12,6 +12,10 @@ command.add(nil, {
|
||||
core.quit()
|
||||
end,
|
||||
|
||||
["core:restart"] = function()
|
||||
core.restart()
|
||||
end,
|
||||
|
||||
["core:force-quit"] = function()
|
||||
core.quit(true)
|
||||
end,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user