////////////////////////////////////////////////////// // // LuaConsole: // // Parses lines of text, and tells you if you have a valid // lua expression. // ////////////////////////////////////////////////////// #ifndef LUACONSOLE_HPP #define LUACONSOLE_HPP #include #include "luastack.hpp" class LuaConsole { public: enum { STATE_INCOMPLETE, // We need more input text. STATE_COMPLETE, // We have a valid lua expression. STATE_SLASHCOMMAND, // We have a slash-command. STATE_SYNTAX, // We have a syntax error. }; private: lua_State *lua_state_; int state_; int lines_; std::string expression_; std::string syntax_; public: LuaConsole(); ~LuaConsole(); int state() const { return state_; } int lines() const { return lines_; } const std::string &expression() const { return expression_; } const std::string &syntax() const { return syntax_; } void add(std::string line); void add_stdin(); void clear(); }; #endif //LUACONSOLE_HPP