The lua model is responsible to interact with the lua kernel base and keep track of what should be displayed in the console. More...
Public Member Functions | |
lua_model (lua_kernel_base &lk) | |
~lua_model () | |
bool | execute (const std::string &cmd) |
Ask the lua kernel to execute a command. More... | |
void | add_dialog_message (const std::string &msg) |
Add a message from the dialog, formatted in blue to distinguish from issued commands. More... | |
std::string | get_log () const |
Get the log string. More... | |
std::string | get_name () const |
Get a string describing the name of lua kernel. More... | |
std::vector< std::string > | get_globals () |
std::vector< std::string > | get_attribute_names (const std::string &s) |
Private Attributes | |
lua_kernel_base & | L_ |
std::stringstream | log_ |
The lua model is responsible to interact with the lua kernel base and keep track of what should be displayed in the console.
It registers its stringstream with the lua kernel when it is created, and unregisters when it is destroyed.
It is responsible to execute commands as strings, or add dialog messages for the user. It is also responsible to ask the lua kernel for help with tab completion.
Definition at line 124 of file lua_interpreter.cpp.
|
inline |
Definition at line 130 of file lua_interpreter.cpp.
References DBG_LUA, flush(), lua_kernel_base::get_log(), and lua_kernel_base::set_external_log().
|
inline |
Definition at line 144 of file lua_interpreter.cpp.
References DBG_LUA, and lua_kernel_base::set_external_log().
void gui2::tlua_interpreter::lua_model::add_dialog_message | ( | const std::string & | msg | ) |
Add a message from the dialog, formatted in blue to distinguish from issued commands.
Add a dialog message, which will appear in blue.
This message gets put in the interpreter log, but does not get entered in the kernel log, so if the window is closed this message will not appear the next time it is opened.
Definition at line 408 of file lua_interpreter.cpp.
References font::escape_text().
Referenced by execute().
bool gui2::tlua_interpreter::lua_model::execute | ( | const std::string & | cmd | ) |
Ask the lua kernel to execute a command.
Execute a command, and report any errors encountered.
No throw of game::lua_error, instead the error message is formatted and printed to console.
Definition at line 394 of file lua_interpreter.cpp.
References add_dialog_message(), e, lua_kernel_base::interactive_run(), L_, LOG_LUA, and game::error::what().
|
inline |
Definition at line 165 of file lua_interpreter.cpp.
References lua_kernel_base::get_attribute_names().
|
inline |
Definition at line 163 of file lua_interpreter.cpp.
References lua_kernel_base::get_global_var_names().
|
inline |
Get the log string.
Definition at line 159 of file lua_interpreter.cpp.
|
inline |
Get a string describing the name of lua kernel.
Definition at line 160 of file lua_interpreter.cpp.
References lua_kernel_base::my_name().
|
private |
Definition at line 126 of file lua_interpreter.cpp.
Referenced by execute().
|
private |
Definition at line 127 of file lua_interpreter.cpp.