Major changes to api and structure.

- Remove newline caching
- limit petal sizes
- make public facing api use points only
- fix iterators (chunk & line)
This commit is contained in:
2026-08-02 11:07:04 +01:00
parent 89b24a7488
commit 51e193d28b
16 changed files with 355 additions and 422 deletions
+21 -23
View File
@@ -2,46 +2,44 @@
#include "buffer/append.h"
#include "buffer/original.h"
#include "iterators/chunk.h"
#include "iterators/line.h"
#include "pch.h"
#include "search.h"
#include "shard.h"
#include "utils/utils.h"
struct Vase {
OriginalBuffer original;
AppendBuffer append;
/*std::vector<Shard *> undo; // TODO: later
uint8_t top; // of the undo stack.
uint8_t max; // for redo when no edits have been done after some undo.*/
Shard *root;
Vase(char *data, uint32_t length);
~Vase();
uint32_t length();
std::string to_string();
static void flatten(Shard *s, std::string &out);
void type(uint32_t offset, char key);
void insert(uint32_t offset, const char *data, uint32_t len);
void erase(uint32_t cursor, int64_t amount);
Point resolve_column(uint32_t line, uint32_t column);
// Grapheme clusters or the specail cluster "\r\n'
void erase_clusters(uint32_t cursor, int64_t amount);
// moves in clusters from line,col and sets new position to line,col returns false if not enough space to jump.
bool jump_clusters(uint32_t *line, uint32_t *col, int64_t amount);
// need to also make helpers for line width.
LineIterator iterate(uint32_t line);
void input(Point *point, char key);
void insert(Point *point, const char *data, uint32_t len);
void erase(Point *point, int64_t amount);
bool jump(Point *point, int64_t amount);
bool clamp(Point *point);
void regex_search_replace(
std::string_view pattern,
uint32_t start_offset, uint32_t end_offset,
Point start, Point end,
std::string_view replace, std::string_view options
);
private:
OriginalBuffer original;
AppendBuffer append;
Shard *root;
/*std::vector<Shard *> undo; // TODO: later
uint16_t top; // of the undo stack.
uint16_t max; // for redo when no edits have been done after some undo.*/
uint32_t offset_of(Point point);
static void flatten(Shard *s, std::string &out);
};