#pragma once #include "lumacs/editor_core.hpp" #include "lumacs/theme.hpp" #include "lumacs/keybinding.hpp" #include #include #include #include namespace lumacs { class EditorCore; // Forward declaration /// Lua scripting API for Lumacs class LuaApi { public: explicit LuaApi(); // Default constructor ~LuaApi() = default; /// Set the EditorCore instance after construction void set_core(EditorCore& core); /// Get the Lua state [[nodiscard]] sol::state& state() { return lua_; } /// Load and execute a Lua file bool load_file(const std::filesystem::path& path); /// Execute Lua code bool execute(std::string_view code); /// Load init.lua from standard locations bool load_init_file(); /// Bind a key to a Lua function (uses new keybinding system) void bind_key(std::string key, sol::function callback, std::string description = ""); /// Process key using the new keybinding system KeyResult process_key(const std::string& key); /// Get all key bindings (for debugging) - Legacy method [[nodiscard]] std::map key_bindings() const { return legacy_key_bindings_; } // Legacy methods for backward compatibility [[nodiscard]] bool has_key_binding(const std::string& key) const; bool execute_key_binding(const std::string& key); private: sol::state lua_; EditorCore* core_ = nullptr; // Changed to pointer std::map legacy_key_bindings_; // For backward compatibility void setup_api(); void register_types(); void register_functions(); }; } // namespace lumacs