Minor improvements to LuaConsole.cpp
This commit is contained in:
@@ -2,9 +2,21 @@
|
||||
//
|
||||
// LuaConsole:
|
||||
//
|
||||
// Parses lines of text, and tells you if you have a valid
|
||||
// lua expression.
|
||||
//
|
||||
// Used to parse lines of text that are being interactively typed
|
||||
// in by a user.
|
||||
//
|
||||
// Whenever the user types in a line, you should add the line to
|
||||
// the LuaConsole object. After adding a line, the console will
|
||||
// recommend one of several actions:
|
||||
//
|
||||
// 1. DO_NOTHING: The input is not complete, so you need to wait.
|
||||
// 2. DO_COMMAND: Execute a lua command.
|
||||
// 3. DO_SYNTAX: Print a syntax error message.
|
||||
// 4. DO_SLASH: Execute a slash-command that bypasses lua.
|
||||
//
|
||||
// Also: if the first character of the lua form is '=', then
|
||||
// replace the '=' with 'return '.
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LUACONSOLE_HPP
|
||||
@@ -16,14 +28,14 @@
|
||||
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.
|
||||
DO_NOTHING, // We need more input text.
|
||||
DO_COMMAND, // We have a valid lua expression.
|
||||
DO_SYNTAX, // We have a syntax error.
|
||||
DO_SLASH, // We have a slash-command.
|
||||
};
|
||||
private:
|
||||
lua_State *lua_state_;
|
||||
int state_;
|
||||
int action_;
|
||||
int lines_;
|
||||
std::string expression_;
|
||||
std::string syntax_;
|
||||
@@ -32,7 +44,7 @@ public:
|
||||
LuaConsole();
|
||||
~LuaConsole();
|
||||
|
||||
int state() const { return state_; }
|
||||
int action() const { return action_; }
|
||||
int lines() const { return lines_; }
|
||||
const std::string &expression() const { return expression_; }
|
||||
const std::string &syntax() const { return syntax_; }
|
||||
@@ -42,4 +54,4 @@ public:
|
||||
void clear();
|
||||
};
|
||||
|
||||
#endif //LUACONSOLE_HPP
|
||||
#endif // LUACONSOLE_HPP
|
||||
|
||||
Reference in New Issue
Block a user