Add undo/redo infrastructure and buffer management additions.

This commit is contained in:
2025-11-29 22:48:31 -08:00
parent 40d33e1847
commit 1a72e2b312
16 changed files with 1000 additions and 73 deletions

83
UndoNode.h Normal file
View File

@@ -0,0 +1,83 @@
#ifndef KTE_UNDONODE_H
#define KTE_UNDONODE_H
#include <cstddef>
#include <cstddef>
enum UndoKind {
UNDO_INSERT,
UNDO_DELETE,
};
class UndoNode {
public:
explicit UndoNode(const UndoKind kind, const size_t row, const size_t col)
: kind_(kind), row_(row), col_(col) {}
~UndoNode() = default;
[[nodiscard]] UndoKind Kind() const
{
return kind_;
}
[[nodiscard]] UndoNode *Next() const
{
return next_;
}
void Next(UndoNode *next)
{
next_ = next;
}
[[nodiscard]] UndoNode *Child() const
{
return child_;
}
void Child(UndoNode *child)
{
child_ = child;
}
void SetRowCol(const std::size_t row, const std::size_t col)
{
this->row_ = row;
this->col_ = col;
}
[[nodiscard]] std::size_t Row() const
{
return row_;
}
[[nodiscard]] std::size_t Col() const
{
return col_;
}
void DeleteNext() const;
private:
[[maybe_unused]] UndoKind kind_;
[[maybe_unused]] UndoNode *next_{nullptr};
[[maybe_unused]] UndoNode *child_{nullptr};
[[maybe_unused]] std::size_t row_{}, col_{};
};
#endif // KTE_UNDONODE_H