From d1d521fbdb07eb72e57d2918b48d6c7cfd9a37b3 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 16 Apr 2023 22:34:29 -0700 Subject: [PATCH] infrastructure for hiding the terminal console on startup --- docs/changelog.txt | 1 + library/Core.cpp | 9 +++++++++ library/lua/dfhack.lua | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index f7a3102cc..3bb16251c 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -40,6 +40,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Misc Improvements - `buildingplan`: minimized planner panel stays minimized until you change it again - ``toggle-kbd-cursor``: add hotkey for toggling the keyboard cursor (Alt-K) +- `gui/control-panel`: add option for hiding the terminal console by default ## Documentation diff --git a/library/Core.cpp b/library/Core.cpp index c3c7bb7f2..4f06c3d62 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1314,6 +1314,15 @@ static void run_dfhack_init(color_ostream &out, Core *core) // load user overrides std::vector prefixes(1, "dfhack"); loadScriptFiles(core, out, prefixes, CONFIG_PATH + "init"); + + // if the option is set, hide the terminal + auto L = Lua::Core::State; + Lua::StackUnwinder top(L); + Lua::CallLuaModuleFunction(out, L, "dfhack", "getHideConsoleOnStartup", 0, 1, + Lua::DEFAULT_LUA_LAMBDA, [&](lua_State* L) { + if (lua_toboolean(L, -1)) + core->getConsole().hide(); + }, false); } // Load dfhack.init in a dedicated thread (non-interactive console mode) diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index aa33b62d6..bc543fd10 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -51,6 +51,13 @@ if dfhack.is_core_context then SC_UNPAUSED = 8 end +-- User-changeable options + +dfhack.HIDE_CONSOLE_ON_STARTUP = true +function dfhack.getHideConsoleOnStartup() + return dfhack.HIDE_CONSOLE_ON_STARTUP +end + -- Error handling safecall = dfhack.safecall