Major fixes:
- ChunkIterator is now bidirectional - LineIterator is now also bidirectional - Undo/redo history operations - Replace operation - Range based api functions - And more minor bug fixes
This commit is contained in:
+33
-11
@@ -2,14 +2,29 @@
|
||||
|
||||
#include "buffer/append.h"
|
||||
#include "buffer/original.h"
|
||||
#include "constants.h"
|
||||
#include "iterators/line.h"
|
||||
#include "pch.h"
|
||||
#include "search.h"
|
||||
#include "shard.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
struct Point {
|
||||
uint32_t row;
|
||||
uint32_t col;
|
||||
};
|
||||
|
||||
struct Range {
|
||||
Point start;
|
||||
Point end;
|
||||
};
|
||||
|
||||
struct Vase {
|
||||
Vase(char *data, uint32_t length);
|
||||
OriginalBuffer original;
|
||||
AppendBuffer append;
|
||||
Shard *root;
|
||||
|
||||
Vase(std::string path);
|
||||
|
||||
~Vase();
|
||||
|
||||
@@ -20,26 +35,33 @@ struct Vase {
|
||||
|
||||
LineIterator iterate(uint32_t line);
|
||||
|
||||
void input(Point *point, char key);
|
||||
void insert(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 erase(Range range);
|
||||
void replace(Range range, const char *data, uint32_t len);
|
||||
|
||||
void move_clusters(Point *point, int64_t amount);
|
||||
void move_lines(Point *point, int64_t amount);
|
||||
void clamp(Point *point);
|
||||
|
||||
void regex_search_replace(
|
||||
std::string_view pattern,
|
||||
Point start, Point end,
|
||||
std::string_view replace, std::string_view options
|
||||
);
|
||||
|
||||
private:
|
||||
OriginalBuffer original;
|
||||
AppendBuffer append;
|
||||
Shard *root;
|
||||
bool undo();
|
||||
bool redo();
|
||||
|
||||
/*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.*/
|
||||
void snapshot();
|
||||
void prune_history(uint32_t n);
|
||||
|
||||
private:
|
||||
std::vector<Shard *> history;
|
||||
uint32_t history_top;
|
||||
|
||||
uint32_t offset_of(Point point);
|
||||
static void flatten(Shard *s, std::string &out);
|
||||
void _insert(Point *point, const char *data, uint32_t len);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user