47 lines
739 B
C
47 lines
739 B
C
union Range {
|
|
struct {
|
|
Int min;
|
|
Int max;
|
|
};
|
|
Int e[2];
|
|
};
|
|
|
|
struct Caret {
|
|
union {
|
|
Range range;
|
|
Int pos[2];
|
|
};
|
|
Int ifront;
|
|
};
|
|
|
|
struct XY {
|
|
Int col;
|
|
Int line;
|
|
};
|
|
|
|
struct Edit {
|
|
Range range;
|
|
String16 string;
|
|
};
|
|
|
|
// @idea: maybe redo tree?
|
|
struct HistoryEntry {
|
|
Array<Edit> edits;
|
|
Array<Caret> carets;
|
|
};
|
|
|
|
// @todo: gap buffer to improve speed of inserting on big files with only one cursor?
|
|
struct Buffer {
|
|
union {
|
|
U16 *data;
|
|
wchar_t *str;
|
|
};
|
|
Int len;
|
|
Int cap;
|
|
Array<Int> line_starts;
|
|
|
|
Array<HistoryEntry> undo_stack;
|
|
Array<HistoryEntry> redo_stack;
|
|
int debug_edit_phase;
|
|
};
|