diff --git a/data/core/commands/core.lua b/data/core/commands/core.lua index e8ed61b..8843a75 100644 --- a/data/core/commands/core.lua +++ b/data/core/commands/core.lua @@ -7,6 +7,8 @@ local DocView = require "core.docview" local LogView = require "core.logview" +local fullscreen = false + command.add(nil, { ["core:quit"] = function() core.quit() @@ -16,6 +18,11 @@ command.add(nil, { core.quit(true) end, + ["core:toggle-fullscreen"] = function() + fullscreen = not fullscreen + system.set_fullscreen(fullscreen) + end, + ["core:reload-module"] = function() core.command_view:enter("Reload Module", function(text, item) local text = item and item.text or text diff --git a/data/core/keymap.lua b/data/core/keymap.lua index fe2e45e..e506d24 100644 --- a/data/core/keymap.lua +++ b/data/core/keymap.lua @@ -88,6 +88,7 @@ keymap.add { ["ctrl+p"] = "core:open-project-file", ["ctrl+o"] = "core:open-file", ["ctrl+n"] = "core:new-doc", + ["alt+return"] = "core:toggle-fullscreen", ["alt+shift+j"] = "root:split-left", ["alt+shift+l"] = "root:split-right", diff --git a/src/api/system.c b/src/api/system.c index 675c379..cd18376 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "api.h" #ifdef _WIN32 @@ -160,6 +161,14 @@ static int f_set_window_title(lua_State *L) { } +static int f_set_fullscreen(lua_State *L) { + luaL_checkany(L, 1); + bool b = lua_toboolean(L, 1); + SDL_SetWindowFullscreen(window, b ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); + return 0; +} + + static int f_window_has_focus(lua_State *L) { unsigned flags = SDL_GetWindowFlags(window); lua_pushboolean(L, flags & SDL_WINDOW_INPUT_FOCUS); @@ -318,6 +327,7 @@ static const luaL_Reg lib[] = { { "poll_event", f_poll_event }, { "set_cursor", f_set_cursor }, { "set_window_title", f_set_window_title }, + { "set_fullscreen", f_set_fullscreen }, { "window_has_focus", f_window_has_focus }, { "show_confirm_dialog", f_show_confirm_dialog }, { "list_dir", f_list_dir },