Cleaning up and adding comments

This commit is contained in:
Christopher Sanden
2025-11-20 15:24:00 +01:00
parent e77d7ff21e
commit a014e4ca73
7 changed files with 102 additions and 27 deletions

View File

@@ -10,8 +10,13 @@ enum EnumActionType {
DELETE
};
// Simple fixed-size stack used for undo/redo.
// Stores actions describing line insert/delete operations.
class TStack {
private:
// Describes a single text-edit action.
// 'action' indicates INSERT or DELETE,
// 'text' stores the affected line, and 'index' is the line position.
struct TAction {
EnumActionType action;
std::string text;
@@ -24,9 +29,8 @@ private:
public:
TStack() = default;
~TStack() = default;
void Push(const TAction& action);
TAction Pop();
void Push(const TAction& action); // Adds a new action to the top of the stack.
TAction Pop(); // Removes and returns the most recent action.
[[nodiscard]] TAction Peek() const;
[[nodiscard]] bool IsEmpty() const;
void Clear();