wex v24.10.0
Public Member Functions | List of all members
wex::macro_mode Class Reference

Offers the macro mode, like playing back or recording, and the current macro that is recorded or was played back. More...

#include <wex/ex/macro-mode.h>

Public Member Functions

 macro_mode (macros *macros)
 Constructor.
 
 ~macro_mode ()
 Destructor.
 
bool expand (ex *ex, const variable &variable, std::string &expanded) const
 Expands template variable.
 
const std::string get_macro () const
 Returns current macro.
 
auto * get_macros ()
 Returns the macros collection.
 
bool is_playback () const
 Are we playing back?
 
bool is_recording () const
 Are we recording?
 
const std::string str () const
 Returns the mode as a string.
 
size_t transition (const std::string &command, ex *ex=nullptr, bool complete=false, size_t repeat=1)
 transitions between modes.
 

Detailed Description

Offers the macro mode, like playing back or recording, and the current macro that is recorded or was played back.

Constructor & Destructor Documentation

◆ macro_mode()

wex::macro_mode::macro_mode ( macros * macros)

Constructor.

The macros specified is the collection of macros used for replay or record. This collection might be changed depending on the mode.

Member Function Documentation

◆ expand()

bool wex::macro_mode::expand ( ex * ex,
const variable & variable,
std::string & expanded ) const

Expands template variable.

Returns true if the template file name exists, and all variables in it could be expanded.

Parameters
exex component to use
variablevariable (containing template file name)
expandedvalue to receive contents

◆ transition()

size_t wex::macro_mode::transition ( const std::string & command,
ex * ex = nullptr,
bool complete = false,
size_t repeat = 1 )

transitions between modes.

If command starts with: q: Starts recording a macro (appends to existing macro if macro is single upper case character). @: Playsback the macro. Returns number of characters processed from command.

Parameters
commandmacro name after first character
exex component to use, required in case of playback
completeis the command complete
repeatnumber of times this macro should be executed, in case of playback