The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
gui2::tlua_interpreter::lua_model Class Reference

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::stringget_globals ()
 
std::vector< std::stringget_attribute_names (const std::string &s)
 

Private Attributes

lua_kernel_baseL_
 
std::stringstream log_
 

Detailed Description

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.

Constructor & Destructor Documentation

gui2::tlua_interpreter::lua_model::lua_model ( lua_kernel_base lk)
inline
gui2::tlua_interpreter::lua_model::~lua_model ( )
inline

Definition at line 144 of file lua_interpreter.cpp.

References DBG_LUA, and lua_kernel_base::set_external_log().

Member Function Documentation

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().

std::vector<std::string> gui2::tlua_interpreter::lua_model::get_attribute_names ( const std::string s)
inline

Definition at line 165 of file lua_interpreter.cpp.

References lua_kernel_base::get_attribute_names().

std::vector<std::string> gui2::tlua_interpreter::lua_model::get_globals ( )
inline

Definition at line 163 of file lua_interpreter.cpp.

References lua_kernel_base::get_global_var_names().

std::string gui2::tlua_interpreter::lua_model::get_log ( ) const
inline

Get the log string.

Definition at line 159 of file lua_interpreter.cpp.

std::string gui2::tlua_interpreter::lua_model::get_name ( ) const
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().

Member Data Documentation

lua_kernel_base& gui2::tlua_interpreter::lua_model::L_
private

Definition at line 126 of file lua_interpreter.cpp.

Referenced by execute().

std::stringstream gui2::tlua_interpreter::lua_model::log_
private

Definition at line 127 of file lua_interpreter.cpp.


The documentation for this class was generated from the following file: