Add cancel buffer (to store cancelled operations.)

This commit is contained in:
2026-09-08 11:50:17 +01:00
parent 51676362b9
commit d6d3f31326
6 changed files with 31 additions and 19 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once
#include "../decl.h"
#include "history.h"
#include "readonly.h"
#include "shard.h"
namespace bed::internal::buffer {
@@ -25,7 +25,7 @@ struct GenericBuffer : ShardBuffer {
~GenericBuffer();
void list_history(BEd &ctx);
HistoryBuffer *get_history(uint64_t version);
ReadonlyBuffer *get_history(uint64_t version);
void snapshot(std::string action);
bool undo(BEd &ctx);
bool redo(BEd &ctx);
@@ -4,36 +4,38 @@
#include "shard.h"
namespace bed::internal::buffer {
struct HistoryBuffer : ShardBuffer {
HistoryBuffer(
struct ReadonlyBuffer : ShardBuffer {
bool useless = true;
ReadonlyBuffer(
std::string name, vase::Shard *root,
const syntax::ParserSnapshot &snapshot
) : ShardBuffer(std::move(name), root, snapshot, Kind::History) {}
bool waste() override {
return true;
return useless;
}
void load(BEd &, vase::Shard *) override {
throw ed_error("History buffers are read-only.");
throw ed_error("This buffer is read-only.");
}
void set_filename(std::filesystem::path) override {}
std::filesystem::path filename() override {
return {};
}
void substitute(BEd &, uint64_t, uint64_t, std::string &, std::string &, std::string &) override {
throw ed_error("History buffers are read-only.");
throw ed_error("This buffer is read-only.");
}
void join(BEd &, uint64_t, uint64_t) override {
throw ed_error("History buffers are read-only.");
throw ed_error("This buffer is read-only.");
}
void remove(BEd &, uint64_t, uint64_t) override {
throw ed_error("History buffers are read-only.");
throw ed_error("This buffer is read-only.");
}
void append(BEd &, vase::Shard *, uint64_t) override {
throw ed_error("History buffers are read-only.");
throw ed_error("This buffer is read-only.");
}
void replace(BEd &, vase::Shard *, uint64_t, uint64_t) override {
throw ed_error("History buffers are read-only.");
throw ed_error("This buffer is read-only.");
}
};
} // namespace bed::internal::buffer