The Battle for Wesnoth  1.19.5+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 108 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

Definition at line 134 of file lua_interpreter.cpp.

References DBG_LUA, L_, and lua_kernel_base::set_external_log().

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

References font::escape_text(), wfl::msg(), and markup::span_color().

Referenced by execute().

◆ clear_log()

void gui2::dialogs::lua_interpreter::lua_model::clear_log ( )
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_.

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

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

◆ get_attribute_names()

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

Definition at line 168 of file lua_interpreter.cpp.

References lua_kernel_base::get_attribute_names(), L_, and s.

◆ get_globals()

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

Definition at line 166 of file lua_interpreter.cpp.

References lua_kernel_base::get_global_var_names(), and L_.

◆ get_log()

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

Get the log string.

Definition at line 150 of file lua_interpreter.cpp.

References log_.

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

References L_, and 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 152 of file lua_interpreter.cpp.

References raw_log_.

Member Data Documentation

◆ L_

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

◆ log_

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

Definition at line 111 of file lua_interpreter.cpp.

Referenced by clear_log(), get_log(), and lua_model().

◆ raw_log_

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

Definition at line 112 of file lua_interpreter.cpp.

Referenced by clear_log(), get_raw_log(), and lua_model().


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