The Battle for Wesnoth  1.15.2+dev
Public Member Functions | Private Attributes | List of all members
gui2::dialogs::lua_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_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_baseL_
 
std::stringstream log_
 
std::stringstream raw_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 129 of file lua_interpreter.cpp.

Constructor & Destructor Documentation

◆ lua_model()

gui2::dialogs::lua_interpreter::lua_model::lua_model ( lua_kernel_base lk)
inline

◆ ~lua_model()

gui2::dialogs::lua_interpreter::lua_model::~lua_model ( )
inline

Member Function Documentation

◆ add_dialog_message()

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 431 of file lua_interpreter.cpp.

References font::escape_text(), log_, and raw_log_.

Referenced by execute(), and ~lua_model().

◆ clear_log()

void gui2::dialogs::lua_interpreter::lua_model::clear_log ( )
inline

Clear the console log.

Definition at line 175 of file lua_interpreter.cpp.

References lua_kernel_base::clear_log().

◆ execute()

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 417 of file lua_interpreter.cpp.

References add_dialog_message(), e, lua_kernel_base::interactive_run(), L_, LOG_LUA, and game::error::what().

Referenced by gui2::dialogs::lua_interpreter::controller::input_keypress_callback(), and ~lua_model().

◆ get_attribute_names()

std::vector<std::string> gui2::dialogs::lua_interpreter::lua_model::get_attribute_names ( const std::string &  s)
inline

Definition at line 186 of file lua_interpreter.cpp.

References lua_kernel_base::get_attribute_names().

◆ get_globals()

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

Definition at line 184 of file lua_interpreter.cpp.

References lua_kernel_base::get_global_var_names().

◆ get_log()

std::string gui2::dialogs::lua_interpreter::lua_model::get_log ( ) const
inline

Get the log string.

Definition at line 170 of file lua_interpreter.cpp.

◆ get_name()

std::string gui2::dialogs::lua_interpreter::lua_model::get_name ( ) const
inline

Get a string describing the name of lua kernel.

Definition at line 172 of file lua_interpreter.cpp.

References lua_kernel_base::my_name().

◆ get_raw_log()

std::string gui2::dialogs::lua_interpreter::lua_model::get_raw_log ( ) const
inline

Get the unescaped log.

Definition at line 171 of file lua_interpreter.cpp.

Member Data Documentation

◆ L_

lua_kernel_base& gui2::dialogs::lua_interpreter::lua_model::L_
private

Definition at line 131 of file lua_interpreter.cpp.

Referenced by execute().

◆ log_

std::stringstream gui2::dialogs::lua_interpreter::lua_model::log_
private

Definition at line 132 of file lua_interpreter.cpp.

Referenced by add_dialog_message().

◆ raw_log_

std::stringstream gui2::dialogs::lua_interpreter::lua_model::raw_log_
private

Definition at line 133 of file lua_interpreter.cpp.

Referenced by add_dialog_message().


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