#pragma once #include #include #include #include #include #include namespace sophia { class ConsolePanel : public Panel { public: using CommandCallback = std::function; ConsolePanel() : Panel{"Console"} { registerDefaultCommands(); } void onUpdate(const FrameInfo& frameInfo) override; void log(const std::string& message); void clear(); void setCommandCallback(CommandCallback callback) { this->commandCallback = std::move(callback); } private: struct Entry { std::string text; ImVec4 color; }; void registerDefaultCommands(); void execute(const std::string& command); int textEditCallback(struct ImGuiInputTextCallbackData* data); std::vector entries; std::vector history; int historyPos = -1; char inputBuffer[256] = {}; bool autoScroll = true; bool scrollToBottom = false; CommandCallback commandCallback; }; } // namespace sophia