yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::MessageEditAction Class Reference

Undoable action for message text edits. More...

#include <message_undo_actions.h>

Inheritance diagram for yaze::editor::MessageEditAction:
Collaboration diagram for yaze::editor::MessageEditAction:

Public Types

using ApplyFn = std::function<void(const MessageSnapshot&)>
 

Public Member Functions

 MessageEditAction (MessageSnapshot before, MessageSnapshot after, ApplyFn apply_fn)
 
absl::Status Undo () override
 
absl::Status Redo () override
 
std::string Description () const override
 Human-readable description (e.g., "Paint 12 tiles on map 5")
 
size_t MemoryUsage () const override
 Approximate memory footprint for budget enforcement.
 
- Public Member Functions inherited from yaze::editor::UndoAction
virtual ~UndoAction ()=default
 
virtual bool CanMergeWith (const UndoAction &) const
 
virtual void MergeWith (UndoAction &)
 

Private Attributes

MessageSnapshot before_
 
MessageSnapshot after_
 
ApplyFn apply_fn_
 

Detailed Description

Undoable action for message text edits.

Stores before/after MessageSnapshot values and a callback that knows how to apply a snapshot back to the owning MessageEditor. The editor binds the callback at action-creation time via a lambda that calls MessageEditor::ApplySnapshot().

Definition at line 36 of file message_undo_actions.h.

Member Typedef Documentation

◆ ApplyFn

using yaze::editor::MessageEditAction::ApplyFn = std::function<void(const MessageSnapshot&)>

Definition at line 38 of file message_undo_actions.h.

Constructor & Destructor Documentation

◆ MessageEditAction()

yaze::editor::MessageEditAction::MessageEditAction ( MessageSnapshot before,
MessageSnapshot after,
ApplyFn apply_fn )
inline

Definition at line 40 of file message_undo_actions.h.

Member Function Documentation

◆ Undo()

absl::Status yaze::editor::MessageEditAction::Undo ( )
inlineoverridevirtual

Implements yaze::editor::UndoAction.

Definition at line 46 of file message_undo_actions.h.

References apply_fn_, and before_.

◆ Redo()

absl::Status yaze::editor::MessageEditAction::Redo ( )
inlineoverridevirtual

Implements yaze::editor::UndoAction.

Definition at line 51 of file message_undo_actions.h.

References after_, and apply_fn_.

◆ Description()

std::string yaze::editor::MessageEditAction::Description ( ) const
inlineoverridevirtual

Human-readable description (e.g., "Paint 12 tiles on map 5")

Implements yaze::editor::UndoAction.

Definition at line 56 of file message_undo_actions.h.

References before_, and yaze::editor::MessageSnapshot::message_index.

◆ MemoryUsage()

size_t yaze::editor::MessageEditAction::MemoryUsage ( ) const
inlineoverridevirtual

Approximate memory footprint for budget enforcement.

Reimplemented from yaze::editor::UndoAction.

Definition at line 60 of file message_undo_actions.h.

References after_, before_, yaze::editor::MessageData::Data, yaze::editor::MessageSnapshot::message, and yaze::editor::MessageSnapshot::parsed_text.

Member Data Documentation

◆ before_

MessageSnapshot yaze::editor::MessageEditAction::before_
private

Definition at line 66 of file message_undo_actions.h.

Referenced by Description(), MemoryUsage(), and Undo().

◆ after_

MessageSnapshot yaze::editor::MessageEditAction::after_
private

Definition at line 67 of file message_undo_actions.h.

Referenced by MemoryUsage(), and Redo().

◆ apply_fn_

ApplyFn yaze::editor::MessageEditAction::apply_fn_
private

Definition at line 68 of file message_undo_actions.h.

Referenced by Redo(), and Undo().


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