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

@@ -4,11 +4,11 @@
auto
KLookupKCommand(const int ascii_key, const bool ctrl, CommandId &out) -> bool
{
// Normalize to lowercase letter if applicable
int k = KLowerAscii(ascii_key);
// For k-prefix, preserve case to allow distinct mappings (e.g., 'U' vs 'u').
const int k_lower = KLowerAscii(ascii_key);
if (ctrl) {
switch (k) {
switch (k_lower) {
case 'd':
out = CommandId::KillLine;
return true; // C-k C-d
@@ -22,7 +22,7 @@ KLookupKCommand(const int ascii_key, const bool ctrl, CommandId &out) -> bool
break;
}
} else {
switch (k) {
switch (k_lower) {
case 'j':
out = CommandId::JumpToMark;
return true; // C-k j
@@ -59,9 +59,17 @@ KLookupKCommand(const int ascii_key, const bool ctrl, CommandId &out) -> bool
case 'p':
out = CommandId::BufferNext;
return true; // C-k p (switch to next buffer)
case 'u':
out = CommandId::Undo;
return true; // C-k u (undo)
default:
break;
}
// Case-sensitive bindings after k-prefix
if (ascii_key == 'U') {
out = CommandId::Redo; // C-k U (redo)
return true;
}
}
return false;
}