From 0c93d619c80ab513c7be0e299e348a2a55d76a9d Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Tue, 2 Dec 2025 11:22:38 -0800 Subject: [PATCH] Set custom ImGui ini file path Path is set to `~/.config/kte/imgui.ini`, enable keyboard and gamepad navigation, and ensure configuration directory creation. --- CMakeLists.txt | 11 +++++++++++ GUIFrontend.cc | 23 +++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f8ab83..195ce99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,6 +222,17 @@ if (BUILD_TESTS) endif () if (${BUILD_GUI}) + # ImGui::CreateContext(); + # ImGuiIO& io = ImGui::GetIO(); + + # // Set custom ini filename path to ~/.config/kte/imgui.ini + # if (const char* home = std::getenv("HOME")) { + # static std::string ini_path = std::string(home) + "/.config/kte/imgui.ini"; + # io.IniFilename = ini_path.c_str(); + # } + + # io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + # io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls target_sources(kte PRIVATE Font.h GUIConfig.cc diff --git a/GUIFrontend.cc b/GUIFrontend.cc index f7cca46..e59e523 100644 --- a/GUIFrontend.cc +++ b/GUIFrontend.cc @@ -13,6 +13,7 @@ #include "Editor.h" #include "Command.h" #include "GUIFrontend.h" +#include #include "Font.h" // embedded default font (DefaultFontRegular) #include "GUIConfig.h" #include "GUITheme.h" @@ -105,7 +106,25 @@ GUIFrontend::Init(Editor &ed) IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO &io = ImGui::GetIO(); - (void) io; + + // Set custom ini filename path to ~/.config/kte/imgui.ini + if (const char *home = std::getenv("HOME")) { + namespace fs = std::filesystem; + fs::path config_dir = fs::path(home) / ".config" / "kte"; + + std::error_code ec; + if (!fs::exists(config_dir)) { + fs::create_directories(config_dir, ec); + } + + if (fs::exists(config_dir)) { + static std::string ini_path = (config_dir / "imgui.ini").string(); + io.IniFilename = ini_path.c_str(); + } + } + + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls ImGui::StyleColorsDark(); // Apply background mode and selected theme (default: Nord). Can be changed at runtime via commands. @@ -318,4 +337,4 @@ GUIFrontend::LoadGuiFont_(const char * /*path*/, float size_px) } -// No runtime font reload or system font resolution in this simplified build. \ No newline at end of file +// No runtime font reload or system font resolution in this simplified build.