diff options
| author | Albert Cervin <albert@acervin.com> | 2023-07-12 16:20:50 +0200 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2023-10-19 22:41:33 +0200 |
| commit | 54c9b4b533210b77be998f458ff96bdc54272f64 (patch) | |
| tree | eb434343bb1083172af50b7372d1e2745af00f8f /src/dged/text.h | |
| parent | 3a8ae83aa13636679c151027cace905fa87ebd8e (diff) | |
| download | dged-54c9b4b533210b77be998f458ff96bdc54272f64.tar.gz dged-54c9b4b533210b77be998f458ff96bdc54272f64.tar.xz dged-54c9b4b533210b77be998f458ff96bdc54272f64.zip | |
big buffer/buffer_view rework
A buffer is only the text and the corresponding operation. A buffer view
holds information about scroll, dot and mark positions. One way to think
about it is that a buffer is stateless whereas a buffer view is stateful.
Diffstat (limited to 'src/dged/text.h')
| -rw-r--r-- | src/dged/text.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/dged/text.h b/src/dged/text.h index fbee89b..e3bb3e4 100644 --- a/src/dged/text.h +++ b/src/dged/text.h @@ -1,10 +1,13 @@ +#ifndef _TEXT_H +#define _TEXT_H + #include <stdbool.h> #include <stddef.h> #include <stdint.h> -// opaque so it is easier to change representation to gap, rope etc. -struct text; +#include "location.h" +struct text; struct render_command; struct text *text_create(uint32_t initial_capacity); @@ -52,3 +55,32 @@ struct text_chunk text_get_region(struct text *text, uint32_t start_line, uint32_t end_col); bool text_line_contains_unicode(struct text *text, uint32_t line); + +enum text_property_type { + TextProperty_Colors, +}; + +struct text_property_colors { + bool set_fg; + uint32_t fg; + bool set_bg; + uint32_t bg; +}; + +struct text_property { + enum text_property_type type; + union { + struct text_property_colors colors; + }; +}; + +void text_add_property(struct text *text, struct location start, + struct location end, struct text_property property); + +void text_get_properties(struct text *text, struct location location, + struct text_property **properties, + uint32_t max_nproperties, uint32_t *nproperties); + +void text_clear_properties(struct text *text); + +#endif |
