Add UndoSystem implementation and refactor UndoNode for simplicity.

This commit is contained in:
2025-11-30 00:04:29 -08:00
parent e91a32dd90
commit 35ffe6d11c
20 changed files with 13950 additions and 1479 deletions

View File

@@ -1,47 +1,3 @@
// Placeholder translation unit for UndoTree struct definition.
// Undo logic is implemented in UndoSystem.
#include "UndoTree.h"
#include <cassert>
void
UndoTree::Begin(const UndoKind kind, const size_t row, const size_t col)
{
if (this->pending != nullptr) {
if (this->pending->Kind() == kind) {
return;
}
this->Commit();
}
assert(this->pending == nullptr);
this->pending = new UndoNode(kind, row, col);
assert(this->pending != nullptr);
}
void
UndoTree::Commit()
{
if (this->pending == nullptr) {
return;
}
if (this->root == nullptr) {
assert(this->current == nullptr);
this->root = this->pending;
this->current = this->pending;
this->pending = nullptr;
return;
}
assert(this->current != nullptr);
if (this->current->Next() != nullptr) {
this->current->DeleteNext();
}
this->current->Next(this->pending);
this->current = this->pending;
this->pending = nullptr;
}