Files
text_editor/src/text_editor/buffer.h
Krzosa Karol a5069cd148 Undo redo
2024-07-22 08:03:22 +02:00

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;
};