Nord theme and undo system refinements

- Improve text input/event batching
- Enhance debugging with optional instrumentation
- Begin implementation of non-linear undo tree structure.
This commit is contained in:
2025-12-01 11:59:51 -08:00
parent 0cb7d36f2a
commit 464ad8d1ae
10 changed files with 944 additions and 294 deletions

View File

@@ -2,6 +2,8 @@
#define KTE_UNDOSYSTEM_H
#include <string_view>
#include <cstddef>
#include <cstdint>
#include "UndoTree.h"
@@ -10,7 +12,7 @@ class Buffer;
class UndoSystem {
public:
explicit UndoSystem(Buffer &owner, UndoTree &tree);
explicit UndoSystem(Buffer &owner, UndoTree &tree);
void Begin(UndoType type);
@@ -28,23 +30,28 @@ public:
void discard_pending();
void clear();
void clear();
void UpdateBufferReference(Buffer &new_buf);
void UpdateBufferReference(Buffer &new_buf);
private:
void apply(const UndoNode *node, int direction); // +1 redo, -1 undo
void free_node(UndoNode *node);
void apply(const UndoNode *node, int direction); // +1 redo, -1 undo
void free_node(UndoNode *node);
void free_branch(UndoNode *node); // frees redo siblings only
UndoNode *find_parent(UndoNode *from, UndoNode *target);
void free_branch(UndoNode *node); // frees redo siblings only
UndoNode *find_parent(UndoNode *from, UndoNode *target);
void update_dirty_flag();
// Debug helpers (compiled only when KTE_UNDO_DEBUG is defined)
void debug_log(const char *op) const;
static const char *type_str(UndoType t);
static bool is_descendant(UndoNode *root, const UndoNode *target);
void update_dirty_flag();
Buffer *buf_;
UndoTree &tree_;
// Internal hint for Delete batching: whether next Append() should prepend
bool pending_prepend_ = false;
// Internal hint for Delete batching: whether next Append() should prepend
bool pending_prepend_ = false;
};
#endif // KTE_UNDOSYSTEM_H