Modularize insertion/deletion

This commit is contained in:
2025-12-11 18:00:17 +00:00
parent 4e25b28bbe
commit 17e8521f6a
7 changed files with 123 additions and 113 deletions

View File

@@ -115,5 +115,7 @@ void cursor_left(Editor *editor, uint32_t number);
void cursor_right(Editor *editor, uint32_t number);
void ensure_scroll(Editor *editor);
void apply_edit(std::vector<Span> &spans, uint32_t x, int64_t y);
void edit_erase(Editor *editor, uint32_t pos, uint32_t len);
void edit_insert(Editor *editor, uint32_t pos, char *data, uint32_t len);
#endif

View File

@@ -100,7 +100,7 @@ char *read(Knot *root, uint32_t offset, uint32_t len);
void split(Knot *node, uint32_t offset, Knot **left, Knot **right);
// Used to convert a byte offset to a line number that contains that byte
uint32_t byte_to_line(Knot *node, uint32_t offset);
uint32_t byte_to_line(Knot *node, uint32_t offset, uint32_t *out_col);
// Used to convert a line number to a byte offset (start of the line)
// also sets out_len to the length of the line

View File

@@ -36,7 +36,7 @@ struct Coord {
uint32_t col;
};
uint32_t grapheme_strlen(const char *s);
uint32_t visual_width(const char *s);
uint32_t get_visual_col_from_bytes(const char *line, uint32_t byte_limit);
uint32_t get_bytes_from_visual_col(const char *line,
uint32_t target_visual_col);