#pragma once #include #include #include #include #include #include namespace render { class RenderDriver; struct RenderState; }; namespace profile { struct Keybind; }; typedef std::vector argList; class Console { public: struct ConsoleFunction { std::function line; std::function call; std::function destruct; }; private: std::unordered_map functions; std::unordered_map binds; std::list lines, history; std::list::const_iterator historyItem; std::list> undo, redo; std::string currentLine; size_t caret; int length; bool open; bool permaStats; render::RenderState *bg; bool compact; unsigned liveStats; bool asMode; std::string asModule; std::string asEngine; bool eraseSelection(); public: void addCommand(std::string name, std::function function, bool replace = false); void addCommand(std::string name, ConsoleFunction& func, bool replace = false); void clearCommands(); void printLn(const std::string& line); void execute(const std::string& command, bool echo); void executeFile(const std::string& filename); profile::Keybind* keybind; void toggle(); void show(); void clear(); Console(); ~Console(); bool preRender(); void render(render::RenderDriver& driver); bool character(int code); bool key(int code, bool pressed); bool globalKey(int code, bool pressed); }; extern Console console;