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_raw_log () const |
Get the unescaped log. More... | |
std::string | get_name () const |
Get a string describing the name of lua kernel. More... | |
void | clear_log () |
Clear the console log. 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_ |
std::stringstream | raw_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 108 of file lua_interpreter.cpp.
|
inline |
Definition at line 115 of file lua_interpreter.cpp.
References DBG_LUA, font::escape_text(), flush(), lua_kernel_base::get_log(), L_, log_, raw_log_, and lua_kernel_base::set_external_log().
|
inline |
Definition at line 134 of file lua_interpreter.cpp.
References DBG_LUA, L_, and lua_kernel_base::set_external_log().
void gui2::dialogs::lua_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 386 of file lua_interpreter.cpp.
References font::escape_text(), wfl::msg(), and markup::span_color().
Referenced by execute().
|
inline |
Clear the console log.
Definition at line 157 of file lua_interpreter.cpp.
References lua_kernel_base::clear_log(), L_, log_, and raw_log_.
bool gui2::dialogs::lua_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 372 of file lua_interpreter.cpp.
References add_dialog_message(), e, lua_kernel_base::interactive_run(), L_, and LOG_LUA.
|
inline |
Definition at line 168 of file lua_interpreter.cpp.
References lua_kernel_base::get_attribute_names(), L_, and s.
|
inline |
Definition at line 166 of file lua_interpreter.cpp.
References lua_kernel_base::get_global_var_names(), and L_.
|
inline |
|
inline |
Get a string describing the name of lua kernel.
Definition at line 154 of file lua_interpreter.cpp.
References L_, and lua_kernel_base::my_name().
|
inline |
|
private |
Definition at line 110 of file lua_interpreter.cpp.
Referenced by clear_log(), execute(), get_attribute_names(), get_globals(), get_name(), lua_model(), and ~lua_model().
|
private |
Definition at line 111 of file lua_interpreter.cpp.
Referenced by clear_log(), get_log(), and lua_model().
|
private |
Definition at line 112 of file lua_interpreter.cpp.
Referenced by clear_log(), get_raw_log(), and lua_model().