Add core:restart function to restart the editor
This commit is contained in:
parent
33109e6110
commit
6409b67ea2
|
@ -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
|
||||
|
|
|
@ -132,6 +132,13 @@ then be loaded manually as needed by using the `require` function.
|
|||
Plugins can be downloaded from the [plugins repository](https://github.com/rxi/lite-plugins).
|
||||
|
||||
|
||||
## Restarting the editor
|
||||
|
||||
If you modifies the user configuration file or some of the Lua implementation files you may
|
||||
restart the editor using the command "Core: Restart".
|
||||
All the application will be restarting by keeping the window that is already used.
|
||||
|
||||
|
||||
## Color Themes
|
||||
Colors themes in lite are lua modules which overwrite the color fields of lite's
|
||||
`core.style` module. Color themes should be placed in the `data/user/colors`
|
||||
|
|
19
src/main.c
19
src/main.c
|
@ -89,8 +89,9 @@ int main(int argc, char **argv) {
|
|||
init_window_icon();
|
||||
ren_init(window);
|
||||
|
||||
|
||||
lua_State *L = luaL_newstate();
|
||||
lua_State *L;
|
||||
init_lua:
|
||||
L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
api_load_libs(L);
|
||||
|
||||
|
@ -117,7 +118,7 @@ int main(int argc, char **argv) {
|
|||
lua_setglobal(L, "EXEFILE");
|
||||
|
||||
|
||||
(void) luaL_dostring(L,
|
||||
const char *init_lite_code = \
|
||||
"local core\n"
|
||||
"xpcall(function()\n"
|
||||
" SCALE = tonumber(os.getenv(\"LITE_SCALE\")) or SCALE\n"
|
||||
|
@ -153,8 +154,18 @@ int main(int argc, char **argv) {
|
|||
" pcall(core.on_error, err)\n"
|
||||
" end\n"
|
||||
" os.exit(1)\n"
|
||||
"end)");
|
||||
"end)\n"
|
||||
"return core and core.restart_request\n";
|
||||
|
||||
if (luaL_loadstring(L, init_lite_code)) {
|
||||
fprintf(stderr, "internal error when starting the application\n");
|
||||
exit(1);
|
||||
}
|
||||
lua_pcall(L, 0, 1, 0);
|
||||
if (lua_toboolean(L, -1)) {
|
||||
lua_close(L);
|
||||
goto init_lua;
|
||||
}
|
||||
|
||||
lua_close(L);
|
||||
SDL_DestroyWindow(window);
|
||||
|
|
Loading…
Reference in New Issue