Rearrange project files.
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
#pragma once
|
||||
|
||||
#include "buffer/append.h"
|
||||
#include "buffer/original.h"
|
||||
#include "constants.h"
|
||||
#include "iterators/line.h"
|
||||
#include "pch.h"
|
||||
#include "search.h"
|
||||
#include "shard.h"
|
||||
|
||||
struct Point {
|
||||
uint64_t row;
|
||||
uint64_t col;
|
||||
};
|
||||
|
||||
struct Range {
|
||||
Point start;
|
||||
Point end;
|
||||
};
|
||||
|
||||
struct RegexGroup {
|
||||
uint64_t start{UINT32_MAX};
|
||||
uint64_t end{UINT32_MAX};
|
||||
};
|
||||
|
||||
struct RegexMatch {
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
RegexGroup groups[9]{};
|
||||
};
|
||||
|
||||
struct ReplacePart {
|
||||
enum struct PartType {
|
||||
FullMatch,
|
||||
CaptureGroup,
|
||||
Constant
|
||||
} type;
|
||||
|
||||
std::variant<uint8_t, Shard *> value;
|
||||
};
|
||||
|
||||
struct Vase {
|
||||
OriginalBuffer *original;
|
||||
AppendBuffer *append;
|
||||
Shard *root;
|
||||
std::filesystem::path path;
|
||||
std::filesystem::path swapdir;
|
||||
|
||||
Vase(std::filesystem::path path, std::filesystem::path swapdir);
|
||||
~Vase();
|
||||
|
||||
uint64_t length();
|
||||
std::string to_string();
|
||||
std::string to_string(Range range);
|
||||
|
||||
Point resolve_column(uint64_t line, uint64_t column);
|
||||
|
||||
LineIterator iterate(uint64_t line);
|
||||
|
||||
void insert(Point *point, char key);
|
||||
void insert(Point *point, const char *data, uint64_t len);
|
||||
void erase(Point *point, uint64_t amount, Direction dir);
|
||||
void erase(Range range);
|
||||
void replace(Range range, const char *data, uint64_t len);
|
||||
|
||||
void move_clusters(Point *point, uint64_t amount, Direction dir);
|
||||
void move_lines(Point *point, uint64_t amount, Direction dir);
|
||||
void clamp(Point *point);
|
||||
|
||||
void regex_search_replace(
|
||||
std::string_view pattern, Range range,
|
||||
std::string_view replace, std::string_view options
|
||||
);
|
||||
|
||||
std::vector<Range> regex_search(
|
||||
std::string_view pattern, Range range, std::string_view options
|
||||
);
|
||||
|
||||
bool undo();
|
||||
bool redo();
|
||||
void snapshot();
|
||||
void prune_history(uint64_t n);
|
||||
|
||||
bool save();
|
||||
bool save_swap();
|
||||
|
||||
uint64_t offset_of(Point point);
|
||||
Point point_of(uint64_t offset);
|
||||
|
||||
private:
|
||||
std::vector<Shard *> history;
|
||||
uint64_t history_top;
|
||||
|
||||
void _insert(Point *point, const char *data, uint64_t len);
|
||||
|
||||
std::vector<ReplacePart> parse_replace(std::string_view s);
|
||||
std::vector<RegexMatch> _regex_search(
|
||||
std::string_view pattern, Range range, std::string_view options
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user