diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-05-11 15:07:55 -0500 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-05-11 15:07:55 -0500 |
| commit | cebb280fe546190e55e071b6adbf37cd47950f34 (patch) | |
| tree | 6e7a7605f8832b1c1bd7e467884a8792a5e1fab4 /src/core/buffer.h | |
initial commit
Diffstat (limited to 'src/core/buffer.h')
| -rw-r--r-- | src/core/buffer.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/core/buffer.h b/src/core/buffer.h new file mode 100644 index 0000000..8fac8ab --- /dev/null +++ b/src/core/buffer.h @@ -0,0 +1,38 @@ +#ifndef LEMACS_BUFFER_H +#define LEMACS_BUFFER_H + +#include <stdbool.h> +#include <stddef.h> + +typedef struct { + char *data; + size_t capacity; + size_t gap_start; + size_t gap_end; + char path[1024]; + bool modified; +} Buffer; + +bool buffer_init(Buffer *buffer); +void buffer_free(Buffer *buffer); + +size_t buffer_length(const Buffer *buffer); +size_t buffer_point(const Buffer *buffer); +void buffer_set_point(Buffer *buffer, size_t point); + +bool buffer_insert_char(Buffer *buffer, char c); +bool buffer_insert_cstr(Buffer *buffer, const char *text); +bool buffer_backspace(Buffer *buffer); +bool buffer_delete_forward(Buffer *buffer); + +char buffer_char_at(const Buffer *buffer, size_t index); + +bool buffer_load_file(Buffer *buffer, const char *path); +bool buffer_save_file(Buffer *buffer, const char *path); +const char *buffer_path(const Buffer *buffer); +bool buffer_modified(const Buffer *buffer); + +void buffer_index_to_line_col(const Buffer *buffer, size_t index, int *line, int *col); +size_t buffer_line_col_to_index(const Buffer *buffer, int target_line, int target_col); + +#endif |
