diff options
author | pommicket <pommicket@gmail.com> | 2023-08-05 13:55:53 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-05 13:55:53 -0400 |
commit | 4ab3631aadcd27df708a16f6bf22953e0ff9b1cf (patch) | |
tree | 4fca0b612ae40cf8723c4c57fd0243631f7e51e7 /buffer.c | |
parent | 601c081d62e0cd9c0e6750b424ecc5baa9a45b5f (diff) |
internalize Line structure
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -8,6 +8,12 @@ #define BUFFER_UNTITLED "Untitled" // what to call untitled buffers +struct Line { + SyntaxState syntax; + u32 len; + char32_t *str; +}; + // this is a macro so we get -Wformat warnings #define buffer_error(buffer, ...) \ snprintf(buffer->error, sizeof buffer->error - 1, __VA_ARGS__) @@ -331,6 +337,10 @@ bool buffer_indent_with_spaces(TextBuffer *buffer) { return buffer_settings(buffer)->indent_with_spaces; } +u32 buffer_get_num_lines(TextBuffer *buffer) { + return buffer->nlines; +} + String32 buffer_get_line(TextBuffer *buffer, u32 line_number) { if (line_number >= buffer->nlines) { return str32(NULL, 0); @@ -341,6 +351,10 @@ String32 buffer_get_line(TextBuffer *buffer, u32 line_number) { }; } +char *buffer_get_line_utf8(TextBuffer *buffer, u32 line_number) { + return str32_to_utf8_cstr(buffer_get_line(buffer, line_number)); +} + // Returns a simple checksum of the buffer. // This is only used for testing, and shouldn't be relied on. static u64 buffer_checksum(TextBuffer *buffer) { |