diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-10-11 14:19:39 -0400 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-10-11 14:31:37 -0400 |
| commit | d3ec525b7d6ecd8de064d3f3a54d112769d1d3b3 (patch) | |
| tree | 935b51f95afb513604c82c9e1efca223af60c109 /include | |
| parent | Fix git clone link in readme (diff) | |
| download | cli-d3ec525b7d6ecd8de064d3f3a54d112769d1d3b3.zip | |
Add unicode support to justify
Diffstat (limited to 'include')
| -rw-r--r-- | include/linebuffer.h | 8 | ||||
| -rw-r--r-- | include/utf8.h | 14 |
2 files changed, 19 insertions, 3 deletions
diff --git a/include/linebuffer.h b/include/linebuffer.h index a3d9e4c..b11cb8f 100644 --- a/include/linebuffer.h +++ b/include/linebuffer.h @@ -6,9 +6,11 @@ #include <stdio.h> typedef struct { - size_t _num_words; - size_t _buffer_length; - size_t _buffer_capacity; + size_t _num_words; // Number of words in the buffer + size_t _line_width; // Max display width (e.g., 72 columns) + size_t _buffer_length; // Current bytes used + size_t _display_width; // Current display width + size_t _buffer_capacity; // Byte capacity (line_width * 4 for UTF-8) char *_buffer; } LineBuffer; diff --git a/include/utf8.h b/include/utf8.h new file mode 100644 index 0000000..aa2cac5 --- /dev/null +++ b/include/utf8.h @@ -0,0 +1,14 @@ +#ifndef UTF8_H +#define UTF8_H + +#include <stddef.h> + +/** + * @brief Calculate the display width of a UTF-8 string + * + * @param str The UTF-8 encoded string + * @return The number of characters (display width) + */ +size_t utf8_display_width(const char *str); + +#endif |