Step 107a: add text mode toggle

This commit is contained in:
Bill
2026-02-09 11:46:57 -07:00
parent bd05b8a68f
commit a8c7b2adfc
5 changed files with 81 additions and 4 deletions

View File

@@ -11,20 +11,27 @@
class BufferManager {
public:
enum class BufferMode {
Structured,
Text
};
struct BufferInfo {
std::string path;
std::string content;
std::string language;
bool modified = false;
BufferMode mode = BufferMode::Structured;
};
BufferManager() = default;
// Open a file into a buffer (makes it active)
bool openBuffer(const std::string& path, const std::string& content,
const std::string& language) {
const std::string& language,
BufferMode mode = BufferMode::Structured) {
if (hasBuffer(path)) return false; // already open
BufferInfo info{path, content, language, false};
BufferInfo info{path, content, language, false, mode};
buffers_[path] = info;
activeBuffer_ = path;
return true;
@@ -70,6 +77,19 @@ public:
}
}
void setBufferMode(const std::string& path, BufferMode mode) {
auto it = buffers_.find(path);
if (it != buffers_.end()) {
it->second.mode = mode;
}
}
BufferMode getBufferMode(const std::string& path) const {
auto it = buffers_.find(path);
if (it != buffers_.end()) return it->second.mode;
return BufferMode::Structured;
}
// Get list of all open buffer paths
std::vector<std::string> getOpenBuffers() const {
std::vector<std::string> result;