Fix minor bugs and add language detection.

This commit is contained in:
2026-09-25 13:23:57 +01:00
parent 6711ecbaee
commit 8d6f7d323e
14 changed files with 230 additions and 90 deletions
+2
View File
@@ -20,6 +20,8 @@ struct BEd {
internal::functions::Function eof_op;
std::array<std::optional<internal::functions::Suffix>, 26> suffixes;
internal::theme::Theme theme;
std::unordered_map<std::string, std::string> extention_to_language;
std::unordered_map<std::string, std::string> filename_to_language;
std::unordered_map<std::string, internal::syntax::Language *> languages;
internal::io::IO io;
internal::vase::AppendStorage append{"/tmp"};
+1 -1
View File
@@ -33,7 +33,7 @@ struct Buffer {
virtual bool waste() = 0;
virtual uint64_t lines() = 0;
virtual uint64_t bytes() = 0;
virtual void set_filename(std::filesystem::path path) = 0;
virtual void set_filename(BEd &ctx, std::filesystem::path path) = 0;
virtual std::filesystem::path filename() = 0;
virtual void saved_hook() = 0;
virtual void load(BEd &ctx, vase::Shard *text) = 0;
+1 -1
View File
@@ -14,7 +14,7 @@ struct ClipBuffer : Buffer {
uint64_t lines() override;
uint64_t bytes() override;
void load(BEd &ctx, vase::Shard *text) override;
void set_filename(std::filesystem::path path) override;
void set_filename(BEd &ctx, std::filesystem::path path) override;
std::filesystem::path filename() override;
vase::Shard *copy(uint64_t start_line, uint64_t end_line) override;
void substitute(
+1 -1
View File
@@ -34,7 +34,7 @@ struct GenericBuffer : ShardBuffer {
void saved_hook() override;
bool waste() override;
void load(BEd &ctx, vase::Shard *text) override;
void set_filename(std::filesystem::path path) override;
void set_filename(BEd &ctx, std::filesystem::path path) override;
std::filesystem::path filename() override;
void substitute(
BEd &ctx, uint64_t start_line, uint64_t end_line,
+1 -1
View File
@@ -19,7 +19,7 @@ struct ReadonlyBuffer : ShardBuffer {
void load(BEd &, vase::Shard *) override {
throw ed_error("This buffer is read-only.");
}
void set_filename(std::filesystem::path) override {}
void set_filename(BEd &, std::filesystem::path) override {}
std::filesystem::path filename() override {
return {};
}
+3
View File
@@ -6,6 +6,9 @@
#include "storage/storage.h"
namespace bed::internal::vase {
// TODO: rewrite with invariant, text ends with a newline, as right now both 1 real and empty line and no text mean teh same thing,
// which causes a ton of issues.
struct Shard {
enum struct Kind : uint8_t {
Branch,