diff options
author | pommicket <pommicket@gmail.com> | 2023-08-07 08:11:29 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-07 08:11:51 -0400 |
commit | 17e65f8dd57762a2e79aeb79a5c0fb69849c07f9 (patch) | |
tree | aa4d3c58ada3069c132e2d69ce494aedd4dcd0a2 /buffer.c | |
parent | 3839577f15d9fa8e460e3042d94970fb8b5dc12f (diff) |
buffer API
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 44 |
1 files changed, 43 insertions, 1 deletions
@@ -91,6 +91,48 @@ void buffer_set_view_only(TextBuffer *buffer, bool view_only) { buffer->view_only = view_only; } +double buffer_get_scroll_columns(TextBuffer *buffer) { + return buffer->scroll_x; +} + +double buffer_get_scroll_lines(TextBuffer *buffer) { + return buffer->scroll_y; +} + +double buffer_last_write_time(TextBuffer *buffer) { + return buffer->last_write_time; +} + +BufferPos buffer_cursor_pos(TextBuffer *buffer) { + return buffer->cursor_pos; +} + +bool buffer_selection_pos(TextBuffer *buffer, BufferPos *pos) { + if (buffer->selection) { + if (pos) *pos = buffer->selection_pos; + return true; + } else { + if (pos) *pos = (BufferPos){0}; + return false; + } +} + +u32 buffer_first_line_on_screen(TextBuffer *buffer) { + return buffer->first_line_on_screen; +} + +u32 buffer_last_line_on_screen(TextBuffer *buffer) { + return buffer->last_line_on_screen; +} + +void buffer_set_undo_enabled(TextBuffer *buffer, bool enabled) { + buffer->store_undo_events = enabled; +} + +Rect buffer_rect(TextBuffer *buffer) { + return rect4(buffer->x1, buffer->y1, buffer->x2, buffer->y2); +} + const char *buffer_get_path(TextBuffer *buffer) { return buffer->path; } @@ -340,7 +382,7 @@ bool buffer_indent_with_spaces(TextBuffer *buffer) { return buffer_settings(buffer)->indent_with_spaces; } -u32 buffer_get_num_lines(TextBuffer *buffer) { +u32 buffer_line_count(TextBuffer *buffer) { return buffer->nlines; } |